paypal plus,上线

时间:2016-04-27 09:05:37

标签: php paypal paypal-sandbox

我已根据本教程https://www.paypalobjects.com/webstatic/de_DE/downloads/PayPal-PLUS-IntegrationGuide.pdf

在我的网站上整合了paypal plus

sandbox模式下一切正常,但是当我尝试转到live时,我在显示付款墙时出现错误Forbidden。在萤火虫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标题回复

Paypal-Debug-Id:    bfd9325f785dd, bfd9325f785dd

我们的客户告诉我们,他与paypal取得联系,并激活了paypal plus的帐户。也许我们在代码中有一些错误?或者也许我们试图在一个限制PayPal的国家/地区进行此操作?

更新

我使用实时凭据。在www.paypal.com/paymentwall/payment-selection的请求中,有User-Agent标题 -

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

1 个答案:

答案 0 :(得分:-3)

更改您的代码:

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

要:

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

注意:生活后&#39;没有COMMA