Inheritance: extends PayPal\Common\PPModel
Esempio n. 1
0
// Second Item
$items[1] = new InvoiceItem();
// Lets add some discount to this item.
$item1discount = new Cost();
$item1discount->setPercent("3");
$items[1]->setName("Injection")->setQuantity(5)->setDiscount($item1discount)->setUnitPrice(new Currency());
$items[1]->getUnitPrice()->setCurrency("USD")->setValue(5);
// #### Tax Item
// You could provide Tax information to each item.
$tax2 = new \PayPal\Api\Tax();
$tax2->setPercent(3)->setName("Local Tax on Injection");
$items[1]->setTax($tax2);
$invoice->setItems($items);
// #### Final Discount
// You can add final discount to the invoice as shown below. You could either use "percent" or "value" when providing the discount
$cost = new Cost();
$cost->setPercent("2");
$invoice->setDiscount($cost);
$invoice->getPaymentTerm()->setTermType("NET_45");
// ### Shipping Information
$invoice->getShippingInfo()->setFirstName("Sally")->setLastName("Patient")->setBusinessName("Not applicable")->setPhone(new Phone())->setAddress(new InvoiceAddress());
$invoice->getShippingInfo()->getPhone()->setCountryCode("001")->setNationalNumber("5039871234");
$invoice->getShippingInfo()->getAddress()->setLine1("1234 Main St.")->setCity("Portland")->setState("OR")->setPostalCode("97217")->setCountryCode("US");
// ### Logo
// You can set the logo in the invoice by providing the external URL pointing to a logo
$invoice->setLogoUrl('https://www.paypalobjects.com/webstatic/i/logo/rebrand/ppcom.svg');
// For Sample Purposes Only.
$request = clone $invoice;
try {
    // ### Create Invoice
    // Create an invoice by calling the invoice->create() method
Esempio n. 2
0
 /**
  * @depends testSerializationDeserialization
  * @param Cost $obj
  */
 public function testGetters($obj)
 {
     $this->assertEquals($obj->getPercent(), "12.34");
     $this->assertEquals($obj->getAmount(), CurrencyTest::getObject());
 }