Adding Discount to Invoice Samples

This commit is contained in:
Jay Patel
2015-06-26 11:57:22 -05:00
parent 18e4eaaf31
commit ccf9008dfa
3 changed files with 134 additions and 375 deletions

View File

@@ -5,6 +5,7 @@
// an invoice.
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Cost;
use PayPal\Api\Invoice;
use PayPal\Api\MerchantInfo;
use PayPal\Api\BillingInfo;
@@ -91,9 +92,13 @@ $items[0]->setTax($tax);
// 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()
@@ -108,6 +113,12 @@ $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");