我已经使用他们的文档创建了单批付款。这样我就可以汇款给卖家。
但我不知道之后我应该做什么。如何显示付款表格,用户可以在其中登录 PayPal 并支付金额?
这是我在控制器功能中的代码
public function payViaPaypal(){
$payouts = new \PayPal\Api\Payout();
$senderBatchHeader = new \PayPal\Api\PayoutSenderBatchHeader();
$senderBatchHeader->setSenderBatchId(uniqid('invoice-1qaqw23wdwdwew').microtime('true'))
->setEmailSubject("You have a Payout!");
$senderItem = new \PayPal\Api\PayoutItem();
$senderItem->setRecipientType('Email')
->setNote('Thanks for your patronage!')
->setReceiver('sb-cwdzv2614448@business.example.com')
->setSenderItemId(uniqid().microtime('true'))
->setAmount(new \PayPal\Api\Currency('{
"value":"1.0",
"currency":"USD"
}'));
$payouts->setSenderBatchHeader($senderBatchHeader)
->addItem($senderItem);
$request = clone $payouts;
$redirect_url = null;
try {
$output = $payouts->create(null, $this->api_context);
} catch (\Exception $e) {
dd('here',$this->errorDetails($e));
}
// dd("Created Single Synchronous Payout", "Payout", $output->getBatchHeader()->getPayoutBatchId(), $request, $output);
$redirect_url = null;
foreach($output->getLinks() as $link) {
if($link->getRel() == 'self') {
$redirect_url = $link->getHref();
break;
}
}
return $output;
}
当我点击路由访问此代码时,我收到此 json 响应。
{ "batch_header": { "payout_batch_id": "79CTFV2X5TS58", "batch_status": "PENDING", "sender_batch_header": { "sender_batch_id": "invoice-1qaqw23wdwdwew5f0f5003612091594839043.3978", "email_subject": "You have a Payout!" } }, "links": [ { "href": "https://api.sandbox.paypal.com/v1/payments/payouts/79CTFV2X5TS58", "rel": "self", "method": "GET", "enctype": "application/json" } ] }
我希望用户将被带到 PayPal 付款页面,用户将在该页面登录并支付金额,然后 PayPal 会通知我有关付款的信息。
但我试图通过互联网找到解决方案,但我找不到示例/解决方案。
守着一只汪
互换的青春