Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Payment module for worldpay and paypal


xlilo

Recommended Posts

hi all,

 

i have errors with all my payment modules, paypal and worldpay.

 

When you go through checkout proccess it adds items to the basket perfectly fine however when you come to pay via worlp pay or paypal the item description will disapear and become the name of the shop, almost like it sends the wrong info to the payment gateway merchant.

 

here are details for you to see for your self to get a better understanding.

 

URL : www.homeofbathrooms.co.uk

USRNAME: [email protected]

PASSWORD : test1

 

please help as this is inportant to me.

 

Thanks very much.

Link to comment
Share on other sites

for anyone looking for a fix on this proble carry on reading, i found this at http://fixlog.blogspot.com/2006/09/paypal-...me-instead.html

 

Paypal module passes STORE_NAME instead of item

The PayPal payment module (paypal.php,v 1.39 2003/01/29) for OSCommerce does not pass a meaningful item description to Paypal as a transaction is processed. Instead, the developer of this module programmed it to send the name of your store instead:

 

tep_draw_hidden_field('item_name', STORE_NAME) .

The result is that when the transaction completes, Paypal sends the store owner an email notification, unhelpfully describing the item purchased as "[name of your store]".

 

We will fix this by changing the code in the payment module to send a better description for that field. While we're at it, we'll change the code to better support stores selling multiple items in one transaction because this Paypal module comes "out of the box" designed more for single item purchase. When multiple items are purchased, this module just gives an aggregate description of the whole transaction, without any detail of what exatly was purchased.

 

To fix both of these problems, use the patch file below, or edit (path to your store)/includes/modules/payment/paypal.php and jump down to this function:

function process_button() {

find the line that looks like:

 

$process_button_string = tep_draw_hidden_field

and insert a comment marker right before it:

/*

$process_button_string = tep_draw_hidden_field

and then go down a few more lines from there until you get to the one that has a semicolon at the end, instead of a period. After that line, insert an ending comment marker:

*/

Now, after your ending comment marker (commenting out the original code makes it not operate anymore, while preserving it for reference), insert the following:

# Multiple item payment, P. 86 of

# https://www.paypal.com/en_US/pdf/PP_Website...rationGuide.pdf

 

$process_button_string = tep_draw_hidden_field('cmd', '_cart') .

tep_draw_hidden_field('upload', '1') .

tep_draw_hidden_field('business', MODULE_PAYMENT_PAYPAL_ID) .

tep_draw_hidden_field('handling_cart', number_format($order->info['shipping_cost'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency))) .

tep_draw_hidden_field('currency_code', $my_currency) .

tep_draw_hidden_field('custom', $order->info['comments']) .

tep_draw_hidden_field('return', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL')) .

tep_draw_hidden_field('cancel_return', tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));

 

# add individual items and amounts to keep in PP transaction history and notices

 

$i=0;

foreach($order->products as $key => $arr)

{

$i++;

$process_button_string .= tep_draw_hidden_field("item_name_$i", $arr["qty"] ." ". $arr["name"]) .

tep_draw_hidden_field("amount_$i", $arr["final_price"]);

 

}

Save the file, and now every payment transaction from your OS-Commerce store that is processed with this payment module will send Paypal the item name and price of each item your customer is purchasing. The "handling_cart" field adds a single shipping fee to the entire order. If you want to charge shipping amount per item, see the manual mentioned in the code comment above and use multiple "shipping_X" fields inside the foreach loop instead.

 

Once you make this change, the email notices that Paypal sends to the shop owner after each purchase will contain a detailed list of what was bought. Both the customer and the merchant will also have detailed records of the itemized list stored in the Paypal transaction history. This is much better than just one aggregate item with a total price and no Paypal record of what the order consisted of.

 

Using my patch file to make the above change.

You can skip a whole lot of manual editting if you download the patchfile included below, save it as paypal.patch in the same directory as the original paypal.php file, and then run the following shell command:

patch -b paypal.php < paypal.patch

The -b option will make a backup copy of the original file, just in case.

 

 

Click to show patch

Hide Patch--- orig.php Wed Sep 20 22:49:53 2006

+++ paypal.php Wed Sep 20 23:05:07 2006

@@ -83,6 +83,8 @@

if (!in_array($my_currency, array('CAD', 'EUR', 'GBP', 'JPY', 'USD'))) {

$my_currency = 'USD';

}

+

+/*

$process_button_string = tep_draw_hidden_field('cmd', '_xclick') .

tep_draw_hidden_field('business', MODULE_PAYMENT_PAYPAL_ID) .

tep_draw_hidden_field('item_name', STORE_NAME) .

@@ -91,6 +93,30 @@

tep_draw_hidden_field('currency_code', $my_currency) .

tep_draw_hidden_field('return', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL')) .

tep_draw_hidden_field('cancel_return', tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));

+*/

+

+# Multiple item payment, P. 86 of

+# https://www.paypal.com/en_US/pdf/PP_Website...rationGuide.pdf

+

+$process_button_string = tep_draw_hidden_field('cmd', '_cart') .

+ tep_draw_hidden_field('upload', '1') .

+ tep_draw_hidden_field('business', MODULE_PAYMENT_PAYPAL_ID) .

+ tep_draw_hidden_field('handling_cart', number_format($order->info['shipping_cost'] * $currencies->get_value($my_currency),

+ $currencies->get_decimal_places($my_currency))) .

+ tep_draw_hidden_field('currency_code', $my_currency) .

+ tep_draw_hidden_field('custom', $order->info['comments']) .

+ tep_draw_hidden_field('return', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL')) .

+ tep_draw_hidden_field('cancel_return', tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));

+

+# add individual items and amounts to keep in PP transaction history and notices

+

+$i=0;

+foreach($order->products as $key => $arr)

+{

+ $i++;

+ $process_button_string .= tep_draw_hidden_field("item_name_$i", $arr["qty"] ." ". $arr["name"]) .

+ tep_draw_hidden_field("amount_$i", $arr["final_price"]);

+}

 

return $process_button_string;

}

 

 

 

Posted by Ptang Ptang Olay Biscuit Barrel at 8:24 PM

 

Labels: linux, oscommerce, paypal

 

 

6 comments:

Anonymous said...

Excellent bit of information. Just had a client come back to us with this problem. Not sure what he thought the use of STORE_NAME was going to have.

 

Anyway .. Good stuff man!

 

7:40 AM

Anonymous said...

Hi!

Thanks for this info. However i implemented it and i noticed that there is a bug.

If a client pay 3 different items in HK$ when he goes to Paypal site the same amount is there but in USD. So, there's a problem with currency conversion!

Any idea to alter this?...

Thank you

 

12:01 AM

Anonymous said...

Check where the value of $my_currency is coming from in the line above:

 

...

tep_draw_hidden_field('currency_code', $my_currency) .

...

 

Or, just replace the variable $my_currency with the literal value for "HongKong" or whatever will clue Paypal on the currency type you want to use.

 

11:51 AM

Rob said...

I site requires size information as well, but this patch only handles item name and price/shipping. Any suggestions?

 

6:03 PM

Anonymous said...

This patch works great, but only handles item name and cost. I need to incorporate product size as well. Any suggestions?

 

6:04 PM

Anonymous said...

First you'll need to identify what variable holds your size value. You can figure thisa out by putting the following code right after the line:

 

function process_button(){

 

Insert this line:

 

print_r($order->products); exit;

 

Then place an order and you should see the entire order products variable values printed to the screen.

 

Lets pretend you find from the above that products' array key 'size' held the size value the shopper sleected. (Get the correct key name from the debugging print above).

 

Now delete that debugging line and go to the end of the file and change this line:

 

$process_button_string .= tep_draw_hidden_field("item_name_$i", $arr["qty"] ." ". $arr["name"]) .

tep_draw_hidden_field("amount_$i", $arr["final_price"]);

 

to this:

 

$process_button_string .= tep_draw_hidden_field("item_name_$i", $arr["qty"] ." ". $arr['size'] ." ". $$arr["name"]) .

tep_draw_hidden_field("amount_$i", $arr["final_price"]);

 

and that will add the size to the breakdown of what specific products were in the order and how much each cost.

Link to comment
Share on other sites

  • 3 weeks later...

The only problem I am having with the followin code is that I have been unable to get the correct item price which isthe price from SSPC price ie the original product price is displayed not the seperate price by customer group with tax

 

# Multiple item payment, P. 86 of 
# [url="https://www.paypal.com/en_US/pdf/PP_WebsitePaymentsStandard_IntegrationGuide.pdf"]https://www.paypal.com/en_US/pdf/PP_Website...rationGuide.pdf[/url]

$process_button_string = tep_draw_hidden_field('cmd', '_cart') .
tep_draw_hidden_field('upload', '1') .
tep_draw_hidden_field('business', MODULE_PAYMENT_PAYPAL_ID) .
tep_draw_hidden_field('handling_cart', number_format($order->info['shipping_cost'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency))) .
tep_draw_hidden_field('currency_code', $my_currency) .
tep_draw_hidden_field('custom', $order->info['comments']) .
tep_draw_hidden_field('return', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL')) .
tep_draw_hidden_field('cancel_return', tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));

# add individual items and amounts to keep in PP transaction history and notices

$i=0;
foreach($order->products as $key => $arr)
{
$i++;
$process_button_string .= tep_draw_hidden_field("item_name_$i", $arr["qty"] ." ". $arr["name"]) .
tep_draw_hidden_field("amount_$i", $arr["final_price"]);

} 

 

Appreciate any advice to have correct pice displayed

 

Thanking you all in advance

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...