Paypal custom variable solution using php - paypal

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

There are two parts to be able to successfully identify your order in the whole process:
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.
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)

Related

Create a payment link given an email

Say I have a given email that is not mine (a customer) xx#gmail.com.
Say I would like to let another unknown customer pay money to this email. (= marketplace)
So in my website anyone who click a button is able to pay using Paypal to this given email. I have no relationship with any of them.
Is it possible with the API ? if so where is the reference to it ?
Is there any generic structure to create a link to request money based on a given email xx#gmail.com ?
In Adaptive Payment, Paypal says :
Adaptive Payments is now a limited release product
Which means ?
This can be done with the Express Checkout APIs, but based on what you're saying I would recommend you just use PayPal Standard.
This URL can be used as a template to build a payment request. Just replace the email in the business parameter with the email you want the payment to go to. Then anybody can use that URL to send a payment to that person.
https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&bn=AngellEYE_PHPClass&business=email#gmail.com&amount=25.00&currency_code=USD
So you can see this specifies the email address for where the payment should go, and it also includes the amount and currency code.
You can add any parameters you want from the PayPal Standard Variables Reference.

Paypal button integration passing session variables

Hello guys I am developing a web store where users are already registered it must track both users the one that is selling the item and the one that is buying the item also some instructions the buyer might to express to the seller.
I have not performed this kind of tasks before have been reviewing the Paypal developer Api however have not found the exact functionality I need right now.
i need to pass session variables from my app into the paypal mechanism.
Please let me know how to integrate a button for buying an item and then store the details about the transaction in my db cause need to know the userid of the users within my app.
Thanks a lot.-
In your case you can use the Express Checkout API or simple PayPal Standard + IPN
If you use Express Checkout, then you don't need to send any session variable to PayPal as the session is not closed and the last step of the transaction (DoExpressCheckoutPayment) occurs in your website. But, if you really want to send some custom data to PayPal you can do it by sending "PAYMENTREQUEST_n_CUSTOM" inside the SetExpressCheckout call.
If you use PayPal Standard + IPN. You can pass to PayPal the variable called "custom" (Pass-through variable for your own tracking purposes, which buyers do not see) and retrieve it back in the IPN.

Can i use pre-approval using PayPal website payments pro?

I am making a system in which user permits pre-approval of amount. I've used pre-approval with chained payment. But the problem is that my customer gets redirected to PayPal site and also he/she must have a PayPal account or need to create one. So can i make pre-approval payment using PayPal website payment pro? So my customers will not get redirected to PayPal account. And the process becomes more fast? Note :- I don't want to use authorization and capture method. Thanks.
Edit
One more question :- If i make the website in the UK and the currency in GBP, can I still use the American Paypal account for this?
Auth and Capture is what you're asking for, but then you say you don't want it..?? That's what gives you the functionality you're after, though.
You could do a $0 auth and then run DoReferenceTransaction when you're ready to process the payment as opposed to capturing an actual auth if you want.
Those are your only options when working with Pro, though, and it would give you the same sort of preapproval experience for the buyer.
Here are the steps to accomplish what you're after.
Use DoDirectPayment to run a $0 Authorization (card verification). Users will enter their credit card details directly into a form on your site without any redirection to PayPal (and without any knowledge PayPal is being used at all unless you notify them some way.)
Save the transaction ID that you get form this card verification into your transaction history for the customer in your database. This ID is what will be used to process future payments using that credit card.
When you're ready to process a payment for this customer, pull the ID out of the database and use it with a DoReferenceTransaction request to process any amount you need to.
So the card verification is your preapproval, and then running reference transactions are the same as running Pay requests with a Preapproval key. Both methods accomplish the same thing, but one is with direct credit cards and the other is not.
If you're using PHP you can use this PayPal PHP SDK to make all of the API calls very quick and easy for you. If you're using some other language then there are SDKs available for those as well I'm sure.
Please correct me if i am wrong, #Andrew Angell #Ved Pandya
Auth and Capture or Capture payments later method allows you to do direct payment, but it comes with additional charges, which might not suitable for crowdfunding model as refund/ cancel payment is very frequent
Auth and Capture: You are required to pay $0.30 for each "Card Verification Transactions"
Capture payments later: You are required to pay $0.30 for each "Uncaptured Authorization" that you triggered
https://www.paypal.com/us/webapps/mpp/merchant-fees

Retrieving Billing Type in PayPal Express Checkout for recurring payments

I'm setting up a payment engine for a custom framework using PayPal Express Checkout. One of the business requirements is adding support for recurring payments. I've found documentation on how to implement this at https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECRecurringPayments
The thing I don't quite understand is how to retrieve the value of BillingType from the API after I've set it via SetExpressCheckout to "RecurringPayments". It doesn't seem to appear anywhere in the response data I get back from neither GetExpressCheckoutDetails nor DoExpressCheckoutPayment. I need this to know whether I need to create a recurring payments profile or not. So as far as I can tell my only option is to store the value of BillingType in my database and query it again after DoExpressCheckoutPayment. This works for me but I find it odd that this data would not be returned at all by the API. Am I missing something? Or is there another way of correctly implementing recurring payments?
Not all data you send in a request is returned in a response. You already have what you're passing to them...there's really no need for them to pass it back.
You could use session variables to save the data instead of the database, or you could log all of your API requests and refer to those logs when you need to see what you sent, but again, your application is what's telling PayPal whether or not the payment should include billing agreement information...not the other way around.

PayPal SetExpressCheckout vs. payment buttons

What is the benefit of calling PayPal API SetExpressCheckout method to get a payment link and forwarding a customer there instead of using payment buttons?
The PayPal buttons can be modified by the visitor's browser client. It is just basic HTML. All of the variables to place the order can be manipulated by the customer. For instance, it takes 3 seconds to change the order total from $900 to $1.
Using the API, you tell PayPal to create an incomplete transaction for a certain amount, with certain information, that can then be referenced/completed later and there is no way (short of expert hacking) to change the order. Instead of trusting the visitor's browser, PayPal trusts your server.