Reputation: 4571
Suppose we have PayPal sandbox account, with created Application for REST API calls.
In our application we use PayPal Pay Buttons, to redirect customer to PayPal site. Customer pays and returning back to site, where we checking status and setting external reference to transaction.
For this operations we're using not Application's credentials, but accounts - email, password and username. After this we're accepting IPN messages from PayPal to track status, using the same credentials.
Then we have a button Refund, pressing this button will make a request to REST API to PayPal with Application's access information (clientId and clientSecret). This part built on top of PayPal PHP SDK.
When I try to execute a call - PayPal returning 404 error. I suppose the payment is not visible to Application.
Better vision of what credentials and where are used:
PayPal account:
For button I use: email-test, username-test, password-test
Then I get $transactionId
. And using it in code:
$api = new ApiContext(new OAuthTokenCredential($clientIdTest, $clientSecretTest));
$ppAmount = new Amount();
$ppAmount->setCurrency('USD')
->setTotal(33.15);
$ppRefund = new Refund();
$ppRefund->setAmount($ppAmount);
$ppSale = new Sale();
$ppSale->setId($transactionId);
$ppSale->refund($ppRefund, $apiContenxt);
And I get 404. As you can see I use test credentials for buttons and for REST call, but for some reason getting 404.
Thanks in advance.
Upvotes: 0
Views: 241
Reputation: 620
As far as I know only payments made via REST API can be refunded using the REST API, meaning if you created the payment via a button or a different API you cannot use REST refund.
REST refund expects a sale_id (which is generated when you "execute" a REST payment) in the Sale entity.
Upvotes: 1