本文整理汇总了PHP中PayPal\Api\Item::getPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::getPrice方法的具体用法?PHP Item::getPrice怎么用?PHP Item::getPrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PayPal\Api\Item
的用法示例。
在下文中一共展示了Item::getPrice方法的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());
}
示例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;
}