I'm trying to validate a payment made through a partner service. The partner is passing me the payment id and I'm using the REST API to look it up. So far, all attempts to use the payments/payment/<Payment-Id> are throwing an INTERNAL_SERVICE_ERROR. (I'm still using the sandbox and demo user.)
Getting a token seems to be working fine:
curl -v https://api.sandbox.paypal.com/v1/oauth2/token -H "Accept: application/json" -H "Accept-Language: en_US" -u "EOJ2S-Z6OoN_le_KS1d75wsZ6y0SFdVsY9183IvxFyZp:EClusMEUk8e9ihI7ZdVLF5cZ6y0SFdVsY9183IvxFyZp" -d "grant_type=client_credentials"
Response:
{"scope":"https://api.paypal.com/v1/developer/.* https://api.paypal.com/v1/payments/.* https://api.paypal.com/v1/vault/credit-card https://api.paypal.com/v1/vault/credit-card/.*","access_token":"A015GzttpnOSOPfcqtfAaq1kdgqow5W.IXSe6TJ9Cpbesr4","token_type":"Bearer","app_id":"APP-8KK24973T6066201W","expires_in":28800}
Taking that token and putting into the payment request:
curl -v -X GET https://api.sandbox.paypal.com/v1/payments/payment/PAY-8UD377151U702286RKOQ3DTQ -H "Content-Type:application/json" -H "Authorization: Bearer A015GzttpnOSOPfcqtfAaq1kdgqow5W.IXSe6TJ9Cpbesr4"
returns the error:
{"name":"INTERNAL_SERVICE_ERROR","message":"An internal service error has occurred","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR","debug_id":"ca33c7679121d"}
UPDATE: basically I'm trying to follow the steps outlined here: https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/
Related
Hey i want know if github have a endpoint to verify if a access_token have expired ?
I have tried this but i have a 404 error
404 would mean you did not authenticate properly.
Make sure to use a PAT (Personal Access Token) to authenticate your query (assuming you are not testing you own PAT itself!)
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \ <==== Important
https://api.github.com/applications/Iv1.8a61f9b3a7aba766/token \
-d '{"access_token":"e72e16c7e42f292c6912e7710c838347ae178b4a"}'
I manually block IP to access my site (dlandroid.com) with Cloudflare "IP Access Rules",
My question is how to block an IP with Cloudflare API Curl request using PHP?
I search API document and find this but don't know how to use it with PHP:
curl -X GET "https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/access_rules/rules?page=1&per_page=20&mode=challenge&configuration.target=ip&configuration.value=198.51.100.4¬es=my note&match=all&order=mode&direction=desc" \
-H "X-Auth-Email: user#example.com" \
-H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \
-H "Content-Type: application/json"
also check this: https://api.cloudflare.com/#firewall-access-rule-for-a-zone-list-access-rules
AZURE - The official documentation and examples for PHP is not working, help?
I am using the code at this link:
https://github.com/courtney7/HTTP-Code-Samples/blob/37a4431f75397e1ccc6ee3f62ef14b3909a2dc85/PHP/PHPAzureToken.php
Always test and debug APIs using curl (i.e. take a curl first approach). Here's an example that works on my Windows 10 system. Here's the curl that gets a token.
curl -k --data "" "https://api.cognitive.microsoft.com/sts/v1.0/issueToken" -H "Ocp-Apim-Subscription-Key:<your Ocp-Apim-Subscription-Key>"
Example to get token and call text translate.
curl -k --data "" "https://api.cognitive.microsoft.com/sts/v1.0/issueToken" -H "Ocp-Apim-Subscription-Key:<your Ocp-Apim-Subscription-Key>" > Bearer.txt
set /p Bearer= < Bearer.txt
curl -H "Authorization: Bearer %Bearer%" "https://api.microsofttranslator.com/v2/Http.svc/Translate?Text=Hello+world.&From=en&To=es"
Make sure you are calling the correct endpoint "https://api.cognitive.microsoft.com/sts/v1.0/issueToken"
https://github.com/paypal/PayPal-iOS-SDK/blob/master/docs/profile_sharing_server.md#profile-sharing-server-side-integration
curl 'https://api.paypal.com/v1/oauth2/token' \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Authorization: Basic QWZVa...==" \
-d 'grant_type=refresh_token&refresh_token=MFYQ...'
What is
Authorization: Basic QWZVa...== ??
and retur true;
Authorization: Basic xxxx is the OAuth 2 auth token. Basic is the token type, and the xxxx piece is your access token. It's a way of authorizing a user, and will be passed in the headers of a request. More info here: https://developer.paypal.com/docs/api/#authentication--headers
what is curl -u equivalent in php unirest
Blockscore API:
$ curl https://api.blockscore.com/people \
-u sk_test_n5049aa6053c9a0217bea78070fbf501: \
--header "Accept: application/vnd.blockscore+json;version=4"
Api key: sk_test_n5049aa6053c9a0217bea78070fbf501
I want to try this out in Unirest. but what is -u?
is it a header or a post?
The -u flag for cURL is used to set the credentials for HTTP Basic authentication. The provided credentials will be base64-encoded and presented in the "Authorization" header as in:
Authorization: Basic c2tfdGVzdF9uNTA0OWFhNjA1M2M5YTAyMTdiZWE3ODA3MGZiZjUwMTo=
So it is a header.
In unirest you should be able to use:
Unirest\Request::auth('sk_test_n5049aa6053c9a0217bea78070fbf501', '');