Search code examples
phppaypalexpress-checkout

Custom Value to Paypal and Getting It Back


I am using express checkout. I have to pass paypal a custom value to get it when the paypal returns to my website. My current request is as follows

$nvpreq = "METHOD=$methodName&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature&RETURNURL=$returnurl&CANCELURL=$cancelurl&PAYMENTREQUEST_0_PAYMENTACTION=$act&PAYERID=$payerid&TOKEN=$token&PAYMENTREQUEST_0_AMT=$amt";

Please let me know how I can include a custom variable in this request.

Thanks


Solution

  • You would use the "custom" parameter in your request. It's literally called custom. You can fill it with whatever you want up a 256 character limit.

    That said, you shouldn't need it simply to get data back to your site in the same Express Checkout flow. You could simply use a session variable for that, which would be accessible upon returning back to your site from PayPal.

    The custom parameter would come in handy if you are using IPN or if you need it when pulling details via the GetTransactionDetails API.

    Another thing to consider is that you could use the custom parameter (or the invoice parameter) to pass a single record ID to PayPal. That ID would then be available in the transaction details so you could easily pull the details back out of your database.

    Also, instead of building your API requests manually like this I would recommend you take a look at this PayPal PHP SDK. It will make all of your API calls with PayPal very quick and easy.