php - Paypal 集成中的未知错误

标签 php paypal

我正在尝试将 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/

相关文章:

paypal - paypal 10544 网关拒绝错误的原因

android - 我想使用 Paypal 给用户钱

php - 从 HTML 表单中发布任意数量的记录

php - 对于包含的 HTML 代码片段文件,哪种命名约定是正确的?

javascript - 使用 javascript 警报框在 php 中连接字符串

php - 当页面加载 php 错误时,与服务器的连接被重置

php - 如何解决 Paypal 保险库信用卡扣费失败的问题

java - Paypal 与 java 集成

未调用 PayPal 快速结帐即时更新回调 [沙盒]

PHP 脚本在 Internet Explorer 和 Firefox 中不起作用