Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

PayPal: FIXED adding shop order and using standard paypal module!!!


jazzychad

Recommended Posts

Ok, I have never done a formal Contribution before, so maybe someone can help me turn this into one if people think it would be worth it:

 

So, there has always been a problem of people using the standard PayPal payment module but the order doesn't get added to your shop orders unless the user clicks the nearly invisible "return to merchant" link and only if you've set it up correctly to return to the checkout_process.php page. Well, now I've come up with a solution to all that.

 

Here's what happens:

 

The checkout process continues the same up until they click the "Confirm Order" button.

Once they click, they are redirected to the PayPal site in a *new window* while underneath the shop website automatically redirects itself to the checkout_process.php page, thereby adding the order to the shop database while the user is paying for their stuff on PayPal. (if the user cancels during the PayPal process, then they're out of luck... their cart has already been emptied, but oh well... at least this is better than losing their order after they've paid!!)

 

Here's what I did to set this up:

 

In /catalog/includes/modules/payment/paypal.php

AFTER: (around line 30ish)
  $this->form_action_url = "https://secure.paypal.com/cgi-bin/webscr";
ADD:
  $this->parameters = "target=\"_new\" onSubmit=\"return location.href='./checkout_process.php';\"";


=============================================

In /catalog/checkout_confirmation.php

AFTER: (around line 390ish)
 if (isset($$payment->form_action_url)) {
$form_action_url = $$payment->form_action_url;
 } else {
$form_action_url = tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL');
 }

ADD:
 if (isset($$payment->parameters)) {
$pay_parameters = $$payment->parameters;
 } else {
$pay_parameters = '';
 }

---------------------------------

CHANGE: (around line 400ish):
 echo tep_draw_form('checkout_confirmation', $form_action_url, 'post');

TO:
 echo tep_draw_form('checkout_confirmation', $form_action_url, 'post', $pay_parameters);

 

This should do it. Someone please try and make sure these directions are accurate. All I know is a solution to this problem is way overdue, and hopefully this will help some people out.

 

-Chad

Edited by jazzychad
Link to comment
Share on other sites

Addendum:

 

This method does have the side effect that it will email the customer an order confirmation whether or not they actually complete payment through PayPal. I'm not too sure how to deal with this (still better than losing order info completely), but maybe someone else has an idea?

-Chad

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...