PayPal payments were created but were never executed

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



PayPal payments were created but were never executed



I am using paypal-rest-sdk@1.8.1 for Node.js. I have created the payments and saved their payerId, token and paymentId, but I never executed those payments.


var paypal = require('paypal-rest-sdk');
paypal.configure(
'mode': 'live',
'client_id': '_CLIENT_ID_',
'client_secret': '_CLIENT_SECRET_'
);
.
.
let payment =
"intent": "sale",
"transactions": [
"item_list":
"items": some_items_array,
"shipping_address":
"recipient_name": "some_recipient_name",
"line1": "Fake street",
"city": "Fake city",
"country_code": "Fake country",
"postal_code": "123456",
"state": "Fake state",
"phone": "0000000"



,
"amount":
"currency": "AUD",
"total": "15",
"details":
"subtotal":"15",
"tax": "0",
"shipping": "0",
"handling_fee": "0",
"shipping_discount": "0",
"insurance": "0"



],
"redirect_urls":
"cancel_url": some_base_url + "/home/cart",
"return_url": some_base_url + "/home/thank-you?cartid=" + cartid
,
"payer":
"payment_method": "paypal",
"payer_info":
"email": "fake_email@gmail.com"


;
paypal.payment.create(payment, function (error, response)
if (error)
console.log(error);
// HANDLE ERROR
else
console.log("Create Payment Response");
console.log(response);
//SEND SUCCESS RESPONSE

);



After successful execution of the above lines, the users are redirected to the PayPal website to make their payment. After the successful payment, it redirects them to the 'return_url' link with payload of information, which is:



paymentId:'PAY-000000',
PayerID:'SOME_PAYER_ID',
token:'SOME_TOKEN'



For many days I have been only saving paymentId, PayerID, & token in the database and NOT BEEN EXECUTING THE PAYMENT, thinking that was not required when 'intent' is set to 'sale'.



Now I have added the following code to execute the payment, which works fine for the orders which are being placed now.


var execute_payment_json =
"payer_id": 'THE_PAYER_ID',
"transactions": [
"amount":
"currency": 'AUD',
"total": '15'

]
;
paypal.payment.execute(paymentId, execute_payment_json, function (error, payment)
if (error)
console.log(JSON.stringify(error.response));
//HANDLE ERROR
else
console.log("Get Payment Response");
console.log(JSON.stringify(payment));
//SEND SUCCESS

);



For the older orders for which payment.execute was not done after the the successful redirection, I tried to do 'payment.execute' on them and got the following error.



"name":"INVALID_RESOURCE_ID",
"message":"The requested resource ID was not found",
"information_link":"https://developer.paypal.com/docs/api/payments/#errors",
"debug_id":"878378979aac7",
"httpStatusCode":404



Please help me if I can execute those old payments. I have their payerId, paymentId, and token.





Unfortunately we are not able to check whether the paymentId, payerId, and token are valid or not. Try to ask Paypal support team. Here's a similar problem: github.com/paypal/PayPal-PHP-SDK/issues/980, looks like they can explain why you got the error if you provide the debug_id.
– ekad
Aug 10 at 13:12


debug_id




1 Answer
1



It looks like you're doing what used to be called Express Checkout and forgot to perform the final callback.



What likely happened is your tokens expired. While this is from the docs for the legacy system, I have no reason to believe this doesn't apply here.



A timestamped token that indicates Express Checkout processing for the current payment. This token is typically returned in the SetExpressCheckout response, but if you are calling SetExpressCheckout a second time, using the Express Checkout second redirect flow, you can pass the same token back to SetExpressCheckout as a request parameter. PayPal also appends this token as a GET parameter named token to your RETURN URL when redirecting the buyer back to your website from paypal.com. By default, the token expires after three hours.



Even if that's not entirely true for REST, the same principle holds



To my knowledge that entire transaction is now dead. You would have to start a new one to get a payment now.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard