2016-02-28 110 views
2

我創建使用信用卡的PayPal應用程序。它正在以批准的狀態成功創建付款。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); 

現在我想以完成交易執行此付款,但我無法找到計費用戶標識。這是什麼計費用戶標識和我在哪裏怎麼得來的?

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

回答

1

信用卡付款是一個步驟,當付款時 $payment->create($this->_api_context);被批准。

所以沒有必要執行步驟($payment->execute($paymentExecution, $this->_api_context);)的。另外,在這種情況下,我們不需要付款人ID。