PayPal webhook all events remain pending - paypal

When I complete a payment with PayPal using a sandbox account, webhook events are listed as "Pending" with an orange icon in the "Webhook events" section of the PayPal developer dashboard, and the log shows that the webhook has not been called. However, when using a different REST API app, the webhook call works perfectly!
I have tried:
Ensuring that currency is correctly configured
Changing the "Payment Review" setting to "Off" for each sandbox account
Making the app call the webhook for all events
Comparing settings with the other app I made, for which the webhook does get called
Checking that the webhook causes log output, so there is no error causing the lack of output
What other things could be causing this difference, making webhook calls work for one app but get stuck in "Pending" for another that I created more recently?

I was testing in wrong way, i had a test ambient develop and when I was sending events to paypal, the return route was indicating to production ambient. Thats my error and my soluction was buying some stuffs in production ambient. Summarize, the paypal cant get a response for your event, in other words, paypal cant finish the event. Verify your RETURN URL and CANCEL URL.

Sandbox accounts and REST Apps are free and unlimited, so if one isn't working the way you need it to, the simple solution is to not use it anymore and use any number of new ones you create instead.
But if this remains an issue for you, it seems like you should direct the question to PayPal's support, since you've included no request/response log information to actually review for what might be different about the two apps or accounts' situations that causes one to be pending.

Related

PayPal Subscription Cancellation - Webhook

From a developer perspective, what is the best way to capture (webhook wise) a user cancelling their PayPal subscription via their dashboard (and/or subscription payment failing)?
I've had some discussions with PayPal support and have learnt the following:
Subscription button:
-simple, elegant, works well to let user subscribe
-however, when user cancels subscription via their dashboard does NOT fire a BILLING.SUBSCRIPTION.CANCELLED webhook. Only an IPN HTTP "webhook" gets fired. From the paypal docs, IPN seems harder to integrate (not REST, and for example the IPN simulator doesn't even have "subscription cancellation" events)
Using API (PayPal PHP SDK):
-DOES fire BILLING.SUBSCRIPTION.CANCELLED webhook events when user cancels their subscription via their PayPal dashboard (why this doesn't work for button-created subscriptions I do not understand)
-However, seems much more complex to set up than the button (what does the web flow look like?)
Just some thoughts on the best approach would be appreciated.
It depends on the type of 'Subscribe' button.
Legacy 'Subscribe' buttons created via e.g. https://www.paypal.com/buttons , will not fire a BILLING.SUBSCRIPTION.CANCELLED webhook. Those buttons predate webhooks by 10 years, and only use the very old IPN service. Stay away...
Current smart subscribe buttons, created via e.g. https://www.paypal.com/billing/plans or following the documentation do trigger the BILLING.SUBSCRIPTION.CANCELLED webhook.
In general, you can make use of the CANCELLED webhook and track this status if you want to but it's not necessary. The most important best practice is to make use of PAYMENT.SALE.COMPLETED and record when a subscription was last actually successfully paid for. If it doesn't get paid for again on time, then it's lapsed and you treat it accordingly.
When creating a subscription, along with the plan_id you can pass a custom_id which will be returned in all the webhooks. This can be useful for reconciliation purposes so you know which user it's for.
Using API (PayPal PHP SDK):
That SDK is deprecated, don't use it. Any API calls should be done directly via HTTPS.

PayPal webhook events never being sent?

We have a production game that uses PayPal as one of the methods of payment. In some cases, we're never receiving webhook notifications.
Here's the sequence that's occurring. Sometimes we get the webhook from this sequence, and other times we don't. On the server, we're using the Java API. All of this is the behavior with the production (NOT SANDBOX) PayPal servers.
After the user selects a product, it calls our server, which creates the Payment object via Payment.create(). At that point the state is 'created' and we redirect the user to the approval_url returned in the links.
The user approves the payment and is sent back to our server. We fetch the payment via Payment.get(), which is successful and has a state of 'created'.
We execute the payment using a PaymentExecution. This returns the payment with an updated state of "approved".
We then wait for a WebHook to inform us that the payment was completed. On occasion, this webhook is never sent, leaving the purchase incomplete. Checking the PayPal console, no webhook event exists for the payment, even though the payment is showing up as completed.
The questions here are:
Is this the correct sequence? Or is something missing?
Shouldn't the payment be "approved" when the user is returned from PayPal rather than still "created"?
Shouldn't the payment be either "completed" or "in_progress" after a successful execute?
What is the correct way to handle the case where the webhook never arrives? Keep polling the payment until the state updates?
I do not see any problem with your sequence. You can also refer to the steps here as an example - https://developer.paypal.com/docs/integration/web/accept-paypal-payment/
Regarding Webhooks, you mentioned sometimes you get Webhooks and only some times you do not. Can you please provide a correlation or debug id for the calls where you don't see any Webhook? We will trouble shoot and get back?

Is there any real time paypal ipn service

PayPal has explicitly stated that their IPN service should not be relied on during the user checkout process. I believe the idea here is that IPN should be a tracking mechanism to keep our back end data in sync with PayPal's data. What I want to do is to use express checkout but enforce an "IPN" to hit my server, and for my server to appropriately respond, before anything is finalized.
I can then ensure that I only give out content to users once they've paid, and that if a user does pay for a piece of content they do not have to refresh or wait for the IPN to come in. One of the problems with doing this using a return url and query string, is that i have a single page website on the firefox phone. The phone gets data from our API web service. So i need this endpoint to be hit regardless of the return url.
I know there are some more features with PayPal advanced developer, at a fee. I'm fine with that if that's the case, but i just want to know my options first.
As the name implies, IPN is instant. There are rare occasions where it may be slightly delayed, but that doesn't happen often, especially on the live servers.
You can build your IPN listener to do whatever you need as far as updating a database, generating custom email notifications, hitting 3rd party web services, etc. and those actions will be triggered in real-time.
You just need to get your listener created and configured in the PayPal IPN settings, or you can also pass the IPN URL in the NotifyURL parameter of your Express Checkout API calls.
If you happen to be using WordPress you may be interested in my PayPal IPN for WordPress plugin. It gets you up-and-running with IPN very quickly, and then you can hook into the plugin to trigger your own functions based on different IPN types or payment statuses.
Extra Info from Comments
As mentioned, IPN is a post-transaction thing. What you could do, though, is setup Auth and Capture on your checkout system. When the order comes through you would run it as an Authorization, and when you're ready to "finalize" you would run the capture.
You would get an IPN for both the authorization and the capture. So, one thing you could do, if it suits you, would be to run the order as an Authorization, and then within your IPN script, go ahead and run the capture. That way you could do whatever checks you want to do and only capture if they pass.
In passing cases, the capture would take place "almost" instantly when the order takes place. Cases where it doesn't pass, you could either void the Auth or let it sit there in a pending state.

Payout in Sandbox

Paypal newbie here. I am using the .net sdk to call PayPal's rest api in the Sandbox environment. I am trying to test a batch payout(Mass Payment).
Issue 1. The sandbox "facilitator" account which came pre-created has a zero balance. I cant seem to find any way to get some money in the account so that i can test payouts. If i create a new business account, i get to specify an opening balance, but when i try to do payouts using this new account, i get back a 403 forbidden response when i try to payout even though i am able to get a token successfully.
Issue 2: Using the facilitator account, i am able to submit a payout request, but its behavior seems to have changed since a couple of day ago. A few days ago, all payout request used to be DECLINED and would show up on the transactions list on the sandbox site. I assumed they were getting DECLINED because the balance was zero. Since yesterday, all payout transactions via the facilitator account stays in PENDING stage and they do not show up on the transaction list. A Payment/Get request for the payout_batch_id always returns back as pending even aftter a day, but theres no sign of those transactions on the sandbox site.
1 - Creating a fresh account and giving it an opening balance is correct, and that should work just fine for you to test MassPay. If you're getting a 403 error that sounds like a problem with your API endpoint or something. Need to see a sample of the API request/response to know more on that.
2 - Again, need to see a sample of the API request/response that you're getting to know more here. My MassPay transactions in the sandbox work just fine. Here's an example. You'll see the request and response data there, showing it was successful. Then when I go look at the separate accounts I see the money as expected.

I am not able to trigger Paypal REST API webhook events

I'm trying to implement the Paypal REST API for a client and I'm at the point where I need to test the webhook system. I can not get the API to generate an event; a successful payment should generate one, I've also tried using the REST API to issue refunds, and I've tried issuing refunds from the developer sandbox. None of those activities have generated an event for me.
For example, if I execute the command:
curl -v -X GET -H 'Authorization: Bearer VALID_BEARER_TOKEN' 'https://api.sandbox.paypal.com/v1/notifications/webhooks-events'
I get this:
{"events":[],"count":0}
Even after a dozen or so successful payments and maybe a half-dozen refunds, in both sandbox and live, I see "count": 0. The sandbox merchant center and transaction detail both are aware of the correct state of each transaction, and if I query the /v1/payments/payment/{id} resource, I see the correct state for that {id}.
Operationally, I have everything set up correctly:
the webhook uri is registered correctly in the app details, with subscriptions to all event types
the endpoint has a valid SSL Certificate
the endpoint has no firewall or other security that would prevent a successful SSL connection (I've tested this thoroughly)
I have application logging ratcheted up to the finest detail, with no results. I have tcpdump listening on the webhook target machine just to see if any handshake is attempted, also with no results. I've even tried the old "delete and recreate" trick with the app, which didn't help. I've also registered a new PayPal merchant account and encountered the same problem.
I do see IPN traffic for one of the accounts that had a default IPN handler enabled. I would prefer to use the webhooks if at all possible, the reason my client wants to do this in the first place is to get away from IPN.
Am I missing a setting somewhere? Is there some magic undocumented flag? Or is webhook support too new and I shouldn't rely on it and just stop wasting my time and go back to IPN?
There's nothing wrong on your side. If you do sale, paypal webhooks only support echeck case for now. PayPal is adding webhooks support covering other funding sources for sale payment, estimated release is in next Jan.
To update this thread, PayPal has added webhooks support for other funding sources for sale payment.
https://developer.paypal.com/docs/integration/direct/rest-webhooks-overview/