Example #1
0
  public OrderWS buildOrder(int userId, List<Integer> itemIds, BigDecimal linePrice) {
    OrderWS order = new OrderWS();
    order.setUserId(userId);
    order.setBillingTypeId(Constants.ORDER_BILLING_POST_PAID);
    order.setPeriod(ORDER_PERIOD_ONCE); // once
    order.setCurrencyId(CURRENCY_USD);
    order.setActiveSince(new Date());
    order.setProrateFlag(Boolean.FALSE);

    ArrayList<OrderLineWS> lines = new ArrayList<OrderLineWS>(itemIds.size());
    for (int i = 0; i < itemIds.size(); i++) {
      OrderLineWS nextLine = new OrderLineWS();
      nextLine.setTypeId(Constants.ORDER_LINE_TYPE_ITEM);
      nextLine.setDescription("Order line: " + i);
      nextLine.setItemId(itemIds.get(i));
      nextLine.setQuantity(1);
      nextLine.setPrice(linePrice);
      nextLine.setAmount(nextLine.getQuantityAsDecimal().multiply(linePrice));

      lines.add(nextLine);
    }
    order.setOrderLines(lines.toArray(new OrderLineWS[lines.size()]));
    return order;
  }
Example #2
0
  private Integer getOrCreateSuspendedStatus(JbillingAPI api) {
    List<AgeingWS> steps = Arrays.asList(api.getAgeingConfiguration(LANGUAGE_ID));

    for (AgeingWS step : steps) {
      if (step.getSuspended().booleanValue()) {
        return step.getStatusId();
      }
    }

    AgeingWS suspendStep = new AgeingWS();
    suspendStep.setSuspended(Boolean.TRUE);
    suspendStep.setDays(Integer.valueOf(180));
    suspendStep.setStatusStr("Ageing Step 180");
    suspendStep.setFailedLoginMessage("You are suspended");
    suspendStep.setWelcomeMessage("Welcome");
    steps.add(suspendStep);
    api.saveAgeingConfiguration(steps.toArray(new AgeingWS[steps.size()]), LANGUAGE_ID);
    return getOrCreateOrderChangeStatusApply(api);
  }