Not too sure if this best fits as a bug or as a feature request but here goes.
In this thread here it has been said that the Simple Commerce Module (from now on referred to as SCM) doesn’t recognise multiple items being sent back to it when those items have been added to PayPal using the all in one Cart method.
At the moment if you use the SCM the method you employ is adding an item to the PayPal cart and then coming back to the site to add another and so on and so forth.
Using the plugin that I have created it allows you to have a shopping cart directly on your site so that you don’t have to keep on popping up a PayPal window every single time you want to add an item to the cart. It stores everything and then you can pass them all along to PayPal in one go using the PayPal Cart method.
It has been said that the purchase do go through using this method but that PayPal is then sending back the variables in a format which isn’t recognised by the SCM so that purchases don’t get registered in the backend of ExpressionEngine.
I was just wondering if someone could confirm this and if so could the code of the SCM be changed to allow multiple items to be sent back to it?
It seems a little weird to me as I would have thought that it wouldn’t matter which way you add more than one item to the PayPal cart as it is still sending back multiple items but apparently it won’t work if done using the Cart method.
Any help on this would be greatly appreciated.
Best wishes,
Mark
Mark, I’m going to shift to ‘Plugins’ for now, because it looks like simple commerce is working as expected ‘stock’. If paypal is sending back data in a different format when purchased via the plugin and you need EE to handle that format, it would be in the range of a feature request. Or, it may be possible to tweak the plugin so that paypal uses the variables EE’s relying on. (But paypal is quirky, so I won’t swear on that one.)
You might take a look at this debug code from Derek- it’s an easy way to get a look at exactly what paypal is returning via IPN. But comparing that to what EE’s looking for in incoming_ipn() you should be able to spot whether anything is mismatching there. If it IS seen as verified but the problem is entering the data, you could take a look at perform_actions(). And note- there IS a hook in there- simple_commerce_evaluate_ipn_response. If it’s a matter of tweaking variables names, etc? You could modify the returned data before it goes through verification/entry. I suspect you could get things working like you want via that.
The above all make sense?
Hi Robin,
Admitted the SCM does work as it is programmed to but this isn’t really anything to do with the plugin I have created, more the fact that the SCM handles things differently when multiple items are sent back which have been sent in different ways to it.
If you use the standard stock SCM code and add items laboriously to a PayPal cart then all works as it should do, the items get processed by ExpressionEngine and get added into the database.
However if you use the Cart method of PayPal it appears that the information being sent back is not recognised by ExpressionEngine or so I have been told.
Forgetting about my plugin for a minute I was informed that even if you were to set up a static form with hard-coded values and send multiple items off to a PayPal cart in one go then the payment goes through on the PayPal side but when the information is sent back to ExpressionEngine it can’t handle the items being sent.
I personally would have thought that no matter how multiple items are added into the PayPal cart that ExpressionEngine (as long as it gets back the items it needs) would be able to handle them?
Seems like PayPal might be sending back information differently depending on the method used to add items to the PayPal cart?
I’m not very good or up on the PayPal API so I might be wrong but could you possibly move this over to Feature Requests or somewhere as I still feel that this is a bug somewhere along the line. If not ExpressionEngine then possibly PayPal but it would be nice for the SCM to have this functionality as I think it is definitely a very much needed piece of code for a lot of people.
I may of course be completely wrong on all of this but I’ve always had problems trying to track down things with PayPal and the Sandbox environment and I know that the Dev team here would be able to figure out what is going on much faster than I ever could so any help on this would be massively appreciated.
Again this is not really anything to do with the plugin I created because I have been told that if you hard-code a form then the same thing happens.
Any help on this would be greatly appreciated.
Best wishes,
Mark
P.S. I will take a look at that debug code again, thanks for that.
Mark, do you mind dumping the array that PayPal is sending back? I think you’re right, that it’s doing it situationally. Did my recommended fix do the trick to allow the IPN to work? The user in that thread didn’t really address that issue, as they had the larger issue of the purchases not being made by logged in members, so IPN wasn’t going to work for him in any case.
Hi Derek,
Thanks for coming in on this one. I just went to test all this out and have had to go through the lovely headache of setting up all the PayPal accounts again as for some reason the Sandbox accounts I set up some time ago don’t work any more!
I just tested by using the stock ExpressionEngine code on one entry that I made into an SCM entry and got back an e-mail with the code that was in the post linked above with your test code although I did have to delete a space somewhere in the code or the template wouldn’t show and was coming up with a T_STRING error. Something to do with copying and pasting from the forum though I think.
I got back this code although the purchase hasn’t shown up in the control panel. I am literally just using the standard ExpressionEngine code to buy the item and not using my plugin at all at this stage.
Array ( [mc_gross] => 1.00 [protection_eligibility] => Eligible [address_status] => confirmed [item_number1] => 1 [payer_id] => KLSQ96CDP4LBU [tax] => 0.00 [address_street] => 1 Main Terrace [payment_date] => 14:33:53 Dec 04, 2008 PST [payment_status] => Pending [charset] => windows-1252 [address_zip] => W12 4LQ [mc_shipping] => 0.00 [mc_handling] => 0.00 [first_name] => Test [address_country_code] => GB [address_name] => Test User [notify_version] => 2.6 [custom] => 4 [payer_status] => unverified [business] => [email protected] [address_country] => United Kingdom [num_cart_items] => 1 [mc_handling1] => 0.00 [address_city] => Wolverhampton [verify_sign] => ARpTDwNXMO-0GBxqU9zU.bGoALCVAQBKUY1FlR6HOqNwAJ3lzHWWgSV4 [payer_email] => [email protected] [mc_shipping1] => 0.00 [tax1] => 0.00 [txn_id] => 5VG754957B111925A [payment_type] => instant [last_name] => User [address_state] => West Midlands [item_name1] => PayPal Item [receiver_email] => [email protected] [quantity1] => 1 [receiver_id] => KF8QM9EVNY6GY [pending_reason] => multi_currency [txn_type] => cart [mc_gross_1] => 1.00 [mc_currency] => USD [residence_country] => GB [test_ipn] => 1 [transaction_subject] => 4 [payment_gross] => 1.00 )
This was just with one item. I didn’t even bother trying with more than one as I get the e-mail as shown above but the purchase isn’t going into the Control Panel at the moment!!
Sheesh how I hate the PayPal API!!
Any help on this would be great, thanks.
Best wishes,
Mark
Sheesh how I hate the PayPal API!!
You and me both.
[test_ipn] => 1
It won’t show up in your CP since you’re coming from the sandbox, though if you flip $debug to TRUE, it should keep going. Though I recall someone mentioning to me a few weeks ago that they thought PayPal stopped processing IPN from the sandbox to cut down on traffic. You could confirm by also dumping the $response to an email on line 402 after PayPal has been pinged for verification.
Actually it does send to the control panel, just got it to work. You have to make sure you click on their stupid orange button that says return to store (or whatever it says), the purchase then shows up in the control panel.
Off to try it out with the plugin now and see what happens.
Will let you know. May take a while though so may have to do this on the weekend and let you know then what happens. Will give you a couple of days rest from the pest that is me anyway 😉
Did everything look okay in the array above though?
Best wishes,
Mark
Thanks for looking at the array content for me. Glad it’s all looking ok.
One more thing if I may Derek?
I was just wondering how exactly I would code a static form to send off multiple (2 will do me for now) items to the sandbox so that I can test it out with sending more than one item at a time instead of adding items one at a time as the SCM currently does.
Basically if I can just find out exactly what form fields I need to add in to send off items and then I can test out sending more than one at once with my entry_ids.
I’m just not sure what I have to send off to PayPal so that it gets all the information it is expecting.
I found this code below on this page :
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="item_name_1" value="Item Name 1">
<input type="hidden" name="amount_1" value="1.00">
<input type="hidden" name="item_name_2" value="Item Name 2">
<input type="hidden" name="amount_2" value="2.00">
<input type="submit" value="PayPal">
</form>
It looks like they are using underscores although I don’t care if PayPal have it wrong as they seem to a lot!! Just wondering what input fields I need to place for an item and then I can create a static form with my site entries in it and send that off to PayPal and see if that works. If it does then I can try it out with my plugin and get it all working with that too.
Hope that all made some sense?
Thanks again for the help on this Derek.
Best wishes,
Mark
Er, didn’t your plugin already send multiple items to the cart at once? The underscores should be used, if I’m reading the docs correctly, for that task. The issue is, at least how I understood it from the other thread, that PayPal returns the data without the underscores normally, which is what the SCM expects to see, but returns it differently when the aggregate cart is used, hence why the proposed fix I linked to earlier adds the underscores in to the validation and use in the SCM module’s acceptance of the IPN. Clear as mud?
Er, didn’t your plugin already send multiple items to the cart at once?
No. The plugin literally is just a sessions based cart which stores all the items and allows you to spit out their names and prices etc whenever and wherever you want on your site. You can then create a form to send off the details to wherever you need to.
The underscores should be used, if I’m reading the docs correctly, for that task.
Understood so far 😉
The issue is, at least how I understood it from the other thread, that PayPal returns the data without the underscores normally, which is what the SCM expects to see, but returns it differently when the aggregate cart is used, hence why the proposed fix I linked to earlier adds the underscores in to the validation and use in the SCM module’s acceptance of the IPN. Clear as mud?
Absolutely clear as a face mask, yes 😉 Why does PayPal have to be so darned awkard?
So I can test this out though can you tell me what information I have to send to PayPal for an item so that I can make a static cart form and send off a couple of items at once?
Once I have a static HTML page form sending off to PayPal and working then I can integrate the plugin with it as all the cart plugin will do is automatically fill out the form fields for me. I just need to know what fields I need to send in the first place though.
Thanks again for the help on this as it’s very much appreciated.
Best wishes,
Mark
Okay so I just can’t sleep can I? I must be like Gustav Graves from the James Bond film!! 😉
I just tried creating a form with this code :
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="custom" value="4">
<input type="hidden" name="lc" value="GB">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="item_name_1" value="PayPal Item" />
<input type="hidden" name="quantity_1" value="1" />
<input type="hidden" name="amount_1" value="1" />
<input type="hidden" name="item_number_1" value="12" />
<input type="hidden" name="item_name_2" value="Super Admin Test" />
<input type="hidden" name="quantity_2" value="1" />
<input type="hidden" name="amount_2" value="2" />
<input type="hidden" name="item_number_2" value="10" />
<input type="submit" value="PayPal">
</form>
I get sent to the PayPal Sandbox cart and both items have been added there and show the correct information. I log in, pay and then it says it has all gone through. This all works fine but then I notice something a little different. There is no big ugly orange button saying return to merchant site so I am thinking to myself it’s not going to send back the IPN is it?
Absolutely right I was too!! It didn’t!!
I did get back another e-mail showing this code in the array this time though :
Array
(
[mc_gross] => 3.00
[protection_eligibility] => Eligible
[address_status] => confirmed
[item_number1] => 12
[tax] => 0.00
[item_number2] => 10
[payer_id] => KLSQ96CDP4LBU
[address_street] => 1 Main Terrace
[payment_date] => 16:34:22 Dec 04, 2008 PST
[payment_status] => Completed
[charset] => windows-1252
[address_zip] => W12 4LQ
[mc_shipping] => 0.00
[mc_handling] => 0.00
[first_name] => Test
[mc_fee] => 0.30
[address_country_code] => GB
[address_name] => Test User
[notify_version] => 2.6
[custom] => 4
[payer_status] => unverified
[business] => [email protected]
[address_country] => United Kingdom
[num_cart_items] => 2
[mc_handling1] => 0.00
[mc_handling2] => 0.00
[address_city] => Wolverhampton
[verify_sign] => An5ns1Kso7MWUdW4ErQKJJJ4qi4-Anfbk775MuXgWIMyftEhexzsANqK
[payer_email] => [email protected]
[mc_shipping1] => 0.00
[mc_shipping2] => 0.00
[tax1] => 0.00
[tax2] => 0.00
[txn_id] => 93R435627B685632G
[payment_type] => instant
[last_name] => User
[address_state] => West Midlands
[item_name1] => PayPal Item
[receiver_email] => [email protected]
[item_name2] => Super Admin Test
[payment_fee] =>
[quantity1] => 1
[quantity2] => 1
[receiver_id] => KF8QM9EVNY6GY
[txn_type] => cart
[mc_gross_1] => 1.00
[mc_currency] => GBP
[mc_gross_2] => 2.00
[residence_country] => GB
[test_ipn] => 1
[transaction_subject] => 4
[payment_gross] =>
)
I see that the items this time when sent back don’t have the underscores just as per normal but for some reason the site never gets the IPN call. Am I missing something blatantly obvious here? I think I’m about to tear my hair out on this one.
I’m sure I must be missing something somewhere and just need a good kick in the right direction if you could perhaps?
Best wishes,
Mark
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.