gpt4 book ai didi

php - Paypal 支付执行

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

我正在使用信用卡创建一个 PayPal 应用程序。它正在成功创建付款,状态为已批准。

$addr = new Address();
$addr->setLine1($street);
$addr->setCity($city);
$addr->setPostalCode(zip);
$addr->setState($state);
$addr->setCountryCode($code);

$card = new CreditCard();
$card->setNumber($number);
$card->setType($type);
$card->setExpireMonth($m);
$card->setExpireYear($y);
$card->setCvv2($cvv);
$card->setFirstName($fname);
$card->setLastName($lname);
$card->setBillingAddress($addr);

$fi = new FundingInstrument();
$fi->setCreditCard($card);

$payer = new Payer();
$payer->setPaymentMethod('credit_card');
$payer->setFundingInstruments(array($fi));

$amountDetails = new Details();
$amountDetails->setSubtotal('100');
$amountDetails->setTax('10');
$amountDetails->setShipping('10');

$amount = new Amount();
$amount->setCurrency('JPY');
$amount->setTotal('120');
$amount->setDetails($amountDetails);

$transaction = new Transaction();
$transaction->setAmount($amount);
$transaction->setDescription('This is the payment transaction description.');

$payment = new Payments();
$payment->setIntent('sale');
$payment->setPayer($payer);
$payment->setTransactions(array($transaction));

$payment->create($this->_api_context);

现在我正在尝试执行此付款以完成交易,但我无法找到付款人 ID。这个付款人 ID 是什么,我从哪里得到它?

$payer_id = ?;
$paymentExecution = new PaymentExecution();
$paymentExecution->setPayerId($payer_id);
$payment->execute($paymentExecution, $this->_api_context);

最佳答案

信用卡付款是一个步骤,付款时$payment->create($this->_api_context); 已获批准。

因此不需要执行步骤 ($payment->execute($paymentExecution, $this->_api_context);)。此外,在这种情况下我们不需要付款人 ID。

关于php - Paypal 支付执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35681895/

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