snowplow-archive / codeigniter-paypal-ipn

A CodeIgniter library for working with the PayPal IPN (Instant Payment Notification) service

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ipn_order_items not being inserted in sandbox mode

brwnll opened this issue · comments

First of all, great library, appreciate all the work.

I recently setup the library and was testing in on the PayPal sandbox, everything appears to work great, except 'ipn_order_items' is not being filled with any items.

Is this a known issue with the library when used with the sandbox, or is there a way I can verify that products are correctly being added to the DB before going live?

Thanks.

Hi @smalldogs - thanks for your kind words. On your issue: nobody has reported a specific issue with the sandbox not populating ipn_order_items. I will recheck the code tonight but I can't think of a setting that would make the sandbox play up just with the line items.

In other words: I wouldn't recommend going live yet, because you will probably experience the same problem in live.

Have you gone through debug mode to check that you haven't got a problem with your setup? Here are my instructions on debug mode:


To switch on debugging, set 'debug' => TRUE for your current environment in the file:

https://github.com/orderly/codeigniter-paypal-ipn/blob/master/common/config/paypal_ipn.php

Once debugging is switched on, this is how you test:

  • Run through your checkout process as normal, making your PayPal sandbox payment etc
  • PayPal will fire your IPN script, something will go wrong
  • Now you manually invoke your IPN URL in a browser and see what happens (e.g. PHP error, database not found error)
  • Fix
  • Repeat

The way that debug mode works is that it stores the last IPN access which had IPN data (i.e. POST variables) into the database, and then when you access the IPN URL directly without data, it reloads the cached data. So it's kind of like a replay mode which let's you directly inspect what the IPN handler is doing.


If the problem isn't at your end, then there may be an issue with either a) a recent PayPal IPN change or b) this pull request from a couple of months ago: #6

Let me know in this thread how your debugging goes and I will investigate as required...

Thanks!

I've found at least symptom of the problem.

on Line 64 of ipn_open_model for Active Record, I dumped $orderItems and it was a blank array.

Does the sandbox send the "numItems" variable? My logs on an IPN test:
ERROR --> Severity: Notice --> Undefined index: num_cart_items /libraries/PayPal_IPN.php 297

Hi @smalldogs, thanks - that's a very helpful clue. Can you confirm that PayPal is sending you:

txn_type -> "cart"
num_cart_items -> ""

If it is, then that's your problem: for some reason PayPal is not telling you how many items are in the cart.

To confirm what PayPal is sending you, you need to run a PHP unserialize on the detail field in ipn_log

Doesn't appear to pass num_cart_items at all.
Note: These are all the default options in the IPN sandbox, other than business/receiver email for a "Cart Checkout"

Array
(
    [test_ipn] => 1
    [payment_type] => instant
    [payment_date] => 10:28:30 Jan 19, 2012 PST
    [payment_status] => Completed
    [payer_status] => verified
    [first_name] => John
    [last_name] => Smith
    [payer_email] => buyer@paypalsandbox.com
    [payer_id] => TESTBUYERID01
    [business] => dustin@smalldo.gs
    [receiver_email] => dustin@smalldo.gs
    [receiver_id] => TESTSELLERID1
    [residence_country] => US
    [item_name1] => something
    [item_number1] => AK-1234
    [quantity1] => 1
    [tax] => 2.02
    [mc_currency] => USD
    [mc_fee] => 0.44
    [mc_gross] => 15.34
    [mc_gross_1] => 12.34
    [mc_handling] => 2.06
    [mc_handling1] => 1.67
    [mc_shipping] => 3.02
    [mc_shipping1] => 1.02
    [txn_type] => cart
    [txn_id] => 301191828
    [notify_version] => 2.4
    [custom] => xyz123
    [invoice] => abc1234
    [charset] => windows-1252
    [verify_sign] => AQqMGpA57Y8mvzZacFNIKmzbfGcWAJeab8gULkbXHu7vGdUIUVD8Jn1t
)

I don't know if it is a recent PayPal change, or just a flaw in the sandbox. But that is causing this

$hasCart = ($this->order['txn_type'] == 'cart');
$numItems = $hasCart ? (int)$this->order['num_cart_items'] : 1;

to throw the error, because the txn_type is cart, but there is no num_cart_items variable set.

Ah! I think we're on the same page now @smalldogs When you said you were using the sandbox, I thought you meant you were sending a test order into the PayPal sandbox, but I think you meant that you were hitting the "send test IPN" from the PayPal interface. I don't think PayPal's IPN test is a valid one - because it's saying it's a cart transaction but it's not setting any line items.

So you have two options: 1. go live and test it works with a real order, or 2. deploy to your test environment, and test against the PayPal sandbox using the sandbox settings in https://github.com/orderly/codeigniter-paypal-ipn/blob/master/common/config/paypal_ipn.php

I switched to the Live environmental and everything works as expected. Closing this issue with the confirmation that it is a PayPal test IPN issue and not a library issue.

Great - thanks Dustin!

Alex
On Jan 19, 2012 9:25 PM, "Dustin B" <
reply@reply.github.com>
wrote:

I switched to the Live environmental and everything works as expected.
Closing this issue with the confirmation that it is a PayPal test IPN issue
and not a library issue.


Reply to this email directly or view it on GitHub:

#9 (comment)