More Invoice API Updates

This commit is contained in:
japatel
2014-11-18 16:50:57 -06:00
parent e6fb968509
commit 383d12622b
11 changed files with 357 additions and 1209 deletions

View File

@@ -14,7 +14,7 @@ try {
// static `get_all` method on the Invoice class.
// Refer the method doc for valid values for keys
// (See bootstrap.php for more on `ApiContext`)
$invoices = Invoice::get_all($apiContext);
$invoices = Invoice::getAll(array('page' => 0, 'page_size' => 4, 'total_count_required' => true), $apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Lookup Invoice History", "Invoice", null, null, $ex);
exit(1);

View File

@@ -11,13 +11,6 @@ use PayPal\Api\Invoice;
use PayPal\Api\Notification;
try {
// ### Retrieve Invoice
// Retrieve the invoice object by calling the
// static `get` method
// on the Invoice class by passing a valid
// Invoice ID
// (See bootstrap.php for more on `ApiContext`)
$invoice = Invoice::get($invoice->getId(), $apiContext);
// ### Notification Object
// This would send a notification to both merchant as well

View File

@@ -0,0 +1,41 @@
<?php
// # Retrieve QR Code for Invoice Sample
// Specify an invoice ID to get a QR code (image) that corresponds to the invoice ID. A QR code for an invoice can be added to a paper or PDF invoice. When a customer uses their mobile device to scan the QR code, the customer is redirected to the PayPal mobile payment flow, where they can pay online with PayPal or a credit card.
/** @var Invoice $invoice */
$invoice = require 'SendInvoice.php';
use PayPal\Api\Invoice;
use PayPal\Api\Notification;
try {
// ### Retrieve QR Code of Sent Invoice
// Retrieve QR Code of Sent Invoice by calling the
// `qrCode` method
// on the Invoice class by passing a valid
// notification object
// (See bootstrap.php for more on `ApiContext`)
$image = Invoice::qrCode($invoice->getId(), array('height' => '300', 'width' => '300'), $apiContext);
// ### Optionally Save to File
// This is not a required step. However, if you want to store this image as a file, you can use
// 'saveToFile' method with proper file name.
// This will save the image as /samples/invoice/images/sample.png
$path = $image->saveToFile("images/sample.png");
} catch (Exception $ex) {
ResultPrinter::printError("Retrieved QR Code for Invoice", "Invoice", $invoice->getId(), null, $ex);
exit(1);
}
ResultPrinter::printResult("Retrieved QR Code for Invoice", "Invoice", $invoice->getId(), null, $image);
// ### Show the Image
// In PHP, there are many ways to present an images.
// One of the ways, you could directly inject the base64-encoded string
// with proper image information in front of it.
echo '<img src="data:image/png;base64,'. $image->getImageBase64() . '" alt="Invoice QR Code" />';

View File

@@ -10,13 +10,6 @@ $invoice = require 'CreateInvoice.php';
use PayPal\Api\Invoice;
try {
// ### Retrieve Invoice
// Retrieve the invoice object by calling the
// static `get` method
// on the Invoice class by passing a valid
// Invoice ID
// (See bootstrap.php for more on `ApiContext`)
$invoice = Invoice::get($invoice->getId(), $apiContext);
// ### Send Invoice
// Send a legitimate invoice to the payer

View File

@@ -0,0 +1,31 @@
<?php
// # Update Invoice Sample
// This sample code demonstrate how you can update
// an invoice.
/** @var Invoice $invoice */
$invoice = require 'CreateInvoice.php';
use PayPal\Api\Invoice;
// ### Update Invoice
// Lets update some information
$invoice->setInvoiceDate("2014-11-16 PST");
// For Sample Purposes Only.
$request = clone $invoice;
try {
// ### Update Invoice
// Update an invoice by calling the invoice->update() method
// with a valid ApiContext (See bootstrap.php for more on `ApiContext`)
$invoice->update($apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Invoice Updated", "Invoice", null, $request, $ex);
exit(1);
}
ResultPrinter::printResult("Invoice Updated", "Invoice", $invoice->getId(), $request, $invoice);
return $invoice;