Paypal SDK 支付 - 无法捕获异常并接收 http 400
Paypal SDK Payouts - cannot catch Exception and Receive http 400
您好,我目前正在尝试执行以下操作:有人通过贝宝付款 - 之后第三人应该会在他们的贝宝帐户中收到大约 50% 的价格。所以我总是想遵循以下步骤:A 支付 10 欧元,我收到 10 欧元,我向 C 支付 5 欧元。
第一部分在 php 中通过 paypal sdk 工作,第二部分(目前无法正常转账给其他人...)
这是我的代码
$payouts = new \PayPal\Api\Payout();
$senderBatchHeader = new \PayPal\Api\PayoutSenderBatchHeader();
$senderBatchHeader->setSenderBatchId(uniqid())
->setEmailSubject("Test.");
$senderItem1 = new \PayPal\Api\PayoutItem();
$senderItem1->setRecipientType('Email')
->setNote('Test.')
->setReceiver('test@paypalsandbox.de')
->setSenderItemId('test ' . uniqid())
->setAmount(new \PayPal\Api\Currency('{
"value": "5.00",
"currency":"EUR"
}'));
$payouts->setSenderBatchHeader($senderBatchHeader)
->addItem($senderItem1);
// For Sample Purposes Only.
$request = clone $payouts;
// ### Create Payout
try {
$output = $payouts->createSynchronous($this->_api_context);
} catch (PayPapl\Exception\PayPalConnectionException $ex) {
//todo add exception handler
dd('test');
ResultPrinter::printError("Created Batch Payout", "Payout", null, $request, $ex);
exit(1);
}
dd('test');
我无法以某种方式捕获错误。它说
PayPalHttpConnection.php 第 174 行中的 PayPalConnectionException:
访问 https://api.sandbox.paypal.com/v1/payments/payouts?sync_mode=true.
时得到 Http 响应代码 400
我正在使用 laravel 5.1
实现这个
有什么想法吗?
根据您的业务模型,REST API 不是一个好的选择。
Paypal 有自适应支付 API 可以让你在许多不同的场景下汇款,从简单到 complex.So 在你的情况下,你可以参考 chained payment, the sender pays the primary receiver an amount, from which the primary receiver pays secondary receivers. The sender only knows about the primary receiver, not the secondary receivers. The secondary receivers only know about the primary receiver, not the sender. Adaptive payment demo download.
在您的 paypal 错误信息前加一个“\”。为我工作。它是一个名称空间冲突。
try {
$output = $payouts->createSynchronous($this->_api_context);
} catch (\PayPal\Exception\PayPalConnectionException $ex) {
//todo add exception handler
dd('test');
ResultPrinter::printError("Created Batch Payout", "Payout", null, $request, $ex);
exit(1);
}catch (\Exception $e){
dd($e->getMessage( );
}
See this post
您好,我目前正在尝试执行以下操作:有人通过贝宝付款 - 之后第三人应该会在他们的贝宝帐户中收到大约 50% 的价格。所以我总是想遵循以下步骤:A 支付 10 欧元,我收到 10 欧元,我向 C 支付 5 欧元。
第一部分在 php 中通过 paypal sdk 工作,第二部分(目前无法正常转账给其他人...)
这是我的代码
$payouts = new \PayPal\Api\Payout();
$senderBatchHeader = new \PayPal\Api\PayoutSenderBatchHeader();
$senderBatchHeader->setSenderBatchId(uniqid())
->setEmailSubject("Test.");
$senderItem1 = new \PayPal\Api\PayoutItem();
$senderItem1->setRecipientType('Email')
->setNote('Test.')
->setReceiver('test@paypalsandbox.de')
->setSenderItemId('test ' . uniqid())
->setAmount(new \PayPal\Api\Currency('{
"value": "5.00",
"currency":"EUR"
}'));
$payouts->setSenderBatchHeader($senderBatchHeader)
->addItem($senderItem1);
// For Sample Purposes Only.
$request = clone $payouts;
// ### Create Payout
try {
$output = $payouts->createSynchronous($this->_api_context);
} catch (PayPapl\Exception\PayPalConnectionException $ex) {
//todo add exception handler
dd('test');
ResultPrinter::printError("Created Batch Payout", "Payout", null, $request, $ex);
exit(1);
}
dd('test');
我无法以某种方式捕获错误。它说
PayPalHttpConnection.php 第 174 行中的 PayPalConnectionException: 访问 https://api.sandbox.paypal.com/v1/payments/payouts?sync_mode=true.
时得到 Http 响应代码 400我正在使用 laravel 5.1
实现这个有什么想法吗?
根据您的业务模型,REST API 不是一个好的选择。 Paypal 有自适应支付 API 可以让你在许多不同的场景下汇款,从简单到 complex.So 在你的情况下,你可以参考 chained payment, the sender pays the primary receiver an amount, from which the primary receiver pays secondary receivers. The sender only knows about the primary receiver, not the secondary receivers. The secondary receivers only know about the primary receiver, not the sender. Adaptive payment demo download.
在您的 paypal 错误信息前加一个“\”。为我工作。它是一个名称空间冲突。
try {
$output = $payouts->createSynchronous($this->_api_context);
} catch (\PayPal\Exception\PayPalConnectionException $ex) {
//todo add exception handler
dd('test');
ResultPrinter::printError("Created Batch Payout", "Payout", null, $request, $ex);
exit(1);
}catch (\Exception $e){
dd($e->getMessage( );
}
See this post