From bbd016beb14e1e131df7f8be05e4cb962a6a61a2 Mon Sep 17 00:00:00 2001 From: jaypatel512 and sdcoffey Date: Mon, 9 Jan 2017 11:08:42 -0600 Subject: [PATCH] New samples demonstrating GetThirdPartyInvoice - Fixes #757. --- sample/doc/assets/behavior.js | 376 +++--------------- .../doc/invoice/CreateThirdPartyInvoice.html | 27 +- sample/doc/invoice/GetInvoice.html | 2 +- sample/doc/invoice/GetThirdPartyInvoice.html | 21 + sample/doc/invoice/SearchInvoices.html | 2 +- sample/doc/payments/AuthorizationCapture.html | 2 +- .../payments/CreatePaymentUsingPayPal.html | 2 +- sample/doc/payments/GetAuthorization.html | 2 +- sample/doc/payments/GetPayment.html | 2 +- sample/index.php | 11 + sample/invoice/CreateThirdPartyInvoice.php | 9 +- sample/invoice/GetThirdPartyInvoice.php | 38 ++ 12 files changed, 149 insertions(+), 345 deletions(-) create mode 100644 sample/doc/invoice/GetThirdPartyInvoice.html create mode 100644 sample/invoice/GetThirdPartyInvoice.php diff --git a/sample/doc/assets/behavior.js b/sample/doc/assets/behavior.js index 6716c04..694c5af 100644 --- a/sample/doc/assets/behavior.js +++ b/sample/doc/assets/behavior.js @@ -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 } ] }, { diff --git a/sample/doc/invoice/CreateThirdPartyInvoice.html b/sample/doc/invoice/CreateThirdPartyInvoice.html index ae2b318..fe4fb5c 100644 --- a/sample/doc/invoice/CreateThirdPartyInvoice.html +++ b/sample/doc/invoice/CreateThirdPartyInvoice.html @@ -1,7 +1,7 @@ invoice/CreateThirdPartyInvoice
invoice/CreateThirdPartyInvoice.php
<?php

Create Third Party Invoice Sample

This sample code demonstrate how you can create third party invoice on someone else's behalf. This requires using Obtain User's Consent to fetch the refresh token of the third party merchant. Please look at http://paypal.github.io/PayPal-PHP-SDK/sample/doc/lipp/ObtainUserConsent.html 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 http://paypal.github.io/PayPal-PHP-SDK/sample/doc/lipp/GetUserInfo.html 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 http://paypal.github.io/PayPal-PHP-SDK/sample/doc/lipp/GetUserInfo.html for more info. Please make sure to use merchantInfo.email as the email address of the third party.

require __DIR__ . '/../bootstrap.php'; use PayPal\Api\BillingInfo; use PayPal\Api\Currency; @@ -10,9 +10,10 @@ Please make sure to use merchantInfo.email as the email address of use PayPal\Api\InvoiceItem; use PayPal\Api\MerchantInfo; use PayPal\Api\PaymentTerm; -use PayPal\Api\ShippingInfo; - -$invoice = new Invoice();

Invoice Info

+use PayPal\Api\ShippingInfo;
$refreshToken = "SCNWVZfdg43XaOmoEicazpkXyda32CGnP208EkuQ_QBIrXCYMhlvORFHHyoXPT0VbEMIHYVJEm0gVf1Vf72YgJzPScBenKoVPq__y1QRT7wwJo3WYADwUW4Q5ic";

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 http://paypal.github.io/PayPal-PHP-SDK/sample/doc/lipp/GetUserInfo.html for more info.

$thirdPartyMerchant = "developer@sample.com"; +

Step 3. Create an invoice object. +Make sure to set $invoice->getMerchantInfo()->setEmail() with the third party merchant email you retrieved from Step 2.

$invoice = new Invoice();

Invoice Info

Fill in all the information that is required for invoice APIs

$invoice ->setMerchantInfo(new MerchantInfo()) @@ -20,7 +21,7 @@ required for invoice APIs

->setNote("Medical Invoice 16 Jul, 2013 PST") ->setPaymentTerm(new PaymentTerm());

Merchant Info

A resource representing merchant information that can be -used to identify merchant

$invoice->getMerchantInfo()

This would be the email address of third party merchant.

->setEmail("developer@sample.com") +used to identify merchant

$invoice->getMerchantInfo()

This would be the email address of third party merchant.

->setEmail($thirdPartyMerchant) ->setFirstName("Dennis") ->setLastName("Doctor") ->setbusinessName("Medical Professionals, LLC") @@ -58,18 +59,18 @@ detailed breakdown of invoice

5); $invoice->getPaymentTerm() - ->setTermType("NET_45");

For Sample Purposes Only.

$request = clone $invoice;
$refreshToken = "SCNWVZfdg43XaOmoEicazpkXyda32CGnP208EkuQ_QBIrXCYMhlvORFHHyoXPT0VbEMIHYVJEm0gVf1Vf72YgJzPScBenKoVPq__y1QRT7wwJo3WYADwUW4Q5ic"; + ->setTermType("NET_45");

For Sample Purposes Only.

$request = clone $invoice; -try {

Use Refresh Token. MAKE SURE TO update MerchantInfo.Email based on

$invoice->updateAccessToken($refreshToken, $apiContext);

Create Invoice

+ +try {

Use Refresh Token obtained from Step 1.

$invoice->updateAccessToken($refreshToken, $apiContext);

Create Invoice

Create an invoice by calling the invoice->create() method with a valid ApiContext (See bootstrap.php for more on ApiContext)

$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); +} catch (Exception $ex) {

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

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);

Send Invoice

try {

Send Invoice

$invoice->send($apiContext); +}

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printResult("Create Third Party Invoice", "Invoice", $invoice->getId(), $request, $invoice);

Send Invoice

try {

Send Invoice

$invoice->send($apiContext); $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); +} catch (Exception $ex) {

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

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); +}

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printResult("Send Third Party Invoice", "Invoice", $invoice->getId(), $request, $invoice); - -return $invoice;
+return $invoice; \ No newline at end of file diff --git a/sample/doc/invoice/GetInvoice.html b/sample/doc/invoice/GetInvoice.html index eeec8bf..934ca74 100644 --- a/sample/doc/invoice/GetInvoice.html +++ b/sample/doc/invoice/GetInvoice.html @@ -15,4 +15,4 @@ Invoice ID exit(1); }

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printResult("Get Invoice", "Invoice", $invoice->getId(), $invoiceId, $invoice); -return $invoice;
+return $invoice; \ No newline at end of file diff --git a/sample/doc/invoice/GetThirdPartyInvoice.html b/sample/doc/invoice/GetThirdPartyInvoice.html new file mode 100644 index 0000000..0bcd956 --- /dev/null +++ b/sample/doc/invoice/GetThirdPartyInvoice.html @@ -0,0 +1,21 @@ +invoice/GetThirdPartyInvoice
invoice/GetThirdPartyInvoice.php
<?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();
$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;
\ No newline at end of file diff --git a/sample/doc/invoice/SearchInvoices.html b/sample/doc/invoice/SearchInvoices.html index 8b22153..d9735eb 100644 --- a/sample/doc/invoice/SearchInvoices.html +++ b/sample/doc/invoice/SearchInvoices.html @@ -22,4 +22,4 @@ Refer the method doc for valid values for keys (See bootstrap.php for more on ApiContext)

$invoices = Invoice::search($search, $apiContext); } catch (Exception $ex) {

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printError("Search Invoice", "Invoice", null, null, $ex); exit(1); -}

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printResult("Search Invoice", "Invoice", null, $search, $invoices);
+}

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printResult("Search Invoice", "Invoice", null, $search, $invoices);
\ No newline at end of file diff --git a/sample/doc/payments/AuthorizationCapture.html b/sample/doc/payments/AuthorizationCapture.html index d4d29c5..e7d996a 100644 --- a/sample/doc/payments/AuthorizationCapture.html +++ b/sample/doc/payments/AuthorizationCapture.html @@ -23,4 +23,4 @@ with a valid ApiContext (See bootstrap.php for more on ApiContext)< exit(1); }

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printResult("Capture Payment", "Authorization", $getCapture->getId(), $capture, $getCapture); -return $getCapture;
+return $getCapture; \ No newline at end of file diff --git a/sample/doc/payments/CreatePaymentUsingPayPal.html b/sample/doc/payments/CreatePaymentUsingPayPal.html index dbad9b3..3f2f985 100644 --- a/sample/doc/payments/CreatePaymentUsingPayPal.html +++ b/sample/doc/payments/CreatePaymentUsingPayPal.html @@ -74,4 +74,4 @@ for payment approval

$approvalUrl = $payment->getApprovalLink();

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printResult("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", "<a href='$approvalUrl' >$approvalUrl</a>", $request, $payment); -return $payment;
+return $payment; \ No newline at end of file diff --git a/sample/doc/payments/GetAuthorization.html b/sample/doc/payments/GetAuthorization.html index cc8aa03..82401f5 100644 --- a/sample/doc/payments/GetAuthorization.html +++ b/sample/doc/payments/GetAuthorization.html @@ -13,4 +13,4 @@ The return object contains the authorization state.

exit(1); }

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printResult("Get Authorization", "Authorization", $authorizationId, null, $result); -return $result;
+return $result; \ No newline at end of file diff --git a/sample/doc/payments/GetPayment.html b/sample/doc/payments/GetPayment.html index e4bb1a2..d8ed527 100644 --- a/sample/doc/payments/GetPayment.html +++ b/sample/doc/payments/GetPayment.html @@ -20,4 +20,4 @@ Payment ID exit(1); }

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printResult("Get Payment", "Payment", $payment->getId(), null, $payment); -return $payment;
+return $payment; \ No newline at end of file diff --git a/sample/index.php b/sample/index.php index 77b56c3..f8f02fc 100644 --- a/sample/index.php +++ b/sample/index.php @@ -1218,6 +1218,17 @@ if (PHP_SAPI == 'cli') { +
  • +
    +
    Get Third Party Invoice
    + +
    +
  • Send an Invoice
    diff --git a/sample/invoice/CreateThirdPartyInvoice.php b/sample/invoice/CreateThirdPartyInvoice.php index 5a4bbed..0c1c2f4 100644 --- a/sample/invoice/CreateThirdPartyInvoice.php +++ b/sample/invoice/CreateThirdPartyInvoice.php @@ -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; diff --git a/sample/invoice/GetThirdPartyInvoice.php b/sample/invoice/GetThirdPartyInvoice.php new file mode 100644 index 0000000..0c075ea --- /dev/null +++ b/sample/invoice/GetThirdPartyInvoice.php @@ -0,0 +1,38 @@ +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;