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 Dictionary<string, string> BuildAimRequest(Payment payment) { var postValues = new Dictionary<string, string> { { "x_login", LoginID }, { "x_tran_key", TransactionKey }, { "x_delim_data", "TRUE" }, { "x_delim_char", RESPONSE_DELIMITER }, { "x_relay_response", "FALSE" }, { "x_type", "AUTH_CAPTURE" }, { "x_method", payment.PaymentType.ToString() }, { "x_amount", payment.Amount.ToString(CultureInfo.InvariantCulture) }, { "x_description", payment.ToString() }, { "x_first_name", payment.FirstName }, { "x_last_name", payment.LastName }, { "x_address", payment.AddressLine1 }, { "x_state", payment.State }, { "x_zip", payment.ZipCode } }; if (payment.PaymentType == PaymentType.CC) { postValues.Add("x_card_num", payment.AccountNumber); postValues.Add("x_exp_date", payment.GetFormattedDate()); postValues.Add("x_card_code", payment.Cid); } else // ECheck { postValues.Add("x_bank_aba_code", payment.RoutingNumber); postValues.Add("x_bank_acct_num", payment.AccountNumber); postValues.Add("x_bank_acct_type", payment.CheckType.ToString()); postValues.Add("x_bank_name", payment.BankName); postValues.Add("x_bank_acct_name", string.Format("{0} {1}", payment.FirstName, payment.LastName)); postValues.Add("x_echeck_type", "WEB"); postValues.Add("x_bank_check_number", payment.CheckNumber); postValues.Add("x_recurring_billing", "NO"); } // NOTE: From the Authorize.net API documentation: // Additional fields can be added here as outlined in the AIM integration // guide at: http://developer.authorize.net AppendCustomFields(postValues, payment); return postValues; }