/// <summary> /// Creates the customer profile. /// </summary> /// <param name="emailAddress">The email address.</param> /// <returns></returns> public static long CreateCustomerProfile(string emailAddress) { long customerProfileId = 0; try { CustomerProfileType m_new_cust = new CustomerProfileType(); m_new_cust.email = emailAddress; m_new_cust.description = "Website customer " + DateTime.Now.ToShortTimeString(); CreateCustomerProfileResponseType response = ServiceSoapClient.CreateCustomerProfile(MerchantAuthentication, m_new_cust, ValidationModeEnum.none); customerProfileId = response.customerProfileId; if (response.resultCode == MessageTypeEnum.Error) { throw new Exception(string.Format("Could not create customer profile for email: {0}.", emailAddress)); } } catch (Exception ex) { throw; } return(customerProfileId); }
public static bool CreateCustomerProfile(SiteDT site, CustomerDT customer, CreditCardDT cc, out long customerProfileId, out long customerPaymentProfileId) { // if (1 == 0) { MerchantAuthenticationType merchantAT = new MerchantAuthenticationType(); merchantAT.name = site.AuthorizeLoginId; merchantAT.transactionKey = site.AuthorizeTransactionKey; CustomerProfileType customerPT = new CustomerProfileType(); customerPT.merchantCustomerId = customer.Id.ToString(); customerPT.email = customer.Email; customerPT.paymentProfiles = new CustomerPaymentProfileType[1]; CustomerPaymentProfileType customerPPT = new CustomerPaymentProfileType(); customerPPT.customerType = CustomerTypeEnum.individual; customerPPT.customerTypeSpecified = true; customerPPT.billTo = new CustomerAddressType() { firstName = customer.FirstName, lastName = customer.LastName, address = customer.Address, city = customer.City, country = "USA", state = customer.StateId, zip = customer.ZipCode }; CreditCardType ccT = new CreditCardType(); ccT.cardNumber = cc.CardNumber; ccT.expirationDate = cc.ExpDate; ccT.cardCode = cc.CVV; PaymentType payment = new PaymentType(); payment.Item = ccT; customerPPT.payment = payment; customerPT.paymentProfiles[0] = customerPPT; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; ServiceSoapClient client = new ServiceSoapClient(); CreateCustomerProfileResponseType resp = client.CreateCustomerProfile(merchantAT, customerPT, ValidationModeEnum.testMode); customerProfileId = resp.customerProfileId; customerPaymentProfileId = resp.customerPaymentProfileIdList.Length == 1 ? resp.customerPaymentProfileIdList[0] : 0; if (resp.resultCode != MessageTypeEnum.Ok) { string errorValidate = resp.validationDirectResponseList != null && resp.validationDirectResponseList.Count() > 0 ? resp.validationDirectResponseList.ToList().Aggregate((a, b) => a + " || " + b) : string.Empty; string error = resp.messages != null && resp.messages.Count() > 0 ? resp.messages.ToList().Select(a => a.text).Aggregate((a, b) => a + " || " + b) : string.Empty; LoggingUtilities.Logger.LogEntry("Resp Error code:" + resp.resultCode.ToString() + ". Errors: " + error + "Error V: " + errorValidate); } return(resp.resultCode == MessageTypeEnum.Ok); /* } * * else * { * customerProfileId = 1; * customerPaymentProfileId = 1; * return true; * }*/ }