Check if a PaypalTransactionID is valid (express checkout) - paypal

I am using Express Checkout. The DoExpressCheckoutPayment method completes the payment and returns a TransactionID.
I am using this transactionID in a web service. Is there a way to check if a transactionID is valid or belongs to a completed payment?
Thanks.

If the call is successful and you get a transaction ID then that's a valid ID. Not sure why you would think it's not..?? You could also make a call to GetTransactionDetails using that transaction ID just to confirm you get data back.

Related

Paypal: Express Checkout custom PAYMENTREQUEST_n_TRANSACTIONID not working

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.

PayPal Integrations - DoReferenceTransaction and DoAuthorization

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.

PayPal SOAP API Error 13606 When trying to call Refund API method with Payer ID and amount

When I try to call RefundTransaction API method usiong PayerID i get Error "13606 Feature Not Enabled. You are not enabled for this feature.".
What it does mean? Is there a way to enable it?
To reproduce you can go to https://devtools-paypal.com/apiexplorer/PayPalAPIs and try to execute RefundTransaction method with PayerID and Amount filled in.
Direct from PayPal Support:
TransactionID and PayerID are marked "conditional", but you couldn't set blank.
For example, A buyer purchased several items in different period , but if you call RefundTransaciton API only set PayerID,
PayPal couldn't judge in which transaction to refund, and also could not refund the amount about all of these items.
PayPal is not allowed this case happen.
So at least you have to set the transaction ID while calling the refund API.
So the solution is to always specify TransactionID.
Yes, their own API Documentation says:
"Either the transaction ID or the payer ID must be specified."
But apparently this is not the case.
If you don't log subscr_payment IPN calls, you can look up TransactionID from a PayerID by using the TransactionSearch API request. Put your PayerID in the ProfileID search field.

Paypal shipment details

I am using PayPal Adaptive payments (chained payments).
If I set:
1. CREATE payment
2. In the SetPaymentOptions -> Requires shipping address selection = true
3. When I redirect user for the https://www.sandbox.paypal.com/webscr&cmd=_ap-payment&paykey=[PA KEY] user after authentication is not shown any prompt for shipping address
why?
Accordingly to the
https://www.x.com/developers/paypal/documentation-tools/api/pay-api-operation
when using CREATE I should do: CREATE – Use this option to set up the payment instructions with SetPaymentOptions and then execute the payment at a later time with the ExecutePayment.
But as soon as I try to run ExecutePayment I get the following information:
This payment request must be authorized by the sender
How can I set additional payment options then?
The ExecutePayment call would only be used if you're utilizing delayed chained payments. Otherwise, the payment still happens as soon as the buyer logs in and approves it, so there is no need for ExecutePayment. Calling it at that point results in the error you're getting, that the paykey was already used.
Did the sender actually authorize the payment?
The flow should be like:
Call Pay API operation with actionType as CREATE
If paymentExecStatus=CREATED and ack=SUCCESS, obtain payKey (here, keep detailLevel=ReturnAll in RequestEnvelope field of your Pay API request)
Redirect user to Paypal https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=YOUR_PAYKEY_ABOVE
If user approves payment, you will be redirected to your returnURL sent as a part of Pay API request
Verify approval status using PaymentDetails API operation
Later you can execute the payment thus setup in step 4 using ExecutePayment API operation. Send the same payKey you obtained in step 2.
You have got error code 550001 since the user approval seems to be not yet done successfully. It may be due to:
The application did not redirect user/sender to Paypal for authorization
OR
The user did not enter correct login details
OR
There were not sufficient funds available
etc.

Paypal NVP with IPN for confirmation - what ties them together

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.