getTransactionByHash() must be of the type string, null given I'm building my first Payment Gateway (offsite gateway) for Commerce 2.  This one is for Moneris.  I'm hitting an error when the page returns the response.

Argument 1 passed to craft\commerce\services\Transactions::getTransactionByHash() must be of the type string, null given

I'm pretty sure I need to do something in completePurchase with the response given, but I don't really understand where to start.  I've looked at Mollie and Paypal Express for exemples and I can't figure it out.  Can anyone point me in the right direction?

Here is the Post Moneris is sending me back:

$_POST = [
    'response_order_id' =&gt; '85a6df720018874fde293aa3418e7a97',
    'date_stamp' =&gt; '2018-09-11',
    'time_stamp' =&gt; '08:37:36',
    'bank_transaction_id' =&gt; '660186290010010030',
    'charge_total' =&gt; '88.10',
    'bank_approval_code' =&gt; '945622',
    'response_code' =&gt; '027',
    'iso_code' =&gt; '01',
    'message' =&gt; 'APPROVED           *                    =',
    'trans_name' =&gt; 'purchase',
    'cardholder' =&gt; 'Test Card',
    'f4l4' =&gt; '4242***4242',
    'card' =&gt; 'V',
    'expiry_date' =&gt; '2108',
    'result' =&gt; '1',
    'txn_num' =&gt; '3-0_11',
    'cvd_response_code' =&gt; 'M',
];

Thank you!
When you redirect to the gateway's site to accept payment, within the data they receive, they usually ask for the URL to return to after payment is made.

This URL should point to the PaymentsController::actionCompletePayment() controller action, but have the param ?commerceTransactionHash=YOUR_TRANSACTION_HASH appended to it.

My guess is that the error you are getting is being triggered in PaymentsController::actionCompletePayment() on line 346:

$hash = Craft::$app-&gt;getRequest()-&gt;getParam('commerceTransactionHash');

$transaction = Plugin::getInstance()-&gt;getTransactions()-&gt;getTransactionByHash($hash);


Where it is passing null to getTransactionByHash.

Once it is able to get the transaction, it will call your gateway's completePayment method where you can inspect the request data from your gateway.

Hope that helps.