Search code examples
paypalpaypal-ipn

PayPal IPN message not sending invoice, even though it was definitely included in button code


I have a paypal checkout button on my website along with funding icons. This is part of the code for it:

                 style: {
                    label: 'checkout',
                    fundingicons: true, // optional
                    size: 'responsive', // small | medium | large | responsive
                    shape: 'rect',   // pill | rect
                    color: 'gold'   // gold | blue | silver | black
                },
                payment: function (data, actions) {
                    return actions.payment.create({
                        payment: {
                            transactions: [
                                {
                                    amount: {
                                        total: amount,
                                        currency: currency
                                    },
                                    invoice_number: '{$invoice}',
                                    custom: '{$invoice}'
                                }
                            ],
                            "redirect_urls": {
                                "return_url":  , // these are both filled correctly
                                "cancel_url": 
                            }
                        }
                    });

As you can see, the invoice field is explicitly defined, however, when getting sent back IPN messages, my ipn.php file is failing due to the lack of an invoice number being sent to it.

What makes this even weirder is that whenever the txn_type is express_checkout the invoice is there, but when it's web_accept, which is most of the time, neither the invoice nor the custom field are getting passed (I added the custom field when the IPN messages started failing).

The api we use for the button is https://www.paypalobjects.com/api/checkout.js

Is there something I'm missing or is it just that the api is deprecated and this is another sign to switch over?

EDIT:

After testing this out on other browsers it seems that adblock is blocking part of the checkout.js dependencies from loading:

  • Firefox: Cross-Origin Request Blocked
  • Opera: Failed to load resource: net::ERR_BLOCKED_BY_ADBLOCKER
  • Edge: POST https://www.paypal.com/xoplatform/logger/api/logger net::ERR_BLOCKED_BY_CLIENT

No error message from chrome.

EDIT 2:

sample IPN of type web_accept

mc_gross=300.00&protection_eligibility=Ineligible&payer_id=SOMEREALID&
            payment_date=11:32:11 Sep 27, 2021 PDT&payment_status=Completed&charset=windows-1252&
            first_name=&mc_fee=9.00&notify_version=3.9&custom=&payer_status=unverified&
            business=our_business_email&quantity=1&
            verify_sign=sign_in_alpha_numeric&
            payer_email=random_alpha_numeric@dcc2.paypal.com&txn_id=1KM93595HU1361254&payment_type=instant&
            last_name=NotProvided&receiver_email=same_as_business_email&payment_fee=&
            shipping_discount=0.00&receiver_id=more_alpha_numeric&insurance_amount=0.00&
            txn_type=web_accept&item_name=&discount=0.00&mc_currency=CAD&item_number=&
            residence_country=OUR_COUNTRY_CODE&receipt_id=1111-1111-1111-1111&shipping_method=Default&
            transaction_subject=&payment_gross=

Solution

  • In the example IPN given:

    mc_gross=300.00&protection_eligibility=Ineligible&payer_id=SOMEREALID&
    payment_date=11:32:11 Sep 27, 2021 PDT&payment_status=Completed&charset=windows-1252&
    first_name=&mc_fee=9.00&notify_version=3.9&custom=&payer_status=unverified&
    business=our_business_email&quantity=1&
    verify_sign=sign_in_alpha_numeric&
    payer_email=random_alpha_numeric@dcc2.paypal.com&txn_id=1KM93595HU1361254&payment_type=instant&
    last_name=NotProvided&receiver_email=same_as_business_email&payment_fee=&
    shipping_discount=0.00&receiver_id=more_alpha_numeric&insurance_amount=0.00&
    txn_type=web_accept&item_name=&discount=0.00&mc_currency=CAD&item_number=&
    residence_country=OUR_COUNTRY_CODE&receipt_id=1111-1111-1111-1111&shipping_method=Default&
    transaction_subject=&payment_gross=
    

    Note: @dcc2.paypal.com

    This is from a direct credit card integration, perhaps using the classic NVP DoDirectPayment API, or Virtual Terminal [or Payflow with PayPal as the processor, as it happens]

    So, not related to the button code in the question -- rather a separate integration to this PayPal account.