Paypal Checkout Button is not passing custom filed to IPN message

196 Views Asked by At

I'm updating the PayPal system on my website, replacing older PayPal buttons with newer PayPal Checkout, and I have problems while trying to pass the custom field from the button script to the IPN message that I use to update my database with customer's payments: I receive the IPN message with all the rights $_POST fields/values, except for the $_POST['custom'] field that always remains empty. I'm using sandbox merchant and customer accounts, this is my button code:

<script src='https://www.paypal.com/sdk/js?client-id=xxxxx&currency=EUR' data-sdk-integration-source='button-factory'></script>
<script>
paypal.Buttons({
    style: {
        shape: 'rect',
        color: 'gold',
        layout: 'horizontal',
        label: 'pay',
        tagline: true
    },
    createOrder: function(data, actions) {
        return actions.order.create({
            purchase_units: [{
                amount: {
                    value: '1'
                },
                custom: '35627187'
            }]
        });
    },
    onApprove: function(data, actions) {
        return actions.order.capture().then(function(details) {
            alert('Transaction completed by ' + details.payer.name.given_name + '!');
        });
    }
}).render('#paypal-button-container');
</script> 
1

There are 1 best solutions below

2
Preston PHX On

Replace with custom_id, as documented in the Checkout Orders API reference for a purchase_unit

custom will be ignored