简体   繁体   中英

How to process a refund with Omnipay - NAB Transact

I am trying to do the refund process and it is connected to the nab test mode server but not processing the refund transaction.

I did a transaction yesterday and wanted to refund the part money but it is not going through and shows the error that Credit card details not available (Error Code 133).

I am sending the request using TransactionID and TransactionReference and the amount to be deducted but not working.

My code:-

public function pay()
    {
      $gateway = Omnipay::create('NABTransact_SecureXML');
    $gateway->setMerchantId('XYZ0010');
    $gateway->setTransactionPassword('abcd1234');
    $gateway->setTestMode(true);

    $card = new CreditCard([
            'firstName' => 'ABC',
            'lastName' => 'DEF',
            'number'      => '4444333322221111',
            'expiryMonth' => '05',
            'expiryYear'  => '2025',
            'cvv'         => '123',
        ]
    );

    $transaction = $gateway->purchase([
            'amount'        => '5000.00',
            'currency'      => 'AUD',
            'transactionId' => '100321', // (My order ID)
            'card'          => $card,
        ]
    );

    $response = $transaction->send();


    }

The transactionID i got here is: 706256

please view the screenshot for the above transaction in the NAB: 在此处输入图片说明

    public function refund()
        {
          $gateway = Omnipay::create('NABTransact_SecureXML');
          $gateway->setMerchantId('XYZ0010');
          $gateway->setTransactionPassword('abcd1234');
          $gateway->setTestMode(true);

          $card = ([
                 'firstName' => 'ABC',
                 'lastName' => 'DEF',
                 'number'      => '4444333322221111',
                 'expiryMonth' => '05',
                 'expiryYear'  => '2025',
                 'cvv'         => '123',
             ]
         );

           $refund = $gateway->refund([
                           'transactionReference' => "706256",
                           'amount' => "5.00",
                           'currency' => "AUD",
                           'transactionId' => "100321",
                           'messageID' => '4',
                           'card' => $card,
                            ]);


             $refund->send();


        }

please view the screenshot for the above transaction in the NAB when trying to refund:

在此处输入图片说明

yes, i had solved it.

this is the sample of my code:

$gateway = Omnipay::create('NABTransact_SecureXML');
gateway->setMerchantId('_ID_');
$gateway->setTransactionPassword('_PASSWORD_');
$gateway->setTestMode(false); 

$refund = $gateway->refund([
            'transactionReference' => "12345",
            'amount' => "500",
            'transactionId' => 765897, (hope u must have saved this number in DB)
      ]);

  $response = $refund->send();
  $message = $response->getMessage();
  if ($response->isSuccessful()) {

   return "I m Happy"

    } else {
              return back()->with('amountError', $message);
           }
                    
       

Let me know how did it go :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM