本文整理汇总了PHP中PayPal\Api\ItemList::getItems方法的典型用法代码示例。如果您正苦于以下问题:PHP ItemList::getItems方法的具体用法?PHP ItemList::getItems怎么用?PHP ItemList::getItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PayPal\Api\ItemList
的用法示例。
在下文中一共展示了ItemList::getItems方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createPayment
/**
* Create the Payment request and process
* @return null|string The approval url to which the user has to be redirected
*/
public function createPayment()
{
$payer = new Payer();
$payer->setPaymentMethod("paypal");
$this->validateData();
if (!is_null($this->details)) {
$this->getAmount()->setDetails($this->details);
}
$transaction = new Transaction();
$transaction->setAmount($this->getAmount())->setDescription($this->getDescription())->setInvoiceNumber($this->getInvoiceNumber());
if (count($this->itemList->getItems())) {
$transaction->setItemList($this->itemList);
}
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl($this->getSuccessUrl(self::paymentMethod))->setCancelUrl($this->getCancelUrl(self::paymentMethod));
$payment = new Payment();
$payment->setIntent(self::ACTION)->setPayer($payer)->setRedirectUrls($redirectUrls)->setTransactions(array($transaction));
try {
$payment->create($this->getApiContext($this->clientId, $this->clientSecret));
} catch (\Exception $ex) {
$this->container->get('logger')->error($ex);
return null;
}
$approvalUrl = $payment->getApprovalLink();
return $approvalUrl;
}
示例2: testRemoveItemMethod
public function testRemoveItemMethod()
{
$itemList = new ItemList();
$item1 = ItemTest::createItem();
$item1->setName("Name1");
$item2 = ItemTest::createItem();
$itemList->addItem($item1);
$itemList->addItem($item2);
$itemList->removeItem($item2);
$this->assertEquals(sizeof($itemList->getItems()), 1);
$remainingElements = $itemList->getItems();
$this->assertEquals($remainingElements[0]->getName(), "Name1");
}
示例3: testGetters
/**
* @depends testSerializationDeserialization
* @param ItemList $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getItems(), ItemTest::getObject());
$this->assertEquals($obj->getShippingAddress(), ShippingAddressTest::getObject());
$this->assertEquals($obj->getShippingMethod(), "TestSample");
$this->assertEquals($obj->getShippingPhoneNumber(), "TestSample");
}