gpt4 book ai didi

php - 访问 https ://api. sandbox.paypal.com/v1/payments/payouts?sync_mode=true 时得到 Http 响应代码 403

转载 作者:太空宇宙 更新时间:2023-11-03 16:15:47 25 4
gpt4 key购买 nike

当我尝试使用 paypal 执行付款时,出现此错误。我试图避免 sync_mode 等方法但没有帮助。请帮忙解决这个错误我的功能

$payouts = new Payout();
$senderBatchHeader = new PayoutSenderBatchHeader();
$senderBatchHeader->setSenderBatchId(uniqid())
->setEmailSubject("You have a Payout!");
$senderItem = new PayoutItem();
$senderItem->setRecipientType('Email')
->setNote('Thanks for your patronage!')
->setReceiver('paypalemail@gmail.com')
->setSenderItemId("2014031400023")
->setAmount(new Currency('{
"value":"1.0",
"currency":"USD"
}'));
$payouts->setSenderBatchHeader($senderBatchHeader)
->addItem($senderItem);
$request = clone $payouts;
$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
'client_id',
'client_secrete_id'
)
);
try {
$output = $payouts>createSynchronous($apiContext);
} catch (Exception $ex) {
return $ex;
}
return $output;

最佳答案

很高兴我找到了对我有用的答案!

将上面的代码改成,

$payouts = new \PayPal\Api\Payout();
$senderBatchHeader = new \PayPal\Api\PayoutSenderBatchHeader();
$senderBatchHeader->setSenderBatchId(uniqid().microtime(true))
->setEmailSubject("You have a payment");


$senderItem = new \PayPal\Api\PayoutItem();
$senderItem->setRecipientType('Email')
->setNote('Thanks you.')
->setReceiver('paypal_email@gmail.com')
->setSenderItemId("item_1" . uniqid().microtime('true'))
->setAmount(new \PayPal\Api\Currency('{
"value":"1.0",
"currency":"USD"
}'));
$payouts->setSenderBatchHeader($senderBatchHeader)->addItem($senderItem);
$request = clone $payouts;
$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
$paypal->client_id,
$paypal->client_secrete
)
);
try {
$output = $payouts->create(null, $apiContext);
} catch (Exception $ex) {
Flash::error(trans('payout.payout_error'));
return redirect()->back();
}
Flash::success(trans('payout.payout_success'));
return redirect()->back();

关于php - 访问 https ://api. sandbox.paypal.com/v1/payments/payouts?sync_mode=true 时得到 Http 响应代码 403,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54491115/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com