/** * Add the subscription id to the request. * * @param document * @param subscription */ private void addSubscriptionIdToRequest(BasicXmlDocument document, Subscription subscription) { if (subscription.getSubscriptionId() != null) { Element subscr_id_el = document.createElement(AuthNetField.ELEMENT_SUBSCRIPTION_ID.getFieldName()); subscr_id_el.appendChild( document.getDocument().createTextNode(subscription.getSubscriptionId())); document.getDocumentElement().appendChild(subscr_id_el); } }
/** * Add subscription information to the subscription request. * * @param document * @param subscription */ private void addSubscriptionToRequest(BasicXmlDocument document, Subscription subscription) { addSubscriptionIdToRequest(document, subscription); Element subscr_el = document.createElement(AuthNetField.ELEMENT_SUBSCRIPTION.getFieldName()); if (subscription.getName() != null) { Element name_el = document.createElement(AuthNetField.ELEMENT_NAME.getFieldName()); name_el.appendChild(document.getDocument().createTextNode(subscription.getName())); subscr_el.appendChild(name_el); } addPaymentScheduleToSubscription(document, subscription, subscr_el); if (!subscription.getAmount().equals(ZERO_AMOUNT) || !subscription.getTrialAmount().equals(ZERO_AMOUNT)) { Element amount_el = document.createElement(AuthNetField.ELEMENT_AMOUNT.getFieldName()); amount_el.appendChild( document .getDocument() .createTextNode( subscription .getAmount() .setScale(Transaction.CURRENCY_DECIMAL_PLACES, BigDecimal.ROUND_HALF_UP) .toPlainString())); subscr_el.appendChild(amount_el); Element trial_el = document.createElement(AuthNetField.ELEMENT_TRIAL_AMOUNT.getFieldName()); trial_el.appendChild( document .getDocument() .createTextNode( subscription .getTrialAmount() .setScale(Transaction.CURRENCY_DECIMAL_PLACES, BigDecimal.ROUND_HALF_UP) .toPlainString())); subscr_el.appendChild(trial_el); } addPaymentToSubscription(document, subscription, subscr_el); addBillingInfoToSubscription(document, subscription, subscr_el); document.getDocumentElement().appendChild(subscr_el); }