问题
Trying to take my paypal REST api site live. It works well in sandbox mode, with verified transfers.
When I switch my sandbox for live client ID and secret, I get the error
{"error":"invalid_client","error_description":"Client Authentication failed"}
I checked and made sure that my code should go live
$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
PP_CLIENT_ID , // ClientID
PP_CLIENT_SECRET // ClientSecret
)
);
// setting mode to live
// https://github.com/paypal/PayPal-PHP-SDK/wiki/Going-Live
$apiContext->setConfig([
'mode' => 'live',
]);
running this via wp_ajax
Any help would be appreciated! Thanks!
2/5/2019: Seems other people got this problem: https://github.com/paypal/PayPal-PHP-SDK/issues/435
Also the same question on StackOverflow that I missed ... that also had no answer. PayPal App works perfectly as Sandbox, Client Authentication failed on Live: list of steps to check?
回答1:
https://developer.paypal.com/docs/api/overview/#api-requests
when using live credentials the url should be https://api.paypal.com instead https://api.sandbox.paypal.com
reference https://github.com/paypal/PayPal-PHP-SDK/issues/435#issuecomment-462133355
回答2:
Try to change
return new SandboxEnvironment($clientId, $clientSecret);
to
return new ProductionEnvironment($clientId, $clientSecret);
in your PayPalClient.php class
来源:https://stackoverflow.com/questions/54511617/paypal-client-authentication-failed