Updated Invoicing APIs

- Updated Model objects.
- Updated Samples.
- Updated Tests.
This commit is contained in:
Jay Patel
2016-07-13 15:16:25 -05:00
parent 9534bcb176
commit c714f77980
48 changed files with 3320 additions and 2881 deletions

View File

@@ -17,18 +17,22 @@ use PayPal\Validation\UrlValidator;
*
* @property string id
* @property string number
* @property string template_id
* @property string uri
* @property string status
* @property \PayPal\Api\MerchantInfo merchant_info
* @property \PayPal\Api\BillingInfo[] billing_info
* @property \PayPal\Api\Participant[] cc_info
* @property \PayPal\Api\ShippingInfo shipping_info
* @property \PayPal\Api\InvoiceItem[] items
* @property string invoice_date
* @property \PayPal\Api\PaymentTerm payment_term
* @property String reference
* @property string reference
* @property \PayPal\Api\Cost discount
* @property \PayPal\Api\ShippingCost shipping_cost
* @property \PayPal\Api\CustomAmount custom
* @property bool allow_partial_payment
* @property \PayPal\Api\Currency minimum_amount_due
* @property bool tax_calculated_after_discount
* @property bool tax_inclusive
* @property string terms
@@ -39,12 +43,14 @@ use PayPal\Validation\UrlValidator;
* @property \PayPal\Api\PaymentDetail[] payments
* @property \PayPal\Api\RefundDetail[] refunds
* @property \PayPal\Api\Metadata metadata
* @property string additional_data
* @property \PayPal\Api\PaymentSummary paid_amount
* @property \PayPal\Api\PaymentSummary refunded_amount
* @property \PayPal\Api\FileAttachment[] attachments
*/
class Invoice extends PayPalResourceModel
{
/**
* Unique invoice resource identifier.
* The unique invoice resource identifier.
*
* @param string $id
*
@@ -57,7 +63,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Unique invoice resource identifier.
* The unique invoice resource identifier.
*
* @return string
*/
@@ -89,6 +95,29 @@ class Invoice extends PayPalResourceModel
return $this->number;
}
/**
* The template ID used for the invoice. Useful for copy functionality.
*
* @param string $template_id
*
* @return $this
*/
public function setTemplateId($template_id)
{
$this->template_id = $template_id;
return $this;
}
/**
* The template ID used for the invoice. Useful for copy functionality.
*
* @return string
*/
public function getTemplateId()
{
return $this->template_id;
}
/**
* URI of the invoice resource.
*
@@ -114,7 +143,7 @@ class Invoice extends PayPalResourceModel
/**
* Status of the invoice.
* Valid Values: ["DRAFT", "SENT", "PAID", "MARKED_AS_PAID", "CANCELLED", "REFUNDED", "PARTIALLY_REFUNDED", "MARKED_AS_REFUNDED"]
* Valid Values: ["DRAFT", "SENT", "PAID", "MARKED_AS_PAID", "CANCELLED", "REFUNDED", "PARTIALLY_REFUNDED", "MARKED_AS_REFUNDED", "UNPAID", "PAYMENT_PENDING"]
*
* @param string $status
*
@@ -160,7 +189,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Email address of invoice recipient (required) and optional billing information. (Note: We currently only allow one recipient).
* The required invoice recipient email address and any optional billing information. One recipient is supported.
*
* @param \PayPal\Api\BillingInfo[] $billing_info
*
@@ -173,7 +202,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Email address of invoice recipient (required) and optional billing information. (Note: We currently only allow one recipient).
* The required invoice recipient email address and any optional billing information. One recipient is supported.
*
* @return \PayPal\Api\BillingInfo[]
*/
@@ -213,7 +242,60 @@ class Invoice extends PayPalResourceModel
}
/**
* Shipping information for entities to whom items are being shipped.
* 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 \PayPal\Api\Participant[] $cc_info
*
* @return $this
*/
public function setCcInfo($cc_info)
{
$this->cc_info = $cc_info;
return $this;
}
/**
* 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.
*
* @return \PayPal\Api\Participant[]
*/
public function getCcInfo()
{
return $this->cc_info;
}
/**
* Append CcInfo to the list.
*
* @param \PayPal\Api\Participant $participant
* @return $this
*/
public function addCcInfo($participant)
{
if (!$this->getCcInfo()) {
return $this->setCcInfo(array($participant));
} else {
return $this->setCcInfo(
array_merge($this->getCcInfo(), array($participant))
);
}
}
/**
* Remove CcInfo from the list.
*
* @param \PayPal\Api\Participant $participant
* @return $this
*/
public function removeCcInfo($participant)
{
return $this->setCcInfo(
array_diff($this->getCcInfo(), array($participant))
);
}
/**
* The shipping information for entities to whom items are being shipped.
*
* @param \PayPal\Api\ShippingInfo $shipping_info
*
@@ -226,7 +308,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Shipping information for entities to whom items are being shipped.
* The shipping information for entities to whom items are being shipped.
*
* @return \PayPal\Api\ShippingInfo
*/
@@ -236,7 +318,7 @@ class Invoice extends PayPalResourceModel
}
/**
* List of items included in the invoice. 100 items max per invoice.
* The list of items to include in the invoice. Maximum value is 100 items per invoice.
*
* @param \PayPal\Api\InvoiceItem[] $items
*
@@ -249,7 +331,7 @@ class Invoice extends PayPalResourceModel
}
/**
* List of items included in the invoice. 100 items max per invoice.
* The list of items to include in the invoice. Maximum value is 100 items per invoice.
*
* @return \PayPal\Api\InvoiceItem[]
*/
@@ -289,7 +371,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Date on which the invoice was enabled. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
* The date when the invoice was enabled. The date format is *yyyy*-*MM*-*dd* *z* as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6).
*
* @param string $invoice_date
*
@@ -302,7 +384,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Date on which the invoice was enabled. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
* The date when the invoice was enabled. The date format is *yyyy*-*MM*-*dd* *z* as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6).
*
* @return string
*/
@@ -312,7 +394,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Optional field to pass payment deadline for the invoice. Either term_type or due_date can be passed, but not both.
* Optional. The payment deadline for the invoice. Value is either `term_type` or `due_date` but not both.
*
* @param \PayPal\Api\PaymentTerm $payment_term
*
@@ -325,7 +407,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Optional field to pass payment deadline for the invoice. Either term_type or due_date can be passed, but not both.
* Optional. The payment deadline for the invoice. Value is either `term_type` or `due_date` but not both.
*
* @return \PayPal\Api\PaymentTerm
*/
@@ -337,7 +419,7 @@ class Invoice extends PayPalResourceModel
/**
* Reference data, such as PO number, to add to the invoice. Maximum length is 60 characters.
*
* @param String $reference
* @param string $reference
*
* @return $this
*/
@@ -350,7 +432,7 @@ class Invoice extends PayPalResourceModel
/**
* Reference data, such as PO number, to add to the invoice. Maximum length is 60 characters.
*
* @return String
* @return string
*/
public function getReference()
{
@@ -358,7 +440,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Invoice level discount in percent or amount.
* The invoice level discount, as a percent or an amount value.
*
* @param \PayPal\Api\Cost $discount
*
@@ -371,7 +453,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Invoice level discount in percent or amount.
* The invoice level discount, as a percent or an amount value.
*
* @return \PayPal\Api\Cost
*/
@@ -381,7 +463,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Shipping cost in percent or amount.
* The shipping cost, as a percent or an amount value.
*
* @param \PayPal\Api\ShippingCost $shipping_cost
*
@@ -394,7 +476,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Shipping cost in percent or amount.
* The shipping cost, as a percent or an amount value.
*
* @return \PayPal\Api\ShippingCost
*/
@@ -404,7 +486,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Custom amount applied on an invoice. If a label is included then the amount cannot be empty.
* The custom amount to apply on an invoice. If you include a label, the amount cannot be empty.
*
* @param \PayPal\Api\CustomAmount $custom
*
@@ -417,7 +499,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Custom amount applied on an invoice. If a label is included then the amount cannot be empty.
* The custom amount to apply on an invoice. If you include a label, the amount cannot be empty.
*
* @return \PayPal\Api\CustomAmount
*/
@@ -427,7 +509,53 @@ class Invoice extends PayPalResourceModel
}
/**
* Indicates whether tax is calculated before or after a discount. If false (the default), the tax is calculated before a discount. If true, the tax is calculated after a discount.
* Indicates whether the invoice allows a partial payment. If set to `false`, invoice must be paid in full. If set to `true`, the invoice allows partial payments. Default is `false`.
*
* @param bool $allow_partial_payment
*
* @return $this
*/
public function setAllowPartialPayment($allow_partial_payment)
{
$this->allow_partial_payment = $allow_partial_payment;
return $this;
}
/**
* Indicates whether the invoice allows a partial payment. If set to `false`, invoice must be paid in full. If set to `true`, the invoice allows partial payments. Default is `false`.
*
* @return bool
*/
public function getAllowPartialPayment()
{
return $this->allow_partial_payment;
}
/**
* If `allow_partial_payment` is set to `true`, the minimum amount allowed for a partial payment.
*
* @param \PayPal\Api\Currency $minimum_amount_due
*
* @return $this
*/
public function setMinimumAmountDue($minimum_amount_due)
{
$this->minimum_amount_due = $minimum_amount_due;
return $this;
}
/**
* If `allow_partial_payment` is set to `true`, the minimum amount allowed for a partial payment.
*
* @return \PayPal\Api\Currency
*/
public function getMinimumAmountDue()
{
return $this->minimum_amount_due;
}
/**
* Indicates whether tax is calculated before or after a discount. If set to `false`, the tax is calculated before a discount. If set to `true`, the tax is calculated after a discount. Default is `false`.
*
* @param bool $tax_calculated_after_discount
*
@@ -440,7 +568,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Indicates whether tax is calculated before or after a discount. If false (the default), the tax is calculated before a discount. If true, the tax is calculated after a discount.
* Indicates whether tax is calculated before or after a discount. If set to `false`, the tax is calculated before a discount. If set to `true`, the tax is calculated after a discount. Default is `false`.
*
* @return bool
*/
@@ -450,7 +578,7 @@ class Invoice extends PayPalResourceModel
}
/**
* A flag indicating whether the unit price includes tax. Default is false
* Indicates whether the unit price includes tax. Default is `false`.
*
* @param bool $tax_inclusive
*
@@ -463,7 +591,7 @@ class Invoice extends PayPalResourceModel
}
/**
* A flag indicating whether the unit price includes tax. Default is false
* Indicates whether the unit price includes tax. Default is `false`.
*
* @return bool
*/
@@ -519,7 +647,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Bookkeeping memo that is private to the merchant. 150 characters max.
* A private bookkeeping memo for the merchant. Maximum length is 150 characters.
*
* @param string $merchant_memo
*
@@ -532,7 +660,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Bookkeeping memo that is private to the merchant. 150 characters max.
* A private bookkeeping memo for the merchant. Maximum length is 150 characters.
*
* @return string
*/
@@ -542,7 +670,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Full URL of an external image to use as the logo. 4000 characters max.
* Full URL of an external image to use as the logo. Maximum length is 4000 characters.
*
* @param string $logo_url
* @throws \InvalidArgumentException
@@ -556,7 +684,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Full URL of an external image to use as the logo. 4000 characters max.
* Full URL of an external image to use as the logo. Maximum length is 4000 characters.
*
* @return string
*/
@@ -612,12 +740,12 @@ class Invoice extends PayPalResourceModel
}
/**
* Append PaymentDetails to the list.
* Append Payments to the list.
*
* @param \PayPal\Api\PaymentDetail $paymentDetail
* @return $this
*/
public function addPaymentDetail($paymentDetail)
public function addPayment($paymentDetail)
{
if (!$this->getPayments()) {
return $this->setPayments(array($paymentDetail));
@@ -629,12 +757,12 @@ class Invoice extends PayPalResourceModel
}
/**
* Remove PaymentDetails from the list.
* Remove Payments from the list.
*
* @param \PayPal\Api\PaymentDetail $paymentDetail
* @return $this
*/
public function removePaymentDetail($paymentDetail)
public function removePayment($paymentDetail)
{
return $this->setPayments(
array_diff($this->getPayments(), array($paymentDetail))
@@ -665,12 +793,12 @@ class Invoice extends PayPalResourceModel
}
/**
* Append RefundDetails to the list.
* Append Refunds to the list.
*
* @param \PayPal\Api\RefundDetail $refundDetail
* @return $this
*/
public function addRefundDetail($refundDetail)
public function addRefund($refundDetail)
{
if (!$this->getRefunds()) {
return $this->setRefunds(array($refundDetail));
@@ -682,12 +810,12 @@ class Invoice extends PayPalResourceModel
}
/**
* Remove RefundDetails from the list.
* Remove Refunds from the list.
*
* @param \PayPal\Api\RefundDetail $refundDetail
* @return $this
*/
public function removeRefundDetail($refundDetail)
public function removeRefund($refundDetail)
{
return $this->setRefunds(
array_diff($this->getRefunds(), array($refundDetail))
@@ -718,8 +846,8 @@ class Invoice extends PayPalResourceModel
}
/**
* Any miscellaneous invoice data. 4000 characters max.
*
* Any miscellaneous invoice data. Maximum length is 4000 characters.
* @deprecated Not publicly available
* @param string $additional_data
*
* @return $this
@@ -731,8 +859,8 @@ class Invoice extends PayPalResourceModel
}
/**
* Any miscellaneous invoice data. 4000 characters max.
*
* Any miscellaneous invoice data. Maximum length is 4000 characters.
* @deprecated Not publicly available
* @return string
*/
public function getAdditionalData()
@@ -741,7 +869,106 @@ class Invoice extends PayPalResourceModel
}
/**
* Create a new invoice by passing the details for the invoice, including the merchant_info, to the request URI.
* Payment summary of the invoice including amount paid through PayPal and other sources.
*
* @param \PayPal\Api\PaymentSummary $paid_amount
*
* @return $this
*/
public function setPaidAmount($paid_amount)
{
$this->paid_amount = $paid_amount;
return $this;
}
/**
* Payment summary of the invoice including amount paid through PayPal and other sources.
*
* @return \PayPal\Api\PaymentSummary
*/
public function getPaidAmount()
{
return $this->paid_amount;
}
/**
* Payment summary of the invoice including amount refunded through PayPal and other sources.
*
* @param \PayPal\Api\PaymentSummary $refunded_amount
*
* @return $this
*/
public function setRefundedAmount($refunded_amount)
{
$this->refunded_amount = $refunded_amount;
return $this;
}
/**
* Payment summary of the invoice including amount refunded through PayPal and other sources.
*
* @return \PayPal\Api\PaymentSummary
*/
public function getRefundedAmount()
{
return $this->refunded_amount;
}
/**
* List of files attached to the invoice.
*
* @param \PayPal\Api\FileAttachment[] $attachments
*
* @return $this
*/
public function setAttachments($attachments)
{
$this->attachments = $attachments;
return $this;
}
/**
* List of files attached to the invoice.
*
* @return \PayPal\Api\FileAttachment[]
*/
public function getAttachments()
{
return $this->attachments;
}
/**
* Append Attachments to the list.
*
* @param \PayPal\Api\FileAttachment $fileAttachment
* @return $this
*/
public function addAttachment($fileAttachment)
{
if (!$this->getAttachments()) {
return $this->setAttachments(array($fileAttachment));
} else {
return $this->setAttachments(
array_merge($this->getAttachments(), array($fileAttachment))
);
}
}
/**
* Remove Attachments from the list.
*
* @param \PayPal\Api\FileAttachment $fileAttachment
* @return $this
*/
public function removeAttachment($fileAttachment)
{
return $this->setAttachments(
array_diff($this->getAttachments(), array($fileAttachment))
);
}
/**
* Creates an invoice. Include invoice details including merchant information in the request.
*
* @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
@@ -763,7 +990,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Search for a specific invoice or invoices by passing a search object that specifies your search criteria to the request URI.
* Searches for an invoice or invoices. Include a search object that specifies your search criteria in the request.
*
* @param Search $search
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
@@ -788,7 +1015,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Send a specific invoice to its intended recipient by passing the invoice ID to the request URI. Optionally, you can specify whether to send the merchant an invoice update notification by using the notify_merchant query parameter. By default, notify_merchant is true.
* Sends an invoice, by ID, to a recipient. Optionally, set the `notify_merchant` query parameter to send the merchant an invoice update notification. By default, `notify_merchant` is `true`.
*
* @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
@@ -810,7 +1037,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Send a reminder about a specific invoice to its intended recipient by providing the ID of the invoice in the request URI. In addition, pass a notification object that specifies the subject of the reminder and other details in the request JSON.
* Sends a reminder about a specific invoice, by ID, to a recipient. Include a notification object that defines the reminder subject and other details in the JSON request body.
*
* @param Notification $notification
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
@@ -834,7 +1061,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Cancel an invoice by passing the invoice ID to the request URI.
* Cancels an invoice, by ID.
*
* @param CancelNotification $cancelNotification
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
@@ -858,7 +1085,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Mark the status of an invoice as paid by passing the invoice ID to the request URI. In addition, pass a payment detail object that specifies the payment method and other details in the request JSON.
* Marks the status of a specified invoice, by ID, as paid. Include a payment detail object that defines the payment method and other details in the JSON request body.
*
* @param PaymentDetail $paymentDetail
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
@@ -882,7 +1109,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Mark the status of an invoice as refunded by passing the invoice ID to the request URI. In addition, pass a refund-detail object that specifies the type of refund and other details in the request JSON.
* Marks the status of a specified invoice, by ID, as refunded. Include a refund detail object that defines the refund type and other details in the JSON request body.
*
* @param RefundDetail $refundDetail
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
@@ -906,7 +1133,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Retrieve the details for a particular invoice by passing the invoice ID to the request URI.
* Gets the details for a specified invoice, by ID.
*
* @param string $invoiceId
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
@@ -931,7 +1158,7 @@ class Invoice extends PayPalResourceModel
}
/**
* List some or all invoices for a merchant according to optional query string parameters specified.
* Lists some or all merchant invoices. Filters the response by any specified optional query string parameters.
*
* @param array $params
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
@@ -963,7 +1190,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Fully update 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.
* 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.
*
* @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
@@ -986,7 +1213,7 @@ class Invoice extends PayPalResourceModel
}
/**
* Delete a particular invoice by passing the invoice ID to the request URI.
* Deletes an invoice, by ID.
*
* @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
@@ -1041,4 +1268,27 @@ class Invoice extends PayPalResourceModel
return $ret;
}
/**
* Generate the successive invoice number for the merchant.
*
* @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 InvoiceNumber
*/
public static function generateNumber($apiContext = null, $restCall = null)
{
$payLoad = "";
$json = self::executeCall(
"/v1/invoicing/invoices/next-invoice-number",
"POST",
$payLoad,
null,
$apiContext,
$restCall
);
$ret = new InvoiceNumber();
$ret->fromJson($json);
return $ret;
}
}