New samples demonstrating GetThirdPartyInvoice

- Fixes #757.
This commit is contained in:
jaypatel512 and sdcoffey
2017-01-09 11:08:42 -06:00
parent 7e96a3c8e8
commit bbd016beb1
12 changed files with 149 additions and 345 deletions

View File

@@ -30,29 +30,7 @@ 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
"pageTitle": "billing/CreateBillingAgreementWithCreditCard",
"title": "CreateBillingAgreementWithCreditCard"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Create Billing Agreement with Credit Card as Payment Source",
"slug": "create-billing-agreement-with-credit-card-as-payment-source"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "Create Agreement",
"slug": "create-agreement"
},
"depth": 3
}
]
}
]
"depth": 2
}, {
"type": "file",
"data": {
@@ -505,6 +483,54 @@ 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
"title": "GetNextInvoiceNumber"
},
"depth": 2
}, {
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/paypal/github/PayPal-PHP-SDK/sample/invoice/GetThirdPartyInvoice.php",
"projectPath": "invoice/GetThirdPartyInvoice.php",
"targetPath": "invoice/GetThirdPartyInvoice",
"pageTitle": "invoice/GetThirdPartyInvoice",
"title": "GetThirdPartyInvoice"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Get Third Invoice Sample",
"slug": "get-third-invoice-sample"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "Step 2",
"slug": "step-2"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Retrieve Invoice",
"slug": "retrieve-invoice"
},
"depth": 3
}
]
}
]
}, {
"type": "file",
"data": {
@@ -1138,93 +1164,7 @@ 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
"pageTitle": "payments/CreatePayment",
"title": "CreatePayment"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "CreatePaymentSample",
"slug": "createpaymentsample"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "PaymentCard",
"slug": "paymentcard"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "FundingInstrument",
"slug": "fundinginstrument"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Payer",
"slug": "payer"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Itemized information",
"slug": "itemized-information"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Additional payment details",
"slug": "additional-payment-details"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Amount",
"slug": "amount"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Transaction",
"slug": "transaction"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Payment",
"slug": "payment"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Create Payment",
"slug": "create-payment"
},
"depth": 3
}
]
}
]
"depth": 2
}, {
"type": "file",
"data": {
@@ -1278,101 +1218,7 @@ 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
"pageTitle": "payments/CreateThirdPartyPayment",
"title": "CreateThirdPartyPayment"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Create Third Party Payment using PayPal as payment method",
"slug": "create-third-party-payment-using-paypal-as-payment-method"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "Payer",
"slug": "payer"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Itemized information",
"slug": "itemized-information"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Additional payment details",
"slug": "additional-payment-details"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Amount",
"slug": "amount"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Payee",
"slug": "payee"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Transaction",
"slug": "transaction"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Redirect urls",
"slug": "redirect-urls"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Payment",
"slug": "payment"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Create Payment",
"slug": "create-payment"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Get redirect url",
"slug": "get-redirect-url"
},
"depth": 3
}
]
}
]
"depth": 2
}, {
"type": "file",
"data": {
@@ -1444,29 +1290,7 @@ 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
"pageTitle": "payments/GetPayment",
"title": "GetPayment"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "GetPaymentSample",
"slug": "getpaymentsample"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "Retrieve payment",
"slug": "retrieve-payment"
},
"depth": 3
}
]
}
]
"depth": 2
}, {
"type": "file",
"data": {
@@ -1664,29 +1488,7 @@ 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
"pageTitle": "payments/RefundCapture",
"title": "RefundCapture"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Refund Capture Sample",
"slug": "refund-capture-sample"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "Refund",
"slug": "refund"
},
"depth": 3
}
]
}
]
"depth": 2
}, {
"type": "file",
"data": {
@@ -1850,37 +1652,7 @@ 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
"pageTitle": "sale/GetSale",
"title": "GetSale"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Get Sale sample",
"slug": "get-sale-sample"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "Get Sale From Created Payment",
"slug": "get-sale-from-created-payment"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Retrieve the sale object",
"slug": "retrieve-the-sale-object"
},
"depth": 3
}
]
}
]
"depth": 2
}, {
"type": "file",
"data": {
@@ -1898,45 +1670,7 @@ 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
"pageTitle": "sale/RefundSale",
"title": "RefundSale"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Sale Refund Sample",
"slug": "sale-refund-sample"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "Refund amount",
"slug": "refund-amount"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Refund object",
"slug": "refund-object"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Sale",
"slug": "sale"
},
"depth": 3
}
]
}
]
"depth": 2
}
]
}, {

View File

@@ -1,7 +1,7 @@
<!DOCTYPE html><html lang="en"><head><title>invoice/CreateThirdPartyInvoice</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/CreateThirdPartyInvoice"><meta name="groc-project-path" content="invoice/CreateThirdPartyInvoice.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/CreateThirdPartyInvoice.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="create-third-party-invoice-sample">Create Third Party Invoice Sample</h1>
<p>This sample code demonstrate how you can create third party invoice on someone else&#39;s behalf.
This requires using <code>Obtain User&#39;s Consent</code> to fetch the refresh token of the third party merchant. Please look at <a href="http://paypal.github.io/PayPal-PHP-SDK/sample/doc/lipp/ObtainUserConsent.html">http://paypal.github.io/PayPal-PHP-SDK/sample/doc/lipp/ObtainUserConsent.html</a> for more info.
You need the email address of the third party. This can be retrieved using the refresh token obtained from previous call. Please refere to <a href="http://paypal.github.io/PayPal-PHP-SDK/sample/doc/lipp/GetUserInfo.html">http://paypal.github.io/PayPal-PHP-SDK/sample/doc/lipp/GetUserInfo.html</a> for more info.
You need the email address of the third party. This can be retrieved using the refresh token obtained from previous call. Please refer to <a href="http://paypal.github.io/PayPal-PHP-SDK/sample/doc/lipp/GetUserInfo.html">http://paypal.github.io/PayPal-PHP-SDK/sample/doc/lipp/GetUserInfo.html</a> for more info.
Please make sure to use <code>merchantInfo.email</code> as the email address of the third party.</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">BillingInfo</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>;
@@ -10,9 +10,10 @@ Please make sure to use <code>merchantInfo.email</code> as the email address of
<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">MerchantInfo</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>
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">ShippingInfo</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Step 1. This would be refresh token retrieved from <a href="http://paypal.github.io/PayPal-PHP-SDK/sample/doc/lipp/ObtainUserConsent.html">http://paypal.github.io/PayPal-PHP-SDK/sample/doc/lipp/ObtainUserConsent.html</a></p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$refreshToken</span> = <span class="hljs-string">"SCNWVZfdg43XaOmoEicazpkXyda32CGnP208EkuQ_QBIrXCYMhlvORFHHyoXPT0VbEMIHYVJEm0gVf1Vf72YgJzPScBenKoVPq__y1QRT7wwJo3WYADwUW4Q5ic"</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Step 2. Get the email address of third party merchant who you want to create this invoice for.
This can be retrieved using the refresh token obtained from previous call. Please refer to <a href="http://paypal.github.io/PayPal-PHP-SDK/sample/doc/lipp/GetUserInfo.html">http://paypal.github.io/PayPal-PHP-SDK/sample/doc/lipp/GetUserInfo.html</a> for more info.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$thirdPartyMerchant</span> = <span class="hljs-string">"developer@sample.com"</span>;
</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Step 3. Create an invoice object.
Make sure to set <code>$invoice-&gt;getMerchantInfo()-&gt;setEmail()</code> with the third party merchant email you retrieved from Step 2.</p></div></div><div class="code"><div class="wrapper"><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>
-&gt;setMerchantInfo(<span class="hljs-keyword">new</span> MerchantInfo())
@@ -20,7 +21,7 @@ required for invoice APIs</p></div></div><div class="code"><div class="wrapper">
-&gt;setNote(<span class="hljs-string">"Medical Invoice 16 Jul, 2013 PST"</span>)
-&gt;setPaymentTerm(<span class="hljs-keyword">new</span> PaymentTerm());</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>-&gt;getMerchantInfo()</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>This would be the email address of third party merchant.</p></div></div><div class="code"><div class="wrapper"> -&gt;setEmail(<span class="hljs-string">"developer@sample.com"</span>)
used to identify merchant</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$invoice</span>-&gt;getMerchantInfo()</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>This would be the email address of third party merchant.</p></div></div><div class="code"><div class="wrapper"> -&gt;setEmail(<span class="hljs-variable">$thirdPartyMerchant</span>)
-&gt;setFirstName(<span class="hljs-string">"Dennis"</span>)
-&gt;setLastName(<span class="hljs-string">"Doctor"</span>)
-&gt;setbusinessName(<span class="hljs-string">"Medical Professionals, LLC"</span>)
@@ -58,18 +59,18 @@ detailed breakdown of invoice</p></div></div><div class="code"><div class="wrapp
-&gt;setValue(<span class="hljs-number">5</span>);
<span class="hljs-variable">$invoice</span>-&gt;getPaymentTerm()
-&gt;setTermType(<span class="hljs-string">"NET_45"</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>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>This would be refresh token retrieved from <a href="http://paypal.github.io/PayPal-PHP-SDK/sample/doc/lipp/ObtainUserConsent.html">http://paypal.github.io/PayPal-PHP-SDK/sample/doc/lipp/ObtainUserConsent.html</a></p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$refreshToken</span> = <span class="hljs-string">"SCNWVZfdg43XaOmoEicazpkXyda32CGnP208EkuQ_QBIrXCYMhlvORFHHyoXPT0VbEMIHYVJEm0gVf1Vf72YgJzPScBenKoVPq__y1QRT7wwJo3WYADwUW4Q5ic"</span>;
-&gt;setTermType(<span class="hljs-string">"NET_45"</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="use-refresh-token-make-sure-to-update-merchantinfo-email-based-on">Use Refresh Token. MAKE SURE TO update <code>MerchantInfo.Email</code> based on</h3></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$invoice</span>-&gt;updateAccessToken(<span class="hljs-variable">$refreshToken</span>, <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-invoice">Create Invoice</h3>
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="use-refresh-token-obtained-from-step-1">Use Refresh Token obtained from Step 1.</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="hljs-variable">$invoice</span>-&gt;updateAccessToken(<span class="hljs-variable">$refreshToken</span>, <span class="hljs-variable">$apiContext</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-&gt;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>-&gt;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>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> 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">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Create Third Party 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>);
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Create Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>-&gt;getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$invoice</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="send-invoice">Send Invoice</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><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></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="hljs-variable">$invoice</span>-&gt;send(<span class="hljs-variable">$apiContext</span>);
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Create Third Party Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>-&gt;getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$invoice</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="send-invoice">Send Invoice</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><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></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="hljs-variable">$invoice</span>-&gt;send(<span class="hljs-variable">$apiContext</span>);
<span class="hljs-variable">$invoice</span> = Invoice::get(<span class="hljs-variable">$invoice</span>-&gt;getId(), <span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Send 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">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Send Third Party 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>);
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper">ResultPrinter::printResult(<span class="hljs-string">"Send Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>-&gt;getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$invoice</span>);
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper">ResultPrinter::printResult(<span class="hljs-string">"Send Third Party Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>-&gt;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>
<span class="hljs-keyword">return</span> <span class="hljs-variable">$invoice</span>;</div></div></div></div></body></html>

View File

@@ -15,4 +15,4 @@ Invoice ID
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Get Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>-&gt;getId(), <span class="hljs-variable">$invoiceId</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>
<span class="hljs-keyword">return</span> <span class="hljs-variable">$invoice</span>;</div></div></div></div></body></html>

View File

@@ -0,0 +1,21 @@
<!DOCTYPE html><html lang="en"><head><title>invoice/GetThirdPartyInvoice</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/GetThirdPartyInvoice"><meta name="groc-project-path" content="invoice/GetThirdPartyInvoice.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/GetThirdPartyInvoice.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="get-third-invoice-sample">Get Third Invoice Sample</h1>
<p>This sample code demonstrate how you can retrieve
a third party invoice.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/** <span class="hljs-doctag">@var</span> Invoice $invoice */</span>
<span class="hljs-variable">$invoice</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateThirdPartyInvoice.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-variable">$invoice</span>-&gt;getId();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Step 1. This would be refresh token retrieved from <a href="http://paypal.github.io/PayPal-PHP-SDK/sample/doc/lipp/ObtainUserConsent.html">http://paypal.github.io/PayPal-PHP-SDK/sample/doc/lipp/ObtainUserConsent.html</a></p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$refreshToken</span> = <span class="hljs-string">"SCNWVZfdg43XaOmoEicazpkXyda32CGnP208EkuQ_QBIrXCYMhlvORFHHyoXPT0VbEMIHYVJEm0gVf1Vf72YgJzPScBenKoVPq__y1QRT7wwJo3WYADwUW4Q5ic"</span>;
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="step-2">Step 2</h3>
<p>Update your apiContext with refresh token obtained from Step 1.</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$apiContext</span>-&gt;getCredential()-&gt;updateAccessToken(<span class="hljs-variable">$apiContext</span>-&gt;getConfig(), <span class="hljs-variable">$refreshToken</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>)
Similar calls can be done to search invoices, delete, and update.</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$retrievedInvoice</span> = Invoice::get(<span class="hljs-variable">$invoiceId</span>, <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Get Third Party Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$retrievedInvoice</span>-&gt;getId(), <span class="hljs-variable">$invoiceId</span>, <span class="hljs-variable">$retrievedInvoice</span>);
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Get Third Party Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoiceId</span>, <span class="hljs-variable">$invoiceId</span>, <span class="hljs-variable">$ex</span>);
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}
<span class="hljs-keyword">return</span> <span class="hljs-variable">$retrievedInvoice</span>;</div></div></div></div></body></html>

View File

@@ -22,4 +22,4 @@ 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>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> 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>);
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> 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>
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> 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>

View File

@@ -23,4 +23,4 @@ with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)<
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Capture Payment"</span>, <span class="hljs-string">"Authorization"</span>, <span class="hljs-variable">$getCapture</span>-&gt;getId(), <span class="hljs-variable">$capture</span>, <span class="hljs-variable">$getCapture</span>);
<span class="hljs-keyword">return</span> <span class="hljs-variable">$getCapture</span>;</div></div></div></div></body></html>
<span class="hljs-keyword">return</span> <span class="hljs-variable">$getCapture</span>;</div></div></div></div></body></html>

View File

@@ -74,4 +74,4 @@ for payment approval</p></div></div><div class="code"><div class="wrapper"><span
the buyer to. Retrieve the url from the $payment-&gt;getApprovalLink()
method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$payment</span>-&gt;getApprovalLink();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Created Payment Using PayPal. Please visit the URL to Approve."</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-string">"&lt;a href='$approvalUrl' &gt;$approvalUrl&lt;/a&gt;"</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$payment</span>);
<span class="hljs-keyword">return</span> <span class="hljs-variable">$payment</span>;</div></div></div></div></body></html>
<span class="hljs-keyword">return</span> <span class="hljs-variable">$payment</span>;</div></div></div></div></body></html>

View File

@@ -13,4 +13,4 @@ The return object contains the authorization state.</p></div></div><div class="c
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Get Authorization"</span>, <span class="hljs-string">"Authorization"</span>, <span class="hljs-variable">$authorizationId</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$result</span>);
<span class="hljs-keyword">return</span> <span class="hljs-variable">$result</span>;</div></div></div></div></body></html>
<span class="hljs-keyword">return</span> <span class="hljs-variable">$result</span>;</div></div></div></div></body></html>

View File

@@ -20,4 +20,4 @@ Payment ID
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Get Payment"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-variable">$payment</span>-&gt;getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$payment</span>);
<span class="hljs-keyword">return</span> <span class="hljs-variable">$payment</span>;</div></div></div></div></body></html>
<span class="hljs-keyword">return</span> <span class="hljs-variable">$payment</span>;</div></div></div></div></body></html>

View File

@@ -1218,6 +1218,17 @@ if (PHP_SAPI == 'cli') {
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-8"><h5>Get Third Party Invoice</h5></div>
<div class="col-md-4">
<a href="invoice/GetThirdPartyInvoice.php" class="btn btn-primary pull-left execute"> Try It <i
class="fa fa-play-circle-o"></i></a>
<a href="doc/invoice/GetThirdPartyInvoice.html" class="btn btn-default pull-right">Source <i
class="fa fa-file-code-o"></i></a>
</div>
</div>
</li>
<li class="list-group-item">
<div class="row">
<div class="col-md-8"><h5>Send an Invoice</h5></div>

View File

@@ -105,12 +105,12 @@ try {
$invoice->create($apiContext);
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Create Invoice", "Invoice", null, $request, $ex);
ResultPrinter::printError("Create Third Party Invoice", "Invoice", null, $request, $ex);
exit(1);
}
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Create Invoice", "Invoice", $invoice->getId(), $request, $invoice);
ResultPrinter::printResult("Create Third Party Invoice", "Invoice", $invoice->getId(), $request, $invoice);
// ### Send Invoice
@@ -121,12 +121,11 @@ 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("Send Invoice", "Invoice", null, $request, $ex);
ResultPrinter::printError("Send Third Party Invoice", "Invoice", null, $request, $ex);
exit(1);
}
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Send Invoice", "Invoice", $invoice->getId(), $request, $invoice);
ResultPrinter::printResult("Send Third Party Invoice", "Invoice", $invoice->getId(), $request, $invoice);
return $invoice;

View File

@@ -0,0 +1,38 @@
<?php
// # Get Third Invoice Sample
// This sample code demonstrate how you can retrieve
// a third party invoice.
/** @var Invoice $invoice */
$invoice = require 'CreateThirdPartyInvoice.php';
use PayPal\Api\Invoice;
$invoiceId = $invoice->getId();
// Step 1. This would be refresh token retrieved from http://paypal.github.io/PayPal-PHP-SDK/sample/doc/lipp/ObtainUserConsent.html
$refreshToken = "SCNWVZfdg43XaOmoEicazpkXyda32CGnP208EkuQ_QBIrXCYMhlvORFHHyoXPT0VbEMIHYVJEm0gVf1Vf72YgJzPScBenKoVPq__y1QRT7wwJo3WYADwUW4Q5ic";
try {
// ### Step 2
// Update your apiContext with refresh token obtained from Step 1.
$apiContext->getCredential()->updateAccessToken($apiContext->getConfig(), $refreshToken);
// ### 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`)
// Similar calls can be done to search invoices, delete, and update.
$retrievedInvoice = Invoice::get($invoiceId, $apiContext);
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Get Third Party Invoice", "Invoice", $retrievedInvoice->getId(), $invoiceId, $retrievedInvoice);
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Get Third Party Invoice", "Invoice", $invoiceId, $invoiceId, $ex);
exit(1);
}
return $retrievedInvoice;