PayPal Adaptive Payments return URL parameters - paypal

I'm using PayPal Adaptive Payments (a deprecated integration method) with PHP.
When calling the "Pay" request, I always used to set the return URL to:
https://my-website/my-return-page.php?payKey=${payKey}
Then, when the payment is succesful, PayPal should redirect the user to something like:
https://my-website/my-return-page.php?payKey=AP-ABCDEF123456
But now, the PayPal API is throwing an error:
The URL https://my-website/my-return-page.php?payKey=${payKey} is malformed
There was no change in our end, it just stopped working.
I need the payKey in the return URL, so I can check the paymentDetails.

adding &payKey=${payKey}
Oh, based on the answer you linked you were sending that actual text as-is and PayPal was dynamically replacing that with the value.
It doesn't seem that syntax is supported anymore; it's not documented.
What I would recommend is generate your own unique ID, and pass that as ?id=abcde12345. Then when you first get the payKey from the initial Pay API response, associate this payKey with your own id (e.g. abcde12345). It could be the same as the TrackingID or Invoice ID, if you happen to use either parameter/feature of Adaptive Payments.
Then, the return should have ?id=abcde12345 and you can look up the payKey and proceed from there with paymentDetails.
You can also report this change in behavior with Adaptive Payments as a PayPal bug, but since it's a very old and deprecated product that's likely to be sunset at some point, I'm not sure how much traction re-implementing an undocumented feature would have, so the above workaround of your own id seems like a better plan.

Related

Paypal Chained Payment - Pay Key & IPN

I recently converted from basic Paypal payments to Chained Payments...and I have a few questions if you guys would be so kind to help out.
First, when I setup a PayRequest, I also create an order record in the database. Previously with my basic Paypal implementation, I passed that OrderId in the custom field as part of the form post to Paypal. I would then get that OrderId back in the IPN handler and use it to mark the order as paid or whatever based on the response from Paypal IPN.
Now I am wondering what is a good unique value for my locally created order? Should I use the paykey to look up the order on the IPN callback? Or should I just set the trackingId property of the PayRequest to be the order id and pick up in the IPN callback Request object?
Secondly, there is a returnUrl and ipnNotificationUrl for the PayRequest. Should the returnUrl process the IPN callback or does the ipnNotificationUrl only should do that?
The reason why I ask is because the return url must be able to show the buyer the status of their payment and the transaction info, the same data that I get in the IPN callback.
Thanks for the input guys, once I get these two minor details ironed out, I'll be good to go!
I would add your record ID into the tracking ID parameter of the Pay request like you mentioned. That way you'll get it back in your IPN similar to what you're doing with the custom parameter now.
The IPN notification URL is what you want to set in order to trigger IPNs for the Pay request. You do not want to use the same URL for return because then the script would actually run twice.

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
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)

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.

Paypal no BUTTONSOURCE in return URL

I'm trying to integrate booking system everything was fine in posting and other flow. But after paypal payment page and return to my url BUTTONSOURCE was empty.
any suggestion?
Did you include it in both DoExpressCheckoutPayment as well as SetExpressCheckout?
BUTTONSOURCE must be included in both.
Although you'd probably be better off using CUSTOM or INVNUM if you want to use it to link orders on your end together with PayPal transactions.