public PaymentInitializeResult Initialize(PaymentMethod currentPayment, string orderNumber, string returnUrl, string orderRef) { Log.InfoFormat("Retrieving consumer legal address for payment with ID:{0} belonging to order with ID: {1}", currentPayment.Payment.Id, currentPayment.OrderGroupId); CustomerDetails customerDetails = CreateModel(currentPayment); if (customerDetails == null) { throw new Exception("Payment class must be ExtendedPayExPayment when using this payment method"); } ConsumerLegalAddressResult result = _verificationManager.GetConsumerLegalAddress(customerDetails.SocialSecurityNumber, customerDetails.CountryCode); if (!result.Status.Success) { return new PaymentInitializeResult { ErrorMessage = result.Status.Description } } ; _paymentActions.UpdateConsumerInformation(currentPayment, result); Log.InfoFormat("Successfully retrieved consumer legal address for payment with ID:{0} belonging to order with ID: {1}", currentPayment.Payment.Id, currentPayment.OrderGroupId); return(_paymentInitializer.Initialize(currentPayment, orderNumber, returnUrl, orderRef)); }
public void UpdateConsumerInformation(PaymentMethod paymentMethod, ConsumerLegalAddressResult consumerLegalAddress) { Log.InfoFormat("Updating consumer information for payment with ID:{0} belonging to order with ID: {1}", paymentMethod.Payment.Id, paymentMethod.OrderGroupId); if (!(paymentMethod.Payment is ExtendedPayExPayment)) { Log.ErrorFormat("Payment with ID:{0} belonging to order with ID: {1} is not an ExtendedPayExPayment, cannot update consumer information", paymentMethod.Payment.Id, paymentMethod.OrderGroupId); return; } ExtendedPayExPayment payment = paymentMethod.Payment as ExtendedPayExPayment; try { using (TransactionScope scope = new TransactionScope()) { payment.FirstName = consumerLegalAddress.FirstName; payment.LastName = consumerLegalAddress.LastName; payment.StreetAddress = consumerLegalAddress.Address; payment.PostNumber = consumerLegalAddress.PostNumber; payment.City = consumerLegalAddress.City; payment.CountryCode = consumerLegalAddress.Country; payment.AcceptChanges(); scope.Complete(); Log.InfoFormat("Successfully updated consumer information for payment with ID:{0} belonging to order with ID: {1}", paymentMethod.Payment.Id, paymentMethod.OrderGroupId); } } catch (Exception e) { Log.Error("Could not update consumer information. See next log item for more information", e); Log.ErrorFormat( "Could not update consumer information for payment with ID:{0}. ConsumerLegalAddressResult:{1}.", payment.Id, consumerLegalAddress); } }
private static ConsumerLegalAddressResult ConvertToConsumerAddress(LegalAddressResult result) { string lastName = string.Empty; string[] names = result.Name.Split(' '); string firstName = names[0]; if (names.Length > 1) { lastName = string.Join(" ", names.Skip(1)); } ConsumerLegalAddressResult consumerLegalAddressResult = new ConsumerLegalAddressResult() { Status = result.Status, Address = result.StreetAddress, City = result.City, Country = result.CountryCode, FirstName = firstName, LastName = lastName, PostNumber = result.ZipCode }; return(consumerLegalAddressResult); }
public ConsumerLegalAddressResult GetConsumerLegalAddress(string socialSecurityNumber, string countryCode) { Log.InfoFormat("Calling GetConsumerLegalAddress for SocialSecurityNumber:{0}. CountryCode:{1}.", socialSecurityNumber, countryCode); string hash = _hasher.Create(_payExSettings.AccountNumber, socialSecurityNumber, countryCode, _payExSettings.EncryptionKey); string xmlResult = _verificationFacade.GetConsumerLegalAddress(_payExSettings.AccountNumber, socialSecurityNumber, countryCode, hash); ConsumerLegalAddressResult result = _resultParser.Deserialize <ConsumerLegalAddressResult>(xmlResult); if (result.Status.Success) { Log.InfoFormat("Successfully called GetConsumerLegalAddress for SocialSecurityNumber:{0}. CountryCode:{1}. Result:{2}", socialSecurityNumber, countryCode, xmlResult); } else { Log.ErrorFormat("Error when calling GetConsumerLegalAddress for SocialSecurityNumber:{0}. CountryCode:{1}. Result:{2}", socialSecurityNumber, countryCode, xmlResult); } return(result); }