I'm having some difficulty implementing paypal implicit payments and unfortunately there is very limited details in the error message response from paypal.
Here's the request:
{
"actionType": "PAY",
"currencyCode": "USD",
"cancelUrl": "http://my_domain.com/cancel_url",
"returnUrl": "http://my_domain.com/return_url",
"requestEnvelope.errorLanguage": "en_US",
"requestEnvelope.detailLevel": "ReturnAll",
"senderEmail": "sender#email.com",
"receiverList.receiver(0).amount": 50,
"receiverList.receiver(0).email": "receiver#email.com"
}
Here's the headers i'm setting:
"Content-Type", "application/json"
"Accept-Language", "en_US"
"X-PAYPAL-SECURITY-USERID", "username"
"X-PAYPAL-SECURITY-PASSWORD", "pwd"
"X-PAYPAL-SECURITY-SIGNATURE", "sig"
"X-PAYPAL-APPLICATION-ID", "My App id"
"X-PAYPAL-REQUEST-DATA-FORMAT", "JSON"
"X-PAYPAL-RESPONSE-DATA-FORMAT", "JSON"
Here's the response:
{
"responseEnvelope":{
"timestamp":"2013-04-06T12:02:41.011-07:00",
"ack":"Failure",
"correlationId":"3842d361b077d",
"build":"5563463"},"error":[{
"errorId":"580001",
"domain":"PLATFORM",
"subdomain":"Application",
"severity":"Error",
"category":"Application",
"message":"Invalid request: {0}"
}]
}
I just had the exact same problem and couldn't find the answer anywhere. Turns out I was using a GET request instead of POST. It's odd though that the errorId 580001 is nowhere to be found in their docs.
The adaptive payments API doesn't accept whitespace in the request payload, remove all the spaces and newlines and give it another try. Took me ages to figure that out.
Another thing to look out for is encoding. I've had this error and realised that it was due to an ampersand in the "memo" field. If you send the request as NVP be sure to URL encode where possible.
let payload={
"actionType":"PAY",
"currencyCode":"USD",
"receiverList":{
"receiver":[{
"amount":1.00,
"email":"buyer email"
}]
},
"returnUrl":"succes url",
"cancelUrl":"cancel url",
"requestEnvelope":{
"errorLanguage":"en_US",
"detailLevel":"ReturnAll"
}
}
let url = "https://svcs.sandbox.paypal.com/AdaptivePayments/Pay";
return this.http.post(url, payload, { headers: headers })
headers.append('X-PAYPAL-SECURITY-USERID', 'security id');
headers.append('X-PAYPAL-SECURITY-PASSWORD', 'password');
headers.append('X-PAYPAL-SECURITY-SIGNATURE', 'signature');
headers.append('X-PAYPAL-REQUEST-DATA-FORMAT', 'JSON');
headers.append('X-PAYPAL-RESPONSE-DATA-FORMAT', 'JSON');
headers.append('X-PAYPAL-APPLICATION-ID', 'APP-id');
As another cause of this issue, make sure the amount property for each receiver does not contain a comma, as this will also break. I.e. 1000.00 instead of 1,000.00.
Related
I'm currently attempting to create an upload system that takes local files and uploads them to google drive. This is being done through Retool. My PUT query is coming back fine with the needed URI, but my POST is failing. I've been unable to identify the cause after a good amount of research.
Here is the error message i'm receiving (Thrown through JSON formatter for readability):
{
"data":{
"statusCode":400,
"error":"Bad Request",
"message":"{\"message\":\"Not Found\"}",
"data":{
"message":"Not Found"
},
"metadata":{
"request":{
"url":"https://www.googleapis.com/upload/drive/v3/files?key=---sanitized---%26uploadType%3Dresumable%26upload_id%3D---sanitized---",
"method":"PUT",
"body":"UEsDBBQACAgIAHNbzlIAAAAAAAAAAAAAAAAYAAAAeGw...", //base64 string.
"headers":{
"User-Agent":"Retool/2.0 (+https://docs.tryretool.com/docs/apis)",
"Content-Transfer-Encoding":"base64",
"Content-Length":535487,
"Authorization":"---sanitized---",
"X-Retool-Forwarded-For":"104.129.199.15"
}
},
"headers":{
"x-guploader-uploadid":[
"--READACTED--"
],
"vary":[
"Origin, X-Origin"
],
"content-type":[
"text/html; charset=UTF-8"
],
"content-length":[
"9"
],
"date":[
"Fri, 10 Sep 2021 01:58:07 GMT"
],
"server":[
"UploadServer"
],
"alt-svc":[
"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\""
]
},
"status":404,
"statusText":"Not Found"
}
},
"errorData":"Not Found",
"displayOptions":{
"hideToast":false
},
"trigger":"NATURAL_FAILURE"
}
The URI matches the URI recorded from PUT_QUERY.headers.location[0] perfectly. My API key is valid, I even decoded the base64 string back to an excel document to double check it was getting corrupted, and I've run out of idea on what could be causing this.
Here are the scopes i've given to the Oauth2 Token being used:
https://www.googleapis.com/auth/docs
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.appdata
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/drive.metadata
https://www.googleapis.com/auth/drive.metadata.readonly
https://www.googleapis.com/auth/drive.photos.readonly
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/drive.apps.readonly
https://www.googleapis.com/auth/drive.activity
https://www.googleapis.com/auth/drive.activity.readonly
In case it helps, my POST requests looks like..
{
"request":{
"url":"https://www.googleapis.com/upload/drive/v3/files?key=--sanitized--&uploadType=resumable",
"method":"POST",
"body":"{"name":"03 Mar 21 Conv--sanitized--.xlsx","parents":"[1NJ--sanitized--ka5W4Zz9Tc]"}",
"headers":{
"Content-Type":"application/json; charset=UTF-8",
"User-Agent":"Retool/2.0 (+https://docs.tryretool.com/docs/apis)",
"Authorization":"Bearer ---sanitized---",
"X-Content-Length":535487,
"X-Upload-Content-Type":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
}
}
}
Found the error. Something about how the url substring was being appended was creating a bad link. Changed code to only pull out the upload_id and now it’s working. Another error with this code that I hope might help someone else out is that the google drive api resumable PUT needs a Content-Encoding header, not a Content-Transfer-Encoding. Otherwise the upload will go through, and retain all its metadata (name, directory, etc) and size, but will not open correctly.
I am trying to create an Issue in my own repo using Github API, but for some reason it keeps throwing me an error
Route::post('/issue/create/{repo}',function ($_repo){
$client = new Client([
// Base URI is used with relative requests
'base_uri' => 'https://api.github.com',
// You can set any number of default request options.
// 'timeout' => 2.0,
]);
$url = '/repos/rehan-dckap/'.$_repo.'/issues';
// Set various headers on a request
$response = $client->request('POST', $url, [
'query' => [
'title' => 'IssueCreation',
'body' => 'ThPI',
'assignee' => '',
'milestone' => 1,
'labels' => [],
'assignees' => []
],
'headers' => [
'Authorization' => 'Bearer TOKENTOKENTOKENTOKEN'
]
]);
return response($response->getBody());
});
ERROR
Client error: POST https://api.github.com/repos/rehan-dckap/qatouch-api-docs/issues?title=IssueCreation&body=ThPI&assignee=&milestone=1 resulted in a 422 Unprocessable Entity response: { "message": "Invalid request.\n\nFor 'links/0/schema', nil is not an object.", "documentation_url": "https://develo (truncated...)
Can someone guide me?
I've taken quite a bit of time to try and understand what the problem is here, but without running the code itself it will be a bit tricky. Can you provide an online sandbox with that code so I can play with it? I'm happy to provide the token myself. There's two main things here.
First the 422 generally means that there was an error parsing the payload. Looking at your payload, and the error message I would try to start by removing all non-mandatory fields starting by the arrays. If we look at the error message it's saying Nil is a not an object. My best guesses would be problems with the arrays or the assignee string.
Overall my tip in these cases is to reduce the API call to the bare functional. minimum and try to isolate the problem. I would go as far as using the GitHub Example they've posted on the API page and even remove the assignee since it's been deprecated:
{
"title": "Found a bug",
"body": "I'm having a problem with this.",
"milestone": 1,
"labels": [
"bug"
]
}
Hope this helps.
here you can check the error code: https://developer.github.com/v3/
Sending invalid fields will result in a 422 Unprocessable Entity response.
HTTP/1.1 422 Unprocessable Entity
Content-Length: 149
{
"message": "Validation Failed",
"errors": [
{
"resource": "Issue",
"field": "title",
"code": "missing_field"
}
]
}
I’m having some trouble with getting my zapier REST Hook subscribe working. The Authentication setup is working.
I receive the POST subscribe from zapier with the “target_url,event” data. As soon as I POST any data to the “target_url” for some reason the unsubscribe url is then called which disables the “target_url”. So every attempt to POST or GET to the “target_url” just responds with “please unsubscribe me!”. Any help would be appreciated
Zapier Subscribe Post Respone
{
"subscription_url": "https://hooks.zapier.com/hooks/standard/2954661/d9bd6b7a323747628ee4cb6102a15056/",
"target_url": "https://hooks.zapier.com/hooks/standard/2954661/d9bd6b7a323747628ee4cb6102a15056/",
"event": "get_contact"
}
Zapier Post Header Response
{
"host": "messagebot.ngrok.io",
"x-hook-test": "true",
"accept-encoding": "gzip, deflate",
"content-length": "228",
"accept": "application/json",
"user-agent": "Zapier",
"content-type": "application/json; charset=utf-8",
"authorization": "Basic NTcyOGUxOTU1OTUzZmEzMmUwNTliMGNmOg==",
"x-newrelic-id": "VgMAVF9bGwIHVVRQBwMA",
"x-newrelic-transaction": "PxRRUVQBDQNRXFEHAwJWXwEBFB8EBw8RVU4aBAgKVgcDBAFRVFUAA11TB0NKQQsLAVZXV1ZUFTs=",
"x-forwarded-for": "35.168.226.6"
}
Post Data To Zapier target_url
[{
"first_name": "Jim",
"last_name": "Bozack",
"tag_1": "DTW010517A",
"event": "get_contact",
"email": "testing#fakeemail.come"
}]
Response from Zapier target_url
{
"status": "success",
"attempt": "5a85c059-19c0-4129-a44f-79be9f8ea270",
"id": "10593f34-d7a2-4cdd-b805-6da0d8ace9eb",
"request_id": "5a85c059-19c0-4129-a44f-79be9f8ea270"
}
After the response from the "target_url" the unsubscribe is called.
Hope this helps someone. I spent way to long on this.
When you are testing your Zap will be automatically put in "Off" mode. As I learned that any Zap that is "Off" will automatically "delete/unsubscribe" a subscribe. But when you turn the Zap to "On" the POST subscribe will be triggered again with a "target_url" that is usable.
From the Zapier documentation it looks like you are supposed to return a 201 to confirm receipt of the subscription. This may be needed to confirm registration on the remote server.
You can do this with:
http_response_code(201)
I realize this is assuming that you are working with PHP, but your development environment is unspecified. Does this apply?
I'm using Loopback and
I'm trying to user auth for graph api without javascript sdk or passport
I got the code successfully however I can't exchange it with access token
I followed this guide https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/#confirm
my get request is https://graph.facebook.com/v2.7/dialog/oauth?code={xxxx}&client_secret={xxxx}&client_id={xxx}&redirect_uri={myURL}
myURL is the one used to get the code but not be used again if I understand
If I understand correctly I should it the access_token in the body of the response instead I get this error
{
"error": {
"message": "Unknown path components: /oauth",
"type": "OAuthException",
"code": 2500,
"fbtrace_id": "HXe+214tGpW"
}
}
It looks like a bug in the docs. The first call is to www.facebook.com in a browser.
See here for an example client https://github.com/yschimke/oksocial/blob/master/src/main/java/com/baulsupp/oksocial/services/facebook/FacebookAuthFlow.java
The second should be to something like https://graph.facebook.com/v2.7/oauth/access_token
$response = $fb->sendRequest(
'GET',
'/oauth/access_token',
[
'client_id' => $config['client_id'],
'client_secret' => $config['client_secret'],
'grant_type' => 'fb_exchange_token',
'fb_exchange_token' => $short_token
],
$short_token,
null,
'v2.7');
By following the guide on https://developer.paypal.com/webapps/developer/docs/integration/web/accept-paypal-payment/ , I have successfully created a payment and redirect the user to approve it.
The created payment is something look like bellow, and I save it in user's session for further reference.
{
"id": "PAY-6RV70583SB702805EKEYSZ6Y",
"create_time": "2013-03-01T22:34:35Z",
"update_time": "2013-03-01T22:34:36Z",
"state": "created",
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"transactions": [
{
"amount": {
"total": "7.47",
"currency": "USD",
"details": {
"subtotal": "7.47"
}
},
"description": "This is the payment transaction description."
}
],
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-6RV70583SB702805EKEYSZ6Y",
"rel": "self",
"method": "GET"
},
{
"href": "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=EC-60U79048BN7719609",
"rel": "approval_url",
"method": "REDIRECT"
},
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-6RV70583SB702805EKEYSZ6Y/execute",
"rel": "execute",
"method": "POST"
}
]
}
After user approved the payment, Paypal will redirect the user to the return_url. For example, http://<return_url>?token=EC-60U79048BN7719609&PayerID=7E7MGXCWTTKK2.
In order to execute the payment, a POST request has to made to https://api.sandbox.paypal.com/v1/payments/payment/{payment_id}/execute/.
Question
The only two pieces of information provided from Paypal in the URL is token and PayerID. How can I find the corresponding payment_id?
Possible Solution
The token is part of the approval_url, parse the URL and store the token -> payment relationship can solve the problem. But I'm looking for a better solution that doesn't require parsing.
I think the paypal documentation isn't clear about this. But you can do something simple to resolve your problem passing de PaymentID through a parameter in your return url.
Like this:
return_url = 'http://www.yourdomain.com/paypal/success/?paymentID=PAY-1234567'
When the Paypal redirect to your site, then, it will return the paymentID together with the other parameters.
You would have to remember the Payment ID on your side (typically attached with your user session - shopping cart or order or as a session cookie) before redirecting the user to PayPal approval url. Once the is redirected back to your return Url along with the PayerID - you would need to extract the PaymentID from your user session and execute the Payment.
The Payment Id can be obtained in PHP by using the following method after the first API request has returned a successful response:
$payment->getId();
The online code sample (http://paypal.github.io/PayPal-PHP-SDK/sample/doc/payments/CreatePaymentUsingPayPal.html) shows how to send the request, however it does not include the getId() method.
To find this out I had to look in the downloaded SDK files at the file sample\payments\CreatePayment.php which has the following example code showing the use of this method:
ResultPrinter::printResult('Create Payment Using Credit Card', 'Payment', $payment->getId(), $request, $payment);
I found this link to be extremely helpful, in case anyone wants to check it out: https://github.com/paypal/PayPal-NET-SDK/issues/79
Since the v1/payments API has been deprecated for some time now, the best solution is to use the current v2/checkout/orders API for all new integrations. The order ID is returned in the URL.
However, redirects are an old integration method, for old websites. It is preferred to not use any redirects, at all, and keep your site loaded at ALL times. Instead use this approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server
paymentid:
After you created the payment, in return json, you can get paymentid.
like this: "id":"PAY-01K00482KX842131HKORKVKY"
payerid:
you can use API:GET /v1/payments/payment/{paymentId} to get payer id after user approved the payment,and you will find payerid in return json,like this:
{
"id":"PAY-01K00482KX842131HKORKVKY",
"create_time":"2014-06-19T09:17:31Z",
"update_time":"2014-06-19T09:17:31Z",
"state":"created",
"intent":"sale",
"payer":{
"payment_method":"paypal",
"payer_info":{
"email":"buyer#samsung.com",
"first_name":"buyer",
"last_name":"samsung",
"payer_id":"H2DKRTTYWW8HS",
"shipping_address":{ "line1":"Lushan Road Num.188", "line2":"JianYe",
"city":"Tucson",
"state":"AZ",
"postal_code":"85715",
"country_code":"US",
"recipientName":"buyer samsung"}}},
"transactions":[{
"amount":{
"total":"12.00",
"currency":"USD",
"details"{"subtotal":"12.00"}},
"description":"creating a payment"}],
"links":[
{"href":"xxxxxxx","rel":"self","method":"GET"},
{"href":"xxxxxxx","rel":"approval_url","method":"REDIRECT"},
{"href":"xxxxxxx","rel":"execute","method":"POST"}]}