예제 #1
0
  /**
   * Test subscribe.
   *
   * @return the iD
   * @throws Exception the exception
   */
  public ID createSubscribe() throws Exception {
    ZuoraUtility utility = new ZuoraUtility();
    ZuoraAPIHelper helper = new ZuoraAPIHelper();
    helper.login();
    stub = helper.getStub();
    header = helper.getHeader();

    ProductRatePlanCharge charge =
        getChargeByAccountingCode(utility.getPropertyValue(PROPERTY_ACCOUNTING_CODE));
    AccountSample testData = new AccountSample();
    Account acc = testData.makeAccount();
    Contact con = testData.makeContact();
    PaymentMethod pm = testData.makePaymentMethod();
    Subscription subscription = makeSubscription();

    SubscriptionData sd = new SubscriptionData();
    sd.setSubscription(subscription);

    RatePlanData[] subscriptionRatePlanDataArray = makeRatePlanData(charge);
    sd.setRatePlanData(subscriptionRatePlanDataArray);

    SubscribeRequest subReq = new SubscribeRequest();
    subReq.setAccount(acc);
    subReq.setBillToContact(con);
    subReq.setPaymentMethod(pm);
    subReq.setSubscriptionData(sd);

    SubscribeRequest[] subscribes = new SubscribeRequest[1];
    subscribes[0] = subReq;

    Subscribe subscribe = new Subscribe();
    subscribe.setSubscribes(subscribes);
    SubscribeResponse resp = stub.subscribe(subscribe, this.header);
    SubscribeResult result = resp.getResult()[0];
    if (result.getErrors() == null) {
      ZuoraUtility.print("Subscribe status : Success");

    } else {
      ZuoraUtility.print("Subscribe status: Fail");
      ZuoraUtility.print(ZuoraUtility.createErrorMessage(result));
    }
    return result.getSubscriptionId();
  }
예제 #2
0
  /**
   * Test subscribe with existing account.
   *
   * @return the iD
   * @throws Exception the exception
   */
  public ID createSubscribeWithExistingAccount() throws Exception {

    ZuoraUtility utility = new ZuoraUtility();
    ZuoraAPIHelper helper = new ZuoraAPIHelper();
    helper.login();
    stub = helper.getStub();
    header = helper.getHeader();

    ProductRatePlanCharge charge =
        getChargeByAccountingCode(utility.getPropertyValue(PROPERTY_ACCOUNTING_CODE));
    Account account = getAccountByName("ACC-1336382492856");
    Subscription subscription = makeSubscription();

    SubscriptionData sd = new SubscriptionData();
    sd.setSubscription(subscription);

    RatePlanData[] subscriptionRatePlanDataArray = makeRatePlanData(charge);
    sd.setRatePlanData(subscriptionRatePlanDataArray);

    SubscribeRequest subRequest = new SubscribeRequest();
    subRequest.setAccount(account);
    subRequest.setSubscriptionData(sd);

    SubscribeRequest[] subscribes = new SubscribeRequest[1];
    subscribes[0] = subRequest;

    Subscribe sr = new Subscribe();
    sr.setSubscribes(subscribes);

    SubscribeResponse resp = stub.subscribe(sr, this.header);
    SubscribeResult result = resp.getResult()[0];
    if (result.getErrors() == null) {
      ZuoraUtility.print("Subscribe status : Success");
    } else {
      ZuoraUtility.print("Subscribe status: Fail");
      ZuoraUtility.print(ZuoraUtility.createErrorMessage(result));
    }
    return result.getSubscriptionId();
  }