Problem/Motivation
#3582241 switched Accept Hosted to send the order number as the invoiceNumber whenever the order has one, while the net.authorize.payment.authcapture.created webhook still loads the order by ID. Sites that assign order numbers before payment cannot complete orders from the webhook, and an order number that equals another order's ID loads the wrong order.
Accept.js has sent the order number when present since 2018, so the two gateways were never consistent. Some sites need the order number on the transaction; most are better served by the order ID, which is always present and unique.
The refund request also has an operator-precedence bug: 'REFUND#' . $order->getOrderNumber() ?: $order->id() concatenates first, so the fallback to the ID never runs.
Proposed resolution
- Standardize on the order ID by default for Accept Hosted and Accept.js.
- Add an "Invoice number" setting to both gateways ("Use the order ID" / "Use the order number"), similar to the order number strategy in Commerce Moneris Checkout. Orders without a number always send the ID.
- Webhook lookup follows the setting with a fallback so existing transactions keep resolving:
- Order ID: load by ID, then by order number (transactions created after #3582241).
- Order number: load by order number, then by ID only for orders that have no number.
- Fix the refund
invoiceNumberprecedence bug. - Kernel test coverage for both strategies, the webhook lookup, and refunds on both gateways.
Remaining tasks
- Review MR !70.
- Manual test of the webhook against a sandbox account with both strategies.
User interface changes
New "Invoice number" radios on the Accept Hosted and Accept.js gateway configuration forms.
API changes
New invoice_number_strategy gateway setting (default order_id) and InvoiceNumberTrait::getInvoiceNumber() / getInvoiceNumberStrategy().
Release notes snippet
Accept Hosted and Accept.js now send the order ID as the Authorize.net invoice number by default. This changes what Accept.js has sent since 2018 and reverts the Accept Hosted change from #3582241. Sites that want the order number on transactions (for example, to match invoices in the Merchant Interface) should set Invoice number to "Use the order number" on the payment gateway after updating. The Accept Hosted webhook resolves orders under either value, so existing transactions are not affected.
Issue fork commerce_authnet-3627239
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
vmarchukComment #4
vmarchukComment #5
vmarchukComment #6
vmarchukComment #7
adrianandres commentedComment #8
adrianandres commentedComment #10
vmarchukCommitted!