我正在使用信用卡创建一个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。
您将从"创建付款"的返回URL(GET方法)获得payer_id。查看PayPal REST API 参考以获取更多详细信息