Updated Invoice API

This commit is contained in:
Jay Patel
2016-09-19 14:32:33 -05:00
parent a1039ae38a
commit 4f20bc4b97
10 changed files with 209 additions and 11 deletions

View File

@@ -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
*

View File

@@ -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

View File

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

View File

@@ -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.
*

View File

@@ -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
*/

View File

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

View File

@@ -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
*/

View File

@@ -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;
}
}

View File

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

View File

@@ -2,7 +2,6 @@
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\TemplateData;
/**