bluebit
bluebit

Reputation: 3017

Paypal payment buttons and IPN: how to link users up uniquely?

Strangely the documentation on the Paypal site does not cover this very well.

We have a payment button that redirects to Paypal to process a payment.

We also have an IPN server running that catches paypal payments once they're made.

However, where can we place the "user id" of our system user in the paypal button, so that it will be forwarded to the IPN request in order to match the user up on our system that they have paid. Paypal seems to want people to do this manually, which is a real mission.

Upvotes: 11

Views: 5386

Answers (4)

TomoMiha
TomoMiha

Reputation: 1279

For anyone trying to get this working for Paypal SmartButtons, you should do something like this:

return actions.order.create({
  purchase_units: [{
       invoice_id: 'your_custom_stuff1',
       custom_id: 'your_custom_stuff2',
       amount: {
         value: '100'
       }
  }]
});

IPN will sent it as POST data, for example in PHP:

$_POST['invoice']; // 'your_custom_stuff1'
$_POST['custom']; // 'your_custom_stuff2'

Upvotes: 0

Reign.85
Reign.85

Reputation: 2518

As said in the doc (https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNandPDTVariables/)

in your form :

<input type="hidden" name="custom" value="<?php echo $id ?>">

and get it with ipn :

$_POST['custom']

Upvotes: 3

mirza
mirza

Reputation: 960

You should use:

<input type="hidden" name="item_number" value="{user id}">

and here is the documentation:

https://www.paypalobjects.com/IntegrationCenter/ic_std-variable-ref-buy-now.html

Upvotes: 3

Julian Go
Julian Go

Reputation: 4492

I'm currently doing some PayPal integration and I concur their documentation is a mess!

I finally found a guide somewhere that details which variables of a PayPal button form are forwarded to the IPN callback. You can use the variable item_name to forward a user id:

<input type="hidden" name="item_name" value="{user id}">

Upvotes: 4

Related Questions