Worldpay / Worldpay-Magento2-CG

Worldpay Magento 2 Plugin for Worldpay Corporate Gateway
Other
17 stars 35 forks source link

Some of the orders are converting into recurring order #137

Open shunmugakumaran opened 2 months ago

shunmugakumaran commented 2 months ago

Hi

Customer invoice gets raised early due to stored credentials/tokenization which is considered as recurring order. we don't want create a invoice from worldpay. As We have a system that will generate a invoice by third party ERP from their side. But some of the respective user placing the order which is converting into recurring order due to stored credentials/tokenization as the user stored the card details when placing order

Once done all the future order will be consider as recurring order magento will send an authorization request if successful follow-up capture requests are triggered. After successful capturing/invoicing, recurring orders are fulfilled.

This is the reason we suspecting for the issue.

Above is the default behaviour from worldpay module.. finally worldpay is capturing the order & creating the invoice. because of this order modification is happening that is not necessary

Can we turn off the stored credentials/tokenization from magneto (currently enabled in production) and still customers can save their CC?

Can we turn off this cron job worldpay_recurring_transactions in magento if this not required?

Can we have any workaround for this ? like patch to avoid this

We have also raised a support ticket with worldpay & currently reviewed by

Donovan Loftin Client Success Manager Global Enterprise North America

shunmugakumaran commented 2 months ago

Hi Team,

On checking the worldpay.log in Magento, we found that

A direct token order request is happening. When a shopper saves a card, the token generated by WorldPay is saved in the Magento database; we use this token for future authorizations & create a capture request & invoice generated

  1. The order is submitted with a direct token order request.

    Reference for 1 log we found: a. [2024-03-07T16:24:22.540111+00:00] WorldPay. INFO: ########## Submit a direct token order request. OrderCode: xxxxx-xxxxx ########## [] [] b. [2024-03-04T08:49:05.110370+00:00] WorldPay. INFO: ########## Submit a direct token order request. OrderCode: xxxxx-xxxxx ########## [] [] c. [2024-04-08T12:58:05.604528+00:00] WorldPay. INFO: ########## Submit a direct token order request. OrderCode: xxxxx-xxxxx ########## [] [] d. [2024-04-12T10:34:58.334335+00:00] WorldPay. INFO: ########## Submit a direct token order request. OrderCode: xxxxx-xxxxx ########## [] []

  2. A direct token order request will be submitted when a payment request is sent using a tokenized saved card to the WorldPay server based on the token order parameters.

  3. As per logs, we traced and tracked the below PaymentServiceRequest.php file, which is calling the below function method.

    vendor/sapient/module-worldpay/Model/Request/PaymentServiceRequest.php

    function method: capture (\Magento\Sales\Model\ (Order $order, $wp, $paymentMethodCode, $capturedItems = null)

  4. Set the capture type to full (we believe), which is then sent as a capture XML in the below function method.

    $captureSimpleXml = $this->xmlcapture->build($merchantCode, $orderCode, $order->getOrderCurrencyCode(), $order->getGrandTotal(), $exponent, $order, $captureType, $wp->getIsMultishippingOrder(), $wp->getPaymentType(), $invoicedItems);

    /vendor/sapient/module-worldpay/Model/XmlBuilder/Capture.php

    function method:build($merchantCode, $orderCode, $currencyCode, $amount, $exponent, $order, $captureType, $isMultishippingOrder, $paymentType = null, $invoicedItems = null

  5. Once Magento creates a recurring/tokenization saved card order, which is submitting the direct token order request, it sends an authorization request to Worldpay, and, if successful, follow-up capture requests are triggered. After successful capture and invoicing, created

  6. As we don't need to create an invoice from WorldPay once a capture request is submitted from the direct token order request (because this customer invoice gets raised early as the invoice will be created by our third-party ERP system only). it is submitting the first direct token order request and capturing the request after that order is submitted.