forked from LiveCarta/PayPal-PHP-SDK
Removing Dependency from SDK Core Project
- Copied files required for Rest API SDK - Removed PPApiContext and directly connected APIContext with PPConfigManager - Removed duplicate data storage of configuration and credentials. - Code Style Fixes - Remove build.xml file as it is not required anymore - Updated the samples - Updated the documentations
This commit is contained in:
44
sample/doc/invoice/CancelInvoice.html
Normal file
44
sample/doc/invoice/CancelInvoice.html
Normal file
@@ -0,0 +1,44 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>invoice/CancelInvoice</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="invoice/CancelInvoice"><meta name="groc-project-path" content="sample/invoice/CancelInvoice.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">sample/invoice/CancelInvoice.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="cancel-invoice-sample">Cancel Invoice Sample</h1>
|
||||
<p>This sample code demonstrate how you can cancel
|
||||
an invoice.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;
|
||||
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Invoice</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">CancelNotification</span>;
|
||||
|
||||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
|
||||
<p>Retrieve the invoice object by calling the
|
||||
static <code>get</code> method
|
||||
on the Payment class by passing a valid
|
||||
Invoice ID
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$invoice</span> = Invoice::get(<span class="hljs-string">"INV2-CJL7-PF4G-BLQF-5FWG"</span>, <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="cancel-notification-object">Cancel Notification Object</h3>
|
||||
<p>This would send a notification to both merchant as well
|
||||
the payer about the cancellation. The information of
|
||||
merchant and payer is retrieved from the invoice details</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$notify</span> = <span class="hljs-keyword">new</span> CancelNotification();
|
||||
<span class="hljs-variable">$notify</span>
|
||||
->setSubject(<span class="hljs-string">"Past due"</span>)
|
||||
->setNote(<span class="hljs-string">"Canceling invoice"</span>)
|
||||
->setSendToMerchant(<span class="hljs-keyword">true</span>)
|
||||
->setSendToPayer(<span class="hljs-keyword">true</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="cancel-invoice">Cancel Invoice</h3>
|
||||
<p>Cancel invoice object by calling the
|
||||
static <code>cancel</code> method
|
||||
on the Invoice class by passing a valid
|
||||
notification object
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$cancelStatus</span> = <span class="hljs-variable">$invoice</span>->cancel(<span class="hljs-variable">$notify</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
<span class="hljs-preprocessor">?></span>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Cancel Invoice</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>Cancel Invoice:</div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoice</span>->toJSON(JSON_PRETTY_PRINT); <span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
95
sample/doc/invoice/CreateInvoice.html
Normal file
95
sample/doc/invoice/CreateInvoice.html
Normal file
@@ -0,0 +1,95 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>invoice/CreateInvoice</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="invoice/CreateInvoice"><meta name="groc-project-path" content="sample/invoice/CreateInvoice.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">sample/invoice/CreateInvoice.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="create-invoice-sample">Create Invoice Sample</h1>
|
||||
<p>This sample code demonstrate how you can create
|
||||
an invoice.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Invoice</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">MerchantInfo</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">BillingInfo</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">InvoiceItem</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Phone</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Address</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Currency</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">PaymentTerm</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">ShippingInfo</span>;
|
||||
|
||||
<span class="hljs-variable">$invoice</span> = <span class="hljs-keyword">new</span> Invoice();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="invoice-info">Invoice Info</h3>
|
||||
<p>Fill in all the information that is
|
||||
required for invoice APIs</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$invoice</span>
|
||||
->setMerchantInfo(<span class="hljs-keyword">new</span> MerchantInfo())
|
||||
->setBillingInfo(<span class="hljs-keyword">array</span>(<span class="hljs-keyword">new</span> BillingInfo()))
|
||||
->setItems(<span class="hljs-keyword">array</span>(<span class="hljs-keyword">new</span> InvoiceItem()))
|
||||
->setNote(<span class="hljs-string">"Medical Invoice 16 Jul, 2013 PST"</span>)
|
||||
->setPaymentTerm(<span class="hljs-keyword">new</span> PaymentTerm())
|
||||
->setShippingInfo(<span class="hljs-keyword">new</span> ShippingInfo());</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="merchant-info">Merchant Info</h3>
|
||||
<p>A resource representing merchant information that can be
|
||||
used to identify merchant</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$invoice</span>->getMerchantInfo()
|
||||
->setEmail(<span class="hljs-string">"PPX.DevNet-facilitator@gmail.com"</span>)
|
||||
->setFirstName(<span class="hljs-string">"Dennis"</span>)
|
||||
->setLastName(<span class="hljs-string">"Doctor"</span>)
|
||||
->setbusinessName(<span class="hljs-string">"Medical Professionals, LLC"</span>)
|
||||
->setPhone(<span class="hljs-keyword">new</span> Phone())
|
||||
->setAddress(<span class="hljs-keyword">new</span> Address());
|
||||
|
||||
<span class="hljs-variable">$invoice</span>->getMerchantInfo()->getPhone()
|
||||
->setCountryCode(<span class="hljs-string">"001"</span>)
|
||||
->setNationalNumber(<span class="hljs-string">"5032141716"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="address-information">Address Information</h3>
|
||||
<p>The address used for creating the invoice</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$invoice</span>->getMerchantInfo()->getAddress()
|
||||
->setLine1(<span class="hljs-string">"1234 Main St."</span>)
|
||||
->setCity(<span class="hljs-string">"Portland"</span>)
|
||||
->setState(<span class="hljs-string">"OR"</span>)
|
||||
->setPostalCode(<span class="hljs-string">"97217"</span>)
|
||||
->setCountryCode(<span class="hljs-string">"US"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="billing-information">Billing Information</h3>
|
||||
<p>Set the email address for each billing</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$billing</span> = <span class="hljs-variable">$invoice</span>->getBillingInfo();
|
||||
<span class="hljs-variable">$billing</span>[<span class="hljs-number">0</span>]
|
||||
->setEmail(<span class="hljs-string">"example@example.com"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="items-list">Items List</h3>
|
||||
<p>You could provide the list of all items for
|
||||
detailed breakdown of invoice</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$items</span> = <span class="hljs-variable">$invoice</span>->getItems();
|
||||
<span class="hljs-variable">$items</span>[<span class="hljs-number">0</span>]
|
||||
->setName(<span class="hljs-string">"Sutures"</span>)
|
||||
->setQuantity(<span class="hljs-number">100</span>)
|
||||
->setUnitPrice(<span class="hljs-keyword">new</span> Currency());
|
||||
|
||||
<span class="hljs-variable">$items</span>[<span class="hljs-number">0</span>]->getUnitPrice()
|
||||
->setCurrency(<span class="hljs-string">"USD"</span>)
|
||||
->setValue(<span class="hljs-number">5</span>);
|
||||
|
||||
<span class="hljs-variable">$invoice</span>->getPaymentTerm()
|
||||
->setTermType(<span class="hljs-string">"NET_45"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="shipping-information">Shipping Information</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-variable">$invoice</span>->getShippingInfo()
|
||||
->setFirstName(<span class="hljs-string">"Sally"</span>)
|
||||
->setLastName(<span class="hljs-string">"Patient"</span>)
|
||||
->setBusinessName(<span class="hljs-string">"Not applicable"</span>)
|
||||
->setPhone(<span class="hljs-keyword">new</span> Phone())
|
||||
->setAddress(<span class="hljs-keyword">new</span> Address());
|
||||
|
||||
<span class="hljs-variable">$invoice</span>->getShippingInfo()->getPhone()
|
||||
->setCountryCode(<span class="hljs-string">"001"</span>)
|
||||
->setNationalNumber(<span class="hljs-string">"5039871234"</span>);
|
||||
|
||||
<span class="hljs-variable">$invoice</span>->getShippingInfo()->getAddress()
|
||||
->setLine1(<span class="hljs-string">"1234 Main St."</span>)
|
||||
->setCity(<span class="hljs-string">"Portland"</span>)
|
||||
->setState(<span class="hljs-string">"OR"</span>)
|
||||
->setPostalCode(<span class="hljs-string">"97217"</span>)
|
||||
->setCountryCode(<span class="hljs-string">"US"</span>);
|
||||
|
||||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-invoice">Create Invoice</h3>
|
||||
<p>Create an invoice by calling the invoice->create() method
|
||||
with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$invoice</span>->create(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
<span class="hljs-preprocessor">?></span>
|
||||
<html>
|
||||
<head>
|
||||
<title>Invoice Creation</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
Created Invoice:
|
||||
<span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoice</span>->getId(); <span class="hljs-preprocessor">?></span>
|
||||
</div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoice</span>->toJSON(JSON_PRETTY_PRINT); <span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
28
sample/doc/invoice/GetInvoice.html
Normal file
28
sample/doc/invoice/GetInvoice.html
Normal file
@@ -0,0 +1,28 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>invoice/GetInvoice</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="invoice/GetInvoice"><meta name="groc-project-path" content="sample/invoice/GetInvoice.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">sample/invoice/GetInvoice.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="get-invoice-sample">Get Invoice Sample</h1>
|
||||
<p>This sample code demonstrate how you can retrieve
|
||||
an invoice.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Invoice</span>;
|
||||
|
||||
<span class="hljs-variable">$invoiceId</span> = <span class="hljs-string">"INV2-9DRB-YTHU-2V9Q-7Q24"</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
|
||||
<p>Retrieve the invoice object by calling the
|
||||
static <code>get</code> method
|
||||
on the Invoice class by passing a valid
|
||||
Invoice ID
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$invoice</span> = Invoice::get(<span class="hljs-variable">$invoiceId</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception:"</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
<span class="hljs-preprocessor">?></span>
|
||||
<html>
|
||||
<head>
|
||||
<title>Lookup invoice details</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>Retrieving Invoice: <span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoiceId</span>;<span class="hljs-preprocessor">?></span></div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoice</span>->toJSON(JSON_PRETTY_PRINT); <span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
26
sample/doc/invoice/ListInvoice.html
Normal file
26
sample/doc/invoice/ListInvoice.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>invoice/ListInvoice</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="invoice/ListInvoice"><meta name="groc-project-path" content="sample/invoice/ListInvoice.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">sample/invoice/ListInvoice.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="list-invoices-sample">List Invoices Sample</h1>
|
||||
<p>This sample code demonstrate how you can get
|
||||
all invoice from history.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Invoice</span>;
|
||||
|
||||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoices">Retrieve Invoices</h3>
|
||||
<p>Retrieve the Invoice History object by calling the
|
||||
static <code>get_all</code> method on the Invoice class.
|
||||
Refer the method doc for valid values for keys
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$invoices</span> = Invoice::get_all(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception:"</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
<span class="hljs-preprocessor">?></span>
|
||||
<html>
|
||||
<head>
|
||||
<title>Lookup invoice history</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>Got invoices </div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoices</span>->toJSON(JSON_PRETTY_PRINT); <span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
43
sample/doc/invoice/RemindInvoice.html
Normal file
43
sample/doc/invoice/RemindInvoice.html
Normal file
@@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>invoice/RemindInvoice</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="invoice/RemindInvoice"><meta name="groc-project-path" content="sample/invoice/RemindInvoice.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">sample/invoice/RemindInvoice.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="remind-invoice-sample">Remind Invoice Sample</h1>
|
||||
<p>This sample code demonstrate how you can remind
|
||||
an invoice to the payer</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;
|
||||
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Invoice</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Notification</span>;
|
||||
|
||||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
|
||||
<p>Retrieve the invoice object by calling the
|
||||
static <code>get</code> method
|
||||
on the Invoice class by passing a valid
|
||||
Invoice ID
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$invoice</span> = Invoice::get(<span class="hljs-string">"INV2-9CAH-K5G7-2JPL-G4B4"</span>, <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="notification-object">Notification Object</h3>
|
||||
<p>This would send a notification to both merchant as well
|
||||
the payer. The information of merchant
|
||||
and payer is retrieved from the invoice details</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$notify</span> = <span class="hljs-keyword">new</span> Notification();
|
||||
<span class="hljs-variable">$notify</span>
|
||||
->setSubject(<span class="hljs-string">"Past due"</span>)
|
||||
->setNote(<span class="hljs-string">"Please pay soon"</span>)
|
||||
->setSendToMerchant(<span class="hljs-keyword">true</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="remind-invoice">Remind Invoice</h3>
|
||||
<p>Remind the notifiers by calling the
|
||||
<code>remind</code> method
|
||||
on the Invoice class by passing a valid
|
||||
notification object
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$remindStatus</span> = <span class="hljs-variable">$invoice</span>->remind(<span class="hljs-variable">$notify</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
<span class="hljs-preprocessor">?></span>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Remind Invoice</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>Remind Invoice:</div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoice</span>->toJSON(JSON_PRETTY_PRINT); <span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
31
sample/doc/invoice/SendInvoice.html
Normal file
31
sample/doc/invoice/SendInvoice.html
Normal file
@@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>invoice/SendInvoice</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="invoice/SendInvoice"><meta name="groc-project-path" content="sample/invoice/SendInvoice.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">sample/invoice/SendInvoice.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="create-invoice-sample">Create Invoice Sample</h1>
|
||||
<p>This sample code demonstrate how you can send
|
||||
a legitimate invoice to the payer</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;
|
||||
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Invoice</span>;
|
||||
|
||||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
|
||||
<p>Retrieve the invoice object by calling the
|
||||
static <code>get</code> method
|
||||
on the Invoice class by passing a valid
|
||||
Invoice ID
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$invoice</span> = Invoice::get(<span class="hljs-string">"INV2-9DRB-YTHU-2V9Q-7Q24"</span>, <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="send-invoice">Send Invoice</h3>
|
||||
<p>Send a legitimate invoice to the payer
|
||||
with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$sendStatus</span> = <span class="hljs-variable">$invoice</span>->send(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
<span class="hljs-preprocessor">?></span>
|
||||
<html>
|
||||
<head>
|
||||
<title>Send Invoice</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>Send Invoice:</div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoice</span>->toJSON(JSON_PRETTY_PRINT); <span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
Reference in New Issue
Block a user