From bb21c1e44571eacffd1603055fa204068220c019 Mon Sep 17 00:00:00 2001 From: siddick Date: Wed, 23 Apr 2014 17:43:04 +0530 Subject: [PATCH] Added invoice samples --- sample/invoicing/CancelInvoice.php | 37 +++++++++++ sample/invoicing/CreateInvoice.php | 100 +++++++++++++++++++++++++++++ sample/invoicing/GetInvoice.php | 19 ++++++ sample/invoicing/ListInvoice.php | 22 +++++++ sample/invoicing/RemindInvoice.php | 35 ++++++++++ sample/invoicing/SendInvoice.php | 27 ++++++++ 6 files changed, 240 insertions(+) create mode 100644 sample/invoicing/CancelInvoice.php create mode 100644 sample/invoicing/CreateInvoice.php create mode 100644 sample/invoicing/GetInvoice.php create mode 100644 sample/invoicing/ListInvoice.php create mode 100644 sample/invoicing/RemindInvoice.php create mode 100644 sample/invoicing/SendInvoice.php diff --git a/sample/invoicing/CancelInvoice.php b/sample/invoicing/CancelInvoice.php new file mode 100644 index 0000000..5abefd6 --- /dev/null +++ b/sample/invoicing/CancelInvoice.php @@ -0,0 +1,37 @@ +setSubject("Past due") + ->setNote("Canceling invoice") + ->setSendToMerchant(true) + ->setSendToPayer(true); + + + $cancelStatus = $invoice->cancel($notify, $apiContext); +} catch (PayPal\Exception\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} + +?> + + + + Cancel Invoice + + +
Cancel Invoice:
+
+ Back + + diff --git a/sample/invoicing/CreateInvoice.php b/sample/invoicing/CreateInvoice.php new file mode 100644 index 0000000..e67fcab --- /dev/null +++ b/sample/invoicing/CreateInvoice.php @@ -0,0 +1,100 @@ +setMerchantInfo(new MerchantInfo()) + ->setBillingInfo(array(new BillingInfo())) + ->setItems(array(new InvoiceItem())) + ->setNote("Medical Invoice 16 Jul, 2013 PST") + ->setPaymentTerm(new PaymentTerm()) + ->setShippingInfo(new ShippingInfo()); + +$invoice->getMerchantInfo() + ->setEmail("PPX.DevNet-facilitator@gmail.com") + ->setFirstName("Dennis") + ->setLastName("Doctor") + ->setbusinessName("Medical Professionals, LLC") + ->setPhone(new Phone()) + ->setAddress(new Address()); + +$invoice->getMerchantInfo()->getPhone() + ->setCountryCode("001") + ->setNationalNumber("5032141716"); + +$invoice->getMerchantInfo()->getAddress() + ->setLine1("1234 Main St.") + ->setCity("Portland") + ->setState("OR") + ->setPostalCode("97217") + ->setCountryCode("US"); + +$billing = $invoice->getBillingInfo(); +$billing[0] + ->setEmail("example@example.com"); + +$items = $invoice->getItems(); +$items[0] + ->setName("Sutures") + ->setQuantity(100) + ->setUnitPrice(new Currency()); + +$items[0]->getUnitPrice() + ->setCurrency("USD") + ->setValue(5); + +$invoice->getPaymentTerm() + ->setTermType("NET_45"); + +$invoice->getShippingInfo() + ->setFirstName("Sally") + ->setLastName("Patient") + ->setBusinessName("Not applicable") + ->setPhone(new Phone()) + ->setAddress(new Address()); + +$invoice->getShippingInfo()->getPhone() + ->setCountryCode("001") + ->setNationalNumber("5039871234"); + +$invoice->getShippingInfo()->getAddress() + ->setLine1("1234 Main St.") + ->setCity("Portland") + ->setState("OR") + ->setPostalCode("97217") + ->setCountryCode("US"); + +print(var_dump($invoice->toArray())); + +try { + $invoice->create($apiContext); +} catch (PayPal\Exception\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} +?> + + + Direct Credit card payments + + +
+ Created Invoice: + getId();?> +
+
toArray());?>
+ Back + + diff --git a/sample/invoicing/GetInvoice.php b/sample/invoicing/GetInvoice.php new file mode 100644 index 0000000..3add02c --- /dev/null +++ b/sample/invoicing/GetInvoice.php @@ -0,0 +1,19 @@ + + + + Lookup invoice details + + +
Retrieving Invoice:
+
+ Back + + diff --git a/sample/invoicing/ListInvoice.php b/sample/invoicing/ListInvoice.php new file mode 100644 index 0000000..420ebba --- /dev/null +++ b/sample/invoicing/ListInvoice.php @@ -0,0 +1,22 @@ +getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} +?> + + + Lookup invoice history + + +
Got invoices
+
toArray());?>
+ Back + + diff --git a/sample/invoicing/RemindInvoice.php b/sample/invoicing/RemindInvoice.php new file mode 100644 index 0000000..1d20789 --- /dev/null +++ b/sample/invoicing/RemindInvoice.php @@ -0,0 +1,35 @@ +setSubject("Past due") + ->setNote("Please pay soon") + ->setSendToMerchant(true); + + $remindStatus = $invoice->remind($notify, $apiContext); +} catch (PayPal\Exception\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} + +?> + + + + Remind Invoice + + +
Remind Invoice:
+
+ Back + + diff --git a/sample/invoicing/SendInvoice.php b/sample/invoicing/SendInvoice.php new file mode 100644 index 0000000..61d39cc --- /dev/null +++ b/sample/invoicing/SendInvoice.php @@ -0,0 +1,27 @@ +send($apiContext); +} catch (PayPal\Exception\PPConnectionException $ex) { + echo "Exception: " . $ex->getMessage() . PHP_EOL; + var_dump($ex->getData()); + exit(1); +} + +?> + + + Send Invoice + + +
Send Invoice:
+
+ Back + +