Hi @vahanavagyan1,
Please find a technical explanation of the payment process below.
Step 1: When the consumer clicks the “Place Order” button from the checkout page, WooCommerce calls the process_payment
method of the WC_Payment_Gateway
class (reference) that corresponds to the consumer’s chosen payment method. If Afterpay was selected at the checkout, this would be the WC_Gateway_Afterpay
class.
Step 2: At this point, the Afterpay plugin looks up the newly created Order using the Order ID provided by WooCommerce, and uses the Order information to create an Afterpay Checkout. The Afterpay Checkout token is then attached to the Order as meta data, and the consumer is redirected to Afterpay to confirm the payment schedule.
Step 3: When the consumer returns from Afterpay, the Checkout token is appended to the WC-API URL for “WC_Gateway_Afterpay”. The Afterpay plugin uses the Checkout token in the URL to lookup the WooCommerce Order with which the token was associated in Step 2.
This is the only point of the process that changed between version 3.0.0 and 3.0.1. Version 3.0.0 used the token to request the “Merchant Reference” (WooCommerce Order Number) from Afterpay. It then used this number to lookup the WooCommerce order. This failed if the Order Number differed from the Post ID (in cases where a third-party plugin had customised the Order Number).
Version 3.0.1 instead uses the token to perform a post query for a WooCommerce Order in either “Pending Payment” or “Failed” status upon which the Afterpay token was attached in Step 2. The current estimation based on cases considered thus far is that third-party plugins are moving or copying the post meta that was originally created by Afterpay to one or more unrelated orders.
Step 4: The token is then used to call the “Capture Payment” Afterpay API, and if approved, a note containing the Afterpay Order ID is attached to the WooCommerce Order, and its payment_complete
method is called (reference). This method moves the Order into either “Processing” or “Completed” status, depending on whether shipping is required.
During each step of this process, detailed information is recorded in the WooCommerce logs. This information will be beneficial for the support team as they continue working to investigate and resolve this challenge.
The current plan is to release a subsequent patch that stores the unique, unchanging Post ID within the Afterpay system. This will allow the Afterpay plugin to reliably lookup the WooCommerce Order without depending on the integrity of any data stored within the WooCommerce system.
Please expect further correspondence within 1 business day.
Thank you.