diff --git a/lib/PayPal/Api/BillingInfo.php b/lib/PayPal/Api/BillingInfo.php index 57d15ea..c1eca2d 100644 --- a/lib/PayPal/Api/BillingInfo.php +++ b/lib/PayPal/Api/BillingInfo.php @@ -140,7 +140,7 @@ class BillingInfo extends PayPalModel /** * The language in which the email was sent to the payer. Used only when the payer does not have a PayPal account. - * Valid Values: ["da_DK", "de_DE", "en_AU", "en_GB", "en_US", "es_ES", "es_XC", "fr_CA", "fr_FR", "fr_XC", "he_IL", "id_ID", "it_IT", "ja_JP", "nl_NL", "no_NO", "pl_PL", "pt_BR", "pt_PT", "ru_RU", "sv_SE", "th_TH", "zh_CN", "zh_HK", "zh_TW", "zh_XC"] + * Valid Values: ["da_DK", "de_DE", "en_AU", "en_GB", "en_US", "es_ES", "es_XC", "fr_CA", "fr_FR", "fr_XC", "he_IL", "id_ID", "it_IT", "ja_JP", "nl_NL", "no_NO", "pl_PL", "pt_BR", "pt_PT", "ru_RU", "sv_SE", "th_TH", "tr_TR", "zh_CN", "zh_HK", "zh_TW", "zh_XC"] * * @param string $language * diff --git a/lib/PayPal/Api/Invoice.php b/lib/PayPal/Api/Invoice.php index 6db360f..37efa26 100644 --- a/lib/PayPal/Api/Invoice.php +++ b/lib/PayPal/Api/Invoice.php @@ -1190,7 +1190,7 @@ class Invoice extends PayPalResourceModel } /** - * Fully updates an invoice by passing the invoice ID to the request URI. In addition, pass a complete invoice object in the request JSON. Does not support partial updates. + * Fully updates an invoice by passing the invoice ID to the request URI. In addition, pass a complete invoice object in the request JSON. Partial updates are not supported. * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls @@ -1213,7 +1213,7 @@ class Invoice extends PayPalResourceModel } /** - * Deletes an invoice, by ID. + * Delete a particular invoice by passing the invoice ID to the request URI. * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls @@ -1234,6 +1234,52 @@ class Invoice extends PayPalResourceModel return true; } + /** + * Delete external payment. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function deleteExternalPayment($transactionId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($transactionId, "TransactionId"); + $payLoad = ""; + self::executeCall( + "/v1/invoicing/invoices/{$this->getId()}/payment-records/{$transactionId}", + "DELETE", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * Delete external refund. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function deleteExternalRefund($transactionId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($transactionId, "TransactionId"); + $payLoad = ""; + self::executeCall( + "/v1/invoicing/invoices/{$this->getId()}/refund-records/{$transactionId}", + "DELETE", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + /** * Generate a QR code for an invoice by passing the invoice ID to the request URI. The request generates a QR code that is 500 pixels in width and height. You can change the dimensions of the returned code by specifying optional query parameters. * @@ -1269,7 +1315,7 @@ class Invoice extends PayPalResourceModel } /** - * Generate the successive invoice number for the merchant. + * Generates the successive invoice number. * * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls diff --git a/lib/PayPal/Api/InvoiceItem.php b/lib/PayPal/Api/InvoiceItem.php index 08811c3..ee93e3c 100644 --- a/lib/PayPal/Api/InvoiceItem.php +++ b/lib/PayPal/Api/InvoiceItem.php @@ -80,7 +80,7 @@ class InvoiceItem extends PayPalModel */ public function setQuantity($quantity) { - NumericValidator::validate($quantity, "Percent"); + NumericValidator::validate($quantity, "Quantity"); $quantity = FormatConverter::formatToPrice($quantity); $this->quantity = $quantity; return $this; diff --git a/lib/PayPal/Api/RefundDetail.php b/lib/PayPal/Api/RefundDetail.php index e2b293c..7674ec1 100644 --- a/lib/PayPal/Api/RefundDetail.php +++ b/lib/PayPal/Api/RefundDetail.php @@ -12,6 +12,7 @@ use PayPal\Common\PayPalModel; * @package PayPal\Api * * @property string type + * @property string transaction_id * @property string date * @property string note * @property \PayPal\Api\Currency amount @@ -42,6 +43,29 @@ class RefundDetail extends PayPalModel return $this->type; } + /** + * The PayPal refund transaction ID. Required with the `PAYPAL` refund type. + * + * @param string $transaction_id + * + * @return $this + */ + public function setTransactionId($transaction_id) + { + $this->transaction_id = $transaction_id; + return $this; + } + + /** + * The PayPal refund transaction ID. Required with the `PAYPAL` refund type. + * + * @return string + */ + public function getTransactionId() + { + return $this->transaction_id; + } + /** * Date on which the invoice was refunded. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST. * diff --git a/lib/PayPal/Api/ShippingInfo.php b/lib/PayPal/Api/ShippingInfo.php index fc31852..f851e67 100644 --- a/lib/PayPal/Api/ShippingInfo.php +++ b/lib/PayPal/Api/ShippingInfo.php @@ -111,7 +111,7 @@ class ShippingInfo extends PayPalModel } /** - * + * @deprecated Not used anymore * * @param string $email * @return $this @@ -123,7 +123,7 @@ class ShippingInfo extends PayPalModel } /** - * + * @deprecated Not used anymore * * @return string */ diff --git a/lib/PayPal/Api/Template.php b/lib/PayPal/Api/Template.php index e3a1104..4602e9b 100644 --- a/lib/PayPal/Api/Template.php +++ b/lib/PayPal/Api/Template.php @@ -2,7 +2,10 @@ namespace PayPal\Api; -use PayPal\Common\PayPalModel; +use PayPal\Common\PayPalResourceModel; +use PayPal\Rest\ApiContext; +use PayPal\Transport\PayPalRestCall; +use PayPal\Validation\ArgumentValidator; /** * Class Template @@ -19,7 +22,7 @@ use PayPal\Common\PayPalModel; * @property string unit_of_measure * @property bool custom */ -class Template extends PayPalModel +class Template extends PayPalResourceModel { /** * Unique identifier id of the template. @@ -212,4 +215,95 @@ class Template extends PayPalModel return $this->custom; } + /** + * Retrieve the details for a particular template by passing the template ID to the request URI. + * + * @param string $templateId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Template + */ + public static function get($templateId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($templateId, 'templateId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/invoicing/templates/$templateId", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new Template(); + $ret->fromJson($json); + return $ret; + } + + /** + * Delete a particular template by passing the template ID to the request URI. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function delete($apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getTemplateId(), "Id"); + $payLoad = ""; + self::executeCall( + "/v1/invoicing/templates/{$this->getTemplateId()}", + "DELETE", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * Creates a template. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Template + */ + public function create($apiContext = null, $restCall = null) + { + $json = self::executeCall( + "/v1/invoicing/templates", + "POST", + $this->toJSON(), + null, + $apiContext, + $restCall + ); + $this->fromJson($json); + return $this; + } + + /** + * Update an existing template by passing the template ID to the request URI. In addition, pass a complete template object in the request JSON. Partial updates are not supported. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Template + */ + public function update($apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getTemplateId(), "Id"); + $payLoad = $this->toJSON(); + $json = self::executeCall( + "/v1/invoicing/templates/{$this->getTemplateId()}", + "PUT", + $payLoad, + null, + $apiContext, + $restCall + ); + $this->fromJson($json); + return $this; + } + } diff --git a/lib/PayPal/Api/TemplateData.php b/lib/PayPal/Api/TemplateData.php index b0c3569..64d56c1 100644 --- a/lib/PayPal/Api/TemplateData.php +++ b/lib/PayPal/Api/TemplateData.php @@ -114,7 +114,7 @@ class TemplateData extends PayPalModel /** * For invoices sent by email, one or more email addresses to which to send a Cc: copy of the notification. Supports only email addresses under participant. * - * @param string $cc_info + * @param string[] $cc_info * * @return $this */ diff --git a/lib/PayPal/Api/Templates.php b/lib/PayPal/Api/Templates.php index 4ecb376..c9b0ad0 100644 --- a/lib/PayPal/Api/Templates.php +++ b/lib/PayPal/Api/Templates.php @@ -3,6 +3,7 @@ namespace PayPal\Api; use PayPal\Common\PayPalResourceModel; +use PayPal\Transport\PayPalRestCall; use PayPal\Validation\ArgumentValidator; use PayPal\Api\Template; use PayPal\Rest\ApiContext; @@ -235,8 +236,10 @@ class Templates extends PayPalResourceModel } /** - * Shows the details for a template, by ID. + * Retrieve the details for a particular template by passing the template ID to the request URI. * + * @deprecated Please use `Template::get()` instead. + * @see Template::get * @param string $templateId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls @@ -260,14 +263,14 @@ class Templates extends PayPalResourceModel } /** - * Lists all templates for the merchant. + * Retrieves the template information of the merchant. * * @param array $params * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls * @return Templates */ - public static function getAll($params, $apiContext = null, $restCall = null) + public static function getAll($params = array(), $apiContext = null, $restCall = null) { ArgumentValidator::validate($params, 'params'); $payLoad = ""; @@ -286,5 +289,4 @@ class Templates extends PayPalResourceModel $ret->fromJson($json); return $ret; } - } diff --git a/sample/doc/invoice-templates/CreateInvoiceTemplate.html b/sample/doc/invoice-templates/CreateInvoiceTemplate.html new file mode 100644 index 0000000..8657e0e --- /dev/null +++ b/sample/doc/invoice-templates/CreateInvoiceTemplate.html @@ -0,0 +1,43 @@ +invoice-templates/CreateInvoiceTemplate
invoice-templates/CreateInvoiceTemplate.php
<?php

Create Invoice Template Sample

+

This sample code demonstrate how you can create +an invoice template.

use PayPal\Api\Currency; +use PayPal\Api\InvoiceItem; +use PayPal\Api\MerchantInfo; +use PayPal\Api\Template; +use PayPal\Api\TemplateData; +use PayPal\Api\TemplateSettings; +use PayPal\Api\TemplateSettingsMetadata; + +require __DIR__ . '/../bootstrap.php';

Invoice Template Item

$invoiceTemplateDataItem = new InvoiceItem(); +$invoiceTemplateDataItem + ->setName("Nutri Bullet") + ->setQuantity(1) + ->setUnitPrice(new Currency('{ "currency": "USD", "value": "50.00" }'));

Invoice Template Data

$invoiceTemplateData = new TemplateData(); +$invoiceTemplateData + ->setTaxCalculatedAfterDiscount(false) + ->setTaxInclusive(false) + ->setNote("Thank you for your business") + ->setLogoUrl("https://pics.paypal.com/v1/images/redDot.jpeg") + ->addItem($invoiceTemplateDataItem) + ->setMerchantInfo(new MerchantInfo('{ "email": "jaypatel512-facilitator@hotmail.com" }'));

Template Settings

$displayPreferences = new TemplateSettingsMetadata(); +$displayPreferences->setHidden(true); + +$settingDate = new TemplateSettings(); +$settingDate + ->setFieldName("items.date") + ->setDisplayPreference($displayPreferences);

Template

$invoiceTemplate = new Template(); +$invoiceTemplate + ->setName("Hours Template" . rand()) + ->setDefault(true) + ->setUnitOfMeasure("HOURS") + ->setTemplateData($invoiceTemplateData)

This is another way of initializing the object.

->addSetting(new TemplateSettings('{ "field_name": "custom", "display_preference": { "hidden": true } }')) + ->addSetting($settingDate);

For Sample Purposes Only.

$request = clone $invoiceTemplate; + +try {

Create Invoice Template

+

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

$invoiceTemplate->create($apiContext); +} catch (Exception $ex) {

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

ResultPrinter::printError("Create Invoice Template", "Template", null, $request, $ex); + exit(1); +}

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

ResultPrinter::printResult("Create Invoice Template", "Template", $invoiceTemplate->getTemplateId(), $request, $invoiceTemplate); + +return $invoiceTemplate;
\ No newline at end of file diff --git a/sample/doc/invoice-templates/DeleteInvoiceTemplate.html b/sample/doc/invoice-templates/DeleteInvoiceTemplate.html new file mode 100644 index 0000000..d2669dd --- /dev/null +++ b/sample/doc/invoice-templates/DeleteInvoiceTemplate.html @@ -0,0 +1,16 @@ +invoice-templates/DeleteInvoiceTemplate
invoice-templates/DeleteInvoiceTemplate.php
<?php

Delete Invoice Template Sample

+

This sample code demonstrate how you can delete +an invoice template

/** @var Template $template */ +$template = require 'CreateInvoiceTemplate.php'; + +use PayPal\Api\Template; + +try {

Delete Invoice Template

+

Delete invoice object by calling the +delete method +on the Invoice Template class by passing a valid +notification object +(See bootstrap.php for more on ApiContext)

$deleteStatus = $template->delete($apiContext); +} catch (Exception $ex) {

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

ResultPrinter::printError("Delete Invoice Template", "Template", null, $deleteStatus, $ex); + exit(1); +}

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

ResultPrinter::printResult("Delete Invoice Template", "Template", $template->getTemplateId(), null, null);
\ No newline at end of file diff --git a/sample/doc/invoice-templates/GetAllInvoiceTemplates.html b/sample/doc/invoice-templates/GetAllInvoiceTemplates.html new file mode 100644 index 0000000..892fe09 --- /dev/null +++ b/sample/doc/invoice-templates/GetAllInvoiceTemplates.html @@ -0,0 +1,13 @@ +invoice-templates/GetAllInvoiceTemplates
invoice-templates/GetAllInvoiceTemplates.php
<?php + +use PayPal\Api\Templates; + +require 'CreateInvoiceTemplate.php'; + +try { + $templates = Templates::getAll(array("fields" => "all"), $apiContext); +} catch (Exception $ex) {

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

ResultPrinter::printError("Get all Templates", "Templates", null, null, $ex); + exit(1); +}

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

ResultPrinter::printResult("Get all Templates", "Templates", null, null, $templates); + +return $templates;
\ No newline at end of file diff --git a/sample/doc/invoice-templates/GetInvoiceTemplate.html b/sample/doc/invoice-templates/GetInvoiceTemplate.html new file mode 100644 index 0000000..716461a --- /dev/null +++ b/sample/doc/invoice-templates/GetInvoiceTemplate.html @@ -0,0 +1,19 @@ +invoice-templates/GetInvoiceTemplate
invoice-templates/GetInvoiceTemplate.php
<?php

Retrieve Invoice Template Sample

+

This sample code demonstrate how you can get +an invoice template using templateId.

use PayPal\Api\Template; + +$invoiceTemplate = require 'CreateInvoiceTemplate.php'; + +/** @var Template $invoiceTemplate */ +$templateId = $invoiceTemplate->getTemplateId();

Retrieve Invoice Template

+

Retrieve the invoice template object by calling the +static get method +on the Template class by passing a valid +Template ID +(See bootstrap.php for more on ApiContext)

try { + $template = Template::get($templateId, $apiContext); +} catch (Exception $ex) {

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

ResultPrinter::printError("Get Invoice Template", "Template", $template->getTemplateId(), $templateId, $ex); + exit(1); +}

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

ResultPrinter::printResult("Get Invoice Template", "Template", $template->getTemplateId(), $templateId, $template); + +return $template;
\ No newline at end of file diff --git a/sample/doc/invoice-templates/UpdateInvoiceTemplate.html b/sample/doc/invoice-templates/UpdateInvoiceTemplate.html new file mode 100644 index 0000000..a6b3a22 --- /dev/null +++ b/sample/doc/invoice-templates/UpdateInvoiceTemplate.html @@ -0,0 +1,12 @@ +invoice-templates/UpdateInvoiceTemplate
invoice-templates/UpdateInvoiceTemplate.php
<?php

Update Invoice Sample

+

This sample code demonstrate how you can update +an invoice.

/** @var Template $template */ +$template = require 'GetInvoiceTemplate.php'; +use PayPal\Api\Template;

Update Invoice

$template->setUnitOfMeasure("QUANTITY");

NOTE: These are the work-around added to the

+

sample, to get past the bug in PayPal APIs.

$template->setCustom(null);

For Sample Purposes Only.

$request = clone $template; +try {

Update Invoice Template

+

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

$template->update($apiContext); +} catch (Exception $ex) {

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

ResultPrinter::printError("Invoice Template Updated", "Invoice", null, $request, $ex); + exit(1); +}

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

ResultPrinter::printResult("Invoice Template Updated", "Invoice", $template->getTemplateId(), $request, $template);
\ No newline at end of file diff --git a/sample/index.php b/sample/index.php index daeb2d9..bc55caf 100644 --- a/sample/index.php +++ b/sample/index.php @@ -225,6 +225,7 @@ if (PHP_SAPI == 'cli') {
  • Payment Experience
  • Notifications
  • Invoice
  • +
  • Invoice Templates
  • Identity (LIPP)
  • @@ -1343,6 +1344,73 @@ if (PHP_SAPI == 'cli') { +
    +
    +

    Invoice Templates

    +
    + + +
    +

    setName("Nutri Bullet") + ->setQuantity(1) + ->setUnitPrice(new Currency('{ "currency": "USD", "value": "50.00" }')); + +// ### Invoice Template Data +$invoiceTemplateData = new TemplateData(); +$invoiceTemplateData + ->setTaxCalculatedAfterDiscount(false) + ->setTaxInclusive(false) + ->setNote("Thank you for your business") + ->setLogoUrl("https://pics.paypal.com/v1/images/redDot.jpeg") + ->addItem($invoiceTemplateDataItem) + ->setMerchantInfo(new MerchantInfo('{ "email": "jaypatel512-facilitator@hotmail.com" }')); + +// ### Template Settings +$displayPreferences = new TemplateSettingsMetadata(); +$displayPreferences->setHidden(true); + +$settingDate = new TemplateSettings(); +$settingDate + ->setFieldName("items.date") + ->setDisplayPreference($displayPreferences); + + +// ### Template +$invoiceTemplate = new Template(); +$invoiceTemplate + ->setName("Hours Template" . rand()) + ->setDefault(true) + ->setUnitOfMeasure("HOURS") + ->setTemplateData($invoiceTemplateData) + // This is another way of initializing the object. + ->addSetting(new TemplateSettings('{ "field_name": "custom", "display_preference": { "hidden": true } }')) + ->addSetting($settingDate); + +// For Sample Purposes Only. +$request = clone $invoiceTemplate; + +try { + // ### Create Invoice Template + // Create an invoice by calling the invoice->create() method + // with a valid ApiContext (See bootstrap.php for more on `ApiContext`) + $invoiceTemplate->create($apiContext); +} catch (Exception $ex) { + // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY + ResultPrinter::printError("Create Invoice Template", "Template", null, $request, $ex); + exit(1); +} + +// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY +ResultPrinter::printResult("Create Invoice Template", "Template", $invoiceTemplate->getTemplateId(), $request, $invoiceTemplate); + +return $invoiceTemplate; diff --git a/sample/invoice-templates/DeleteInvoiceTemplate.php b/sample/invoice-templates/DeleteInvoiceTemplate.php new file mode 100644 index 0000000..99610b6 --- /dev/null +++ b/sample/invoice-templates/DeleteInvoiceTemplate.php @@ -0,0 +1,28 @@ +delete($apiContext); +} catch (Exception $ex) { + // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY + ResultPrinter::printError("Delete Invoice Template", "Template", null, $deleteStatus, $ex); + exit(1); +} + +// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY + ResultPrinter::printResult("Delete Invoice Template", "Template", $template->getTemplateId(), null, null); diff --git a/sample/invoice-templates/GetAllInvoiceTemplates.php b/sample/invoice-templates/GetAllInvoiceTemplates.php new file mode 100644 index 0000000..0bef017 --- /dev/null +++ b/sample/invoice-templates/GetAllInvoiceTemplates.php @@ -0,0 +1,18 @@ + "all"), $apiContext); +} catch (Exception $ex) { + // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY + ResultPrinter::printError("Get all Templates", "Templates", null, null, $ex); + exit(1); +} + +// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY +ResultPrinter::printResult("Get all Templates", "Templates", null, null, $templates); + +return $templates; \ No newline at end of file diff --git a/sample/invoice-templates/GetInvoiceTemplate.php b/sample/invoice-templates/GetInvoiceTemplate.php new file mode 100644 index 0000000..ba0b6e4 --- /dev/null +++ b/sample/invoice-templates/GetInvoiceTemplate.php @@ -0,0 +1,31 @@ +getTemplateId(); + +// ### Retrieve Invoice Template +// Retrieve the invoice template object by calling the +// static `get` method +// on the Template class by passing a valid +// Template ID +// (See bootstrap.php for more on `ApiContext`) +try { + $template = Template::get($templateId, $apiContext); +} catch (Exception $ex) { + // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY + ResultPrinter::printError("Get Invoice Template", "Template", $template->getTemplateId(), $templateId, $ex); + exit(1); +} + +// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY +ResultPrinter::printResult("Get Invoice Template", "Template", $template->getTemplateId(), $templateId, $template); + +return $template; \ No newline at end of file diff --git a/sample/invoice-templates/UpdateInvoiceTemplate.php b/sample/invoice-templates/UpdateInvoiceTemplate.php new file mode 100644 index 0000000..0afb4cb --- /dev/null +++ b/sample/invoice-templates/UpdateInvoiceTemplate.php @@ -0,0 +1,33 @@ +setUnitOfMeasure("QUANTITY"); + +// ### NOTE: These are the work-around added to the +// sample, to get past the bug in PayPal APIs. +$template->setCustom(null); + +// For Sample Purposes Only. +$request = clone $template; +try { + // ### Update Invoice Template + // Update an invoice by calling the invoice->update() method + // with a valid ApiContext (See bootstrap.php for more on `ApiContext`) + $template->update($apiContext); +} catch (Exception $ex) { + // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY + ResultPrinter::printError("Invoice Template Updated", "Invoice", null, $request, $ex); + exit(1); +} + +// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY + ResultPrinter::printResult("Invoice Template Updated", "Invoice", $template->getTemplateId(), $request, $template); diff --git a/tests/PayPal/Test/Api/RefundDetailTest.php b/tests/PayPal/Test/Api/RefundDetailTest.php index d5c4711..ec66a40 100644 --- a/tests/PayPal/Test/Api/RefundDetailTest.php +++ b/tests/PayPal/Test/Api/RefundDetailTest.php @@ -39,6 +39,7 @@ class RefundDetailTest extends \PHPUnit_Framework_TestCase $obj = new RefundDetail(self::getJson()); $this->assertNotNull($obj); $this->assertNotNull($obj->getType()); + $this->assertNotNull($obj->getTransactionId()); $this->assertNotNull($obj->getDate()); $this->assertNotNull($obj->getNote()); $this->assertNotNull($obj->getAmount()); @@ -53,6 +54,7 @@ class RefundDetailTest extends \PHPUnit_Framework_TestCase public function testGetters($obj) { $this->assertEquals($obj->getType(), "TestSample"); + $this->assertEquals($obj->getTransactionId(), "TestSample"); $this->assertEquals($obj->getDate(), "TestSample"); $this->assertEquals($obj->getNote(), "TestSample"); $this->assertEquals($obj->getAmount(), CurrencyTest::getObject()); diff --git a/tests/PayPal/Test/Api/TemplateDataTest.php b/tests/PayPal/Test/Api/TemplateDataTest.php index f132b6b..d1aa55f 100644 --- a/tests/PayPal/Test/Api/TemplateDataTest.php +++ b/tests/PayPal/Test/Api/TemplateDataTest.php @@ -2,7 +2,6 @@ namespace PayPal\Test\Api; -use PayPal\Common\PayPalModel; use PayPal\Api\TemplateData; /**