当前位置: 首页>>代码示例>>PHP>>正文


PHP Payment::execute方法代码示例

本文整理汇总了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;
 }
开发者ID:hughgrigg,项目名称:ching-shop,代码行数:13,代码来源:PayPalExecution.php

示例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();
     }
 }
开发者ID:sio-ag,项目名称:PaypalRest,代码行数:47,代码来源:CaptureAction.php

示例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);
 }
开发者ID:Roc4rdho,项目名称:app,代码行数:12,代码来源:PaymentTest.php


注:本文中的PayPal\Api\Payment::execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。