贝宝(Paypal)将我接受的付款退还给我

时间:2018-09-24 05:52:42

标签: paypal-rest-sdk

你好吗?

问题是API Paypal创建了付款,我尝试用我的信用卡“应拒绝”付款,但接受付款!当我到达贝宝(Paypal)时,我没有看到购买的金额,但是最糟糕的是我成功退还了付款!

我不明白,我按照教程创建了API调用,但是没有用!

require __DIR__  . '/vendor/autoload.php';

$ apiContext = new \ PayPal \ Rest \ ApiContext(         新\ PayPal \ Auth \ OAuthTokenCredential(             'keyID',//客户ID             'keySecret'// ClientSecret         )   );

$ apiContext-> setConfig(       数组(         '模式'=>'实时'       )   );

$payer = new \PayPal\Api\Payer();
$payer->setPaymentMethod('paypal');

$amount = new \PayPal\Api\Amount();
$amount->setTotal($prix);
$amount->setCurrency('EUR');

$transaction = new \PayPal\Api\Transaction();
$transaction->setAmount($amount);

$redirectUrls = new \PayPal\Api\RedirectUrls();
$redirectUrls->setReturnUrl("https://xx.fr/accepted.php")
    ->setCancelUrl("https://xx.fr/failure.php");

$payment = new \PayPal\Api\Payment();
$payment->setIntent('sale')
    ->setPayer($payer)
    ->setTransactions(array($transaction))
    ->setRedirectUrls($redirectUrls);

try {
$payment->create($apiContext);

echo $payment;


$json = json_decode($payment);

$id_0 = $json->id;  

$req = $bdd->prepare("INSERT INTO paypal_verif (id_pay, email, offre) VALUES (?, ?, ?) ");
$req->execute(array($id_0, $_SESSION['email'], $_GET['offre']));

header("location:".$payment->getApprovalLink()." ");
}
catch (\PayPal\Exception\PayPalConnectionException $ex) {
    // header("location:boutique.php");
}

enter image description here

感谢您的帮助!

0 个答案:

没有答案