dongyi3616 2019-06-03 10:30
浏览 327

PayPal支付网关与REST Api问题中的实时凭证集成

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line