Its several days that i'm trying to solve a payment method problem, and I really need support to solve it.

I have to create a new payment method, i studied the existing ones, i tried to simulate the paypall express, but it is still hard for me to understand the flow beetween purchase and purchase_return method.

This is the problem: I have to create a new payment method that redirect the user in a bank page. Here, the user will insert his bank datas (like paypall) and later, the system redirect the user back to my site. Here i have to do some operations with some informations that the bank give back to me in a GET way.

1 - complete checkout DONE 2 - create a new payment method DONE 3 - connect to a bank DONE (using the "purchase" function) -> the user is redirected to the bank page. The customer insert his datas, and after the bank redirect my to a url of my site that i told it before in a request. It is like:


so, the hash_code and some parameters that the bank append to my return_url, because i need thosevdatas in order to make more operations later.

4 - Redirection from the bank to my site at the url above DONE

now, if I'm correct, i expect the code inside the function "purchase_return" will be automatically executed (if i understand right). But it doesn't. I force the call of this function from the template of the checkout/complete page, importing the merchant library and my custom payment method code. Now the code that i put inside the "purchase_return" function will run. I return new Merchant_response(Merchant_response::COMPLETE, NULL, $order_id);

RESULTS: The order is still pending. It's not paid and it isn't complete. So: my cart is not empty, too!

Somebody can help me, please??? thanks on advance!!

  • 2
    Don't try to call the purchase_return method manually, it will break everything. If you specify the correct return URL, Store will automatically call that method for you. It's not possible to help without seeing your code though, can you put it up on gist.github.com or something? Jul 23, 2013 at 13:49

1 Answer 1


You don't need to import the merchant library or call purchase_return() manually.

If you pass the correct return_url to the gateway during the purchase() request, then Store will handle the response and call the code inside your purchase_return() method for you.

For example, in the Auth.net gateway, the purchase method looks like this:

$request = array();
// ...
$request['x_relay_url'] = $this->param('return_url');
$request['x_cancel_url'] = $this->param('cancel_url');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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