From e644c8cb9d1e235abc7fd3c9c45da3c86ead237a Mon Sep 17 00:00:00 2001 From: Joshua Lewis Date: Fri, 9 Apr 2021 12:58:22 -0400 Subject: [PATCH] Added IPN updates --- .../Bitpay/BPCheckout/Model/IpnManagement.php | 19 ++++++++++--------- .../Bitpay/BPCheckout/Observer/BPRedirect.php | 2 +- code/Bitpay/BPCheckout/composer.json | 4 ++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/code/Bitpay/BPCheckout/Model/IpnManagement.php b/code/Bitpay/BPCheckout/Model/IpnManagement.php index aebff3c..6bc47f2 100755 --- a/code/Bitpay/BPCheckout/Model/IpnManagement.php +++ b/code/Bitpay/BPCheckout/Model/IpnManagement.php @@ -116,12 +116,12 @@ public function BPC_Invoice($item){ return $item; } - public function BPC_checkInvoiceStatus($orderID,$item) + public function BPC_checkInvoiceStatus($orderID,$item,$token) { $post_fields = ($item->item_params); $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, 'https://' . $item->invoice_endpoint . '/invoices/' . $post_fields->invoiceID); + curl_setopt($ch, CURLOPT_URL, 'https://' . $item->invoice_endpoint . '/invoices/' . $post_fields->invoiceID.'?token='.$token); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); @@ -225,7 +225,8 @@ public function postIpn() $item = $this->BPC_Item( $config,$params); $invoice = $this->BPC_Invoice($item); - $orderStatus = json_decode($this->BPC_checkInvoiceStatus($order_invoice,$item)); + $orderStatus = json_decode($this->BPC_checkInvoiceStatus($order_invoice,$item,$bitpay_token)); + $invoice_status = $orderStatus->data->status; @@ -242,7 +243,7 @@ public function postIpn() case 'invoice_completed': if ($invoice_status == 'complete'): - $order->addStatusHistoryComment('BitPay Invoice ' . $order_invoice . ' status has changed to Completed.'); + $order->addStatusHistoryComment('BitPay Invoice ' . $order_invoice . ' status has changed to Completed.'); $order->setState(Order::STATE_PROCESSING)->setStatus(Order::STATE_PROCESSING); $order->save(); $this->createMGInvoice($order); @@ -253,7 +254,7 @@ public function postIpn() case 'invoice_confirmed': #pending or processing from plugin settings if ($invoice_status == 'confirmed'): - $order->addStatusHistoryComment('BitPay Invoice ' . $order_invoice . ' processing has been completed.'); + $order->addStatusHistoryComment('BitPay Invoice ' . $order_invoice . ' processing has been completed.'); if ($bitpay_ipn_mapping != 'processing'): #$order->setState(Order::STATE_NEW)->setStatus(Order::STATE_NEW); $order->setState('new', true); @@ -270,7 +271,7 @@ public function postIpn() case 'invoice_paidInFull': #STATE_PENDING if ($invoice_status == 'paid'): - $order->addStatusHistoryComment('BitPay Invoice ' . $order_invoice . ' is processing.'); + $order->addStatusHistoryComment('BitPay Invoice ' . $order_invoice . ' is processing.'); $order->setState('new', true); $order->setStatus('pending', true); $order->save(); @@ -280,7 +281,7 @@ public function postIpn() case 'invoice_failedToConfirm': if ($invoice_status == 'invalid'): - $order->addStatusHistoryComment('BitPay Invoice ' . $order_invoice . ' has become invalid because of network congestion. Order will automatically update when the status changes.'); + $order->addStatusHistoryComment('BitPay Invoice ' . $order_invoice . ' has become invalid because of network congestion. Order will automatically update when the status changes.'); $order->save(); return true; endif; @@ -288,7 +289,7 @@ public function postIpn() case 'invoice_expired': if ($invoice_status == 'expired'): - $order->addStatusHistoryComment('BitPay Invoice ' . $order_invoice . ' has expired.'); + $order->addStatusHistoryComment('BitPay Invoice ' . $order_invoice . ' has expired.'); $order->setState(Order::STATE_CANCELED)->setStatus(Order::STATE_CANCELED); $order->save(); return true; @@ -330,6 +331,6 @@ public function createMGInvoice($order) } public function getExtensionVersion() { - return 'Bitpay_BPCheckout_Magento2_3.14.2002'; + return 'Bitpay_BPCheckout_Magento2_4.09.2102'; } } diff --git a/code/Bitpay/BPCheckout/Observer/BPRedirect.php b/code/Bitpay/BPCheckout/Observer/BPRedirect.php index 23ea378..f8c9f12 100755 --- a/code/Bitpay/BPCheckout/Observer/BPRedirect.php +++ b/code/Bitpay/BPCheckout/Observer/BPRedirect.php @@ -342,7 +342,7 @@ public function execute(\Magento\Framework\Event\Observer $observer) } //end execute function public function getExtensionVersion() { - return 'Bitpay_BPCheckout_Magento2_3.14.2002'; + return 'Bitpay_BPCheckout_Magento2_4.09.2102'; } diff --git a/code/Bitpay/BPCheckout/composer.json b/code/Bitpay/BPCheckout/composer.json index cc306e2..c17eae5 100644 --- a/code/Bitpay/BPCheckout/composer.json +++ b/code/Bitpay/BPCheckout/composer.json @@ -3,7 +3,7 @@ "description": "", "type": "magento2-module", "license": "mit", - "version":"3.14.2002", + "version":"4.09.2102", "authors": [ { "email": "integrations@bitpay.com", @@ -12,7 +12,7 @@ ], "minimum-stability": "dev", "require": { - "php": "~5.5.0|~5.6.0|~7.0.0|~7.1.0|~7.2.0" + "php": "~7.3.0" }, "autoload": { "files": [