Skip to content

Commit

Permalink
Updated redirect page
Browse files Browse the repository at this point in the history
  • Loading branch information
thejoshualewis committed Jun 16, 2021
1 parent c5e5ca4 commit 89497bc
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 45 deletions.
2 changes: 1 addition & 1 deletion code/Bitpay/BPCheckout/Model/IpnManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}
41 changes: 9 additions & 32 deletions code/Bitpay/BPCheckout/Observer/BPRedirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -274,42 +273,20 @@ 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);

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;
Expand Down Expand Up @@ -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();

Expand All @@ -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';

}

Expand Down
2 changes: 1 addition & 1 deletion code/Bitpay/BPCheckout/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "",
"type": "magento2-module",
"license": "mit",
"version":"6.11.2103",
"version":"6.12.1",
"authors": [
{
"email": "[email protected]",
Expand Down
6 changes: 0 additions & 6 deletions code/Bitpay/BPCheckout/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,6 @@
<source_model>Bitpay\BPCheckout\Model\Config\Source\Cancelstatus</source_model>
</field>

<field id="bitpay_redirect_url" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Custom Redirect URL</label>
<comment><![CDATA[If you have a custom url to redirect to (Thank You page, etc), enter the FULL URL here. You will need to customize any additional logic as needed]]></comment>
</field>



<field id="bitpay_ux" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Checkout Flow </label>
Expand Down
2 changes: 1 addition & 1 deletion code/Bitpay/BPCheckout/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Bitpay_BPCheckout" setup_version="6.11.2103"></module>
<module name="Bitpay_BPCheckout" setup_version="6.12.1"></module>
</config>
33 changes: 29 additions & 4 deletions code/Bitpay/BPCheckout/view/frontend/templates/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -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):
?>
<script src = "//bitpay.com/bitpay.min.js" type = "text/javascript"></script>
<script type = "text/javascript">
Expand All @@ -20,13 +21,13 @@ extract($_GET);
if (payment_status == "paid") {
is_paid = true
//clear the cookies
$guest = getParams()['g']


deleteCookie('env')
deleteCookie('invoicedata')
deleteCookie('modal')
jQuery("#bitpay-header").text('')
jQuery("#success-bitpay-page").show()
jQuery("#bitpay-header").text('Thank you for your purchase.')
jQuery("#success-bitpay-page").show()

return;
}
Expand Down Expand Up @@ -80,10 +81,31 @@ extract($_GET);
}
</script>

<!--page to show with modal-->
<h2 id = "bitpay-header">Loading BitPay Invoice...</h2>
<div id = "success-bitpay-page" style = "display:none;">
<?php /** @var $block \Magento\Checkout\Block\Onepage\Success */ ?>
<div class="checkout-success">
<?php if (isset($order_id)) :?>
<p><?php echo 'Your order # is: <b>'.$order_id.'</b> '?></p>
<p><?php echo 'We\'ll email you an order confirmation with details and tracking info. '?></p>
<?php endif;?>
<div class="actions-toolbar">
<div class="primary">
<a class="action primary continue" href="/"><span><?= $block->escapeHtml(__('Continue Shopping')) ?></span></a>
</div>
</div>
</div>
</div>
<!--end page to show with modal-->

<!--page to show with redirect-->

<div id = "success-bitpay-page" style = "display:none;">
<?php else:?>
<h2 id = "bitpay-header">Thank you for your purchase.</h2>


<div id = "success-bitpay-page">
<?php /** @var $block \Magento\Checkout\Block\Onepage\Success */ ?>
<div class="checkout-success">
<?php if (isset($order_id)) :?>
Expand All @@ -99,3 +121,6 @@ extract($_GET);
</div>
</div>
</div>

<?php endif;?>
<!--end page to show with redirect-->

0 comments on commit 89497bc

Please sign in to comment.