Allow logic from TransactionRequestEvent to properly affect whether or not to capture

Created on 31 December 2024, about 1 month ago

Problem/Motivation

Right now, if you use TransactionRequestEvent to add custom logic for Authorization, the request is changed as it should be, but if the site is set to $capture, the payment will be completed on the site, while it is still only auth, pending capture on the Authnet side.

This is because the response, even though the auth is set to authOnlyTransaction, $response->getMessageCode(); will still return a code 1

See AcceptJs.php for example:

    // Select the next state based on fraud detection results.
    $code = $response->getMessageCode();
    $expires = 0;
    $next_state = 'authorization';
    if ($code == 1 && $capture) {
      $next_state = 'completed';
    }

Steps to reproduce

Create a TransactionRequestEvent event subscriber with the payment setting on the site set to capture:

      $transaction_type = TransactionRequest::AUTH_ONLY;
      $transaction_request->addData('transactionType', $transaction_type);

Proposed resolution

Either pass the $capture parameter through the event subscriber or provide a check for TransactionRequest::AUTH_ONLY; setting after the event has been dispatched

Remaining tasks

Providing a hacky patch for AcceptJs.php.

Need to sort out best solution. Maybe I am missing something here.

Feature request
Status

Active

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024