I am using PayPal rest api payment gateway method for payment, when I was using demo details this is working fine but when I used the live details it is returning error, Like 'We aren't able to process your payment using your PayPal account at this time. Please go back to the merchant and try using a different payment method.'
some time I also got the message of invalid details,
{"error":"invalid_client","error_description":"Client Authentication failed"}
I am using 'REST API SDK for PHP' got from the GitHub.
I have updated all the necessary information in the developer PayPal for live mode, but still getting issue.
This is my code what I tried
require __DIR__ . '/vendor/autoload.php';
$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
// ClientID
// ClientSecret
)
);
$apiContext->setConfig(
array(
'log.LogEnabled' => true,
'log.FileName' => 'PayPal.log',
'log.LogLevel' => 'FINE',
'mode' => 'live',
)
);
$payer = new \PayPal\Api\Payer();
$payer->setPaymentMethod('paypal');
$amount = new \PayPal\Api\Amount();
$amount->setTotal($_SESSION['partner_payment'][1]);
$amount->setCurrency('USD');
$transaction = new \PayPal\Api\Transaction();
$transaction->setAmount($amount);
$redirectUrls = new \PayPal\Api\RedirectUrls();
$redirectUrls->setReturnUrl("https://mydomain/paypal/success.php")
->setCancelUrl("https://mydomain/paypal/cancel.php");
$payment = new \PayPal\Api\Payment();
$payment->setIntent('sale')
->setPayer($payer)
->setTransactions(array($transaction))
->setRedirectUrls($redirectUrls);
try {
$payment->create($apiContext);
//echo $payment;
//echo "
Redirect user to approval_url: " . $payment-
>getApprovalLink() . "
";
header("Location:".$payment->getApprovalLink());
}
catch (\PayPal\Exception\PayPalConnectionException $ex) {
echo $ex->getData();
}
----Output:----
We aren't able to process your payment using your PayPal account at this time. Please go back to the merchant and try using a different payment method.