1

I am using authorize.net capture as default magento payment gateway in magento 2.3 and I have one order coming suspected fraud. but when I will suspected fraud to deny payment and I see error but I can't process continue to Deny Payment

enter image description here enter image description here and error like:

Fatal error: Uncaught Error: Call to a member function getAdditionalInformation() on boolean in 
/cache/vendor/magento/module-authorizenet-acceptjs/Gateway/Request/VoidDataBuilder.php:50 

and error coming below file function:

vendor/magento/module-authorizenet-acceptjs/Gateway/Request/VoidDataBuilder.php

public function build(array $buildSubject): array
{
    $paymentDO = $this->subjectReader->readPayment($buildSubject);
    $payment = $paymentDO->getPayment();
    $transactionData = [];

    if ($payment instanceof Payment) {
        $authorizationTransaction = $payment->getAuthorizationTransaction();
        $refId = $authorizationTransaction->getAdditionalInformation('real_transaction_id'); //here error line
        if (empty($refId)) {
            $refId = $authorizationTransaction->getParentTxnId();
        }

        $transactionData['transactionRequest'] = [
            'transactionType' => self::REQUEST_TYPE_VOID,
            'refTransId' => $refId
        ];
    }

    return $transactionData;
}

I know here some one ask this question but nothing find any answer it's magento core bug?

i have change as per @sohelrana answer and now another error coming

Invalid request to gateway.

Any help would be appreciated.

Thanks.

1

I think the following code returns boolean instead of an object.

$payment->getAuthorizationTransaction()

If you look following class:

vendor/magento/module-sales/Model/Order/Payment/Transaction/Manager.php

public function getAuthorizationTransaction($parentTransactionId, $paymentId, $orderId)
{
    $transaction = false;
    if ($parentTransactionId) {
        $transaction = $this->transactionRepository->getByTransactionId(
            $parentTransactionId,
            $paymentId,
            $orderId
        );
    }

    return $transaction ?: $this->transactionRepository->getByTransactionType(
        Transaction::TYPE_AUTH,
        $paymentId,
        $orderId
    );
}

Check sales_payment_transaction table for this order. Maybe entry is missing.

[Fix]

Add one check before getting value. Ex:

if ($authorizationTransaction = $payment->getAuthorizationTransaction()) {

Now full method looks like:

public function build(array $buildSubject): array
{
    $paymentDO = $this->subjectReader->readPayment($buildSubject);
    $payment = $paymentDO->getPayment();
    $transactionData = [];

    if ($payment instanceof Payment) {
        if ($authorizationTransaction = $payment->getAuthorizationTransaction()) {
            $refId = $authorizationTransaction->getAdditionalInformation('real_transaction_id');
            if (empty($refId)) {
                $refId = $authorizationTransaction->getParentTxnId();
            }

            $transactionData['transactionRequest'] = [
                'transactionType' => self::REQUEST_TYPE_VOID,
                'refTransId' => $refId
            ];
        }
    }

    return $transactionData;
}

Don't modify core code. Use plugin or overwrite.

4
  • thanks for answer i am checking in table if entry available or not.. Apr 7 '20 at 15:36
  • how can solve this problem ?@sohel Apr 7 '20 at 16:02
  • Check updated answer
    – Sohel Rana
    Apr 7 '20 at 16:07
  • i have implement your code but after this error coming Invalid request to gateway. (prnt.sc/ruv7bi) Apr 7 '20 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.