gpt4 book ai didi

php - Paypal 集成中的未知错误

转载 作者:太空宇宙 更新时间:2023-11-03 16:00:09 24 4
gpt4 key购买 nike

我正在尝试将 Paypal 集成到我的网站中,但过程很困惑。

该文档似乎与他们的 PHP SDK 不匹配,因此很麻烦,请建议适当的集成方法。

我试过的代码如下:

<?php
ini_set('max_execution_time', 300);
require __DIR__ . '/bootstrap.php';
// 3. Lets try to save a credit card to Vault using Vault API mentioned here
// https://developer.paypal.com/webapps/developer/docs/api/#store-a-credit-card
$apiContext->setConfig(
array(
'log.LogEnabled' => true,
'log.FileName' => 'PayPal.log',
'log.LogLevel' => 'DEBUG'
)
);
$creditCard = new \PayPal\Api\CreditCard();
$creditCard->setType("visa")
->setNumber("403*************")
->setExpireMonth("09")
->setExpireYear("2020")
->setCvv2("123")
->setFirstName("J***")
->setLastName("M*****");
$fi = new \PayPal\Api\FundingInstrument();
$fi->setCreditcard($creditCard);
$payer = new \PayPal\Api\Payer();
$payer->setPaymentmethod('credit_card');
$payer->setFundinginstruments(array($fi));
$amount = new \PayPal\Api\Amount();
$amount->setCurrency('USD');
$amount->setTotal('7.47');
$transaction = new \PayPal\Api\Transaction();
$transaction->setAmount($amount);
$transaction->setDescription('This is the payment transaction description.');
$payment = new \PayPal\Api\Payment();
$payment->setIntent('sale');
$payment->setPayer($payer);
$payment->setTransactions(array($transaction));
// 4. Make a Create Call and Print the Card
try {
//$creditCard->create($apiContext);
//$creditCard->create($apiContext);
$payment->create($apiContext);
echo $payment;
}catch (\PayPal\Exception\PayPalConnectionException $ex) {
// This will print the detailed information on the exception.
//REALLY HELPFUL FOR DEBUGGING
echo $ex->getData();
}
?>

最佳答案

如果您使用保险柜,您需要获得批准才能接受直接信用卡。您需要确保您为 Rest API 和 Vault 提交的申请已获得直接信用卡的完全批准。

来自 PayPal 开发者网站:

Store and use a customer credit card
Direct credit card payment and related features are restricted in some countries.

Vault Information

以下是有关上线您的应用程序的更多信息:
Apps 101

以下是说明:

  1. 在 developer.paypal.com 上登录您的开发者帐户
  2. 点击我的帐户
  3. 向下滚动到直接信用卡
  4. 点击启用
  5. 点击继续
  6. 填写要求的信息

Visual Representation

关于php - Paypal 集成中的未知错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32289121/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com