public override string RecurringBillingAddressUpdate(string RecurringSubscriptionID, int OriginalRecurringOrderNumber, Address UseBillingAddress) { String result = String.Empty; String custNum = RecurringSubscriptionID ?? String.Empty; //clarifying that SubcriptionID is USAePay Customer Number if (UseBillingAddress == null) { return("USAePay Billing Information Update Failed - Address is empty."); } bool updatePaymentMethod = !String.IsNullOrEmpty(UseBillingAddress.CardNumber) && !String.IsNullOrEmpty(UseBillingAddress.CardExpirationMonth) && !String.IsNullOrEmpty(UseBillingAddress.CardExpirationYear) && UseBillingAddress.PaymentMethodLastUsed == AppLogic.ro_PMCreditCard; //set service configuration GatewayUSAePay.USAePaySOAP.ueSoapServerPortType client = GetServiceClient(UseSandBox); var token = GetSecurityToken(); var customer = new GatewayUSAePay.USAePaySOAP.CustomerObject(); var addressBilling = GetUSAePayBillingAddress(UseBillingAddress); try { //get current customer info from USAePay, including existing PaymentMethod customer = client.getCustomer(token, custNum); //USAePay supports multiple payment methods but we should only have one. if (customer.PaymentMethods.Length > 1) { return("USAePay Payment Method Update Error - Please contact customer support to update subscription"); } if (updatePaymentMethod) { customer.PaymentMethods = GetUSAePayCCPaymentMethod(UseBillingAddress); } customer.BillingAddress = addressBilling; //assign billing address if (client.updateCustomer(token, custNum, customer)) { result = AppLogic.ro_OK; } else { result = "USAePay Billing Information Update Failed"; } return(result); } catch (Exception e) { SysLog.LogMessage(String.Format(CultureInfo.CurrentCulture, "USAePay Request Failed - Update Billing for order {0}, USAePay custNum {1}", OriginalRecurringOrderNumber.ToString(CultureInfo.InvariantCulture), RecurringSubscriptionID), e.Message, MessageTypeEnum.GeneralException, MessageSeverityEnum.Error); return("USAePay Billing Information Update Failed"); } }
private GatewayUSAePay.USAePaySOAP.CustomerObject MakeRecurringUSAePayCustomer(Address UseBillingAddress, Customer ThisCustomer, DateIntervalTypeEnum RecurringIntervalType, DateTime StartDate, decimal RecurringAmount, int OriginalRecurringOrderNumber) { var addressBilling = GetUSAePayBillingAddress(UseBillingAddress); var customer = new GatewayUSAePay.USAePaySOAP.CustomerObject(); customer.BillingAddress = addressBilling; customer.CustomerID = ThisCustomer.CustomerID.ToString(CultureInfo.InvariantCulture);//ADNSF CustomerId, not USAePay CustNum (SubscriptionId) //customer recurring setup http://wiki.usaepay.com/developer/soap-1.6/objects/customerobject customer.Schedule = GetUSAePaySchedule(RecurringIntervalType); customer.Enabled = true; //enable recurring customer.NumLeft = "-1"; //unlimited transactions customer.Next = StartDate.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture) ?? String.Empty; customer.Amount = Convert.ToDouble(RecurringAmount); customer.OrderID = OriginalRecurringOrderNumber.ToString(CultureInfo.InvariantCulture) ?? String.Empty; customer.SendReceipt = false; //USAePay gateway sending email receipts var payMethod = GetUSAePayCCPaymentMethod(UseBillingAddress); customer.PaymentMethods = payMethod; return(customer); }