forked from LiveCarta/PayPal-PHP-SDK
More Invoice API Updates
This commit is contained in:
55
lib/PayPal/Api/Image.php
Normal file
55
lib/PayPal/Api/Image.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Api;
|
||||
|
||||
use PayPal\Common\PPModel;
|
||||
|
||||
/**
|
||||
* Class Image
|
||||
*
|
||||
* @package PayPal\Api
|
||||
*
|
||||
* @property string image
|
||||
*/
|
||||
class Image extends PPModel
|
||||
{
|
||||
/**
|
||||
* List of invoices belonging to a merchant.
|
||||
*
|
||||
* @param string $imageBase64String
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setImageBase64($imageBase64String)
|
||||
{
|
||||
$this->image = $imageBase64String;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Image as Base-64 encoded String
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImageBase64()
|
||||
{
|
||||
return $this->image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the Image to file
|
||||
*
|
||||
* @param string $name File Name
|
||||
*/
|
||||
public function saveToFile($name = null)
|
||||
{
|
||||
// Self Generate File Location
|
||||
if (!$name) {
|
||||
$name = uniqid() . '.png';
|
||||
}
|
||||
// Save to File
|
||||
file_put_contents($name, base64_decode($this->getImageBase64()));
|
||||
return $name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,8 +4,6 @@ namespace PayPal\Api;
|
||||
|
||||
use PayPal\Common\ResourceModel;
|
||||
use PayPal\Validation\ArgumentValidator;
|
||||
use PayPal\Api\Invoices;
|
||||
use PayPal\Api\object;
|
||||
use PayPal\Rest\ApiContext;
|
||||
use PayPal\Transport\PPRestCall;
|
||||
use PayPal\Validation\UrlValidator;
|
||||
@@ -1096,7 +1094,7 @@ class Invoice extends ResourceModel
|
||||
* @param Search $search
|
||||
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
|
||||
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
|
||||
* @return Invoices
|
||||
* @return InvoiceSearchResponse
|
||||
*/
|
||||
public function search($search, $apiContext = null, $restCall = null)
|
||||
{
|
||||
@@ -1110,7 +1108,7 @@ class Invoice extends ResourceModel
|
||||
$apiContext,
|
||||
$restCall
|
||||
);
|
||||
$ret = new Invoices();
|
||||
$ret = new InvoiceSearchResponse();
|
||||
$ret->fromJson($json);
|
||||
return $ret;
|
||||
}
|
||||
@@ -1261,26 +1259,49 @@ class Invoice extends ResourceModel
|
||||
/**
|
||||
* List some or all invoices for a merchant according to optional query string parameters specified.
|
||||
*
|
||||
* @param array $params
|
||||
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
|
||||
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
|
||||
* @return Invoices
|
||||
* @return InvoiceSearchResponse
|
||||
*/
|
||||
public static function getAll($apiContext = null, $restCall = null)
|
||||
public static function getAll($params = array(), $apiContext = null, $restCall = null)
|
||||
{
|
||||
ArgumentValidator::validate($params, 'params');
|
||||
|
||||
$allowedParams = array(
|
||||
'page' => 1,
|
||||
'page_size' => 1,
|
||||
'total_count_required' => 1
|
||||
);
|
||||
|
||||
$payLoad = "";
|
||||
$json = self::executeCall(
|
||||
"/v1/invoicing/invoices/",
|
||||
"/v1/invoicing/invoices/?" . http_build_query(array_intersect_key($params, $allowedParams)),
|
||||
"GET",
|
||||
$payLoad,
|
||||
null,
|
||||
$apiContext,
|
||||
$restCall
|
||||
);
|
||||
$ret = new Invoices();
|
||||
$ret = new InvoiceSearchResponse();
|
||||
$ret->fromJson($json);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use getAll instead
|
||||
*
|
||||
* List some or all invoices for a merchant according to optional query string parameters specified.
|
||||
*
|
||||
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
|
||||
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
|
||||
* @return InvoiceSearchResponse
|
||||
*/
|
||||
public static function get_all($apiContext = null, $restCall = null)
|
||||
{
|
||||
return self::getAll(null, $apiContext, $restCall);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
@@ -1329,24 +1350,33 @@ class Invoice extends ResourceModel
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param array $params
|
||||
* @param string $invoiceId
|
||||
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
|
||||
* @param PPRestCall $restCall is the Rest Call Service that is used to make rest calls
|
||||
* @return object
|
||||
* @return Image
|
||||
*/
|
||||
public static function qrCode($invoiceId, $apiContext = null, $restCall = null)
|
||||
public static function qrCode($invoiceId, $params = array(), $apiContext = null, $restCall = null)
|
||||
{
|
||||
ArgumentValidator::validate($invoiceId, 'invoiceId');
|
||||
ArgumentValidator::validate($params, 'params');
|
||||
|
||||
$allowedParams = array(
|
||||
'width' => 1,
|
||||
'height' => 1,
|
||||
'action' => 1
|
||||
);
|
||||
|
||||
$payLoad = "";
|
||||
$json = self::executeCall(
|
||||
"/v1/invoicing/invoices/$invoiceId/qr-code",
|
||||
"/v1/invoicing/invoices/$invoiceId/qr-code?" . http_build_query(array_intersect_key($params, $allowedParams)),
|
||||
"GET",
|
||||
$payLoad,
|
||||
null,
|
||||
$apiContext,
|
||||
$restCall
|
||||
);
|
||||
$ret = new object();
|
||||
$ret = new Image();
|
||||
$ret->fromJson($json);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,8 +4,6 @@ namespace PayPal\Common;
|
||||
|
||||
class FormatConverter {
|
||||
|
||||
const TWO_DECIMAL_PLACES = '%0.2f';
|
||||
|
||||
/**
|
||||
* Format the data based on the input formatter value
|
||||
*
|
||||
@@ -27,7 +25,7 @@ class FormatConverter {
|
||||
public static function formatToTwoDecimalPlaces($value)
|
||||
{
|
||||
if (trim($value) != null) {
|
||||
return static::format($value, self::TWO_DECIMAL_PLACES);
|
||||
return number_format($value, 2, '.', '');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -187,6 +187,94 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><a href="https://developer.paypal.com/webapps/developer/docs/api/#authorizations"
|
||||
target="_blank">Authorization and capture</a></h3>
|
||||
</div>
|
||||
<!-- List group -->
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Authorize Payment</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="payments/AuthorizePayment.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/payments/AuthorizePayment.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Get details of an authorized payment</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="payments/GetAuthorization.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/payments/GetAuthorization.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Capture an authorized payment</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="payments/AuthorizationCapture.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/payments/AuthorizationCapture.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Get details of a captured payment</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="payments/GetCapture.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/payments/GetCapture.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Void an authorized payment</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="payments/VoidAuthorization.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/payments/VoidAuthorization.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Reauthorize a payment</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="payments/Reauthorization.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/payments/Reauthorization.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Refund captured payment</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="payments/RefundCapture.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/payments/RefundCapture.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><a href="https://developer.paypal.com/webapps/developer/docs/api/#sale-transactions"
|
||||
@@ -394,93 +482,6 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><a href="https://developer.paypal.com/webapps/developer/docs/api/#authorizations"
|
||||
target="_blank">Authorization and capture</a></h3>
|
||||
</div>
|
||||
<!-- List group -->
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Authorize Payment</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="payments/AuthorizePayment.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/payments/AuthorizePayment.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Get details of an authorized payment</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="payments/GetAuthorization.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/payments/GetAuthorization.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Capture an authorized payment</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="payments/AuthorizationCapture.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/payments/AuthorizationCapture.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Get details of a captured payment</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="payments/GetCapture.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/payments/GetCapture.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Void an authorized payment</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="payments/VoidAuthorization.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/payments/VoidAuthorization.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Reauthorize a payment</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="payments/Reauthorization.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/payments/Reauthorization.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Refund captured payment</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="payments/RefundCapture.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/payments/RefundCapture.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><a href="https://developer.paypal.com/webapps/developer/docs/api/#payment-experience"
|
||||
@@ -566,7 +567,7 @@
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Create Invoice</h5></div>
|
||||
<div class="col-md-8"><h5>Create an Invoice</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="invoice/CreateInvoice.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
@@ -577,29 +578,7 @@
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Get Invoice</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="invoice/GetInvoice.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/invoice/GetInvoice.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>List All Invoice</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="invoice/ListInvoice.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/invoice/ListInvoice.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Send Invoice</h5></div>
|
||||
<div class="col-md-8"><h5>Send an Invoice</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="invoice/SendInvoice.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
@@ -610,7 +589,51 @@
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Remind Invoice</h5></div>
|
||||
<div class="col-md-8"><h5>Update an Invoice</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="invoice/UpdateInvoice.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/invoice/UpdateInvoice.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Retrieve an Invoice</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="invoice/GetInvoice.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/invoice/GetInvoice.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Get Invoices of a Merchant</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="invoice/ListInvoice.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/invoice/ListInvoice.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Search for Invoices</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="invoice/SearchInvoices.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/invoice/SearchInvoices.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Send an Invoice Reminder</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="invoice/RemindInvoice.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
@@ -621,7 +644,7 @@
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Cancel Invoice</h5></div>
|
||||
<div class="col-md-8"><h5>Cancel an Invoice</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="invoice/CancelInvoice.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
@@ -630,6 +653,50 @@
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Delete an Invoice</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="invoice/DeleteInvoice.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/invoice/DeleteInvoice.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Retrieve a QR Code</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="invoice/RetrieveQRCode.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/invoice/RetrieveQRCode.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Record a Payment</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="invoice/RecordPayment.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/invoice/RecordPayment.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="row">
|
||||
<div class="col-md-8"><h5>Record a Refund</h5></div>
|
||||
<div class="col-md-4">
|
||||
<a href="invoice/RecordRefund.php" class="btn btn-primary pull-left execute"> Execute <i
|
||||
class="fa fa-play-circle-o"></i></a>
|
||||
<a href="doc/invoice/RecordRefund.html" class="btn btn-default pull-right">Source <i
|
||||
class="fa fa-file-code-o"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ try {
|
||||
// static `get_all` method on the Invoice class.
|
||||
// Refer the method doc for valid values for keys
|
||||
// (See bootstrap.php for more on `ApiContext`)
|
||||
$invoices = Invoice::get_all($apiContext);
|
||||
$invoices = Invoice::getAll(array('page' => 0, 'page_size' => 4, 'total_count_required' => true), $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
ResultPrinter::printError("Lookup Invoice History", "Invoice", null, null, $ex);
|
||||
exit(1);
|
||||
|
||||
@@ -11,13 +11,6 @@ use PayPal\Api\Invoice;
|
||||
use PayPal\Api\Notification;
|
||||
|
||||
try {
|
||||
// ### 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`)
|
||||
$invoice = Invoice::get($invoice->getId(), $apiContext);
|
||||
|
||||
// ### Notification Object
|
||||
// This would send a notification to both merchant as well
|
||||
|
||||
41
sample/invoice/RetrieveQRCode.php
Normal file
41
sample/invoice/RetrieveQRCode.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
// # Retrieve QR Code for Invoice Sample
|
||||
// Specify an invoice ID to get a QR code (image) that corresponds to the invoice ID. A QR code for an invoice can be added to a paper or PDF invoice. When a customer uses their mobile device to scan the QR code, the customer is redirected to the PayPal mobile payment flow, where they can pay online with PayPal or a credit card.
|
||||
|
||||
/** @var Invoice $invoice */
|
||||
$invoice = require 'SendInvoice.php';
|
||||
|
||||
use PayPal\Api\Invoice;
|
||||
use PayPal\Api\Notification;
|
||||
|
||||
try {
|
||||
|
||||
// ### Retrieve QR Code of Sent Invoice
|
||||
// Retrieve QR Code of Sent Invoice by calling the
|
||||
// `qrCode` method
|
||||
// on the Invoice class by passing a valid
|
||||
// notification object
|
||||
// (See bootstrap.php for more on `ApiContext`)
|
||||
$image = Invoice::qrCode($invoice->getId(), array('height' => '300', 'width' => '300'), $apiContext);
|
||||
|
||||
// ### Optionally Save to File
|
||||
// This is not a required step. However, if you want to store this image as a file, you can use
|
||||
// 'saveToFile' method with proper file name.
|
||||
// This will save the image as /samples/invoice/images/sample.png
|
||||
$path = $image->saveToFile("images/sample.png");
|
||||
|
||||
|
||||
} catch (Exception $ex) {
|
||||
ResultPrinter::printError("Retrieved QR Code for Invoice", "Invoice", $invoice->getId(), null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult("Retrieved QR Code for Invoice", "Invoice", $invoice->getId(), null, $image);
|
||||
|
||||
// ### Show the Image
|
||||
// In PHP, there are many ways to present an images.
|
||||
// One of the ways, you could directly inject the base64-encoded string
|
||||
// with proper image information in front of it.
|
||||
echo '<img src="data:image/png;base64,'. $image->getImageBase64() . '" alt="Invoice QR Code" />';
|
||||
|
||||
@@ -10,13 +10,6 @@ $invoice = require 'CreateInvoice.php';
|
||||
use PayPal\Api\Invoice;
|
||||
|
||||
try {
|
||||
// ### 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`)
|
||||
$invoice = Invoice::get($invoice->getId(), $apiContext);
|
||||
|
||||
// ### Send Invoice
|
||||
// Send a legitimate invoice to the payer
|
||||
|
||||
31
sample/invoice/UpdateInvoice.php
Normal file
31
sample/invoice/UpdateInvoice.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
// # Update Invoice Sample
|
||||
// This sample code demonstrate how you can update
|
||||
// an invoice.
|
||||
|
||||
/** @var Invoice $invoice */
|
||||
$invoice = require 'CreateInvoice.php';
|
||||
use PayPal\Api\Invoice;
|
||||
|
||||
// ### Update Invoice
|
||||
// Lets update some information
|
||||
$invoice->setInvoiceDate("2014-11-16 PST");
|
||||
|
||||
|
||||
// For Sample Purposes Only.
|
||||
$request = clone $invoice;
|
||||
|
||||
try {
|
||||
// ### Update Invoice
|
||||
// Update an invoice by calling the invoice->update() method
|
||||
// with a valid ApiContext (See bootstrap.php for more on `ApiContext`)
|
||||
$invoice->update($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
ResultPrinter::printError("Invoice Updated", "Invoice", null, $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult("Invoice Updated", "Invoice", $invoice->getId(), $request, $invoice);
|
||||
|
||||
return $invoice;
|
||||
@@ -62,6 +62,12 @@ class FormatConverterTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
}
|
||||
|
||||
public function testFormat()
|
||||
{
|
||||
$result = FormatConverter::format("12.0123", "%0.2f");
|
||||
$this->assertEquals("12.01", $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider apiModelSettersProvider
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user