Gets the details for a specified invoice, by ID.
public static get ( string $invoiceId, |
||
$invoiceId | string | |
$apiContext | is the APIContext for this call. It can be used to pass dynamic configuration and credentials. | |
$restCall | is the Rest Call Service that is used to make rest calls | |
리턴 |
/** * @depends testCreate * @param $invoice Invoice * @return Invoice */ public function testGet($invoice) { $result = Invoice::get($invoice->getId(), null, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertEquals($invoice->getId(), $result->getId()); return $result; }
function getInvoiceDetails($invoiceNumber, $apiContext, $paypal) { try { $invoice = Invoice::get($invoiceNumber, $apiContext); } catch (Exception $ex) { ResultPrinter::printError("Get Invoice", "Invoice", $invoice->getId(), $invoiceId, $ex); exit(1); } $taxSum = 0; foreach ($invoice->getItems() as $item) { if ($item->getTax()) { $taxSum += $item->getTax()->getAmount()->getValue(); } } $tID = 0; //This is the key value to hook up with the classis paypal API $tID = $paypal->request($invoice->getPayments()['0']->getTransactionId())['L_TRANSACTIONID0']; return array('date' => $invoice->getPayments()['0']->getDate(), 'memo' => $invoice->getMerchantMemo(), 'number' => $invoice->getNumber(), 'tax' => $taxSum, 'tID' => $tID); }
$billingInfo = $invoice->getBillingInfo()[0]; $billingInfo->setAddress(null); $invoice->getPaymentTerm()->setDueDate(null); 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) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Invoice Updated", "Invoice", null, $request, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Invoice Updated", "Invoice", $invoice->getId(), $request, $invoice); // ### 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`) try { $invoice = Invoice::get($invoice->getId(), $apiContext); } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $invoice); return $invoice;
<?php require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Invoice; try { $invoice = Invoice::get("INV2-9DRB-YTHU-2V9Q-7Q24", $apiContext); $sendStatus = $invoice->send($apiContext); } catch (PayPal\Exception\PPConnectionException $ex) { echo "Exception: " . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); exit(1); } ?> <html> <head> <title>Send Invoice</title> </head> <body> <div>Send Invoice:</div> <pre><?php var_dump($invoice); ?> </pre> <a href='../index.html'>Back</a> </body> </html>
<?php // # Get Invoice Sample // This sample code demonstrate how you can retrieve // an invoice. /** @var Invoice $invoice */ $invoice = (require 'CreateInvoice.php'); use PayPal\Api\Invoice; $invoiceId = $invoice->getId(); // ### 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`) try { $invoice = Invoice::get($invoiceId, $apiContext); } catch (Exception $ex) { ResultPrinter::printError("Get Invoice", "Invoice", $invoice->getId(), $invoiceId, $ex); exit(1); } ResultPrinter::printResult("Get Invoice", "Invoice", $invoice->getId(), $invoiceId, $invoice); return $invoice;
/** * @dataProvider mockProvider * @param Invoice $obj */ public function testGet($obj, $mockApiContext) { $mockPayPalRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock(); $mockPayPalRestCall->expects($this->any())->method('execute')->will($this->returnValue(InvoiceTest::getJson())); $result = $obj->get("invoiceId", $mockApiContext, $mockPayPalRestCall); $this->assertNotNull($result); }
<?php require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Invoice; use PayPal\Api\Notification; try { $invoice = Invoice::get("INV2-9CAH-K5G7-2JPL-G4B4", $apiContext); $notify = new Notification(); $notify->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); } ?> <html> <head> <title>Remind Invoice</title> </head> <body> <div>Remind Invoice:</div> <pre><?php var_dump($invoice); ?> </pre> <a href='../index.html'>Back</a> </body> </html>
<?php require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Invoice; use PayPal\Api\CancelNotification; try { $invoice = Invoice::get("INV2-CJL7-PF4G-BLQF-5FWG", $apiContext); $notify = new CancelNotification(); $notify->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); } ?> <html> <head> <title>Cancel Invoice</title> </head> <body> <div>Cancel Invoice:</div> <pre><?php var_dump($invoice); ?> </pre> <a href='../index.html'>Back</a> </body> </html>