开发者

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

开发者_JAVA技巧

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.


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}">


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


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']


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'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜