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


PHP Amount::getTotal方法代码示例

本文整理汇总了PHP中PayPal\Api\Amount::getTotal方法的典型用法代码示例。如果您正苦于以下问题:PHP Amount::getTotal方法的具体用法?PHP Amount::getTotal怎么用?PHP Amount::getTotal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PayPal\Api\Amount的用法示例。


在下文中一共展示了Amount::getTotal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 /**
  * @param PaymentInterface $payment
  */
 public function init(PaymentInterface $payment)
 {
     $credentials = new OAuthTokenCredential($this->options['client_id'], $this->options['secret']);
     $apiContext = new ApiContext($credentials);
     $apiContext->setConfig(['mode' => $this->options['mode']]);
     $payer = new Payer();
     $payer->setPaymentMethod('paypal');
     $amount = new Amount();
     $amount->setCurrency($this->options['currency']);
     $amount->setTotal($payment->getPaymentSum());
     $item = new Item();
     $item->setName($payment->getDescription());
     $item->setCurrency($amount->getCurrency());
     $item->setQuantity(1);
     $item->setPrice($amount->getTotal());
     $itemList = new ItemList();
     $itemList->addItem($item);
     $transaction = new Transaction();
     $transaction->setAmount($amount);
     $transaction->setDescription($payment->getDescription());
     $transaction->setItemList($itemList);
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturnUrl($payment->getExtraData('return_url'));
     $redirectUrls->setCancelUrl($payment->getExtraData('cancel_url'));
     $paypalPayment = new Payment();
     $paypalPayment->setIntent('sale');
     $paypalPayment->setPayer($payer);
     $paypalPayment->setTransactions([$transaction]);
     $paypalPayment->setRedirectUrls($redirectUrls);
     $paypalPayment->create($apiContext);
     $payment->setExtraData('paypal_payment_id', $paypalPayment->getId());
     $payment->setExtraData('approval_link', $paypalPayment->getApprovalLink());
 }
开发者ID:moriony,项目名称:payment-gateway,代码行数:36,代码来源:PayPalHandler.php

示例2: testGetters

 /**
  * @depends testSerializationDeserialization
  * @param Amount $obj
  */
 public function testGetters($obj)
 {
     $this->assertEquals($obj->getCurrency(), "TestSample");
     $this->assertEquals($obj->getTotal(), "12.34");
     $this->assertEquals($obj->getDetails(), DetailsTest::getObject());
 }
开发者ID:Roc4rdho,项目名称:app,代码行数:10,代码来源:AmountTest.php


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