TL;DR Version
According to the Express Checkout NVP Api docs I can set my own transaction ID with the PAYMENTREQUEST_n_TRANSACTIONID field. This never works for me - the response from the 'DoExpressCheckoutPayment' always returns a different transaction ID. The docs don't say if it needs to be unique (I presume that it does) or how to generate an ID that is guaranteed to be accepted as valid on Paypal's side. How do I do this?
Full Version (Read above first)
I don't really need to create my own transaction ID. If I could be sure that the my call to 'DoExpressCheckoutPayment' finishes before Paypal issues the IPN - that would be fine. This is so I could update my records from the 'PAYMENTINFO_n_TRANSACTIONID' field before the IPN is issued and then use the 'txn_id' from the IPN call to update my records.
At the moment setting a custom transaction ID at the 'SetExpressCheckout' stage is never returned at the IPN stage.
I'm using API version 98.
You can't create your own transaction ID. What you're seeing in the documentation is that the response would return the transaction ID.
DoExpressCheckoutPayment will always finish before the IPN triggers. In fact, DECP is what triggers the IPN.
If you want to pass your own custom value of some sort you'll need to use the actual CUSTOM parameter in the DoExpressCheckoutPayment request. If you include CUSTOM in SEC but not DECP, it will not be included in the final payment details, and would not be returned in IPN.
Related
I'm trying to integrate "Paypal smart buttons" in my webpage which was with a deprecated paypal implementation.
On this new integration I'm using server-side SDK and I can create and capture an order and save data in my DB.
The problem I have now is to implement the refund.
On my last implementation I had an IPN Listener and whenever I get a refund I could register it in my BD.
Since now IPN listener is deprecated, how can I implemented the "listener function"? Is the webhooks the new approach to implement the listener? I know that with Webhooks Management API I can list all webhooks events, but then how can I related them with the payment made and registered before in my BD?
I've already read lots of official paypal documentation but this is no clear to me, yet.
Register a webhook listener URL for the events you want, including refunds.
When you receive a refund webhook event at that URL, the body of the webhook will contain information about the capture/payment object (transaction id) that was refunded.
If in addition to the capture/transaction id you need some additional id for reconciliation purposes, there are two pieces of information you can include in the original order creation.
an invoice_id, which is essentially your system's unique order ID. It must be unique, never used before for a successful completed transaction since it is used to block any future duplicate (accidental) payment attempts of the same ID.
a custom_id, which can have any arbitrary value and is not indexed and not visible to the payer.
I am creating subscriptions using the PayPal Express Checkout API. What I want to do is add a seller-defined 36 character ID to each subscription that I can later search on.
When sending CreateRecurringPaymentsProfile, I am populating the PROFILEREFERENCE field, which shows up as the 'Invoice Number' on the Recurring Payments dashboard on the seller site.
On the TransactionSearch method, there is an INVMUM field that can be searched, but it doesn't appear this correlates with the 'Invoice Number'.
So...how can I populate the right field so I can use INVNUM to search - or is there a better solution to my problem?
Bruce
I would setup an Instant Payment Notification (IPN) solution. That way any data for transactions will be automatically sent through your script and can be processed accordingly in real-time.
The PROFILEREFERENCE value you're sending will come back in the IPN as invoice_number, so it would be available within your IPN script.
So whatever you're doing within a TransactionSearch script, just do that in IPN instead. Not only will give you access to the value you're after, but it will automate the entire process in real-time so you don't have to mess with TransactionSearch / GetTransactionDetails at all.
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.
We have a requirement where we need to run the auto payment for the PayPal payment for next scheduled order's with out user interaction.
We are able to achieve this using Billing AgreementId that we processed during the user first transaction.
My question is We just need "DoReferenceTransactionReq" or after that even we need to do DoAuthorization. Please suggest.
Before this for the First transaction we are following api call:
1.SetExpressCheckoutReq
2.GetExpressCheckoutDetailsReq
3.DoExpressCheckOutPaymentReq
If you've already gone through the Express Checkout flow and created a Sale or Authorization transaction there, then all you need to do is pass that transaction ID into DoReferenceTransaction to process the new amount. DoAuthorization would simply create another fresh authorization and is not needed to run reference transactions.
I am using PayPal with NVP API (using PHP) for express checkout. I am creating an invoice record in the database before redirecting the user to Paypal. In case the user doesn't return to my site after processing, I am using IPN to confirm the purchase and then update the invoice record that the payment is confirmed. I am still in the sandbox mode and trying to figure out how I will tie the transaction started with NVP to the confirmation I get with IPN.
I need to verify if the "PAYMENTREQUEST_n_INVNUM" sent in the NVP will come back as "invoice" in the IPN post.
It appears I cannot actually test this until I am live since the Sandbox IPN does not seem to be active with NVP initiated sandbox transactions - is this correct?
Thanks for your help.
You can test this in Sandbox. But if you're using "PayPal NVP", I assume you're using PayPal Express Checkout and calling the SetExpressCheckout and DoExpressCheckoutPayment API's.
If that's the case, you don't really need IPN, because a transaction will only be completed as soon as you call DoExpressCheckoutPayment.
In other words, buyers will always be redirected to the RETURNURL you specified in SetExpressCheckout, and the transaction is completed (or not) when you call DoExpressCheckoutPayment on this return page.
To get the invoice number, you could call GetExpressCheckoutDetails and supply the TOKEN you retrieved earlier (it's also appended to the GET of the RETURNURL).
Finally, check PAYMENTSTATUS=Completed in the DoExpressCheckoutPayment API response to see whether the transaction has completed or not.
Thank you Robert for the clarity on the process - especially useraction=commit.
I finally realized that I could turn on IPN in the Sandbox for my test seller and test NVP with IPN together. I was able to verify that PAYMENTREQUEST_0_INVNUM matches the 'INVOICE' parameter in the IPN POST.
I will use the custom field to pass customer email from my system in case they use a different email to log into paypal with, therefore allowing me to have email/invoice number pair for confirmation.