We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

RE : Simple Commerce Module…

Development and Programming

Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Hi Derek,

Sorry for trying to plonk all of this on you that wasn’t my intent. It’s just weird as it does add all the items to the PayPal cart, paypal takes the purchase fine, I get the e-mail in the developer area telling me it all went through fine and I get an e-mail to my own real account with the array information which I think all looks okay but it never seems to ping back the IPN to the site. The only thing I can see that is any different is that once you have paid in this fashion you aren’t presented with the orange button to click which seemed to be the only time the IPN call gets sent back.

I am logged in and I’m pretty sure everything else is working fine so not really too sure what to do now. I will try again over the weekend with a fresh pair of eyes when I’m not so tired though as I might be missing something somewhere.

If anyone else has any ideas on this though then please do shout up 😉

Thanks again Derek for all you help on this so far as it’s really appreciated. I’ll let you get back to your other items as I’m sure they’re more important than my natty pains in the **** 😉

Best wishes,

Mark

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

I thought I would try to test this all out methodically and see where it balks. Silly me. Unless I’m missing something, which I must be I can’t see any difference at all.

This is what I did.

All using standard Add To Cart buttons.

1 - Add 1 item to cart 2 - Add 2 items to cart 3 - Add 3 items to cart (1 item repeated) 4 - Add 1 item (Do not press big orange button at end of PayPal process) I thought the orange button was the only time the IPN got sent through - seems I was wrong

Information I got when adding the 3 items (1 item repeated) so you can see multiple items

Array ( [mc_gross] => 4.00 [protection_eligibility] => Eligible [address_status] => confirmed [item_number1] => 1 [tax] => 0.00 [item_number2] => 2 [payer_id] => KLSQ96CDP4LBU [address_street] => 1 Main Terrace [payment_date] => 04:11:11 Dec 06, 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.34 [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] => AoiCBNGVMlgj2ndAkLS-nFk5d9sfA2Wn6X.22uBt0v2jcYgx6As-VcSc [payer_email] => [email protected] [mc_shipping1] => 0.00 [mc_shipping2] => 0.00 [tax1] => 0.00 [tax2] => 0.00 [txn_id] => 2W5077940W963271A [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] => 2 [quantity2] => 1 [receiver_id] => KF8QM9EVNY6GY [txn_type] => cart [mc_gross_1] => 2.00 [mc_currency] => GBP [mc_gross_2] => 2.00 [residence_country] => GB [test_ipn] => 1 [transaction_subject] => 4 [payment_gross] => )

All okay and all four tests yielded in the purchases being stored in the SCM admin panel. YIPPEEE so far!!

Next up I hard-coded a form like this :

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

{!-- ITEM 1 --}
<input type="hidden" name="item_name_1" value="PayPal Item">
<input type="hidden" name="amount_1" value="1.00">
<input type="hidden" name="quantity_1" value="1" />
<input type="hidden" name="item_number_1" value="1" />

{!-- ITEM 2 --}
<input type="hidden" name="item_name_2" value="Super Admin Test">
<input type="hidden" name="amount_2" value="2.00">
<input type="hidden" name="quantity_2" value="1" />
<input type="hidden" name="item_number_2" value="2" />


<input type="submit" value="PayPal">
</form>

I submit the form and both items show up in the Sandbox cart. All good so far. I log-in using the exact same details. All good. I pay. All good. I then notice that at the end of paying there is no orange button to return to the store although I guess that is because I left out the return address?

I check my mail and have one which has this in it :

Array ( [mc_gross] => 3.00 [protection_eligibility] => Eligible [address_status] => confirmed [item_number1] => 1 [tax] => 0.00 [item_number2] => 2 [payer_id] => KLSQ96CDP4LBU [address_street] => 1 Main Terrace [payment_date] => 04:22:48 Dec 06, 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] => AiKZhEEPLJjSIccz.2M.tbyW5YFwAEUvDfrvhtqaNvKZ5BjWncgxv2ue [payer_email] => [email protected] [mc_shipping1] => 0.00 [mc_shipping2] => 0.00 [tax1] => 0.00 [tax2] => 0.00 [txn_id] => 7X778809NV055172G [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 can’t see anything different personally except for no storage in EE.

I know you are really busy Derek but was just wondering if you could kick me in the right direction on this one as it just doesn’t seem to want to work with multiple items added at once even though I do exactly as PayPal wants and it sends back to the data to the best of my knowledge in the exact same way!

Please help!!!

       
Derek Jones's avatar
Derek Jones
7,561 posts
16 years ago
Derek Jones's avatar Derek Jones

Yep, those two arrays looks the same. Have you added a var_dump($response$result); to the email on line 402?

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Hi Derek,

I’m probably being thick here but on line 402 of mod.simple_commerce.php it (the original module file) has :

Evaluate PayPal’s Response

I’m not seeing e-mail there although could be missing it perhaps?

That or do you mean something to do with the e-mail code that I added in for testing?

Just not too sure what I need to put in and where, sorry.

Best wishes,

Mark

       
Derek Jones's avatar
Derek Jones
7,561 posts
16 years ago
Derek Jones's avatar Derek Jones

402 should be the empty line just above that comment. See immediately above that where $result is set by pinging PayPal back? OH. Daft me. $result, not $response as I typed above. There’s no email automatically, you’ll need to add that to your debugging email.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Okay I must admit to being a little lost now, sorry.

So do I need to move the debugging code from where I have it now to be above the Evaluate PayPal’s Response on the line after the $result is set?

If so do I just add in a new line :

$email->message($result);

to the debugging code I have already or do something else?

Sorry but in your last post you said about var_dump but I thought that was just to print to the browser screen and if this is PayPal pinging back the site then I wouldn’t get to see that would I?

Sorry Derek about all of this as I know you are very busy but I guess I’m just not understanding exactly what I need to do on this one.

Thanks for the help on this.

Best wishes,

Mark

       
Derek Jones's avatar
Derek Jones
7,561 posts
16 years ago
Derek Jones's avatar Derek Jones

It’s going to be similar to the code you’re already using to buffer the contents of the array and email them to yourself.

if ( function_exists('curl_init'))
{
    $result = $this->curl_process($url); 
}
else
{
    $result = $this->fsockopen_process($url);
}

ob_start();
var_dump($result);
$msg = ob_get_contents();
ob_end_clean();

if ( ! class_exists('EEmail'))
{
    require PATH_CORE.'core.email'.EXT;  
}    

$email = new EEmail;
$email->initialize();
$email->from($PREFS->ini('webmaster_email'));
$email->to('[email protected]');
$email->subject('result');
$email->message($msg);
$email->Send();
       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Hi Derek,

Thanks for that. Just tried that and got this in the e-mail.

string(8) "VERIFIED"

That was all that was in the e-mail though. Does this tell us anything more?

Am I right in thinking that because I am getting these e-mails that PayPal is indeed pinging back the site and I it (the site) is receiving the IPN back to it and all the array details look correct but for some reason they just aren’t being added into the control panel?

Thanks.

Best wishes,

Mark

       
Derek Jones's avatar
Derek Jones
7,561 posts
16 years ago
Derek Jones's avatar Derek Jones

Yes, you are correct. Then you simply follow the logic in the code afterward. Is ‘payment_status’ completed? Yes. Is the paypal account identical to the ‘receiver_email’ ([email protected])? Is the transaction a repeat (is there already a record in the purchases table with the txn_id of ‘93R435627B685632G’)? Is the user valid (is there a member with an id of ‘4’)? Is ‘num_cart_items’ > 0? Yes. Does ‘item_number1’ exist? Yes. Is ‘mc_gross_1’ > 0 (or put another way, is the subtotal for this item more than zero?) Yes.

If all of those things are true, then perform_actions() is called. Is the item_id valid (is there a record in exp_simple_commerce_items with an item_id of 12?) Then there’s a 10% wiggle room for the changing of price between the transaction and receipt. In this case, is the item cost less than .90? Shouldn’t be, since it came through with 1.00 but you will want to double check the item regular and sale price, and which one is used. After that, the purchase is inserted. Somewhere above lies the key to it not being recorded.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Me again 😉

Yes, you are correct. Then you simply follow the logic in the code afterward. Is ‘payment_status’ completed? Yes. Is the paypal account identical to the ‘receiver_email’ ([email protected])?

By this, do you mean is this the e-mail address for the merchant? This is the e-mail address that I set up with the PayPal developer section and is the same on the IPNs that work (get saved into the database) and with those that don’t.

Is the transaction a repeat (is there already a record in the purchases table with the txn_id of ‘93R435627B685632G’)?

Just checked that table and no it doesn’t exist.

Is the user valid (is there a member with an id of ‘4’)?

Yes, this is at the moment hard-coded into the form that I am using to test this out with but they definitely do exist. I actually only have two users in the database but I think I must have created a couple of other test users at some point and then deleted them at a later date but the user I am trying with does exist under that member_id. This is also the number that is used if I use one of the Add To Cart buttons so pretty sure that is correct.

Is the item_id valid (is there a record in exp_simple_commerce_items with an item_id of 12?)

No there isn’t but I noticed some time back that I was placing the wrong things into the form. I now have the form setup as per this post here - code shown here below :

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

{!-- ITEM 1 --}
<input type="hidden" name="item_name_1" value="PayPal Item">
<input type="hidden" name="amount_1" value="1.00">
<input type="hidden" name="quantity_1" value="1" />
<input type="hidden" name="item_number_1" value="1" />

{!-- ITEM 2 --}
<input type="hidden" name="item_name_2" value="Super Admin Test">
<input type="hidden" name="amount_2" value="2.00">
<input type="hidden" name="quantity_2" value="1" />
<input type="hidden" name="item_number_2" value="2" />


<input type="submit" value="PayPal">
</form>

I am just sending the item name now and the item_number_1 and item_number_2 as far as I can tell from reading on PayPal are numbers that need to increment by 1 so that it has a different count each time. Is it perhaps that ExpressionEngine is expecting the item_number_ parts to be set to whatever is in the item_id column of the exp_simple_commerce_items table?

If so then it just so happens that they are at the moment 1 & 2 anyway but I guess this wouldn’t be good the further up we get with items.

Then there’s a 10% wiggle room for the changing of price between the transaction and receipt. In this case, is the item cost less than .90? Shouldn’t be, since it came through with 1.00 but you will want to double check the item regular and sale price, and which one is used.

I am using the none-sale price and have never changed them so I don’t think there should be anything there.

After that, the purchase is inserted. Somewhere above lies the key to it not being recorded.

I totally see what you are saying although I really wish I could see where the problem is at it is totally baffling me at the moment 😉

Don’t know if any of that helps at all? I’m almost 100% certain I have everything set up correctly sending what items PayPal wants to receive and any extra variables are being sent like the Add To Cart buttons do but I must be missing something obvious somewhere I just can’t for the life of me see where.

Best wishes,

Mark

       
Derek Jones's avatar
Derek Jones
7,561 posts
16 years ago
Derek Jones's avatar Derek Jones

Yes, the item_number must match a simple commerce item id. Sounds like the culprit!

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen
Yes, the item_number must match a simple commerce item id. Sounds like the culprit!

Could well be! I am a dim-wit! 😉

I was getting confused with what you were saying and what I thought I was doing. I totally realised that the number needed to be the item_id number from the database but for some reason my brain was saying entry_id. I did actually get it working and had item_number_1 set to 1 and item_number_2 set to 2 but I was thinking that they were just the count that PayPal needed!!

Testing now and it all seems to work fine. Going off to do some major testing now, fingers crossed!!

Thanks for everything Derek. Seems like the SCM is fine for this kind of thing. Will do loads more testing and then plug in my plugin (weird sentence that last one!) and see if that works. Pretty sure it will.

Thanks Derek. You have been doing an absolutely sterling job in here this weekend like you do every day anyway but big kudos to you!!

Hopefully I won’t be back bugging you on this one again. Will only post to say that it is all fine, I hope! 😉

Best wishes,

Mark

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

All is good in the Bowen household!!! 😉

All seems to be working fantastically!!

I think I can safely say that the SCM can most definitely work in conjunction with my plugin and PayPal!! 😊

Had to add in a couple more variables to my plugin to get an offset count and to retrieve the item_id from the simple_commerce_items table but all spits out beautifully!

Thanks again Derek. My weekend is now made!

Best wishes,

Mark

       
Derek Jones's avatar
Derek Jones
7,561 posts
16 years ago
Derek Jones's avatar Derek Jones

Okay, thanks for wrapping this up, Mark.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen
Okay, thanks for wrapping this up, Mark.

And thanks to you too 😉

Have a great weekend Derek.

Best wishes,

Mark

       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.