private void PopulateSubscription(ARBCreateSubscriptionRequest request, Payment payment) { ARBSubscriptionType sub = new ARBSubscriptionType(); creditCardType creditCard = new creditCardType(); bankAccountType bankAccount = new bankAccountType(); sub.name = string.Format("{0} {1} Subscription", payment.FirstName, payment.LastName); if (payment.PaymentType == PaymentType.CC) { creditCard.cardNumber = payment.AccountNumber; creditCard.expirationDate = payment.GetFormattedDate(); // required format for API is YYYY-MM sub.payment = new paymentType { Item = creditCard }; } else { bankAccount.accountNumber = payment.AccountNumber; bankAccount.accountTypeSpecified = true; bankAccount.bankName = payment.BankName; bankAccount.routingNumber = payment.RoutingNumber; bankAccount.accountType = GetAccountType(payment); bankAccount.nameOnAccount = payment.NameOnAccount; sub.payment = new paymentType { Item = bankAccount }; } sub.billTo = new nameAndAddressType { firstName = payment.FirstName, lastName = payment.LastName }; sub.paymentSchedule = new paymentScheduleType { startDate = payment.SubscriptionStart, startDateSpecified = true, totalOccurrences = 12, totalOccurrencesSpecified = true }; sub.amount = payment.Amount; sub.amountSpecified = true; sub.paymentSchedule.interval = new paymentScheduleTypeInterval { length = 1, unit = ARBSubscriptionUnitEnum.months }; sub.customer = new customerType { email = payment.Email }; PopulateMerchantAuthentication(request); request.subscription = sub; }
private SubscriptionResponse CreateSubscription(Payment payment) { var createRequest = new ARBCreateSubscriptionRequest(); PopulateSubscription(createRequest, payment); object response = null; XmlDocument xmldoc; bool bResult = PostRequest(createRequest, out xmldoc); if (bResult) { ProcessXmlResponse(xmldoc, out response); } return ProcessResponse(response); }