Let's assume the PayPal REST API is used to fulfill a standard PayPal payment process. When executing the payment it is returned as 'pending', so the payment is not through, yet. The REST APi provides a payment id:
https://developer.paypal.com/docs/api/#execute-an-approved-paypal-payment
When payment is completed the URL of my IPN listener is called, however as said on this site included only a txn_id which seems to be not the same as the payment id of the REST API:
https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNIntro/#id08CKFJ00JYK
So how to match these two ids?
IPN was designed for supporting the classic APIs on PayPal and the txn_id would have matched the txn_id of a payment made with the classic API.
For payments made via the REST API, you may still be notified via IPN but unfortunately cannot match payments using ids currently. Your best option right now would be to check the attributes of the payment (amount, currency etc) and check that it matches attributes of a payment you were expecting.
Currently this is the existing option for push based notifications. The other option may be to poll at regular intervals and check the status of the payment.
There are certainly limitations to both approaches, and there is webhook support upcoming which would have push based notification support for REST payments to alleviate these issues.
The txn_id of IPN messages are also included with the REST API message but called 'sale id' there.
Related
All documentation I can find for PayPal development is focused on capturing payments from a customer. Even IPN and Webhook events are all about taking action when payments are received.
I operate a small press and my primary use of PayPal is to send payments to authors. I need to take certain actions when payment is sent from my PayPal account to many different recipients.
Using any PayPal API, how do I programmatically retrieve a list of recent payments I have sent? Alternatively, how can I receive a webhook notification when I send a payment through PayPal instead of when I receive one?
The TransactionSearch API would allow you to pull transactions based on different types. It uses the Classic API, though, not REST.
IPN would send notifications when any transaction hits in your account, including payments you send from it via send_money, masspay, or the Pay API.
Does the Paypal provides any api to retry the IPN message using message id? I need to integrate functionality similar to the "resend ipn" button available on IPN history page of paypal.
There is no API to trigger the resend of an IPN, but there are API's to obtain the details that would be included in an IPN for a given transaction, so depending on what you're doing that make work for you.
For example, the combination of TransactionSearch and GetTransactionDetails can be very useful.
I have been working paypal integration to an existing system of ours and successfully done tests on sandbox by using rest api and express checkouts.
Although documentation is detailed, I couldnt see anything about chargeback (i.e reverse transactions) and cancellations on rest api documentation page http://developer.paypal.com/docs/api/
So in case a user buys something successfully and the payment status becomes "completed", then there is a reverse transaction like chargeback, paypal will send a request to the return and cancel urls which are predefined while creating the related payment, or the client application has to check the payment statuses manually by rest calls? Or are there any other configs that I need to send while triggering the very first payment request?
You'll need to setup Instant Payment Notification (IPN) to handle that sort of thing.
IPN will automatically POST data about all transactions that hit your PayPal account to a URL you specify. This URL (a script) can receive the data and update your database, generate email notifications, or anything else you might want to automate based on the transactions.
You can handle all sorts of things with IPN. For chargebacks specifically, you would receive an IPN with the following params...
txn_type=new_case
case_type=chargeback
Of course, you'll get a bunch more parameters, too, but those would be how you can pick out the chargebacks and processing them accordingly.
I have been able to get a PayPal adaptive payments payment to work with a simple payment call.
But I want to get shipping details.
I have tried setting action type to create, then using the payKey returned sending a SetPaymentOptions call setting RequireShippingAddressSelection = True, then using the returned url from the payment call as before but still no shipping info.
I have seen others with this problem but without an answer.
Thanks
I have the same problem and here's what I got from PayPal Tech Support.
It is not possible for you to supply a shipping address as part of an
Adaptive Payments transaction. However, you can request that the
customer selects a shipping address from the addresses existing on
their PayPal account when they checkout using the embedded flow.
Details of the embedded flow are available here:
https://developer.paypal.com/webapps/developer/docs/classic/adaptive-payments/integration-guide/APIntro/
(Search for Embedded Payments)
If you think this is an option you would also be required to implement
another API call, SetPaymentOptions, which would be sent after the Pay
API request. Within the SetPaymentOptions API request you would add
the parameter requireShippingAddressSelection. Details of the
SetPaymentOptions API are located here:
https://developer.paypal.com/webapps/developer/docs/classic/api/adaptive-payments/SetPaymentOptions_API_Operation/
If your application requires that you supply a custom shipping address
to PayPal at the time of payment then you will need to consider using
Express Checkout instead of Adaptive Payments.
Are you sure the shipping info isn't passing? I don't think it's anything you'll see during the checkout process, but it will show up in the transaction details of the payment in your PayPal account.
I spent hours researching this and it appears to be an API bug from 2011 (great job PayPal!).
Unfortunately, you have to request the shipping info from the user before redirecting them to PayPal.
Source link
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.