當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。