forked from LiveCarta/PayPal-PHP-SDK
Updated Invoice Object to retrieve payments and refunds
- getPaymentDetails is now getPayments - getRefundDetails is now getRefunds - Updated Sample to Get Invoice at the end of each operation - Updated Tests
This commit is contained in:
@@ -35,8 +35,8 @@ use PayPal\Validation\UrlValidator;
|
|||||||
* @property string merchant_memo
|
* @property string merchant_memo
|
||||||
* @property string logo_url
|
* @property string logo_url
|
||||||
* @property \PayPal\Api\Currency total_amount
|
* @property \PayPal\Api\Currency total_amount
|
||||||
* @property \PayPal\Api\PaymentDetail[] payment_details
|
* @property \PayPal\Api\PaymentDetail[] payments
|
||||||
* @property \PayPal\Api\RefundDetail[] refund_details
|
* @property \PayPal\Api\RefundDetail[] refunds
|
||||||
* @property \PayPal\Api\Metadata metadata
|
* @property \PayPal\Api\Metadata metadata
|
||||||
* @property string additional_data
|
* @property string additional_data
|
||||||
*/
|
*/
|
||||||
@@ -567,13 +567,13 @@ class Invoice extends PayPalResourceModel
|
|||||||
/**
|
/**
|
||||||
* List of payment details for the invoice.
|
* List of payment details for the invoice.
|
||||||
*
|
*
|
||||||
* @param \PayPal\Api\PaymentDetail[] $payment_details
|
* @param \PayPal\Api\PaymentDetail[] $payments
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setPaymentDetails($payment_details)
|
public function setPayments($payments)
|
||||||
{
|
{
|
||||||
$this->payment_details = $payment_details;
|
$this->payments = $payments;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -582,9 +582,9 @@ class Invoice extends PayPalResourceModel
|
|||||||
*
|
*
|
||||||
* @return \PayPal\Api\PaymentDetail[]
|
* @return \PayPal\Api\PaymentDetail[]
|
||||||
*/
|
*/
|
||||||
public function getPaymentDetails()
|
public function getPayments()
|
||||||
{
|
{
|
||||||
return $this->payment_details;
|
return $this->payments;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -595,11 +595,11 @@ class Invoice extends PayPalResourceModel
|
|||||||
*/
|
*/
|
||||||
public function addPaymentDetail($paymentDetail)
|
public function addPaymentDetail($paymentDetail)
|
||||||
{
|
{
|
||||||
if (!$this->getPaymentDetails()) {
|
if (!$this->getPayments()) {
|
||||||
return $this->setPaymentDetails(array($paymentDetail));
|
return $this->setPayments(array($paymentDetail));
|
||||||
} else {
|
} else {
|
||||||
return $this->setPaymentDetails(
|
return $this->setPayments(
|
||||||
array_merge($this->getPaymentDetails(), array($paymentDetail))
|
array_merge($this->getPayments(), array($paymentDetail))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -612,21 +612,21 @@ class Invoice extends PayPalResourceModel
|
|||||||
*/
|
*/
|
||||||
public function removePaymentDetail($paymentDetail)
|
public function removePaymentDetail($paymentDetail)
|
||||||
{
|
{
|
||||||
return $this->setPaymentDetails(
|
return $this->setPayments(
|
||||||
array_diff($this->getPaymentDetails(), array($paymentDetail))
|
array_diff($this->getPayments(), array($paymentDetail))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of refund details for the invoice.
|
* List of refund details for the invoice.
|
||||||
*
|
*
|
||||||
* @param \PayPal\Api\RefundDetail[] $refund_details
|
* @param \PayPal\Api\RefundDetail[] $refunds
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setRefundDetails($refund_details)
|
public function setRefunds($refunds)
|
||||||
{
|
{
|
||||||
$this->refund_details = $refund_details;
|
$this->refunds = $refunds;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -635,9 +635,9 @@ class Invoice extends PayPalResourceModel
|
|||||||
*
|
*
|
||||||
* @return \PayPal\Api\RefundDetail[]
|
* @return \PayPal\Api\RefundDetail[]
|
||||||
*/
|
*/
|
||||||
public function getRefundDetails()
|
public function getRefunds()
|
||||||
{
|
{
|
||||||
return $this->refund_details;
|
return $this->refunds;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -648,11 +648,11 @@ class Invoice extends PayPalResourceModel
|
|||||||
*/
|
*/
|
||||||
public function addRefundDetail($refundDetail)
|
public function addRefundDetail($refundDetail)
|
||||||
{
|
{
|
||||||
if (!$this->getRefundDetails()) {
|
if (!$this->getRefunds()) {
|
||||||
return $this->setRefundDetails(array($refundDetail));
|
return $this->setRefunds(array($refundDetail));
|
||||||
} else {
|
} else {
|
||||||
return $this->setRefundDetails(
|
return $this->setRefunds(
|
||||||
array_merge($this->getRefundDetails(), array($refundDetail))
|
array_merge($this->getRefunds(), array($refundDetail))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -665,8 +665,8 @@ class Invoice extends PayPalResourceModel
|
|||||||
*/
|
*/
|
||||||
public function removeRefundDetail($refundDetail)
|
public function removeRefundDetail($refundDetail)
|
||||||
{
|
{
|
||||||
return $this->setRefundDetails(
|
return $this->setRefunds(
|
||||||
array_diff($this->getRefundDetails(), array($refundDetail))
|
array_diff($this->getRefunds(), array($refundDetail))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ v1.0.0
|
|||||||
* PayPal\Common\FormatConverter => PayPal\Converter\FormatConverter
|
* PayPal\Common\FormatConverter => PayPal\Converter\FormatConverter
|
||||||
* PayPal\Rest\RestHandler => PayPal\Handler\RestHandler
|
* PayPal\Rest\RestHandler => PayPal\Handler\RestHandler
|
||||||
* PayPal\Rest\OauthHandler => PayPal\Handler\OauthHandler
|
* PayPal\Rest\OauthHandler => PayPal\Handler\OauthHandler
|
||||||
|
* Fixes to Methods
|
||||||
|
* PayPal\Api\Invoice->getPaymentDetails() was renamed to getPayments()
|
||||||
|
* PayPal\Api\Invoice->getRefundDetails() was renamed to getRefunds()
|
||||||
|
|
||||||
v1.0.0-beta
|
v1.0.0-beta
|
||||||
----
|
----
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -25,6 +25,18 @@ notification object
|
|||||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultPrinter::printResult(<span class="hljs-string">"Payment for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$record</span>, <span class="hljs-keyword">null</span>);
|
ResultPrinter::printResult(<span class="hljs-string">"Payment for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$record</span>, <span class="hljs-keyword">null</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
|
||||||
|
<p>Retrieve the invoice object by calling the
|
||||||
|
static <code>get</code> method
|
||||||
|
on the Invoice class by passing a valid
|
||||||
|
Invoice ID
|
||||||
|
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||||
|
<span class="hljs-variable">$invoice</span> = Invoice::get(<span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||||
|
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||||
|
ResultPrinter::printError(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$ex</span>);
|
||||||
|
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||||
|
}
|
||||||
|
|
||||||
|
ResultPrinter::printResult(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>);
|
||||||
|
|
||||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$invoice</span>;</div></div></div></div></body></html>
|
<span class="hljs-keyword">return</span> <span class="hljs-variable">$invoice</span>;</div></div></div></div></body></html>
|
||||||
@@ -24,6 +24,18 @@ notification object
|
|||||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultPrinter::printResult(<span class="hljs-string">"Refund for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$refund</span>, <span class="hljs-keyword">null</span>);
|
ResultPrinter::printResult(<span class="hljs-string">"Refund for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$refund</span>, <span class="hljs-keyword">null</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
|
||||||
|
<p>Retrieve the invoice object by calling the
|
||||||
|
static <code>get</code> method
|
||||||
|
on the Invoice class by passing a valid
|
||||||
|
Invoice ID
|
||||||
|
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||||
|
<span class="hljs-variable">$invoice</span> = Invoice::get(<span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||||
|
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||||
|
ResultPrinter::printError(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$ex</span>);
|
||||||
|
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||||
|
}
|
||||||
|
|
||||||
|
ResultPrinter::printResult(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>);
|
||||||
|
|
||||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$invoice</span>;</div></div></div></div></body></html>
|
<span class="hljs-keyword">return</span> <span class="hljs-variable">$invoice</span>;</div></div></div></div></body></html>
|
||||||
@@ -24,4 +24,18 @@ notification object
|
|||||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultPrinter::printResult(<span class="hljs-string">"Remind Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$notify</span>, <span class="hljs-keyword">null</span>);</div></div></div></div></body></html>
|
ResultPrinter::printResult(<span class="hljs-string">"Remind Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$notify</span>, <span class="hljs-keyword">null</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
|
||||||
|
<p>Retrieve the invoice object by calling the
|
||||||
|
static <code>get</code> method
|
||||||
|
on the Invoice class by passing a valid
|
||||||
|
Invoice ID
|
||||||
|
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||||
|
<span class="hljs-variable">$invoice</span> = Invoice::get(<span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||||
|
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||||
|
ResultPrinter::printError(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$ex</span>);
|
||||||
|
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||||
|
}
|
||||||
|
|
||||||
|
ResultPrinter::printResult(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>);
|
||||||
|
|
||||||
|
<span class="hljs-keyword">return</span> <span class="hljs-variable">$invoice</span>;</div></div></div></div></body></html>
|
||||||
@@ -13,6 +13,18 @@ with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)<
|
|||||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultPrinter::printResult(<span class="hljs-string">"Send Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>);
|
ResultPrinter::printResult(<span class="hljs-string">"Send Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
|
||||||
|
<p>Retrieve the invoice object by calling the
|
||||||
|
static <code>get</code> method
|
||||||
|
on the Invoice class by passing a valid
|
||||||
|
Invoice ID
|
||||||
|
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||||
|
<span class="hljs-variable">$invoice</span> = Invoice::get(<span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||||
|
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||||
|
ResultPrinter::printError(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$ex</span>);
|
||||||
|
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||||
|
}
|
||||||
|
|
||||||
|
ResultPrinter::printResult(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>);
|
||||||
|
|
||||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$invoice</span>;</div></div></div></div></body></html>
|
<span class="hljs-keyword">return</span> <span class="hljs-variable">$invoice</span>;</div></div></div></div></body></html>
|
||||||
@@ -18,6 +18,18 @@ with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)<
|
|||||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultPrinter::printResult(<span class="hljs-string">"Invoice Updated"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$invoice</span>);
|
ResultPrinter::printResult(<span class="hljs-string">"Invoice Updated"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$invoice</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
|
||||||
|
<p>Retrieve the invoice object by calling the
|
||||||
|
static <code>get</code> method
|
||||||
|
on the Invoice class by passing a valid
|
||||||
|
Invoice ID
|
||||||
|
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||||
|
<span class="hljs-variable">$invoice</span> = Invoice::get(<span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||||
|
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||||
|
ResultPrinter::printError(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$ex</span>);
|
||||||
|
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||||
|
}
|
||||||
|
|
||||||
|
ResultPrinter::printResult(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>);
|
||||||
|
|
||||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$invoice</span>;</div></div></div></div></body></html>
|
<span class="hljs-keyword">return</span> <span class="hljs-variable">$invoice</span>;</div></div></div></div></body></html>
|
||||||
@@ -36,4 +36,19 @@ try {
|
|||||||
|
|
||||||
ResultPrinter::printResult("Payment for Invoice", "Invoice", $invoice->getId(), $record, null);
|
ResultPrinter::printResult("Payment for Invoice", "Invoice", $invoice->getId(), $record, null);
|
||||||
|
|
||||||
|
// ### Retrieve Invoice
|
||||||
|
// Retrieve the invoice object by calling the
|
||||||
|
// static `get` method
|
||||||
|
// on the Invoice class by passing a valid
|
||||||
|
// Invoice ID
|
||||||
|
// (See bootstrap.php for more on `ApiContext`)
|
||||||
|
try {
|
||||||
|
$invoice = Invoice::get($invoice->getId(), $apiContext);
|
||||||
|
} catch (Exception $ex) {
|
||||||
|
ResultPrinter::printError("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $ex);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
ResultPrinter::printResult("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $invoice);
|
||||||
|
|
||||||
return $invoice;
|
return $invoice;
|
||||||
|
|||||||
@@ -35,4 +35,19 @@ try {
|
|||||||
|
|
||||||
ResultPrinter::printResult("Refund for Invoice", "Invoice", $invoice->getId(), $refund, null);
|
ResultPrinter::printResult("Refund for Invoice", "Invoice", $invoice->getId(), $refund, null);
|
||||||
|
|
||||||
|
// ### Retrieve Invoice
|
||||||
|
// Retrieve the invoice object by calling the
|
||||||
|
// static `get` method
|
||||||
|
// on the Invoice class by passing a valid
|
||||||
|
// Invoice ID
|
||||||
|
// (See bootstrap.php for more on `ApiContext`)
|
||||||
|
try {
|
||||||
|
$invoice = Invoice::get($invoice->getId(), $apiContext);
|
||||||
|
} catch (Exception $ex) {
|
||||||
|
ResultPrinter::printError("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $ex);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
ResultPrinter::printResult("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $invoice);
|
||||||
|
|
||||||
return $invoice;
|
return $invoice;
|
||||||
|
|||||||
@@ -36,3 +36,19 @@ try {
|
|||||||
|
|
||||||
ResultPrinter::printResult("Remind Invoice", "Invoice", null, $notify, null);
|
ResultPrinter::printResult("Remind Invoice", "Invoice", null, $notify, null);
|
||||||
|
|
||||||
|
// ### Retrieve Invoice
|
||||||
|
// Retrieve the invoice object by calling the
|
||||||
|
// static `get` method
|
||||||
|
// on the Invoice class by passing a valid
|
||||||
|
// Invoice ID
|
||||||
|
// (See bootstrap.php for more on `ApiContext`)
|
||||||
|
try {
|
||||||
|
$invoice = Invoice::get($invoice->getId(), $apiContext);
|
||||||
|
} catch (Exception $ex) {
|
||||||
|
ResultPrinter::printError("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $ex);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
ResultPrinter::printResult("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $invoice);
|
||||||
|
|
||||||
|
return $invoice;
|
||||||
|
|||||||
@@ -22,4 +22,19 @@ try {
|
|||||||
|
|
||||||
ResultPrinter::printResult("Send Invoice", "Invoice", $invoice->getId(), null, null);
|
ResultPrinter::printResult("Send Invoice", "Invoice", $invoice->getId(), null, null);
|
||||||
|
|
||||||
|
// ### Retrieve Invoice
|
||||||
|
// Retrieve the invoice object by calling the
|
||||||
|
// static `get` method
|
||||||
|
// on the Invoice class by passing a valid
|
||||||
|
// Invoice ID
|
||||||
|
// (See bootstrap.php for more on `ApiContext`)
|
||||||
|
try {
|
||||||
|
$invoice = Invoice::get($invoice->getId(), $apiContext);
|
||||||
|
} catch (Exception $ex) {
|
||||||
|
ResultPrinter::printError("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $ex);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
ResultPrinter::printResult("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $invoice);
|
||||||
|
|
||||||
return $invoice;
|
return $invoice;
|
||||||
|
|||||||
@@ -35,4 +35,19 @@ try {
|
|||||||
|
|
||||||
ResultPrinter::printResult("Invoice Updated", "Invoice", $invoice->getId(), $request, $invoice);
|
ResultPrinter::printResult("Invoice Updated", "Invoice", $invoice->getId(), $request, $invoice);
|
||||||
|
|
||||||
|
// ### Retrieve Invoice
|
||||||
|
// Retrieve the invoice object by calling the
|
||||||
|
// static `get` method
|
||||||
|
// on the Invoice class by passing a valid
|
||||||
|
// Invoice ID
|
||||||
|
// (See bootstrap.php for more on `ApiContext`)
|
||||||
|
try {
|
||||||
|
$invoice = Invoice::get($invoice->getId(), $apiContext);
|
||||||
|
} catch (Exception $ex) {
|
||||||
|
ResultPrinter::printError("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $ex);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
ResultPrinter::printResult("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $invoice);
|
||||||
|
|
||||||
return $invoice;
|
return $invoice;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public static function getJson()
|
public static function getJson()
|
||||||
{
|
{
|
||||||
return '{"id":"TestSample","number":"TestSample","uri":"TestSample","status":"TestSample","merchant_info":' .MerchantInfoTest::getJson() . ',"billing_info":' .BillingInfoTest::getJson() . ',"shipping_info":' .ShippingInfoTest::getJson() . ',"items":' .InvoiceItemTest::getJson() . ',"invoice_date":"TestSample","payment_term":' .PaymentTermTest::getJson() . ',"discount":' .CostTest::getJson() . ',"shipping_cost":' .ShippingCostTest::getJson() . ',"custom":' .CustomAmountTest::getJson() . ',"tax_calculated_after_discount":true,"tax_inclusive":true,"terms":"TestSample","note":"TestSample","merchant_memo":"TestSample","logo_url":"http://www.google.com","total_amount":' .CurrencyTest::getJson() . ',"payment_details":' .PaymentDetailTest::getJson() . ',"refund_details":' .RefundDetailTest::getJson() . ',"metadata":' .MetadataTest::getJson() . ',"additional_data":"TestSample"}';
|
return '{"id":"TestSample","number":"TestSample","uri":"TestSample","status":"TestSample","merchant_info":' .MerchantInfoTest::getJson() . ',"billing_info":' .BillingInfoTest::getJson() . ',"shipping_info":' .ShippingInfoTest::getJson() . ',"items":' .InvoiceItemTest::getJson() . ',"invoice_date":"TestSample","payment_term":' .PaymentTermTest::getJson() . ',"discount":' .CostTest::getJson() . ',"shipping_cost":' .ShippingCostTest::getJson() . ',"custom":' .CustomAmountTest::getJson() . ',"tax_calculated_after_discount":true,"tax_inclusive":true,"terms":"TestSample","note":"TestSample","merchant_memo":"TestSample","logo_url":"http://www.google.com","total_amount":' .CurrencyTest::getJson() . ',"payments":' .PaymentDetailTest::getJson() . ',"refunds":' .RefundDetailTest::getJson() . ',"metadata":' .MetadataTest::getJson() . ',"additional_data":"TestSample"}';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,8 +63,8 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertNotNull($obj->getMerchantMemo());
|
$this->assertNotNull($obj->getMerchantMemo());
|
||||||
$this->assertNotNull($obj->getLogoUrl());
|
$this->assertNotNull($obj->getLogoUrl());
|
||||||
$this->assertNotNull($obj->getTotalAmount());
|
$this->assertNotNull($obj->getTotalAmount());
|
||||||
$this->assertNotNull($obj->getPaymentDetails());
|
$this->assertNotNull($obj->getPayments());
|
||||||
$this->assertNotNull($obj->getRefundDetails());
|
$this->assertNotNull($obj->getRefunds());
|
||||||
$this->assertNotNull($obj->getMetadata());
|
$this->assertNotNull($obj->getMetadata());
|
||||||
$this->assertNotNull($obj->getAdditionalData());
|
$this->assertNotNull($obj->getAdditionalData());
|
||||||
$this->assertEquals(self::getJson(), $obj->toJson());
|
$this->assertEquals(self::getJson(), $obj->toJson());
|
||||||
@@ -97,8 +97,8 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals($obj->getMerchantMemo(), "TestSample");
|
$this->assertEquals($obj->getMerchantMemo(), "TestSample");
|
||||||
$this->assertEquals($obj->getLogoUrl(), "http://www.google.com");
|
$this->assertEquals($obj->getLogoUrl(), "http://www.google.com");
|
||||||
$this->assertEquals($obj->getTotalAmount(), CurrencyTest::getObject());
|
$this->assertEquals($obj->getTotalAmount(), CurrencyTest::getObject());
|
||||||
$this->assertEquals($obj->getPaymentDetails(), PaymentDetailTest::getObject());
|
$this->assertEquals($obj->getPayments(), PaymentDetailTest::getObject());
|
||||||
$this->assertEquals($obj->getRefundDetails(), RefundDetailTest::getObject());
|
$this->assertEquals($obj->getRefunds(), RefundDetailTest::getObject());
|
||||||
$this->assertEquals($obj->getMetadata(), MetadataTest::getObject());
|
$this->assertEquals($obj->getMetadata(), MetadataTest::getObject());
|
||||||
$this->assertEquals($obj->getAdditionalData(), "TestSample");
|
$this->assertEquals($obj->getAdditionalData(), "TestSample");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user