2

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:

https://www.mysite.com/checkout/complete/ddf4692dbe3ffc47b8605bf226ab9c1c?PaymentID=1176193011631910&tranid=7549221021631910&TrackID=00021551DD695185B0A5.93845334&postdate=0710&resultcode=CAPTURED&auth=999999&Error=&ErrorText=&cardtype=VISA&payinst=CC&liability=Y&responsecode=00

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? – Adrian Macneil Jul 23 '13 at 13:49
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, privacy policy and cookie policy

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