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..e5b0f79 100644 --- a/lib/PayPal/Api/Template.php +++ b/lib/PayPal/Api/Template.php @@ -18,6 +18,7 @@ use PayPal\Common\PayPalModel; * @property \PayPal\Api\TemplateSettings[] settings * @property string unit_of_measure * @property bool custom + * @property \PayPal\Api\Links[] links */ class Template extends PayPalModel { @@ -212,4 +213,57 @@ class Template extends PayPalModel return $this->custom; } + /** + * Sets Links + * + * @param \PayPal\Api\Links[] $links + * + * @return $this + */ + public function setLinks($links) + { + $this->links = $links; + return $this; + } + + /** + * Gets Links + * + * @return \PayPal\Api\Links[] + */ + public function getLinks() + { + return $this->links; + } + + /** + * Append Links to the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function addLink($links) + { + if (!$this->getLinks()) { + return $this->setLinks(array($links)); + } else { + return $this->setLinks( + array_merge($this->getLinks(), array($links)) + ); + } + } + + /** + * Remove Links from the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function removeLink($links) + { + return $this->setLinks( + array_diff($this->getLinks(), array($links)) + ); + } + } 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..6e36a95 100644 --- a/lib/PayPal/Api/Templates.php +++ b/lib/PayPal/Api/Templates.php @@ -235,7 +235,7 @@ 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. * * @param string $templateId * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. @@ -260,7 +260,7 @@ 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. @@ -287,4 +287,77 @@ class Templates extends PayPalResourceModel 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->getId(), "Id"); + $payLoad = ""; + self::executeCall( + "/v1/invoicing/templates/{$this->getId()}", + "DELETE", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * Creates a template. + * + * @param Template $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($template, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($template, 'template'); + $payLoad = $template->toJSON(); + $json = self::executeCall( + "/v1/invoicing/templates", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new Template(); + $ret->fromJson($json); + return $ret; + } + + /** + * 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 Template $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 update($template, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($template, 'template'); + $payLoad = $template->toJSON(); + $json = self::executeCall( + "/v1/invoicing/templates/{$this->getId()}", + "PUT", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new Template(); + $ret->fromJson($json); + return $ret; + } + } 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; /**