本文整理汇总了PHP中PayPal\Api\Payment::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP Payment::execute方法的具体用法?PHP Payment::execute怎么用?PHP Payment::execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PayPal\Api\Payment
的用法示例。
在下文中一共展示了Payment::execute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: payment
/**
* @throws \InvalidArgumentException
*
* @return Payment
*/
private function payment() : Payment
{
if ($this->payment === null) {
$this->payment = $this->return->payment();
$this->payment->execute($this->execution(), $this->context);
}
return $this->payment;
}
示例2: execute
/**
* {@inheritDoc}
*/
public function execute($request)
{
/** @var $request Capture */
RequestNotSupportedException::assertSupports($this, $request);
$details = ArrayObject::ensureArrayObject($request->getModel());
$payment = new Payment();
$payer = new Payer();
$payer->payment_method = "paypal";
$amount = new Amount();
$amount->currency = $details['PAYMENTREQUEST_CURRENCYCODE'];
$amount->total = $details['PAYMENTREQUEST_AMT'];
$transaction = new Transaction();
$transaction->amount = $amount;
$transaction->description = $details['PAYMENTREQUEST_DESCRIPTION'];
$redirectUrls = new RedirectUrls();
$redirectUrls->return_url = $details['RETURN_URL'];
$redirectUrls->cancel_url = $details['CANCEL_URL'];
$payment->intent = "sale";
$payment->payer = $payer;
$payment->redirect_urls = $redirectUrls;
$payment->transactions = [$transaction];
if (false == isset($details['response']) && false == isset($details['response']['state']) && isset($payment->payer->payment_method) && 'paypal' == $payment->payer->payment_method) {
$paymentResponse = $payment->create($this->api);
$details['response'] = $paymentResponse->toArray();
foreach ($paymentResponse->links as $link) {
if ($link->rel == 'approval_url') {
throw new HttpRedirect($link->href);
}
}
}
if (false == isset($details['response']) && false == isset($details['response']['state']) && isset($payment->payer->payment_method) && 'credit_card' == $payment->payer->payment_method) {
$paymentResponse = $payment->create($this->api);
$details['response'] = $paymentResponse->toArray();
}
$this->gateway->execute(new Sync($details));
if (true == isset($details['response']) && true == isset($details['response']['state']) && true == isset($details['response']['id']) && isset($payment->payer->payment_method) && 'paypal' == $payment->payer->payment_method && true == isset($details['PayerID'])) {
$payment->setId($details['response']['id']);
$execution = new PaymentExecution();
$execution->setPayerId($details['PayerID']);
//Execute the payment
$paymentResponse = $payment->execute($execution, $this->api);
$details['response'] = $paymentResponse->toArray();
}
}
示例3: testExecute
/**
* @dataProvider mockProvider
* @param Payment $obj
*/
public function testExecute($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock();
$mockPPRestCall->expects($this->any())->method('execute')->will($this->returnValue(self::getJson()));
$paymentExecution = PaymentExecutionTest::getObject();
$result = $obj->execute($paymentExecution, $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}