Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution]Paypal IPN - Devosc


devosc

Recommended Posts

  • Replies 2.1k
  • Created
  • Last Reply

Top Posters In This Topic

I'll be able to let you know wether my IPNs start working tommorrow - my hosting support people have gone home as its 9pm here, and when i use the provided tools to remove my directory protection it makes the directory unavailable to anyone ! Running on Plesk. Most things work...

 

Thanks for the tip Jose - i guess i was just being over-protective.

Regards

Mark Brindle

Link to comment
Share on other sites

Greg:

 

First of all great contribution still trying to figure out here why i dont get the IPN back to the site, but no time for that this week.

what is this all about in modules/paypal.php ?

tep_draw_hidden_field('mrb', 'R-5X478387L4986632G').tep_draw_hidden_field('pal', 'ZH3UM7MDRAMCG');

Robert

 

We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;)

Link to comment
Share on other sites

still trying to figure out here why i dont get the IPN back to the site, but no time for that this week.

 

Nine time out of ten it is because the Primary Email Address and Business ID is not configured, if these are ok, try out the IPN Test Panel in case there is any error, you would need to uncomment the first error_reporting line in paypal/application_top and comment out the one below which switches it off. Check your debug emails, then see if the Cart Test is failing (info provided in the debug email).

what is this all about in modules/paypal.php ?

tep_draw_hidden_field('mrb', 'R-5X478387L4986632G').tep_draw_hidden_field('pal', 'ZH3UM7MDRAMCG');

That is a merchant referal code for storeowners who have 'not yet' registered for a PayPal merchant account, see your PayPal account profile for more details.

"Any fool can know. The point is to understand." -- Albert Einstein

Link to comment
Share on other sites

greg, you might have missed my previous questions a couple of pages back.

here it goes again:

 

Greg,

well, it turns out that is not the paypal logo that is trying to show up.

that is just the paypal status. This red X as shown in the picture happens when the paypal payment wasnt submited. For example, I was placing a dummy order and when I was in the paypal site about to complete the payment, my computer crashed. When I logged back in to the admin section to see if the order had registered, it did register although not as completed and the little red X showed up instead of telling me the usual "Payment Status: Completed"

 

Can this be changed so it displayes "Payment Status: Not Completed" instead?

 

and while we are at it, the paypal logo too for kicks :D

 

btw, this is in reference to http://www.oscommerce.com/forums/index.php?sho...ndpost&p=436621

Edited by wnfaknd
Link to comment
Share on other sites

Jose,

 

You would need to post the last PPSCIPN edit from admin/orders.php

 

The below is what is in the contrib package which doesn't insert any images:

//begin PayPal_Shopping_Cart_IPN
       if (strtolower($oInfo->payment_method) == 'paypal') {
         include_once(DIR_FS_CATALOG_MODULES . 'payment/paypal/database_tables.inc.php');
         $paypal_payment_status_query = tep_db_query("select p.payment_status from " . TABLE_PAYPAL . " p left join " . TABLE_ORDERS . " o on p.paypal_ipn_id = o.paypal_ipn_id where o.orders_id ='" . $oInfo->orders_id . "'");
         $paypal_payment_status = tep_db_fetch_array($paypal_payment_status_query);
         //quick work around for unkown order status id
         $paypal_payment_status_value = (tep_not_null($paypal_payment_status['payment_status'])) ? $paypal_payment_status['payment_status'] : $oInfo->orders_status_name;
         $contents[] = array('text' => TABLE_HEADING_PAYMENT_STATUS . ': ' . $paypal_payment_status_value );
       }
//end PayPal_shopping_Cart_IPN

If you wanted to show the PayPal logo instead of the text version change the line immediately above the above edit, eg. change

$contents[] = array('text' => '<br>' . TEXT_INFO_PAYMENT_METHOD . ' '  . $oInfo->payment_method);

To

if (strtolower($oInfo->payment_method) == 'paypal') {
 $paypalLogo = echo tep_image(DIR_WS_CATALOG_LANGUAGES . '../modules/payment/paypal/images/paypal_logo.gif','PayPal');
 $contents[] = array('text' => $paypalLogo );
} else {
 $contents[] = array('text' => '<br>' . TEXT_INFO_PAYMENT_METHOD . ' '  . $oInfo->payment_method);
}

But the paypal_logo.gif has a white background; ;et me know if you have a transparent background version.

"Any fool can know. The point is to understand." -- Albert Einstein

Link to comment
Share on other sites

hmm, as hard as I try to fix this on my own, I keep getting this error:

 

Parse error: parse error, unexpected T_ECHO in /home/wnfaknd/public_html/catalog/admin/orders.php on line 568

 

where line 568 is :

$paypalLogo = echo tep_image(DIR_WS_CATALOG_LANGUAGES . '../modules/payment/paypal/images/paypal_logo.gif','PayPal');

 

:( :(

Link to comment
Share on other sites

Here is some Code near the Paypal IPN contrib. Perhaps that other contrib messed something up.

 

//begin order modification contrib
       $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID', 'action')) . 'oID=' . $oInfo->orders_id . '&action=edit') . '">' . tep_image_button('button_details.gif', IMAGE_DETAILS) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID', 'action')) . 'oID=' . $oInfo->orders_id . '&action=delete') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
$contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_ORDERS_INVOICE, 'oID=' . $oInfo->orders_id) . '" TARGET="_blank">' . tep_image_button('button_invoice.gif', IMAGE_ORDERS_INVOICE) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS_PACKINGSLIP, 'oID=' . $oInfo->orders_id) . '" TARGET="_blank">' . tep_image_button('button_packingslip.gif', IMAGE_ORDERS_PACKINGSLIP) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS_EDIT, 'oID=' . $oInfo->orders_id) . '" TARGET="_blank">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a>');
$contents[] = array('text' => '<br>' . TEXT_DATE_ORDER_CREATED . ' ' . tep_date_short($oInfo->date_purchased));

//end order mod contrib


       $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_ORDERS_INVOICE, 'oID=' . $oInfo->orders_id) . '" TARGET="_blank">' . tep_image_button('button_invoice.gif', IMAGE_ORDERS_INVOICE) . '</a> <a href="' . tep_href_link(FILENAME_ORDERS_PACKINGSLIP, 'oID=' . $oInfo->orders_id) . '" TARGET="_blank">' . tep_image_button('button_packingslip.gif', IMAGE_ORDERS_PACKINGSLIP) . '</a>');
       $contents[] = array('text' => '<br>' . TEXT_DATE_ORDER_CREATED . ' ' . tep_date_short($oInfo->date_purchased));
       if (tep_not_null($oInfo->last_modified)) $contents[] = array('text' => TEXT_DATE_ORDER_LAST_MODIFIED . ' ' . tep_date_short($oInfo->last_modified));

if (strtolower($oInfo->payment_method) == 'paypal') {
$paypalLogo =  tep_image(DIR_WS_CATALOG_LANGUAGES . '../modules/payment/paypal/images/paypal-t.gif','PayPal');
$contents[] = array('text' => $paypalLogo );
} else {
$contents[] = array('text' => '<br>' . TEXT_INFO_PAYMENT_METHOD . ' '  . $oInfo->payment_method);
}

       //begin PayPal_Shopping_Cart_IPN
if (strtolower($oInfo->payment_method) == 'paypal') {
  include_once(DIR_FS_CATALOG_MODULES . 'payment/paypal/database_tables.inc.php');
  $paypal_payment_status_query = tep_db_query("select p.payment_status from " . TABLE_PAYPAL . " p left join " . TABLE_ORDERS . " o on p.paypal_ipn_id = o.paypal_ipn_id where o.orders_id ='" . $oInfo->orders_id . "'");
  $paypal_payment_status = tep_db_fetch_array($paypal_payment_status_query);
  //quick work around for unkown order status id
  $paypal_payment_status_value = (tep_not_null($paypal_payment_status['payment_status'])) ? $paypal_payment_status['payment_status'] : $oInfo->orders_status_name;
  $contents[] = array('text' => TABLE_HEADING_PAYMENT_STATUS . ': ' . $paypal_payment_status_value );
}
//end PayPal_shopping_Cart_IPN

Link to comment
Share on other sites

I can't really see anything from the above, the best I could suggestion is to comment out each line that begins with $contents[] untill you find the offending culprit.

 

From the above it looks as if there is som duplication occuring, eg. TEXT_DATE_ORDER_CREATED occurs twice.

"Any fool can know. The point is to understand." -- Albert Einstein

Link to comment
Share on other sites

hello guys i have tried every thing but still cant find out whats the problem here. all my customers can only checkout in USD which is my default currency. i accept 3 types of currencies . USD , GBP , EUR . Now if i a customer selectes GBP when they come to the site , all the prices changes to GBP , every thing works well but when they get to the paypal page , where they have to enter paypal login and password , the price changes back to USD . Can any one tell me how to fix this problem.

 

thankyou

Link to comment
Share on other sites

you say you only allow checkout in USD. Then you say you allow three currencies... which is it?

 

Did you enable paypal to allow any other type of currencies instead of just USD?

 

Did you enable the paypal module in the admin section to allow the selected currently instead of just USD?

Link to comment
Share on other sites

Greg,

I did some Mickey Mouse stuff and I got it working.

If the paypal payment is now pending it will show on red "Pending" with the logo and if the payment was submited succesfully, it will show as green "Submitted"

 

Here is the code in case you want to check it out:

//begin PayPal_Shopping_Cart_IPN
if (strtolower($oInfo->payment_method) == 'paypal') {
$paypalLogo =  tep_image(DIR_WS_CATALOG_LANGUAGES . '../modules/payment/paypal/images/paypal-t.gif','PayPal');
$contents[] = array('text' => $paypalLogo );
} else
 {
 {include_once(DIR_FS_CATALOG_MODULES . 'payment/paypal/database_tables.inc.php');
  $paypal_payment_status_query = tep_db_query("select p.payment_status from " . TABLE_PAYPAL . " p left join " . TABLE_ORDERS . " o on p.paypal_ipn_id = o.paypal_ipn_id where o.orders_id ='" . $oInfo->orders_id . "'");
  $paypal_payment_status = tep_db_fetch_array($paypal_payment_status_query);
  //quick work around for unkown order status id
  $paypal_payment_status_value = (tep_not_null($paypal_payment_status['payment_status'])) ? $paypal_payment_status['payment_status'] : $oInfo->orders_status_name;
  $paypalLogo =  tep_image(DIR_WS_CATALOG_LANGUAGES . '../modules/payment/paypal/images/paypal-t.gif','PayPal');
  $contents[] = array('text' =>  $paypalLogo . '<br>' . TABLE_HEADING_PAYMENT_STATUS . ': '  . '<b><font color="ff0000">' . $paypal_payment_status_value . '</b>' );
  }
}

if (strtolower($oInfo->payment_method) == 'paypal') {
  include_once(DIR_FS_CATALOG_MODULES . 'payment/paypal/database_tables.inc.php');
  $paypal_payment_status_query = tep_db_query("select p.payment_status from " . TABLE_PAYPAL . " p left join " . TABLE_ORDERS . " o on p.paypal_ipn_id = o.paypal_ipn_id where o.orders_id ='" . $oInfo->orders_id . "'");
  $paypal_payment_status = tep_db_fetch_array($paypal_payment_status_query);
  //quick work around for unkown order status id
  $paypal_payment_status_value = (tep_not_null($paypal_payment_status['payment_status'])) ? $paypal_payment_status['payment_status'] : $oInfo->orders_status_name;
  $contents[] = array('text' => TABLE_HEADING_PAYMENT_STATUS . ': ' . '<b><font color="009900">' .  $paypal_payment_status_value . '<b>' );
}
//end PayPal_shopping_Cart_IPN

 

One thing I've noticed though, when checking ~/admin/paypal.php to see all the different paypal orders, the pending orders do not show up at all.

 

Also when the customer does not submit the payment, the order still shows up on their history as pending. The order still shows up, but it shouldn't because they never got to the last step on the shopping cart. I'm not sure if i'm making myself clear on this. Let me know.

Link to comment
Share on other sites

hmmm... further more...

If the customer first selects paypal as the payment method, goes on to Paypal, cancels and finishs the transaction with a credit card, two orders will be logged in for him, one for paypal (pending) and another order with the credit card.

 

Both orders will show as paypal pendings on admin/orders.php page but if you click on the details of the Credit card one, the payment details are correct (credit card)

 

what do you make of that?

Link to comment
Share on other sites

i am completing installation of this contribution and have some questions. these elements from the faq are confusing

 

I'm having problems with Multi-Currencies.

Ok this is a tricky bit, currently the contrib will try and confirm the total order amount to the MC_GROSS amount which is the amount paid to you in the currency they selected (possibly through PayPal), this contrib should work OK if the both currencies are the same but this is an area that still needs to be refined, if you're having problems then switch off the 'Cart Test' via the admin .

 

this explanation is confusing...can anyone clarify?

 

Why is there no PayPal shipping address details in the IPN info?

Set Enable PayPal Shipping Address to 'No' if you require a PayPal verified shipping address, set to 'Yes' if you do not.

This is a bit tricky since there seems to be a confusing conflict especially if you want to get the customers shipping address details in the IPN info, so see what happens when you perform your test transactions with your PayPal config settings etc...

 

what does "set enable paypal shipping address" do? i'm aware that paypal has some config options regarding an address but this extra level of removal confuses me. i don't want my customers to have to create a paypal account, but i do want to get a legitimate billing address connected to their credit card....what should i do?

 

 

 

and lastly...

 

the install of this contribution is pretty strange...why do you overwrite two files and then alter these ?

catalog/account_history_info.php

catalog/checkout_success.php

catalog/includes/application_top.php

catalog/includes/classes/order.php

catalog/admin/orders.php

admin/includes/filenames.php

admin/includes/boxes/customers.php

admin/includes/classes/order.php

admin/includes/functions/general.php

admin/includes/languages/english.php

admin/includes/languages/english/orders.php

 

wouldn't it just be easier to overwrite them all? let me know if you want help writing a script to do this.

FlashMOG - make multiplayer games in Flash/PHP!

Link to comment
Share on other sites

to answer your last questions. The two files you overwrite shouldnt have any modifications and chances are they are the default files, so it is ok to overwrite them. The other files, chances are have been modified by other contribs, so you would just want to alter them to suit your needs.

Link to comment
Share on other sites

i have also noticed that when i refund money from the seller account to the buyer's account that osCommerce has absolutely no record of the refund transaction.

 

how difficult would it be to implement that? i have some pretty sharp PHP skills and would be happy to help.

FlashMOG - make multiplayer games in Flash/PHP!

Link to comment
Share on other sites

Hi Jose, I appreciate what you're saying about the swapping choice of payment method, I did have a solution in mind a while back but that, if I can recall, requires that all payment modules do a check to make sure that the payment session order is theirs and if not to remove and or update it, this is something outside the scope of a simple payment module (contribution).

 

In regard to Pending orders not showing in admin/paypal this is because this page will opnly show IPNs.

 

The problem about the customer abandoning the order once they get to PayPal is a problem, the only real solution here is to have a cron job that will go through and purge any abandoned orders after 4 days, since PayPal can take upto 4 days to send an IPN according to their manual (not the latest publication).

 

SneakyImp, thats the best I can offer at this time, there is better clarification, but really the best way is to test things out, try the sandbox domain if neccessary.

 

Although I will mention one problem I'm recently beginning to have mind of, in short you should only offer currencies that PayPal supports. The problem is the order is prestored in the currency that the customer has selected, but if it is not supported by PayPal it will default to USD (per payment/paypal.php or even if using customer selected currency PayPal will still convert it). Again this is still a tricky bit (I say this because PayPal returns mc_gross but their Integration Manual, if I can recall, does not give examples of when the initial currency is not one of the ones they support), I have attempted to clarify the problem myself, but time and priorities take precedence.

 

In regard to Refunds, yep I've already started to work on it and in fact have the outline solution at hand, however I recently became aware of other Payment merchants utilizing IPN and so now I'm trying to make PPSCIPN compatible so that it will, for example share a payment_id instead of paypal_ipn_id in the orders table. However again time and priorities take precedence.

"Any fool can know. The point is to understand." -- Albert Einstein

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...