Paypal webhook instead of return url - paypal

Here is my flow of the payment.
Create Payment and return Url for user to verify
Using above Url user opens Paypal account and accepts payment
After accepting payment Paypal returns to success url.
Execute payment (final stage of the sale)
My Question is if there exists any webhook triggered after step 2, before step 3. Right after user verifies payment in it's personal paypal page.
The reason to catch webhook is not to rely on success redirect url rather than use webhook.

The terms you are using do not match the keywords you've used here.
Are you working with REST APIs or are you working with PayPal Standard / Classic APIs?
If you're working with REST APIs, then the simple answer is yes, you should use the Webhooks to handle any automated processing. Specifically, take a look at the SALE Webhooks. That should give you what you're after.
If you're working with Standard / Classic, the answer is the same except that you would use IPN instead of Webhooks.

Related

Automatically capture a order in PayPal

I'm integrating my application with PayPal and i found a problem.
I use PayPal REST API with intent: "CAPTURE".
After I create an order in paypal via /v2/checkout/orders POST endpoint and client pay for this order in https://www.sandbox.paypal.com/checkoutnow?token={TOKEN} website I don't receive any money or transaction on my PayPal business account.
When I check this order status it says that it is APPROVED but not COMPLETED, so i need to capture this order via v2/checkout/orders/{TOKEN}/capture POST endpoint. After capturing this order is has status: COMPLETED and i receive money.
Is It possible to automatically capture an order without any additional request to capture it?
Because when I use PayPal button It works automatically and I want to have the same result using REST API.
No, it's not possible. The capture step is required.
Whether you use a client-side integration: https://developer.paypal.com/demo/checkout/#/pattern/client
Or a front-end UI that calls server-side routes of yours: https://developer.paypal.com/demo/checkout/#/pattern/server
The capture step after approval (within onApprove) is always required.

Using PayPal webhooks with NVP DoExpressCheckoutPayment

I'm working on a website where a user can pay for products to another user, the user that is getting paid has his API Signature set and the payment is accomplished using ExpressCheckout (NVP) (the payer just gets redirected to a PayPal page where he logs in if necessary and just clicks a button to pay).
The problem is I tried using webhooks to track refunds for these payments, so I can later insert the refund data into my database via callback URL (php function), but the URL I've set doesn't get called at all(I've previously simulated an event on the same URL and everything was fine).
I am trying to get this to work by setting my API Signature and a friend of mine paying me some cents(via DoExpressCheckoutPayment) after which I refund them to him (no calls, only using the PayPal website).
Also nothing appears on the Sandbox Webhooks Events page or the Live one. I've tried registering other events like "Payment capture completed" or "Payment sale completed" to my webhook but with the same result.
Do I have to change some settings in my account? I've created a REST API app in order to use webhooks, but I've seen there's an option for NVP/SOAP API apps. I have considered IPN if webhooks don't work.
"Webhooks" are used with the REST API. Express Checkout uses IPN.
You'll need to setup a separate listener for IPN similar to what you've done with webhooks on the REST API.

Verifying paypal account

I am building website which requires customer to update paypal account.
Is there anyway to check the reality of customer's account?
When my customer fill out their paypal account in my site, I want them to be directed to paypal login page to login and paypal will return the result.
Does paypal api support this situation?
Pretty much any implementation of PayPal you choose would follow the flow you mentioned.
Payments Standard would allow you to create basic buttons or create an HTML form and POST directly to PayPal to process. It would send the user to PayPal for login and approval to complete the payment. The transaction details would include the payer status (verified or unverified) as well as the address status (confirmed or unconfirmed) and lots of other details about the order.
Express Checkout is basically the API version of Standard, but it's much more advanced and open to integrate in the way that works best for your site or application. In this case, some of buyer/transaction data is available during the process within your app through API requests and responses, and then you can also get to it via transaction details after the fact just like payments standard provides.
Another option would be to use Adaptive Payments, but if you're doing a general payment of any kind you probably don't need that. That's what you would use if/when you start wanting to split payments among multiple receivers within the same transaction, setup preapproval profiles, etc.
If you happen to be working with PHP my class library for PayPal will make the API calls very simple for you.
You could do what PayPal itself does when you register. Send them a few cents and have them tell you how many when they get it. The payment itself will fail if the account doesn't exist, and telling you how many cents proves that they own the account.

How to test a PayPal capture API call with Sandbox

I have setup PayPal Sandbox test accounts, a Personal (buyer) and a Business (merchant).
I'd like to test a PayPal 'DoCapture' API Operation. The problem I'm encountering is that I need an AuthorizationID and don't know how to obtain it. If i run the 'DoExpressCheckoutPayment' API call, I do not get an AuthorizationID returned, using the merchant API credentials, though I do get an 'ACK' of success. Do I need to be using the buyer credentials with the 'DoExpressCheckOutPayment' call? I don't see the API credentials in the PayPal Sandbox profile for the Personal account.
Express Checkout example with authorization and capturing you can find here.
Short answer - according with DoCapture documentation
AuthorizationID ... This is the transaction ID returned from DoExpressCheckoutPayment...
According with DoExpressCheckout documentation you need field from response, attention, PaymentInfo#TransactionId
... this value is your AuthorizationID for use with the Authorization & Capture APIs.
This is what you need to do to implement the capture API.
Create Payment: set intent as authorize in its request to get payment Id
Show Payment Details: to get approval_url. The customer will use this URL to pay for the order.
Execute approved PayPal payment: Use this API after customer successfully pays for the order. This API returns authorization-id along with capture link.
Use Capture API: use the URL obtained from step 3 to capture.
Use this link and check payments API.
https://developer.paypal.com/docs/api/payments/#payment_execute
Hope this helps to someone who stumbles upon here.

PayPal: How do you get notifications of payment through the permissions API?

Using the PayPal permissions API can you receive notifications from payments made after a customer clicks on a payment button, proceeds to PayPal, and then pays?
I notice they have IPN, but will this work with the permissions API?
Thanks!
You can include NotifyURL in your API requests to set a URL for IPN to POST data to. It's not something that technically "works with the permissions API" but any transaction that is made would indeed trigger the IPN.
If you're building an app for 3rd parties to use, though, and you're passing NotifyURL in your API requests, that will override any IPN configuration each individual merchant using your tool might have setup on their own. This can cause frustration for such users because then their own IPN solution doesn't get hit when they take payments through your app.
If you're going to do that I recommend setting up a way for your users to enter their own IPN URL in your app settings, and then if they have a value, forward the POSTed data to their URL when PayPal sends it to yours. That way both IPN scripts will get hit and process the data accordingly.