/// <summary> /// Creates a customer profile for the user. Note: set /// the customer's AccountReference to their UserId; this is an /// optional field we can use for reference. /// </summary> /// <param name="customer"></param> /// <returns>A long representing the customer's unique id. Store this as /// the user's Alias.</returns> long CreatePayerCustomer(ModpayCustomer customer) { var payerAlias = modClient.CreateCustomer(this.clientId, this.clientCode, customer.AccountReference, customer.FirstName, customer.LastName, customer.Address, customer.City, customer.State, customer.Zip, customer.Phone, customer.Fax, customer.Email); return(payerAlias); }
/// <summary> /// In order to allow a user to store multiple bank accounts, /// we create a 'customer' for each account. This will create the /// customer and store the bank account information. /// </summary> /// <param name="bank"></param> /// <returns>The UserBank. If it is a new entry, the object will be /// returned with the Alias created for the bank account.</returns> public UserBank UpdateCustomerBank(UserBank bank) { //if they haven't stored this account before, //create a customer if (!bank.PayerAlias.HasValue) { string addressLine = string.Format("{0} {1}", bank.Address1, bank.Address2); var customer = new ModpayCustomer() { AccountReference = bank.UserId.ToString(), Address = addressLine, City = bank.City, PayerAlias = bank.PayerAlias, FirstName = bank.FirstName, LastName = bank.LastName, Phone = bank.Phone, Email = bank.Email, State = bank.State, Zip = bank.Zip }; //store the customer info customer.PayerAlias = CreatePayerCustomer(customer); bank.PayerAlias = customer.PayerAlias; } //and then store the payer bank account modClient.ModifyCustomerBankAcct( this.clientId, this.clientCode, bank.PayerAlias.Value, bank.AccountName, bank.RoutingNumber, bank.AccountNumber, bank.AccountType); //also create or modify the payee account, if they don't have one. if (!bank.PayeeAlias.HasValue) { bank.PayeeAlias = CreatePayeeCustomer(bank); } else { UpdatePayeeCustomer(bank); } //mask account info bank.AccountNumber = this.MaskNumber(bank.AccountNumber); bank.RoutingNumber = this.MaskNumber(bank.RoutingNumber); return(bank); }
/// <summary> /// In order to allow a user to store multiple credit cards, /// we create a 'customer' for each card. This will create the /// customer and store the card information. /// </summary> /// <param name="card"></param> /// <returns>The UserCreditCard. If it is a new entry, the object will be /// returned with the Alias created for the card.</returns> public UserCreditCard UpdateCustomerCard(UserCreditCard card) { //if they haven't stored this card before, //create a customer string addressLine = string.Format("{0} {1}", card.Address1, card.Address2); var customer = new ModpayCustomer() { AccountReference = card.UserId.ToString(), Address = addressLine, City = card.City, PayerAlias = card.Alias, FirstName = card.FirstName, LastName = card.LastName, Phone = card.Phone, Email = card.Email, State = card.State, Zip = card.Zip }; //store the customer info if (!card.Alias.HasValue) { customer.PayerAlias = CreatePayerCustomer(customer); card.Alias = customer.PayerAlias; } else { ModifyPayerCustomer(customer); } //if or when we add support to modify the card ////and then store the card //modClient.ModifyCustomerCreditCard( // clientId, clientCode, card.Alias.Value, // card.CardName, card.CardNumber, card.ExpirationMonth, card.ExpirationYear); ////mask account info //card.CardNumber = this.MaskNumber(card.CardNumber); return(card); }
public UserCreditCard CreateCustomerCard(UserCreditCard card) { string addressLine = string.Format("{0} {1}", card.Address1, card.Address2); card.AccountReference = Guid.NewGuid(); var customer = new ModpayCustomer() { AccountReference = card.AccountReference.ToString(), Address = addressLine, City = card.City, PayerAlias = card.Alias, FirstName = card.FirstName, LastName = card.LastName, Phone = card.Phone, Email = card.Email, State = card.State, Zip = card.Zip }; try { //store the customer info customer.PayerAlias = CreatePayerCustomer(customer); card.Alias = customer.PayerAlias; //and then store the card modClient.ModifyCustomerCreditCard( clientId, clientCode, card.Alias.Value, card.CardName, card.CardNumber, card.ExpirationMonth, card.ExpirationYear); //mask account info card.CardNumber = this.MaskNumber(card.CardNumber); } catch (Exception exc) { return(null); } return(card); }
public UserCreditCard CreateCustomerCard(UserCreditCard card) { string addressLine = string.Format("{0} {1}", card.Address1, card.Address2); card.AccountReference = Guid.NewGuid(); var customer = new ModpayCustomer() { AccountReference = card.AccountReference.ToString(), Address = addressLine, City = card.City, PayerAlias = card.Alias, FirstName = card.FirstName, LastName = card.LastName, Phone = card.Phone, Email = card.Email, State = card.State, Zip = card.Zip }; try { //store the customer info customer.PayerAlias = CreatePayerCustomer(customer); card.Alias = customer.PayerAlias; //and then store the card modClient.ModifyCustomerCreditCard( clientId, clientCode, card.Alias.Value, card.CardName, card.CardNumber, card.ExpirationMonth, card.ExpirationYear); //mask account info card.CardNumber = this.MaskNumber(card.CardNumber); } catch(Exception exc) { return null; } return card; }
long ModifyPayerCustomer(ModpayCustomer customer) { var payerAlias = modClient.ModifyCustomer(this.clientId, this.clientCode, customer.PayerAlias.Value, customer.AccountReference, customer.FirstName, customer.LastName, customer.Address, customer.City, customer.State, customer.Zip, customer.Phone, customer.Fax, customer.Email); return payerAlias; }
/// <summary> /// In order to allow a user to store multiple credit cards, /// we create a 'customer' for each card. This will create the /// customer and store the card information. /// </summary> /// <param name="card"></param> /// <returns>The UserCreditCard. If it is a new entry, the object will be /// returned with the Alias created for the card.</returns> public UserCreditCard UpdateCustomerCard(UserCreditCard card) { //if they haven't stored this card before, //create a customer string addressLine = string.Format("{0} {1}", card.Address1, card.Address2); var customer = new ModpayCustomer() { AccountReference = card.UserId.ToString(), Address = addressLine, City = card.City, PayerAlias = card.Alias, FirstName = card.FirstName, LastName = card.LastName, Phone = card.Phone, Email = card.Email, State = card.State, Zip = card.Zip }; //store the customer info if(!card.Alias.HasValue) { customer.PayerAlias = CreatePayerCustomer(customer); card.Alias = customer.PayerAlias; } else ModifyPayerCustomer(customer); //if or when we add support to modify the card ////and then store the card //modClient.ModifyCustomerCreditCard( // clientId, clientCode, card.Alias.Value, // card.CardName, card.CardNumber, card.ExpirationMonth, card.ExpirationYear); ////mask account info //card.CardNumber = this.MaskNumber(card.CardNumber); return card; }
/// <summary> /// In order to allow a user to store multiple bank accounts, /// we create a 'customer' for each account. This will create the /// customer and store the bank account information. /// </summary> /// <param name="bank"></param> /// <returns>The UserBank. If it is a new entry, the object will be /// returned with the Alias created for the bank account.</returns> public UserBank UpdateCustomerBank(UserBank bank) { //if they haven't stored this account before, //create a customer if(!bank.PayerAlias.HasValue) { string addressLine = string.Format("{0} {1}", bank.Address1, bank.Address2); var customer = new ModpayCustomer() { AccountReference = bank.UserId.ToString(), Address = addressLine, City = bank.City, PayerAlias = bank.PayerAlias, FirstName = bank.FirstName, LastName = bank.LastName, Phone = bank.Phone, Email = bank.Email, State = bank.State, Zip = bank.Zip }; //store the customer info customer.PayerAlias = CreatePayerCustomer(customer); bank.PayerAlias = customer.PayerAlias; } //and then store the payer bank account modClient.ModifyCustomerBankAcct( this.clientId, this.clientCode, bank.PayerAlias.Value, bank.AccountName, bank.RoutingNumber, bank.AccountNumber, bank.AccountType); //also create or modify the payee account, if they don't have one. if(!bank.PayeeAlias.HasValue) bank.PayeeAlias = CreatePayeeCustomer(bank); else UpdatePayeeCustomer(bank); //mask account info bank.AccountNumber = this.MaskNumber(bank.AccountNumber); bank.RoutingNumber = this.MaskNumber(bank.RoutingNumber); return bank; }