收到类似批量付款的响应,但是我已经完成了一次同步付款,甚至无法看到成功,反而一直面临PENDING batch_status

时间:2019-05-09 07:53:09

标签: php laravel paypal payout

  1. 我正在使用PAYPAL-PHP-SDK并使用php版本在macOS上工作 7.1.4和laravel 5.6。*版。
  2. 我已经实现了由提供的单笔付款功能 贝宝,但得到批量付款的响应。(使用沙箱帐户)
  

我还注意到,我从商家帐户中转出了1美元,   成功转移到买方帐户,但是我得到了   BATCH_STATUS:“ PENDING”也没有得到响应,因为显示的贝宝   (同步)创建单一付款

我尝试将所有代码从https://paypal.github.io/PayPal-PHP-SDK/sample/doc/payouts/CreateSinglePayout.html复制并粘贴到我的程序中,并进行一些与电子邮件地址相关的更改,并更改了bootstrap.php文件中的客户端密钥和秘密密钥,但是它显示了类似BATCH PAYOUT的响应。我注意到另一件事,批量支付和单次支付在代码上没有区别。我也看到了https://github.com/paypal/PayPal-node-SDK/issues/264,但是即使在资金成功转入买方帐户后,我仍处于批处理状态PENDING。

我也尝试将同步模式从true更改为false,因为现在已弃用,但响应却相同。

这是我在laravel控制器中完成的代码

require 'bootstrap.php';
    // Create a new instance of Payout object
    $payouts = new \PayPal\Api\Payout();
$senderBatchHeader = new \PayPal\Api\PayoutSenderBatchHeader();

// #### Batch Header Instance
$senderBatchHeader->setSenderBatchId(uniqid())
    ->setEmailSubject("You have a Payout!");

// #### Sender Item
// Please note that if you are using single payout with sync mode, you can only pass one Item in the request
$senderItem = new \PayPal\Api\PayoutItem();
$senderItem->setRecipientType('Email')
    ->setNote('Thanks for your patronage!')
    ->setReceiver('email@address.com')
    ->setSenderItemId("2014031400023")
    ->setAmount(new \PayPal\Api\Currency({
                        "value":"0.5",
                        "currency":"USD"
                    }));

$payouts->setSenderBatchHeader($senderBatchHeader)
    ->addItem($senderItem);


// For Sample Purposes Only.
$request = clone $payouts;

// ### Create Payout
try {
    // $output = $payouts->createSynchronous($this->_api_context);
    $output = $payouts->createSynchronous($apiContext);
} catch (Exception $ex) {
    ResultPrinter::printError("Created Single Synchronous Payout", "Payout", null, $request, $ex);
    exit(1);
}

 // ResultPrinter::printResult("Created Single Synchronous Payout", "Payout", $output->getBatchHeader()->getPayoutBatchId(), $request, $output);
return $output;

我的预期结果是这样的

{
batch_header: {
payout_batch_id: "3975UQGFRGFPQ",
batch_status: "SUCCESS",
sender_batch_header: {
sender_batch_id: "5cd3cfdb8ca8f",
email_subject: "You have a Payout!"
}
},
items: {}
links: [
{
href: "https://api.sandbox.paypal.com/v1/payments/payouts/3975UQGFRGFPQ",
rel: "self",
method: "GET",
enctype: "application/json"
}
]
}

我的实际结果是

  

{       batch_header:{       payout_batch_id:“ 3975UQGFRGFPQ”,       batch_status:“待处理”,       sender_batch_header:{       sender_batch_id:“ 5cd3cfdb8ca8f”,       email_subject:“您有付款!”       }},链接:[{       href:“ https://api.sandbox.paypal.com/v1/payments/payouts/3975UQGFRGFPQ”,       rel:“自我”,       方法:“ GET”,       编码:“ application / json”}]}

0 个答案:

没有答案