Jump to content

Some Issues With Paypal Like Custom Module


Recommended Posts

Hi,

I'm making some modifications to the paypal module payment, I can get the payment correctly. I just have some small issues. 

 

The flow I'm making is the following:

The users clicks on the payment option which redirect to paypal site to make the payment. Once the user has paid I get automatically the paypal notify callback (which does the validateOrder).

 

here's the sentence :

$paypal->validateOrder($_POST['custom'], _PS_OS_PAYMENT_, $price, $paypal->displayName, $paypal->getL('transaction').$_POST['txn_id']);

Then on the payment flow the user click on button to return to my site (which goes to order-confirmation) but actually displays order history (which I do not like). why is it going to order history?

 

Here's the callbacks:

 

'goBackUrl' => 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'index.php?controller=order-confirmation&key='.$customer->secure_key.'&id_cart='.intval($params['cart']->id).'&id_module='.intval($this->id),
'notify' => 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/' . $this->name. '/validation.php',
'cancelUrl' => 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'index.php',

I'll like that when the user clicks to return to my site, he is redirected to my own order summary.... so can I skip the callback to prestashop's order-confirmation ? How is the correct flow ? Where the goBackUrl should point to?

 

Thanks 

Edited by Maria Gonzalez (see edit history)
Link to comment
Share on other sites

When you pay on paypals website, before you click the button to return to your site, you can go to your back office and see if the order was created. 

 

If the order is created before you click the button, then you know the IPN was received and processed. 

If the order is not created before you click the button, then you know the IPN was not received and/or processed, and there is no way PS can display an order confirmation page.

Link to comment
Share on other sites

I did the test you told me, before going back to my site I checked my back office and the order was there, then I clicked on paypal page to return to my site and yes it went to the confirmation order just fine.......

However I did another test, this time I went faster and did not look at back office....and it failed it redirected me to order history (the recently made order wasn't on the list), then I went to back office and the order was there...refreshed order history and the order suddently appeared............so the problem is that paypal is not fast enough? any solution to that?

Link to comment
Share on other sites

Not sure there is a good solution for that.

 

In theory, Paypal should never allow you to redirect back to your store until the IPN has been acknowledged by your module.  Obviously this is not the case, and they redirect you back.  I suspect that is because IPN's can fail, or be delayed and there fore the customer would be stuck on the Paypal website waiting...

 

So that means that the Paypal module needs to be more intelligent and it needs to create the order under 2 conditions

1) When the IPN is received, the module should first check if the cart has been converted to an order.  If not, then it should convert to order.

2) When the customer is redirected back from Paypal, the module should check if the cart has been converted to an order. If not, then it should query Paypal to ensure the transaction was completed (avoid man in the middle attack) and then convert to order, otherwise just redirect to order confirmation page

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...