gpt4 book ai didi

php - paypal plus,上线

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

我已经根据本教程在我的网站上集成了 paypal plus https://www.paypalobjects.com/webstatic/de_DE/downloads/PayPal-PLUS-IntegrationGuide.pdf

沙箱模式下一切正常,但是当我尝试进入live时,我在显示时遇到错误Forbidden支付墙。在 Firebug 中 NetworkError: 403 Forbidden - https://www.paypal.com/paymentwall/payment-selection。看起来像这样http://joxi.ru/VrwVoeMIKDg5QA

我的 php 代码获取 approval url

$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
Yii::app()->params['paypal']['ClientID'], // ClientID
Yii::app()->params['paypal']['ClientSecret'] // ClientSecret
)
);

$apiContext->setConfig(
array(
'mode' => 'live',
)
);

$item1 = new \PayPal\Api\Item();
$item1->setName('Test item')
->setCurrency('USD')
->setQuantity(1)
->setPrice(1);

$itemList = new \PayPal\Api\ItemList();
$itemList->setItems(array($item1));

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

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

$transaction = new \PayPal\Api\Transaction();
$transaction->setAmount($amount);
$transaction->setItemList($itemList);
$transaction->setInvoiceNumber(uniqid());
$transaction->setDescription('Payment for fashion.com');

$host = 'http' . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . $_SERVER['HTTP_HOST'];

$redirectUrl = new \PayPal\Api\RedirectUrls();
$redirectUrl->setReturnUrl($host . '/shop/pay');
$redirectUrl->setCancelUrl($host . '/shop/pay');

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

$payment = $payment->create($apiContext);

$approvalUrl = $payment->getApprovalLink();

然后我在js

中使用它
    <script type="application/javascript" src="https://www.paypalobjects.com/webstatic/ppplus/ppplus.min.js"></script>
<script>
PAYPAL.apps.PPP({
"approvalUrl": "<?=$approvalUrl?>",
"placeholder": "ppplus",
"mode": "live",
"country": "DE",
"buttonLocation": "outside",
"disableContinue": "continueButton",
"enableContinue": "continueButton",
"showLoadingIndicator": true,
onContinue: function () {
}
});
</script>
<div id="ppplus"></div>

响应中的 Paypal header

Paypal-Debug-Id:    bfd9325f785dd, bfd9325f785dd

我们的客户告诉我们,他与 paypal 取得了联系并激活了他的 paypal plus 帐户。也许我们在输出代码中有一些错误?或者,也许我们正试图在一个限制使用 paypal 的国家这样做?

更新

我使用实时凭证。并且在请求 www.paypal.com/paymentwall/payment-selection 时有 User-Agent header -

User-Agent  
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0

我正在使用标准的 paypal api https://github.com/paypal/PayPal-PHP-SDK

最佳答案

更改您的代码:

$apiContext->setConfig(
array(
'mode' => 'live',
)
);

收件人:

$apiContext->setConfig(
array(
'mode' => 'live'
)
);

注意:'live'后没有逗号

关于php - paypal plus,上线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36885173/

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