From 89497bc7bff444cd1093c43b17d92c57f5ad7d53 Mon Sep 17 00:00:00 2001 From: Joshua Lewis Date: Wed, 16 Jun 2021 10:20:06 -0400 Subject: [PATCH] Updated redirect page --- .../Bitpay/BPCheckout/Model/IpnManagement.php | 2 +- .../Bitpay/BPCheckout/Observer/BPRedirect.php | 41 ++++--------------- code/Bitpay/BPCheckout/composer.json | 2 +- .../BPCheckout/etc/adminhtml/system.xml | 6 --- code/Bitpay/BPCheckout/etc/module.xml | 2 +- .../view/frontend/templates/index.phtml | 33 +++++++++++++-- 6 files changed, 41 insertions(+), 45 deletions(-) diff --git a/code/Bitpay/BPCheckout/Model/IpnManagement.php b/code/Bitpay/BPCheckout/Model/IpnManagement.php index 3e4bd07..62fa522 100755 --- a/code/Bitpay/BPCheckout/Model/IpnManagement.php +++ b/code/Bitpay/BPCheckout/Model/IpnManagement.php @@ -423,6 +423,6 @@ public function createMGInvoice($order) } public function getExtensionVersion() { - return 'Bitpay_BPCheckout_Magento2_6.11.2103'; + return 'Bitpay_BPCheckout_Magento2_6.12.1'; } } diff --git a/code/Bitpay/BPCheckout/Observer/BPRedirect.php b/code/Bitpay/BPCheckout/Observer/BPRedirect.php index 2e60eeb..15299ad 100755 --- a/code/Bitpay/BPCheckout/Observer/BPRedirect.php +++ b/code/Bitpay/BPCheckout/Observer/BPRedirect.php @@ -250,7 +250,6 @@ public function execute(\Magento\Framework\Event\Observer $observer) $modal = true; endif; - $bitpay_redirect_url = $this->getStoreConfig('payment/bpcheckout/bitpay_redirect_url'); $config = $this->BPC_Configuration($bitpay_token,$env); @@ -274,11 +273,7 @@ public function execute(\Magento\Framework\Event\Observer $observer) $buyerInfo->name = $order->getBillingAddress()->getFirstName() . ' ' . $order->getBillingAddress()->getLastName(); $buyerInfo->email = $order->getCustomerEmail(); } - if($guest_login){ - $g = 1; - }else{ - $g = 0; - } + $params->buyer = $buyerInfo; $params->orderId = trim($order_id_long); @@ -286,30 +281,12 @@ public function execute(\Magento\Framework\Event\Observer $observer) setcookie('oar_order_id', $order_id_long, time() + (86400 * 30), "/"); // 86400 = 1 day setcookie('oar_billing_lastname', $order->getBillingAddress()->getLastName(), time() + (86400 * 30), "/"); // 86400 = 1 day setcookie('oar_email', $order->getCustomerEmail(), time() + (86400 * 30), "/"); // 86400 = 1 day - if ($guest_login) { #user is a guest - #leave alone - if ($modal == false): - #this will send them back to the order/returns page to lookup - if(isset($bitpay_redirect_url)): - $params->redirectURL = $bitpay_redirect_url; - else: - $params->redirectURL = $this->getBaseUrl() . 'sales/guest/form'; - endif; - #set some info for guest checkout - else: - if(isset($bitpay_redirect_url)): - $params->redirectURL = $bitpay_redirect_url; - else: - $params->redirectURL = $this->getBaseUrl() . 'checkout/onepage/success/'; - endif; - endif; - } else { - if(isset($bitpay_redirect_url)): - $params->redirectURL = $bitpay_redirect_url; - else: - $params->redirectURL = $this->getBaseUrl() . 'sales/order/view/order_id/' . $order_id_long . '/'; - endif; - } + + $params->redirectURL = $this->getBaseUrl() .'bitpay-invoice/?order_id='.$order_id_long; + + if(!$modal): + $params->redirectURL.="&m=0"; + endif; $params->notificationURL = $this->getBaseUrl() . 'rest/V1/bitpay-bpcheckout/ipn'; $params->closeURL = $this->getBaseUrl() . 'rest/V1/bitpay-bpcheckout/close?orderID='.$order_id_long; @@ -348,7 +325,7 @@ public function execute(\Magento\Framework\Event\Observer $observer) setcookie('oar_billing_lastname', $order->getBillingAddress()->getLastName(), time() + (86400 * 30), "/"); // 86400 = 1 day setcookie('oar_email', $order->getCustomerEmail(), time() + (86400 * 30), "/"); // 86400 = 1 day - $RedirectUrl = $this->getBaseUrl() . 'bitpay-invoice/?invoiceID='.$invoiceID.'&order_id='.$order_id_long.'&g='.$g; + $RedirectUrl = $this->getBaseUrl() . 'bitpay-invoice/?invoiceID='.$invoiceID.'&order_id='.$order_id_long.'&m=1'; $this->_responseFactory->create()->setRedirect($RedirectUrl)->sendResponse(); die(); @@ -363,7 +340,7 @@ public function execute(\Magento\Framework\Event\Observer $observer) } //end execute function public function getExtensionVersion() { - return 'Bitpay_BPCheckout_Magento2_6.11.2103'; + return 'Bitpay_BPCheckout_Magento2_6.12.1'; } diff --git a/code/Bitpay/BPCheckout/composer.json b/code/Bitpay/BPCheckout/composer.json index fa7305d..d011e18 100644 --- a/code/Bitpay/BPCheckout/composer.json +++ b/code/Bitpay/BPCheckout/composer.json @@ -3,7 +3,7 @@ "description": "", "type": "magento2-module", "license": "mit", - "version":"6.11.2103", + "version":"6.12.1", "authors": [ { "email": "integrations@bitpay.com", diff --git a/code/Bitpay/BPCheckout/etc/adminhtml/system.xml b/code/Bitpay/BPCheckout/etc/adminhtml/system.xml index 9e2a3e3..1237e54 100755 --- a/code/Bitpay/BPCheckout/etc/adminhtml/system.xml +++ b/code/Bitpay/BPCheckout/etc/adminhtml/system.xml @@ -95,12 +95,6 @@ Bitpay\BPCheckout\Model\Config\Source\Cancelstatus - - - - - - diff --git a/code/Bitpay/BPCheckout/etc/module.xml b/code/Bitpay/BPCheckout/etc/module.xml index 2157d0e..904233e 100755 --- a/code/Bitpay/BPCheckout/etc/module.xml +++ b/code/Bitpay/BPCheckout/etc/module.xml @@ -5,5 +5,5 @@ */ --> - + \ No newline at end of file diff --git a/code/Bitpay/BPCheckout/view/frontend/templates/index.phtml b/code/Bitpay/BPCheckout/view/frontend/templates/index.phtml index 0fe4ec4..735463c 100644 --- a/code/Bitpay/BPCheckout/view/frontend/templates/index.phtml +++ b/code/Bitpay/BPCheckout/view/frontend/templates/index.phtml @@ -3,6 +3,7 @@ $config = $block->getLayout()->createBlock(\Magento\Config\Block\System\Config\F $configValue = $config->getConfigValue('web/secure/base_url'); $env = $config->getConfigValue('payment/bpcheckout/bitpay_endpoint'); extract($_GET); +if($m==1): ?> +

Loading BitPay Invoice...

+ + + - + + +