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 @@ +
This is another way of initializing the object.
For Sample Purposes Only.
Create an invoice by calling the invoice->create() method
+with a valid ApiContext (See bootstrap.php for more on ApiContext)
NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
This sample code demonstrate how you can delete +an 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)
NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
This sample code demonstrate how you can get +an invoice template using templateId.
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)
NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
This sample code demonstrate how you can update +an invoice.
sample, to get past the bug in PayPal APIs.
For Sample Purposes Only.
Update an invoice by calling the invoice->update() method
+with a valid ApiContext (See bootstrap.php for more on ApiContext)
NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
Create Invoice Template Sample
+This sample code demonstrate how you can create +an invoice template.