questions
questions

Reputation: 29

Paypal custom variable solution using php

I'm trying to using paypal as payment for my site.

My site only sell a virtual currency, like "Diamond" in Online game.

So after reading i starting to use Express Checkout for Digital Goods, Is that right ? or i must other payment method ?

Then my question is when using Express Checkout for Digital Goods, how to pass custom variable ?

Let say i want to pay user_id, diamond_id, and some other variable from my database to the paypal api. It seem like paypal don't support custom variable to pass on the api call. I want after user complete the payment, then Paypal notify my server that the payment is complete by user_id and some other variable that i pass, so easy for me to know the detail.

after searching i find some solution,

First solution is to store "TOKEN"(Generated from "SetExpressCheckout" Method) and my custom variable which is belong to the TOKEN in the database, Then after payment complete paypal will notify my server the same TOKEN saved before. So i will query based on the TOKEN. Second Solution is using get style in RETURNURL variable http://www.mysite.com/successpayment.php?user_id=13&diamond_id=88 So i will easy to grab the GET variable. Which solution is right ? Is there any solution ? and how to secure the payment confirmation, i mean if someone know and hack my returnurl.

Thanks in advance

Upvotes: 0

Views: 1111

Answers (1)

alienhard
alienhard

Reputation: 14712

There are two parts to be able to successfully identify your order in the whole process:

  1. To identify your order when the user is redirected back via the success or cancel URL, just pass the order id via the query string of the URL.

  2. To identify your order when Paypal sends notifications about the transaction and associated events (refunds, reversals, disputes etc.) via IPN: Paypal does support a pass-through variable, which allows you to associate IPNs to the order record in your DB.

    • For express checkout you set PAYMENTREQUEST_0_INVNUM in the SetExpressCheckout call
    • In case you are creating a recurring profile, the parameter is named PROFILEREFERENCE in the CreateRecurringPaymentsProfile call
    • When you receive an IPN the invoice is passed as 'invoice' or 'rp_invoice_id' respectively

(My general advice, though: use Paypal only if you really have to)

Upvotes: 1

Related Questions