Recurring Subscription issue woocommerce

SAIA-dev
New Community Member

Setting up automatic recurring subscriptions via Woocommerce and Paypal.

I am currently setting this up for a client and have run into some issues regarding the payment capture, I am currently testing through sandbox and have verified all keys are correct. I have went through a lot of support and documentation and cannot find a solution to this can you please advise? Is there anything i need to setup with the REST API on woocommerce in order for this to work as intended?

Woocommerce error: "Could not process order because it was not possible to save the payment. Order status changed from On hold to Failed."

 

Snippet from the debug log: "error":"invalid_client","error_description":"Client Authentication failed"

Response Body: {"name":"INVALID_RESOURCE_ID","message":"Resource id is invalid","debug_id":"558dce5b3c3df","information_link":"https://developer.paypal.com/docs/api/webhooks/#errors","details":[],"links":[]}

2022-03-08T08:53:19+00:00 DEBUG POST https://api.sandbox.paypal.com/v1/notifications/webhooks
Request Body: {"url":"https:\/\/scottishattachmentinaction.org\/wp-json\/paypal\/v1\/incoming","event_types":[{"name":"CHECKOUT.ORDER.APPROVED"},{"name":"CHECKOUT.ORDER.COMPLETED"},{"name":"PAYMENT.CAPTURE.REFUNDED"},{"name":"PAYMENT.CAPTURE.REVERSED"},{"name":"PAYMENT.ORDER.CANCELLED"},{"name":"PAYMENT.CAPTURE.DENIED"},{"name":"PAYMENT.CAPTURE.COMPLETED"}]}
Response Debug ID: cd355a623cea1
Response: Array
(
    [code] => 201
    [message] => Created
)


2022-03-08T08:53:19+00:00 INFO Webhooks subscribed.
2022-03-08T08:53:19+00:00 DEBUG POST https://api.sandbox.paypal.com/v1/oauth2/token?grant_type=client_credentials
Response Debug ID: a241018f9355d
Response: Array
(
    [code] => 401
    [message] => Unauthorized
)

Response Body: {"error":"invalid_client","error_description":"Client Authentication failed"}

2022-03-08T08:53:19+00:00 WARNING Could not create token.
2022-03-08T08:53:20+00:00 DEBUG POST https://api.sandbox.paypal.com/v1/oauth2/token?grant_type=client_credentials
Response Debug ID: cce91d2daa711
Response: Array
(
    [code] => 401
    [message] => Unauthorized
)

Response Body: {"error":"invalid_client","error_description":"Client Authentication failed"}

2022-03-08T08:53:20+00:00 WARNING Could not create token.
2022-03-08T08:54:44+00:00 DEBUG POST https://api.paypal.com/v1/oauth2/token?grant_type=client_credentials
Response Debug ID: be1ea6aa12a17
Response: Array
(
    [code] => 200
    [message] => OK

Thank you,
Darren

Login to Me Too
1 REPLY 1

MTS_Justin
Moderator
Moderator
Hello,

The issue seems to be related to authentication when generating an access token.

Response Body: {"error":"invalid_client","error_description":"Client Authentication failed"}

2022-03-08T08:53:19+00:00 WARNING Could not create token.
2022-03-08T08:53:20+00:00 DEBUG POST https://api.sandbox.paypal.com/v1/oauth2/token?grant_type=client_credentials

Check and confirm the "client_id" and "client_secret" being used where retrieved from a "sandbox" REST application and that the e-commerce solution payment module which you're using is set to "sandbox" or "test" mode.

A quick method of checking the validity of REST API credentials, is by conducting a cURL request for an access token.  Please note, you will need access to a host which has cURL installed to perform this request. (If you don't have the technical knowledge or access to a suitable host to perform this request, no problem.  I only provide it as an alternative to validate REST API credentials)

curl -k -v -X POST -H "Accept: application/json " -H "Accept-Language: en_US" -u "CLIENT_ID:CLIENT_SECRET" -d 'grant_type=client_credentials' https://api.sandbox.paypal.com/v1/oauth2/token

Replace "CLIENT_ID" and "CLIENT_SECRET" with your own SANDBOX REST application credentials.  Ensure to leave the colon ":" between the two values.  Copy the request and paste it into a terminal window on linux / mac or in windows (requires cURL to be installed). 

If the credentials are not valid, you'll receive an authentication error.  If they are valid, you'll receive a response which contains the "scopes" or "permissions" currently assigned to your REST application and an access token which allows you to perform other REST API calls.

Thanks !

Was my post helpful? If so, please give me a kudos!
Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.