From ac448655e1e7880bc966a42f94c0e1613954cbc3 Mon Sep 17 00:00:00 2001 From: Antonio Buedo Date: Tue, 25 Feb 2020 18:26:10 +0100 Subject: [PATCH] #v1.2.2002.0-rc - Mayor updates (#7) - Php required version lowered - Invoice model updated - API frame headers added - HTTP Headers refactor - Sub-version upgrade --- src/BitPaySDKLight/Client.php | 4 ++-- src/BitPaySDKLight/Env.php | 14 ++++++----- src/BitPaySDKLight/Model/Invoice/Invoice.php | 24 ++++++++++++++++--- .../Model/Invoice/PaymentCode.php | 5 ++++ .../Model/Invoice/PaymentCodes.php | 5 ++++ src/BitPaySDKLight/Util/RESTcli/RESTcli.php | 6 +++-- 6 files changed, 45 insertions(+), 13 deletions(-) diff --git a/src/BitPaySDKLight/Client.php b/src/BitPaySDKLight/Client.php index 694c89d..d2af999 100644 --- a/src/BitPaySDKLight/Client.php +++ b/src/BitPaySDKLight/Client.php @@ -23,9 +23,9 @@ * Class Client * @package Bitpay light * @author Antonio Buedo - * @version 1.1.1912 + * @version 1.2.2002 * See bitpay.com/api for more information. - * date 11.12.2019 + * date 25.02.2020 */ class Client { diff --git a/src/BitPaySDKLight/Env.php b/src/BitPaySDKLight/Env.php index 4629383..47404b6 100644 --- a/src/BitPaySDKLight/Env.php +++ b/src/BitPaySDKLight/Env.php @@ -6,10 +6,12 @@ interface Env { - const Test = "Test"; - const Prod = "Prod"; - const TestUrl = "https://test.bitpay.com/"; - const ProdUrl = "https://bitpay.com/"; - const BitpayApiVersion = "2.0.0"; - const BitpayPluginInfo = "BitPay_PHP_Client_v1.1.1912"; + const Test = "Test"; + const Prod = "Prod"; + const TestUrl = "https://test.bitpay.com/"; + const ProdUrl = "https://bitpay.com/"; + const BitpayApiVersion = "2.0.0"; + const BitpayPluginInfo = "BitPay_PHP_Client_v1.2.2002"; + const BitpayApiFrame = "custom-light"; + const BitpayApiFrameVersion = "1.0.0"; } \ No newline at end of file diff --git a/src/BitPaySDKLight/Model/Invoice/Invoice.php b/src/BitPaySDKLight/Model/Invoice/Invoice.php index 0ec742b..5a01ac8 100644 --- a/src/BitPaySDKLight/Model/Invoice/Invoice.php +++ b/src/BitPaySDKLight/Model/Invoice/Invoice.php @@ -51,6 +51,13 @@ class Invoice protected $_shopper; protected $_billId; protected $_refundInfo; + + /** + * PaymentCodes will be deprecated TODO on version 2.0 + * + * @var array + * @deprecated + */ protected $_paymentCodes; protected $_extendedNotifications = false; @@ -78,7 +85,7 @@ public function __construct(float $price = null, string $currency = null) $this->_minerFees = new MinerFees(); $this->_shopper = new Shopper(); $this->_refundInfo = new RefundInfo(); - $this->_paymentCodes = new PaymentCodes(); + $this->_paymentCodes = null; $this->_paymentTotals = new PaymentTotal(); $this->_paymentSubtotals = new PaymentTotal(); $this->_paymentDisplayTotals = new PaymentTotal(); @@ -464,14 +471,25 @@ public function setRefundInfo(RefundInfo $refundInfo) $this->_refundInfo = $refundInfo; } + /** + * PaymentCodes will be deprecated TODO on version 2.0 + * + * @deprecated + */ public function getPaymentCodes() { return $this->_paymentCodes; } + /** + * PaymentCodes will be deprecated TODO on version 2.0 + * + * @var array + * @deprecated + */ public function setPaymentCodes(PaymentCodes $paymentCodes) { - $this->_paymentCodes = $paymentCodes; + $this->_paymentCodes = null; } public function getExtendedNotifications() @@ -593,7 +611,7 @@ public function toArray() 'shopper' => $this->getShopper()->toArray(), 'billId' => $this->getBillId(), 'refundInfo' => $this->getRefundInfo()->toArray(), - 'paymentCodes' => $this->getPaymentCodes()->toArray(), + 'paymentCodes' => [], 'extendedNotifications' => $this->getExtendedNotifications(), 'transactionCurrency' => $this->getTransactionCurrency(), 'amountPaid' => $this->getAmountPaid(), diff --git a/src/BitPaySDKLight/Model/Invoice/PaymentCode.php b/src/BitPaySDKLight/Model/Invoice/PaymentCode.php index ccf9e6a..f3c4fee 100644 --- a/src/BitPaySDKLight/Model/Invoice/PaymentCode.php +++ b/src/BitPaySDKLight/Model/Invoice/PaymentCode.php @@ -4,6 +4,11 @@ namespace BitPaySDKLight\Model\Invoice; +/** + * PaymentCode will be deprecated TODO on version 2.0 + * + * @deprecated + */ class PaymentCode { protected $_bip72b; diff --git a/src/BitPaySDKLight/Model/Invoice/PaymentCodes.php b/src/BitPaySDKLight/Model/Invoice/PaymentCodes.php index 56980a8..22d470e 100644 --- a/src/BitPaySDKLight/Model/Invoice/PaymentCodes.php +++ b/src/BitPaySDKLight/Model/Invoice/PaymentCodes.php @@ -4,6 +4,11 @@ namespace BitPaySDKLight\Model\Invoice; +/** + * PaymentCode will be deprecated TODO on version 2.0 + * + * @deprecated + */ class PaymentCodes { protected $_btc; diff --git a/src/BitPaySDKLight/Util/RESTcli/RESTcli.php b/src/BitPaySDKLight/Util/RESTcli/RESTcli.php index 526d063..88ef170 100644 --- a/src/BitPaySDKLight/Util/RESTcli/RESTcli.php +++ b/src/BitPaySDKLight/Util/RESTcli/RESTcli.php @@ -36,8 +36,10 @@ public function init() 'base_url' => $this->_baseUrl, 'defaults' => [ 'headers' => [ - "x-accept-version" => Env::BitpayApiVersion, - 'x-bitpay-plugin-info' => Env::BitpayPluginInfo, + "x-accept-version" => Env::BitpayApiVersion, + 'X-BitPay-Plugin-Info' => Env::BitpayPluginInfo, + 'x-bitpay-api-frame' => Env::BitpayApiFrame, + 'x-bitpay-api-frame-version' => Env::BitpayApiFrameVersion, ], ], ]);