Getting below error while executing payment of paypal:
{"name":"INTERNAL_SERVICE_ERROR","message":"An internal service error
has
occurred","information_link":"https://developer.paypal.com/docs/api/payments/#errors","debug_id":"a997a9f72d8f6"}
Here is the code for payment execution:
var apiContext = PaypalConfiguration.GetAPIContext();
var paymentExecution = new PaymentExecution() { payer_id = payerId };
var payment = new Payment() { id = paymentId };
// Execute authorization.
var executedPayment = payment.Execute(apiContext, paymentExecution);// Execute the payment
if (executedPayment.state.ToLower() == "approved")
{
var auth = payment.transactions[0].related_resources[0].authorization;
var capture = new Capture()
{
amount = amount,
is_final_capture = true
};
var responseCapture = auth.Capture(apiContext, capture);
return responseCapture;
}
2
Answers
This is an internal error from Paypal.
I would submit a ticket with the debug_id to https://www.paypal-techsupport.com/app/home
Below are some links with the same error. Maybe it will help point you in the right direction.
https://www.paypal-community.com/t5/REST-APIs/INTERNAL-SERVICE-ERROR-REST-v1-payments-payment/td-p/1480048#
PayPal REST Sandbox API giving INTERNAL_SERVICE_ERROR
While there are many possible reasons for an INTERNAL_SERVICE_ERROR, some of them transient, in this case and at this moment it’s probably the sandbox bug causing sandbox account emails to be unconfirmed.
Confirm the email via:
Separately from the above, it appears you are integrating a deprecated v1 payments API. You should be using the v2/checkout/orders API, documented here: https://developer.paypal.com/docs/checkout/reference/server-integration/
You want the step ‘Set Up Transaction’ and ‘Capture Transaction’. An intervening authorization step (before the capture) with intent:authorize is optional, only do this if you have very specific and well-defined business needs for that extra step.
The best front-end UI to use for customer approval is: https://developer.paypal.com/demo/checkout-v4/#/pattern/server , as it uses no redirects and keeps your site loaded in the background. This provides the most modern, "in context" experience.