Developer forum

Forum » Integration » Multiple Payments/Tender Types on Order

Multiple Payments/Tender Types on Order

Andrew Rushworth
Reply

Does DW handle multiple tender types for an order?
I have implemented a payment gateway that the user can process a credit card and use loyalty bank points (eBucks) to pay.  This then returns two forms of payment, a credit card transaction for some of the order and the banks loyalty points transaction (eBucks) for the balance of the order.
I implemented the PartialCapture interface and capture each payment here (see screenshot).

From what I see an order only has one Payment Method attached and essentially only one Payment.  So when integration with ERP happens it will only every integrate a single receipt to ERP.
So I'm assuming the PartialCapture interface is for multiple payments for the same Payment Methods and this will not result in multiple receipts on integration?

Screenshot_2022-09-06_184407.jpg

Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Andrew,

you can use this notification subscriber in your project so it will send order to ERP once the Order was captured, see the code below.
It should be triggered after each capture event.
(you will also need to add a reference to a nuget Dynamicweb.Ecommerce.DynamicwebLiveIntegration 7.0.+ version in your project)

using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Configuration;
using Dynamicweb.Extensibility.Notifications;

namespace Dynamicweb.Ecommerce.DynamicwebLiveIntegration.NotificationSubscribers
{
    /// <summary>
    /// Sends the order to the ERP whe it's complete.
    /// </summary>
    /// <seealso cref="NotificationSubscriberBase" />
    [Subscribe(Ecommerce.Notifications.Ecommerce.Order.AfterOrderCaptured)]
    public class CartAfterOrderCaptured : NotificationSubscriberBase
    {
        /// <summary>
        /// Handles the notification.
        /// </summary>
        /// <param name="notification">The notification.</param>
        /// <param name="args">The args.</param>
        public override void OnNotify(string notification, NotificationArgs args)
        {
            if (args != null)
            {
                var myArgs = (Ecommerce.Notifications.Ecommerce.Cart.CheckoutDoneOrderIsCompleteArgs)args;
                if (myArgs.Order == null || myArgs.Order.OrderLines.Count <= 0)
                {
                    return;
                }

                string shopId = myArgs.Order.ShopId;
                Settings settings = SettingsManager.GetSettingsByShop(shopId);

                if (!EnabledAndActive(settings))
                {
                    return;
                }

                if (settings != null && Global.EnableCartCommunication(settings, myArgs.Order.Complete))
                {
                    if (myArgs.Order.Complete && myArgs.Order.Currency != Common.Context.Currency)
                    {
                        // This can happen when redirected back from some CheckOut handler
                        // Common.Context.Currency can be set to the default Application currency,
                        // while the completed order can be in another currency
                        Common.Context.Currency = myArgs.Order.Currency;
                    }

                    bool? result = OrderHandler.UpdateOrder(settings, myArgs.Order, SubmitType.LiveOrderOrCart);
                }
            }
        }
    }
}

BR, Dmitrij

 
Andrew Rushworth
Reply

Thanks Dmitrij.
So will this then send through each Capture as a payment to the ERP?

I add the split cpatures via code when the response comes back from the provider. So if the provider returns 2 payments, one for $100 and eB20, then this will send through two payments to the ERP, one for $100 and one for rhe eB20?

The probelm remains that an order can only have one Payment Method, but the return from the Gatway is essentially two different Payment Methods.

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply
This post has been marked as an answer

Hi Andrew,
yes, the PartialCapture is for multiple payments for the same Payment Method. You can extend the standard LiveIntegration and implement the custom code
that can pass the needed additional fields to the order request to ERP by implementing the Order.OnAfterGenerateOrderXml subscriber,
so in your PartialCapturing custom implementation you can cache the needed information and in the OnAfterGenerateOrderXml subscriber
you can read the cached values and add them into the request xml. Then on the ERP side you will need to implement the custom logic to read the passed values.
I can provider a sample code of OnAfterGenerateOrderXml subscriber if that can help
BR, Dmitrij

Votes for this answer: 1
 
Andrew Rushworth
Reply

Thanks. I resolved in a similar way and store the payments in a json custom field on the order. I then retrieve this in the ERP integration and iterate through the json object.

 

You must be logged in to post in the forum