How to correctly authorise paypal credit card payment in RESTful integration?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am doing RESTful integration of PayPal in C#
I am trying to create a payment with `credit card` as a `payment_method`.
So far I have the angular config and am successfully creating and get authorization response with state "authorized" in my api `Create` method:
createdPayment = payment.Create(apiContext); return createdPayment;
and then:
Authorization authorization = payment.transactions[0].related_resources[0].authorization;
the `authorization` state is authorized.
but I'm getting the response in console:
ppxo_no_token_passed_to_payment Object { timestamp: 1531389390897, windowID: "8b6e6d498f", pageID: "60540ae7ab", prev_corr_ids: "", referer: "localhost:63109", host: "localhost:63109", path: "/order", env: "production", country: "US", lang: "en", … }
(btw not sure it says `env: production` if I'm using the sandbox?)
and:
No value passed to payment
And when I click the confirmation link from payment object (which is eg. https://api.sandbox.paypal.com/v1/payments/payment/PAY-6RD0371739881292ULNDSPRA) I'm getting json:
name "AUTHENTICATION_FAILURE" message "Authentication failed due to invalid authentication credentials or a missing Authorization header." links 0 href "https://developer.paypal.com/docs/api/overview/#error" rel "information_link"
So the payment effectively failed.
I went to the provided ref link: https://developer.paypal.com/docs/api/overview/#error and found out that Access token-related issues often cause authentication errors but I'm getting a Bearer token after successfully creating the payment.
The question is what I'm supposed to do with the Bearer token if anything? what to return in my `payment` method in button config? what to pass to config's `onAuthorize` method if anything? And how to authorise the payment successfully?
I tried to look for solution through paypal api and didn't find anything to answer my question so far.
My angular config:
paypalConfig = { env: 'sandbox', client: { sandbox: 'my sandbox key' }, commit: true, payment: (data: any, actions: any) => { // 2. Make a request to your server var url = '/paypal/create/'; return actions.request.post(url) .then(function (res: any) { // What HERE? return res.id; // if I return payment id then I get redirected to paypal.com where it obviously says the transation is invalid because I'm doing the process in sandbox not live env }); }, onAuthorize: (data: any, actions: any) => { // WHAT HERE?? // normally I'd do a request to paypal with paymentid and payerid (https://developer.paypal.com/docs/checkout/how-to/server-integration/#1-set-up-your-client-to-call-your-server) but in case of credit_card payment I don't get those } };
My `Create` method is based on the `CreatePayment` provided here - the only difference is that I use `payment_method = "credit_card"` (instead of paypal) and I return `Payment` object back to angular instead of redirecting to approval url.
Btw `onAuthorize` method is required by button config. Normally with paypal funds I would send `paymentId` and `payerId` back to paypal for authorising the payment but in case of credit card method I get the payment already authorised within `payment` function. The only problem is it fails.

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- How to enable on-demand / recurring payments to existing PayPal checkout? in SDKs
- I keep getting the error: “Unfortunately, a system error has occurred" in NVP/SOAP APIs
- PayPal Redirection Issue After Successful Payment in Photobooth Integration in Sandbox Environment
- EDD in PayPal Payments Standard
- PayPal integration with Next, Lambda and API Gateway - 400 Invalid Request in Sandbox Environment