private bool UpdateOrderAddress(PaymentMethod currentPayment, TransactionResult transactionDetails2) { Log.InfoFormat("Updating order address for payment with ID:{0} belonging to order with ID: {1}", currentPayment.Payment.Id, currentPayment.OrderGroupId); if (!currentPayment.RequireAddressUpdate) { Log.InfoFormat("This payment method ({0}) does not require an order address update. Payment with ID:{1} belonging to order with ID: {2}", currentPayment.PaymentMethodCode, currentPayment.Payment.Id, currentPayment.OrderGroupId); return(true); } Address newAddress = currentPayment.GetAddressFromPayEx(transactionDetails2); if (newAddress == null) { return(false); } Cart cart = currentPayment.Cart; OrderAddress shippingAddress = GetShippingAddress(cart); if (shippingAddress == null) { Log.ErrorFormat("Could not update address for payment with ID:{0} belonging to order with ID: {1}. Reason: Shipping address was not found!", currentPayment.Payment.Id, currentPayment.OrderGroupId); return(false); } Dictionary <string, string> propertiesToUpdate = new Dictionary <string, string>() { { GetPropertyName(() => shippingAddress.FirstName), newAddress.FirstName }, { GetPropertyName(() => shippingAddress.LastName), newAddress.LastName }, { GetPropertyName(() => shippingAddress.Line1), newAddress.Line1 }, { GetPropertyName(() => shippingAddress.PostalCode), newAddress.PostCode }, { GetPropertyName(() => shippingAddress.City), newAddress.City }, { GetPropertyName(() => shippingAddress.CountryName), newAddress.Country }, { GetPropertyName(() => shippingAddress.Email), newAddress.Email }, }; bool updated = UpdatePropertyValues(shippingAddress, propertiesToUpdate); if (!string.IsNullOrWhiteSpace(newAddress.Fullname)) { Log.InfoFormat("Setting customer name of cart to {0} on payment with ID:{1} belonging to order with ID: {2}", newAddress.Fullname, currentPayment.Payment.Id, currentPayment.OrderGroupId); cart.CustomerName = newAddress.Fullname; } try { if (updated) { using (TransactionScope scope = new TransactionScope()) { shippingAddress.AcceptChanges(); cart.AcceptChanges(); scope.Complete(); } } return(true); } catch (Exception e) { Log.Error("Could not update address for payment. See next log statement for more information", e); Log.ErrorFormat("Could not update address for payment with ID:{0} belonging to order with ID: {1}", currentPayment.Payment.Id, currentPayment.OrderGroupId); return(false); } }