You should take a look at other gateways which handle this situation, for example Paypal Express:
https://github.com/expressodev/ci-merchant/blob/master/libraries/merchant/merchant_paypal_express.php
When you build the purchase request, you need to tell the gateway to return the customer to $this->param('return_url')
. For example, in Paypal this involves:
$request['RETURNURL'] = $this->param('return_url');
This URL will look something like:
https://example.com/index.php?ACT=123&H=abcdef123456
This is a special EE action URL, which is passed through to Store. Store looks up the payment hash to see which gateway requested the payment, then automatically loads that gateway, and calls purchase_return()
. So you need to implement that method on your gateway class:
public function purchase_return()
{
// do something here
}
Inside the purchase_return()
method you should check $_GET
or $_POST
for the encrypted string that the gateway sent back to you. Here is another good example of decoding a response and returning the appropriate reply:
https://github.com/expressodev/ci-merchant/blob/master/libraries/merchant/merchant_dps_pxpay.php#L62
Basically, if the transaction is successful you should return something like:
return new Merchant_response(Merchant_response::COMPLETE, $response_message_from_gateway, $transaction_id_from_gateway);
If the response failed, return something like:
return new Merchant_response(Merchant_response::FAILED, $response_message_from_gateway, $transaction_id_if_there_was_one);
Then Store will know to update the order accordingly, and will either mark the order as complete and redirect the customer to the success page, or send them back to the checkout to try again.