Search code examples
paypalpaypal-sandboxpaypal-ipn

Always empty paypal IPN custom field


I'm trying to send my custom field like this(using sandbox):

paypal.Buttons({

                            createOrder: function(data, actions) {
                                return actions.order.create({
                                    purchase_units: [{
                                        amount: {
                                            value: dataResponse.value
                                        },
                                        custom: 'SOME_DATA',
                                    }]
                                });
                            },

                            // Finalize the transaction
                            onApprove: function(data, actions) {
                                return actions.order.capture().then(function(details) {
                                    // Show a success message to the buyer
                                    alert('Transaction completed by ' + details.payer.name.given_name + '!');
                                });
                            }


                        }).render('#paypal-button-container');

Like that i get a response on the server(i use paypal/ipn-code-samples):

$data_text = "";
foreach ($_POST as $key => $value) {
    $data_text .= $key . " = " . $value . "\r\n";
}

And this is how the IPN looks like(part of it):

paypal_ipn_status = RECEIVER EMAIL MISMATCH
paypal_ipn_date = 2020-02-20 12:20:53 +05
mc_gross = 27.00
protection_eligibility = Eligible
address_status = confirmed
payer_id = 6F3VC36BWPQ7J
address_street = \u0443\u043B\u0438\u0446\u0430 \u041F\u0435\u0440\u0432\u0430\u044F
payment_date = 23:20:41 Feb 19, 2020 PST
payment_status = Completed
charset = KOI8_R
address_zip = 127001
first_name = John
mc_fee = 11.05
address_country_code = RU
address_name = Doe John
notify_version = 3.9
custom = 
payer_status = verified
business = sb-gvgju1033031@business.example.com

Can anyone tell me what I'm doing wrong? Thanks!


Solution

  • Well, i found a mistake.

    instead of this:

                                    return actions.order.create({
                                        purchase_units: [{
                                            amount: {
                                                value: dataResponse.value
                                            },
                                            custom: 'SOME_DATA',
                                        }]
                                    });
    

    Need to use this(prop named - custom_id):

    return actions.order.create({
                                        purchase_units: [{
                                            amount: {
                                                value: dataResponse.value
                                            },
                                            custom_id: 'SOME_DATA',
                                        }]
                                    });
    

    and now i finally got my custom field in IPN

    address_country_code = RU
    address_name = Doe John
    notify_version = 3.9
    custom = SOME DATA
    

    I hope this helps someone.