forked from LiveCarta/PayPal-PHP-SDK
Samples for All Invoice Operations including QR Code
- Invoice search method is static now - Shipping Info has proper Phone Params - Small Changes to Image Class - Updated Sample Docs
This commit is contained in:
@@ -576,6 +576,46 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3
|
||||
]
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
"language": {
|
||||
"nameMatchers": [{}, ".fbp"],
|
||||
"pygmentsLexer": "php",
|
||||
"singleLineComment": ["//"],
|
||||
"ignorePrefix": "}",
|
||||
"foldPrefix": "^",
|
||||
"name": "PHP"
|
||||
},
|
||||
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/PayPal-PHP-SDK/sample/invoice/DeleteInvoice.php",
|
||||
"projectPath": "invoice/DeleteInvoice.php",
|
||||
"targetPath": "invoice/DeleteInvoice",
|
||||
"pageTitle": "invoice/DeleteInvoice",
|
||||
"title": "DeleteInvoice"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Delete Invoice Sample",
|
||||
"slug": "delete-invoice-sample"
|
||||
},
|
||||
"depth": 1,
|
||||
"children": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Delete Invoice",
|
||||
"slug": "delete-invoice"
|
||||
},
|
||||
"depth": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
@@ -656,6 +696,102 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3
|
||||
]
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
"language": {
|
||||
"nameMatchers": [{}, ".fbp"],
|
||||
"pygmentsLexer": "php",
|
||||
"singleLineComment": ["//"],
|
||||
"ignorePrefix": "}",
|
||||
"foldPrefix": "^",
|
||||
"name": "PHP"
|
||||
},
|
||||
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/PayPal-PHP-SDK/sample/invoice/RecordPayment.php",
|
||||
"projectPath": "invoice/RecordPayment.php",
|
||||
"targetPath": "invoice/RecordPayment",
|
||||
"pageTitle": "invoice/RecordPayment",
|
||||
"title": "RecordPayment"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Record Payment Sample",
|
||||
"slug": "record-payment-sample"
|
||||
},
|
||||
"depth": 1,
|
||||
"children": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Record Object",
|
||||
"slug": "record-object"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Record Payment for Invoice",
|
||||
"slug": "record-payment-for-invoice"
|
||||
},
|
||||
"depth": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
"language": {
|
||||
"nameMatchers": [{}, ".fbp"],
|
||||
"pygmentsLexer": "php",
|
||||
"singleLineComment": ["//"],
|
||||
"ignorePrefix": "}",
|
||||
"foldPrefix": "^",
|
||||
"name": "PHP"
|
||||
},
|
||||
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/PayPal-PHP-SDK/sample/invoice/RecordRefund.php",
|
||||
"projectPath": "invoice/RecordRefund.php",
|
||||
"targetPath": "invoice/RecordRefund",
|
||||
"pageTitle": "invoice/RecordRefund",
|
||||
"title": "RecordRefund"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Record Refund Sample",
|
||||
"slug": "record-refund-sample"
|
||||
},
|
||||
"depth": 1,
|
||||
"children": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Record Object",
|
||||
"slug": "record-object"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Record Refund for Invoice",
|
||||
"slug": "record-refund-for-invoice"
|
||||
},
|
||||
"depth": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
@@ -685,14 +821,6 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3
|
||||
"depth": 1,
|
||||
"children": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Retrieve Invoice",
|
||||
"slug": "retrieve-invoice"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
@@ -712,6 +840,110 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3
|
||||
]
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
"language": {
|
||||
"nameMatchers": [{}, ".fbp"],
|
||||
"pygmentsLexer": "php",
|
||||
"singleLineComment": ["//"],
|
||||
"ignorePrefix": "}",
|
||||
"foldPrefix": "^",
|
||||
"name": "PHP"
|
||||
},
|
||||
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/PayPal-PHP-SDK/sample/invoice/RetrieveQRCode.php",
|
||||
"projectPath": "invoice/RetrieveQRCode.php",
|
||||
"targetPath": "invoice/RetrieveQRCode",
|
||||
"pageTitle": "invoice/RetrieveQRCode",
|
||||
"title": "RetrieveQRCode"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Retrieve QR Code for Invoice Sample",
|
||||
"slug": "retrieve-qr-code-for-invoice-sample"
|
||||
},
|
||||
"depth": 1,
|
||||
"children": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Retrieve QR Code of Sent Invoice",
|
||||
"slug": "retrieve-qr-code-of-sent-invoice"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Optionally Save to File",
|
||||
"slug": "optionally-save-to-file"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Show the Image",
|
||||
"slug": "show-the-image"
|
||||
},
|
||||
"depth": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
"language": {
|
||||
"nameMatchers": [{}, ".fbp"],
|
||||
"pygmentsLexer": "php",
|
||||
"singleLineComment": ["//"],
|
||||
"ignorePrefix": "}",
|
||||
"foldPrefix": "^",
|
||||
"name": "PHP"
|
||||
},
|
||||
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/PayPal-PHP-SDK/sample/invoice/SearchInvoices.php",
|
||||
"projectPath": "invoice/SearchInvoices.php",
|
||||
"targetPath": "invoice/SearchInvoices",
|
||||
"pageTitle": "invoice/SearchInvoices",
|
||||
"title": "SearchInvoices"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Search Invoices Sample",
|
||||
"slug": "search-invoices-sample"
|
||||
},
|
||||
"depth": 1,
|
||||
"children": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Search Object",
|
||||
"slug": "search-object"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Search Invoices",
|
||||
"slug": "search-invoices"
|
||||
},
|
||||
"depth": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
@@ -744,16 +976,56 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Retrieve Invoice",
|
||||
"slug": "retrieve-invoice"
|
||||
"title": "Send Invoice",
|
||||
"slug": "send-invoice"
|
||||
},
|
||||
"depth": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
"language": {
|
||||
"nameMatchers": [{}, ".fbp"],
|
||||
"pygmentsLexer": "php",
|
||||
"singleLineComment": ["//"],
|
||||
"ignorePrefix": "}",
|
||||
"foldPrefix": "^",
|
||||
"name": "PHP"
|
||||
},
|
||||
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/PayPal-PHP-SDK/sample/invoice/UpdateInvoice.php",
|
||||
"projectPath": "invoice/UpdateInvoice.php",
|
||||
"targetPath": "invoice/UpdateInvoice",
|
||||
"pageTitle": "invoice/UpdateInvoice",
|
||||
"title": "UpdateInvoice"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Update Invoice Sample",
|
||||
"slug": "update-invoice-sample"
|
||||
},
|
||||
"depth": 1,
|
||||
"children": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Update Invoice",
|
||||
"slug": "update-invoice"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Send Invoice",
|
||||
"slug": "send-invoice"
|
||||
"title": "Update Invoice",
|
||||
"slug": "update-invoice"
|
||||
},
|
||||
"depth": 3
|
||||
}
|
||||
|
||||
@@ -75,10 +75,10 @@ detailed breakdown of invoice</p></div></div><div class="code"><div class="wrapp
|
||||
<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> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Invoice Creation"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
ResultPrinter::printError(<span class="hljs-string">"Create Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Invoice Creation"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$invoice</span>);
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Create Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$invoice</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$invoice</span>;</div></div></div></div></body></html>
|
||||
20
sample/doc/invoice/DeleteInvoice.html
Normal file
20
sample/doc/invoice/DeleteInvoice.html
Normal file
@@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>invoice/DeleteInvoice</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/DeleteInvoice"><meta name="groc-project-path" content="invoice/DeleteInvoice.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">invoice/DeleteInvoice.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="delete-invoice-sample">Delete Invoice Sample</h1>
|
||||
<p>This sample code demonstrate how you can delete
|
||||
an invoice.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Invoice $invoice */</span>
|
||||
<span class="hljs-variable">$invoice</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateInvoice.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="delete-invoice">Delete Invoice</h3>
|
||||
<p>Delete invoice object by calling the
|
||||
<code>delete</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">$deleteStatus</span> = <span class="hljs-variable">$invoice</span>->delete(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Delete Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$deleteStatus</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Delete Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>);</div></div></div></div></body></html>
|
||||
@@ -8,7 +8,7 @@ all invoice from history.</p></div></div><div class="code"><div class="wrapper">
|
||||
<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>);
|
||||
(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::getAll(<span class="hljs-keyword">array</span>(<span class="hljs-string">'page'</span> => <span class="hljs-number">0</span>, <span class="hljs-string">'page_size'</span> => <span class="hljs-number">4</span>, <span class="hljs-string">'total_count_required'</span> => <span class="hljs-string">"true"</span>), <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Lookup Invoice History"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
|
||||
30
sample/doc/invoice/RecordPayment.html
Normal file
30
sample/doc/invoice/RecordPayment.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>invoice/RecordPayment</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/RecordPayment"><meta name="groc-project-path" content="invoice/RecordPayment.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">invoice/RecordPayment.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="record-payment-sample">Record Payment Sample</h1>
|
||||
<p>This sample code demonstrate how you can record
|
||||
an invoice as paid.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Invoice $invoice */</span>
|
||||
<span class="hljs-variable">$invoice</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'SendInvoice.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">PaymentDetail</span>;
|
||||
|
||||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="record-object">Record Object</h3>
|
||||
<p>Create a PaymentDetail object, and fill in the required fields
|
||||
You can use the new way of injecting json directly to the object.</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$record</span> = <span class="hljs-keyword">new</span> PaymentDetail(
|
||||
<span class="hljs-string">'{
|
||||
"method" : "CASH",
|
||||
"date" : "2014-07-06 03:30:00 PST",
|
||||
"note" : "Cash received."
|
||||
}'</span>
|
||||
);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="record-payment-for-invoice">Record Payment for Invoice</h3>
|
||||
<p>Record a payment on invoice object by calling the
|
||||
<code>recordPayment</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">$recordStatus</span> = <span class="hljs-variable">$invoice</span>->recordPayment(<span class="hljs-variable">$record</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Payment for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$recordStatus</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Payment for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$record</span>, <span class="hljs-keyword">null</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$invoice</span>;</div></div></div></div></body></html>
|
||||
29
sample/doc/invoice/RecordRefund.html
Normal file
29
sample/doc/invoice/RecordRefund.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>invoice/RecordRefund</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/RecordRefund"><meta name="groc-project-path" content="invoice/RecordRefund.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">invoice/RecordRefund.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="record-refund-sample">Record Refund Sample</h1>
|
||||
<p>This sample code demonstrate how you can record
|
||||
an invoice as refunded.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Invoice $invoice */</span>
|
||||
<span class="hljs-variable">$invoice</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'RecordPayment.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">RefundDetail</span>;
|
||||
|
||||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="record-object">Record Object</h3>
|
||||
<p>Create a RefundDetail object, and fill in the required fields
|
||||
You can use the new way of injecting json directly to the object.</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$refund</span> = <span class="hljs-keyword">new</span> RefundDetail(
|
||||
<span class="hljs-string">'{
|
||||
"date" : "2014-07-06 03:30:00 PST",
|
||||
"note" : "Refund provided by cash."
|
||||
}'</span>
|
||||
);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="record-refund-for-invoice">Record Refund for Invoice</h3>
|
||||
<p>Record a refund on invoice object by calling the
|
||||
<code>recordRefund</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">$refundStatus</span> = <span class="hljs-variable">$invoice</span>->recordRefund(<span class="hljs-variable">$refund</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Refund for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$refundStatus</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Refund for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$refund</span>, <span class="hljs-keyword">null</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$invoice</span>;</div></div></div></div></body></html>
|
||||
@@ -6,12 +6,7 @@ an invoice to the payer</p></div></div><div class="code"><div class="wrapper"><s
|
||||
<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-variable">$invoice</span>->getId(), <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>
|
||||
<span class="hljs-keyword">try</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();
|
||||
|
||||
27
sample/doc/invoice/RetrieveQRCode.html
Normal file
27
sample/doc/invoice/RetrieveQRCode.html
Normal file
@@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>invoice/RetrieveQRCode</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/RetrieveQRCode"><meta name="groc-project-path" content="invoice/RetrieveQRCode.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">invoice/RetrieveQRCode.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="retrieve-qr-code-for-invoice-sample">Retrieve QR Code for Invoice Sample</h1>
|
||||
<p>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.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Invoice $invoice */</span>
|
||||
<span class="hljs-variable">$invoice</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'SendInvoice.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-qr-code-of-sent-invoice">Retrieve QR Code of Sent Invoice</h3>
|
||||
<p>Retrieve QR Code of Sent Invoice by calling the
|
||||
<code>qrCode</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">$image</span> = Invoice::qrCode(<span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-keyword">array</span>(<span class="hljs-string">'height'</span> => <span class="hljs-string">'300'</span>, <span class="hljs-string">'width'</span> => <span class="hljs-string">'300'</span>), <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="optionally-save-to-file">Optionally Save to File</h3>
|
||||
<p>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</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$path</span> = <span class="hljs-variable">$image</span>->saveToFile(<span class="hljs-string">"images/sample.png"</span>);
|
||||
|
||||
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Retrieved QR Code for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Retrieved QR Code for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$image</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="show-the-image">Show the Image</h3>
|
||||
<p>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.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">echo</span> <span class="hljs-string">'<img src="data:image/png;base64,'</span>. <span class="hljs-variable">$image</span>->getImage() . <span class="hljs-string">'" alt="Invoice QR Code" />'</span>;</div></div></div></div></body></html>
|
||||
27
sample/doc/invoice/SearchInvoices.html
Normal file
27
sample/doc/invoice/SearchInvoices.html
Normal file
@@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>invoice/SearchInvoices</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/SearchInvoices"><meta name="groc-project-path" content="invoice/SearchInvoices.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">invoice/SearchInvoices.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="search-invoices-sample">Search Invoices Sample</h1>
|
||||
<p>This sample code demonstrate how you can
|
||||
search invoices from history.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Invoice $invoice */</span>
|
||||
<span class="hljs-variable">$invoice</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateInvoice.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">Search</span>;
|
||||
|
||||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="search-object">Search Object</h3>
|
||||
<p>Fill up your search criteria for Invoice search.
|
||||
Using the new way to inject raw json string to constructor</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$search</span> = <span class="hljs-keyword">new</span> Search(
|
||||
<span class="hljs-string">'{
|
||||
"start_invoice_date" : "2010-05-10 PST",
|
||||
"end_invoice_date" : "2019-05-11 PST",
|
||||
"page" : 1,
|
||||
"page_size" : 20,
|
||||
"total_count_required" : true
|
||||
}'</span>
|
||||
);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="search-invoices">Search Invoices</h3>
|
||||
<p>Retrieve the Invoice History object by calling the
|
||||
static <code>search</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::search(<span class="hljs-variable">$search</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Search Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Search Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$search</span>, <span class="hljs-variable">$invoices</span>);</div></div></div></div></body></html>
|
||||
@@ -5,12 +5,7 @@ a legitimate invoice to the payer</p></div></div><div class="code"><div class="w
|
||||
|
||||
<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-variable">$invoice</span>->getId(), <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>
|
||||
<span class="hljs-keyword">try</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> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
|
||||
18
sample/doc/invoice/UpdateInvoice.html
Normal file
18
sample/doc/invoice/UpdateInvoice.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>invoice/UpdateInvoice</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/UpdateInvoice"><meta name="groc-project-path" content="invoice/UpdateInvoice.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">invoice/UpdateInvoice.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="update-invoice-sample">Update Invoice Sample</h1>
|
||||
<p>This sample code demonstrate how you can update
|
||||
an invoice.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Invoice $invoice */</span>
|
||||
<span class="hljs-variable">$invoice</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateInvoice.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>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="update-invoice">Update Invoice</h3>
|
||||
<p>Lets update some information</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$invoice</span>->setInvoiceDate(<span class="hljs-string">"2014-11-16 PST"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>For Sample Purposes Only.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$request</span> = <span class="hljs-keyword">clone</span> <span class="hljs-variable">$invoice</span>;
|
||||
|
||||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="update-invoice">Update Invoice</h3>
|
||||
<p>Update an invoice by calling the invoice->update() 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>->update(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Invoice Updated"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Invoice Updated"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$invoice</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$invoice</span>;</div></div></div></div></body></html>
|
||||
@@ -102,10 +102,10 @@ try {
|
||||
// with a valid ApiContext (See bootstrap.php for more on `ApiContext`)
|
||||
$invoice->create($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
ResultPrinter::printError("Invoice Creation", "Invoice", null, $request, $ex);
|
||||
ResultPrinter::printError("Create Invoice", "Invoice", null, $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult("Invoice Creation", "Invoice", $invoice->getId(), $request, $invoice);
|
||||
ResultPrinter::printResult("Create Invoice", "Invoice", $invoice->getId(), $request, $invoice);
|
||||
|
||||
return $invoice;
|
||||
|
||||
27
sample/invoice/DeleteInvoice.php
Normal file
27
sample/invoice/DeleteInvoice.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
// # Delete Invoice Sample
|
||||
// This sample code demonstrate how you can delete
|
||||
// an invoice.
|
||||
|
||||
/** @var Invoice $invoice */
|
||||
$invoice = require 'CreateInvoice.php';
|
||||
|
||||
use PayPal\Api\Invoice;
|
||||
use PayPal\Api\CancelNotification;
|
||||
|
||||
try {
|
||||
|
||||
// ### Delete Invoice
|
||||
// Delete invoice object by calling the
|
||||
// `delete` method
|
||||
// on the Invoice class by passing a valid
|
||||
// notification object
|
||||
// (See bootstrap.php for more on `ApiContext`)
|
||||
$deleteStatus = $invoice->delete($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
ResultPrinter::printError("Delete Invoice", "Invoice", null, $deleteStatus, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult("Delete Invoice", "Invoice", $invoice->getId(), null, null);
|
||||
@@ -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::getAll(array('page' => 0, 'page_size' => 4, 'total_count_required' => true), $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);
|
||||
|
||||
39
sample/invoice/RecordPayment.php
Normal file
39
sample/invoice/RecordPayment.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
// # Record Payment Sample
|
||||
// This sample code demonstrate how you can record
|
||||
// an invoice as paid.
|
||||
|
||||
/** @var Invoice $invoice */
|
||||
$invoice = require 'SendInvoice.php';
|
||||
|
||||
use PayPal\Api\Invoice;
|
||||
use PayPal\Api\PaymentDetail;
|
||||
|
||||
try {
|
||||
// ### Record Object
|
||||
// Create a PaymentDetail object, and fill in the required fields
|
||||
// You can use the new way of injecting json directly to the object.
|
||||
$record = new PaymentDetail(
|
||||
'{
|
||||
"method" : "CASH",
|
||||
"date" : "2014-07-06 03:30:00 PST",
|
||||
"note" : "Cash received."
|
||||
}'
|
||||
);
|
||||
|
||||
// ### Record Payment for Invoice
|
||||
// Record a payment on invoice object by calling the
|
||||
// `recordPayment` method
|
||||
// on the Invoice class by passing a valid
|
||||
// notification object
|
||||
// (See bootstrap.php for more on `ApiContext`)
|
||||
$recordStatus = $invoice->recordPayment($record, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
ResultPrinter::printError("Payment for Invoice", "Invoice", null, $recordStatus, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult("Payment for Invoice", "Invoice", $invoice->getId(), $record, null);
|
||||
|
||||
return $invoice;
|
||||
38
sample/invoice/RecordRefund.php
Normal file
38
sample/invoice/RecordRefund.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
// # Record Refund Sample
|
||||
// This sample code demonstrate how you can record
|
||||
// an invoice as refunded.
|
||||
|
||||
/** @var Invoice $invoice */
|
||||
$invoice = require 'RecordPayment.php';
|
||||
|
||||
use PayPal\Api\Invoice;
|
||||
use PayPal\Api\RefundDetail;
|
||||
|
||||
try {
|
||||
// ### Record Object
|
||||
// Create a RefundDetail object, and fill in the required fields
|
||||
// You can use the new way of injecting json directly to the object.
|
||||
$refund = new RefundDetail(
|
||||
'{
|
||||
"date" : "2014-07-06 03:30:00 PST",
|
||||
"note" : "Refund provided by cash."
|
||||
}'
|
||||
);
|
||||
|
||||
// ### Record Refund for Invoice
|
||||
// Record a refund on invoice object by calling the
|
||||
// `recordRefund` method
|
||||
// on the Invoice class by passing a valid
|
||||
// notification object
|
||||
// (See bootstrap.php for more on `ApiContext`)
|
||||
$refundStatus = $invoice->recordRefund($refund, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
ResultPrinter::printError("Refund for Invoice", "Invoice", null, $refundStatus, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult("Refund for Invoice", "Invoice", $invoice->getId(), $refund, null);
|
||||
|
||||
return $invoice;
|
||||
@@ -37,5 +37,5 @@ ResultPrinter::printResult("Retrieved QR Code for Invoice", "Invoice", $invoice-
|
||||
// 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" />';
|
||||
echo '<img src="data:image/png;base64,'. $image->getImage() . '" alt="Invoice QR Code" />';
|
||||
|
||||
|
||||
36
sample/invoice/SearchInvoices.php
Normal file
36
sample/invoice/SearchInvoices.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
// # Search Invoices Sample
|
||||
// This sample code demonstrate how you can
|
||||
// search invoices from history.
|
||||
|
||||
/** @var Invoice $invoice */
|
||||
$invoice = require 'CreateInvoice.php';
|
||||
use PayPal\Api\Invoice;
|
||||
use PayPal\Api\Search;
|
||||
|
||||
try {
|
||||
// ### Search Object
|
||||
// Fill up your search criteria for Invoice search.
|
||||
// Using the new way to inject raw json string to constructor
|
||||
$search = new Search(
|
||||
'{
|
||||
"start_invoice_date" : "2010-05-10 PST",
|
||||
"end_invoice_date" : "2019-05-11 PST",
|
||||
"page" : 1,
|
||||
"page_size" : 20,
|
||||
"total_count_required" : true
|
||||
}'
|
||||
);
|
||||
|
||||
// ### Search Invoices
|
||||
// Retrieve the Invoice History object by calling the
|
||||
// static `search` method on the Invoice class.
|
||||
// Refer the method doc for valid values for keys
|
||||
// (See bootstrap.php for more on `ApiContext`)
|
||||
$invoices = Invoice::search($search, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
ResultPrinter::printError("Search Invoice", "Invoice", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
ResultPrinter::printResult("Search Invoice", "Invoice", null, $search, $invoices);
|
||||
BIN
sample/invoice/images/sample.png
Normal file
BIN
sample/invoice/images/sample.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
Reference in New Issue
Block a user