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


PHP Item::getQuantity方法代码示例

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


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

示例1: testGetters

 /**
  * @depends testSerializationDeserialization
  * @param Item $obj
  */
 public function testGetters($obj)
 {
     $this->assertEquals($obj->getQuantity(), "TestSample");
     $this->assertEquals($obj->getName(), "TestSample");
     $this->assertEquals($obj->getDescription(), "TestSample");
     $this->assertEquals($obj->getPrice(), "12.34");
     $this->assertEquals($obj->getTax(), "12.34");
     $this->assertEquals($obj->getCurrency(), "TestSample");
     $this->assertEquals($obj->getSku(), "TestSample");
     $this->assertEquals($obj->getUrl(), "http://www.google.com");
     $this->assertEquals($obj->getCategory(), "TestSample");
     $this->assertEquals($obj->getWeight(), MeasurementTest::getObject());
     $this->assertEquals($obj->getLength(), MeasurementTest::getObject());
     $this->assertEquals($obj->getHeight(), MeasurementTest::getObject());
     $this->assertEquals($obj->getWidth(), MeasurementTest::getObject());
     $this->assertEquals($obj->getSupplementaryData(), NameValuePairTest::getObject());
     $this->assertEquals($obj->getPostbackData(), NameValuePairTest::getObject());
 }
开发者ID:omasterdesign,项目名称:omasterdefault,代码行数:22,代码来源:ItemTest.php

示例2: create

 public static function create($items, Details $shippingDetails, $paymentIntent, $paymentMethod, $fi = null)
 {
     $payer = new Payer();
     $payer->setPaymentMethod($paymentMethod);
     if ($fi !== null) {
         $payer->setFundingInstruments(array($fi));
     }
     $fullList = array();
     foreach ($items as $item) {
         if (!$item instanceof ItemInterface) {
             throw new Exception('All the item created for the payment MUST implement the ItemInterface');
         }
         $singleItem = new Item();
         $singleItem->setName($item->getName());
         $singleItem->setSku($item->getSku());
         $singleItem->setCurrency($item->getCurrency());
         $singleItem->setPrice($item->getPrice());
         $singleItem->setQuantity($item->getQuantity());
         $fullList[] = $singleItem;
     }
     $itemList = new ItemList();
     $itemList->setItems($fullList);
     $details = $shippingDetails;
     $subtotal = 0.0;
     /** @var Item $singleItem */
     foreach ($fullList as $singleItem) {
         $subtotal += floatval($singleItem->getPrice()) * floatval($singleItem->getQuantity());
     }
     $details->setSubtotal($subtotal);
     $total = $subtotal + floatval($details->getTax()) + floatval($details->getShipping());
     $currencyMode = Validation::currencyMode($items);
     $amount = new Amount();
     $amount->setCurrency($currencyMode)->setTotal($total)->setDetails($details);
     $transaction = new Transaction();
     $transaction->setAmount($amount)->setItemList($itemList);
     $payment = new Payment();
     $payment->setIntent($paymentIntent)->setPayer($payer)->setTransactions(array($transaction));
     return $payment;
 }
开发者ID:DDFranky22,项目名称:DDFPayPalBundle,代码行数:39,代码来源:PaymentService.php


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