Paypal - RestAPI - Sandbox Webhook not occurring - rest

Using my sandbox account with the RestAPI, I've created an invoice. My buyer account got the notification, I went to the link and paid it ok. There's notifications that I received payment. However, no WebHook notification.
I added all events to my WebHook. When using the WebHook simulator, I get the POST to my API just fine. It's hosted by a Redmond based cloud provider and is https.
Under the WebHook Events link in the Sandbox section, it's showing no entries.
Where else can I go to investigate this?

list all your registered webhooks use following with your actual access-token
curl -v -X GET https://api.sandbox.paypal.com/v1/notifications/webhooks \
-H 'Content-Type:application/json' \
-H 'Authorization: Bearer <Access-Token>'
in the response, you should be able to find out what exactly were in the system for your webhooks, if not, did you created the webhooks as document says?
curl -v POST https://api.sandbox.paypal.com/v1/notifications/webhooks \
-H 'Content-Type:application/json' \
-H 'Authorization: Bearer <Access-Token>' \
-d '{
"url": "https://www.yeowza.com/paypal_webhook",
"event_types": [
{
"name": "PAYMENT.AUTHORIZATION.CREATED"
},
{
"name": "PAYMENT.AUTHORIZATION.VOIDED"
}
]
}'

From what I see on the RestAPI documentation azlankasim is correct saying that only some fundings are supported.
On the bottom of the page it says that only PayPal authorizations are supported.
https://developer.paypal.com/docs/integration/direct/rest-webhooks-overview/
"Note: Only PayPal authorizations are currently supported. Direct credit card transactions are not yet supported. We are actively working on adding more event types."
Have you tried to test using PayPal payment, to check if this is the problem?

You may need to check what are the funding sources used to create the payment. Currently webhook only sends the notification if the customer pays with an echeck. So far there are no notifications sent if the payment is made with other funding sources. Also, you may need to check the events that you have chosen. Based on this documentation , only authorizations are currently supported.

Related

Not receiving some messages via WhatsApp Cloud API webhook

I'm trying to get WhatsApp's Cloud API working. I managed to set up Meta Business Account and configure a WhatsApp app. Then I configured a webhook and subscribed to messages event (see the following screenshot).
I then managed to send a message via the API using the following request:
curl -i -X POST `
https://graph.facebook.com/v13.0/103690452403982/messages `
-H 'Authorization: Bearer MY_TOKEN' `
-H 'Content-Type: application/json' `
-d '{ \"messaging_product\": \"whatsapp\", \"to\": \"MY_NUMBER\", \"type\": \"template\", \"template\": { \"name\": \"hello_world\", \"language\": { \"code\": \"en_US\" } } }'
I received the message and it came through the webhook as well. If I reply to that message, it comes through the webhook too.
The problem
However, when I send a message to the associated number from a different WhatsApp number (not via the API) it is received but the webhook is not called.
I suspect some incorrect configuration on my side. When I text the number from a different phone, the chat has a notice about E2E encryption - something which is not present in a chat window of the API-sent message. I assume that E2E-encrypted messages cannot be passed to the webhook because only the recipients should be able to decrypt the message.
Any ideas what I might be missing?
Thank you in advance
If you're using your business manager as a BSP, then you must Subscribe to your WABA first, to get notifications over your webhook.
See whatsApp cloud API document here:
https://developers.facebook.com/docs/whatsapp/cloud-api/get-started-for-bsps#subscribe-waba
Here, in the Callback URL mention "webhook" after the trailing "/"
i.e.
https://your_callback_url.tld/webhook

get sent or recieved emails from sendgrid

We're using SendGrid for email service for a project backend.
Now, we want to set up e2e tests for the project. To get a well-verified user, we have to know the verification code sent to the user's email at the time of the registration.
I've tried with the messages endpoint as:
curl --request GET \
--url https://api.sendgrid.com/v3/messages \
--header 'Authorization: Bearer SG.xxxxxxxxxxxxxxxxxxxxxxxxx' \
--header 'Content-Type: application/json'
But the response says:
{"errors":[{"message":"authorization required"}]}
Is there any way that we can get the sent emails using the SendGrid API?
Thank you in advance.
At the top of the documentation for the email activity API it says:
In order to gain access to the Email Activity Feed API, you must purchase additional email activity history.
I would guess that you are receiving that error because your account does not have that additional email activity history add-on.

PayPal API returns RESOURCE_NOT_FOUND / INVALID_RESOURCE_ID but the transaction is listed in the Sandbox Business account

I have a similar issue.
Setup
PayPal Sandbox environment
Two test accounts (Personal and Business account). During the tests the personal account buys a product. The transaction goes to the Business account.
I created REST API app which is connected to the Sandbox Business account above.
I logged in to: https://www.sandbox.paypal.com/ with the credentials of the Business account to generate a PayPal button. The HTML code of the button is added to my website.
Steps
I open the website and click the PayPal button.
I log into PayPal Sandbox with the credentials of the Personal account.
I complete the payment process.
I log into the Business account and I see that the transaction (order) is listed there. I can see the Transaction ID.
Issue
In all requests to the API I use the Client ID and the Secret of the REST API app which I already created for the purposes of the tests.
After that I opened Postman and I sent the following request to PayPal API to generate an access token (Doc: https://developer.paypal.com/docs/api/get-an-access-token-curl/).
curl -v https://api.sandbox.paypal.com/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: en_US" \
-u "client_id:secret" \
-d "grant_type=client_credentials"
So far, so good. Then I send an API request to PayPal APIv1 to get more details about the order. I use the Transaction Id which according to what I read is identical to Order ID.
curl -v -X GET https://api.sandbox.paypal.com/v1/checkout/orders/TRANSACTION_ID \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Access-Token"
and I get this:
{
"http_code": 404,
"body": {
"name": "INVALID_RESOURCE_ID",
"message": "INVALID_RESOURCE_ID",
"information_link": "https://developer.paypal.com/docs/api/orders/v1/#error-INVALID_RESOURCE_ID",
"debug_id": "c02871817abba"
}
}
I tried APIv2:
curl -v -X GET https://api.sandbox.paypal.com/v1/checkout/orders/ORDER_ID \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Access-Token"
and I get this:
{
"http_code": 404,
"body": {
"name": "RESOURCE_NOT_FOUND",
"details": [
{
"issue": "INVALID_RESOURCE_ID",
"description": "Specified resource ID does not exist. Please check the resource ID and try again."
}
],
"message": "The specified resource does not exist.",
"debug_id": "c2c24f91a44fd",
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-INVALID_RESOURCE_ID",
"rel": "information_link",
"method": "GET"
}
]
}
}
Confusion
The transaction is clearly listed in the Business account but the API says that there no such transaction.
Suggestions/Solutions?
Solution
The default behaviour of the payments initiated via PayPal button (generated with the Business account) is Sale but not Order. For more details about the differences between the two, read here - https://www.paypal.com/us/smarthelp/article/what-are-the-differences-between-the-express-checkout-payment-actions-ts1501
The solution is to make a request to another PayPal API method (check: https://developer.paypal.com/docs/paypal-plus/germany/how-to/show-sale/?fbclid=IwAR30yROZMjKT2LlRgSRuVBMGrjdmN1MGbuJ50rUiUBWwW11FSpGdxk5JNpY#show-sale-details)
Here is the request returning correct data.
curl -v -X GET https://api.sandbox.paypal.com/v1/payments/sale/TRANSACTION_ID \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Access-Token"
Solution
The default behaviour of the payments initiated via PayPal button (generated with the Business account) is Sale but not Order. For more details about the differences between the two, read here.
The solution is to make a request to another PayPal API method check this
Here is the request returning correct data.
curl -v -X GET https://api.sandbox.paypal.com/v1/payments/sale/TRANSACTION_ID \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Access-Token"
v2/orders objects are for payment approval only, they are not transactions. Their IDs should only be persisted about a month for debugging purposes, as they serve no accounting purpose and are not referenceable in PayPal.com
A PayPal transaction on the other hand is represented by a v2/payments object, returned when you capture a v2/order. You can get a capture's details again with the appropriate GET call: https://developer.paypal.com/docs/api/payments/v2/#captures_get
It is very likely something is broken on PayPal server. It is happening quite often.
They usually fix it, some time it takes longer than reasonable.
In any way to make sure you are doing everything correctly, and to check if they have problems at the time of your experiments, you can contact paypal support
https://www.paypal-support.com/

Cannot call the PayPal Sync API due to Authorization Failure

I'm trying to use the relatively new PayPal Sync API to download my PayPal transactions. I'm following the Sync API guide. I started by logging into the PayPal Developer Dashboard My Apps & Credentials page, scrolling to the REST API apps section, creating an app, clicking on it, and enabling Transaction Search for both the Sandbox and Live accounts.
I then used the Sandbox account's Client ID and Secret to generate an Access Token. I confirmed that the Client ID and Secret are correct and active. My cURL command is below (note that I'm using cURL on Windows 10):
curl -v https://api.sandbox.paypal.com/v1/oauth2/token ^
-H "Accept: application/json" ^
-H "Accept-Language: en_US" ^
-u "<my-client-id>:<my-secret>" ^
-d "grant_type=client_credentials"
I received a response similar to the following (I added the formatting):
{
"scope":"https://uri.paypal.com/services/reporting/search/read
https://api.paypal.com/v1/payments/.*
https://uri.paypal.com/services/applications/webhooks
openid",
"nonce":"2018-04-04T02:20:02Z...",
"access_token":"<my-access-token>",
"token_type":"Bearer",
"app_id":"<my-app-id>",
"expires_in":32400
}
I then took the Access Token and copied it into the sample command on the Sync API guide page. Here is the command I ran:
curl -v -X GET https://api.sandbox.paypal.com/v1/reporting/transactions?transaction_id=5TY05013RG002845M&fields=all&page_size=100&page=1 ^
-H "Content-Type: application/json" ^
-H "Authorization: Bearer <my-access-token>"
I received the following error response:
< HTTP/1.1 401 Unauthorized
...
< Content-Length: 244
< Connection: close
< Content-Type: application/json
<
{
"name":"AUTHENTICATION_FAILURE",
"message":"Authentication failed due to invalid authentication credentials or a missing Authorization header.",
"links":[{
"href":"https://developer.paypal.com/docs/api/overview/#error",
"rel":"information_link"
}]
}
I tried many things to correct this error, including:
Adding a "Accept: application/json" and "Accept-Language: en_US" header to the command.
Creating a new Secret and generating a new Access Token.
Creating a new App with a new Client ID & Secret and generating a new Access Token.
Disabling Transaction Search, re-enabling it, and sending the command again.
Trying in the Live account.
Each of these attempts produced the same result. I noted that in the scope section of the access token response that it doesn't include a path similar to the stated path for the Sync API (/v1/reporting/transactions). However, that's just an observation, and I'm not sure if that is relevant.
I read through the entire Sync API guides and documentation about five times, and I searched Google and StackOverflow pretty thoroughly. I'm seeing evidence that some people are getting past the initial connection to Sync API, so I'm fairly certain this API works.
Can someone help me understand what I'm missing? Could it just be that I need to wait a day or two for their systems to catch up? PayPal's Developer documentation is not very user-friendly, and their Developer Dashboard is extremely glitchy.
I had this same issue. Putting double quotes around the URL solved it for me. The other API endpoints worked (authentication, authorizations/xyz) because they didn't have any special URL characters in them. In the transaction search, the query string delimiters were being parsed by Bash.
Your curl lines above become:
curl -v -X GET "https://api.sandbox.paypal.com/v1/reporting/transactions?transaction_id=5TY05013RG002845M&fields=all&page_size=100&page=1" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <my-access-token>"
Hope that helps someone.
It appears that this error may be caused by either cURL or the way I'm using it. On a hunch, I used Hurl.it to execute this sample request, and the request was successful (HTTP 200). I then tried another request where I searched for all transactions in a given date range, and that was also successful. I'm going to mark the question answered.

Uber GET requests 403

I am trying
curl -X GET -H "Authorization: Bearer <TOKEN>" "https://api.uber.com/v1.2/requests/<REQUEST_ID>"
and response is 403
{"message":"Forbidden","code":"forbidden"}
But the https://developer.uber.com/docs/riders/guides/scopes says that
The good news is you currently have access to these scopes when authorizing your own account or those of the developer accounts you list in your application dashboard (Limited Access). This allows you to start building an app immediately.
I've got token via OAuth using my own account
I've set param "scope=request" to https://login.uber.com/oauth/v2/authorize
And I've set "scope=request" when did https://login.uber.com/oauth/v2/token
Also I've trying to do request to https://sandbox-api.uber.com, it responds
{ "message": "cannot find trip", "code": "not_found" }
But I think it's ok, because sandbox doesn't contain my own account data, right?
Where is my fault could be?