diff --git a/Block/Index.php b/Block/Index.php index 5445fb7..c4e641b 100644 --- a/Block/Index.php +++ b/Block/Index.php @@ -39,16 +39,6 @@ public function getBitpayEnv(): ?string return $this->config->getBitpayEnv(); } - /** - * Get modal param - * - * @return int - */ - public function getModalParam(): int - { - return (int) $this->getRequest()->getParam('m'); - } - /** * Get order id * diff --git a/Model/BPRedirect.php b/Model/BPRedirect.php index 0eeb638..2c4b810 100755 --- a/Model/BPRedirect.php +++ b/Model/BPRedirect.php @@ -129,17 +129,14 @@ public function execute(ResultInterface $defaultResult, string $returnId = null) try { $baseUrl = $this->config->getBaseUrl(); $order = $this->setToPendingAndOverrideMagentoStatus($order); - $modal = $this->config->getBitpayUx() === 'modal'; $redirectUrl = $this->url->getUrl('bitpay-invoice', ['_query' => ['order_id' => $incrementId]]); if ($isStandardCheckoutSuccess) { $this->checkoutSession->setLastSuccessQuoteId($order->getQuoteId()); - if (!$modal) { - $redirectUrl = $this->url->getUrl('checkout/onepage/success', [ - '_query' => ['return_id' => $returnHash] - ]); - } + $redirectUrl = $this->url->getUrl('checkout/onepage/success', [ + '_query' => ['return_id' => $returnHash] + ]); } - $params = $this->getParams($order, $incrementId, $modal, $redirectUrl, $baseUrl); + $params = $this->getParams($order, $incrementId, $redirectUrl, $baseUrl); $billingAddressData = $order->getBillingAddress()->getData(); $this->setSessionCustomerData($billingAddressData, $order->getCustomerEmail(), $incrementId); $client = $this->client->initialize(); @@ -153,34 +150,11 @@ public function execute(ResultInterface $defaultResult, string $returnId = null) $invoice->getAcceptanceWindow() ); $this->transactionRepository->add($incrementId, $invoiceID, 'new'); - - switch ($modal) { - case true: - case 1: - #set some info for guest checkout - $this->setSessionCustomerData($billingAddressData, $order->getCustomerEmail(), $incrementId); - - $redirectParams = [ - 'invoiceID' => $invoiceID, - 'order_id' => $incrementId, - 'm' => 1, - ]; - if ($isStandardCheckoutSuccess) { - $redirectParams['return_id'] = $returnHash; - } - $redirectUrl = $this->url->getUrl('bitpay-invoice', ['_query' => $redirectParams]); - - return $this->resultFactory->create( - \Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT - ) - ->setUrl($redirectUrl); - case false: - default: - return $this->resultFactory->create( - \Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT - ) - ->setUrl($invoice->getUrl()); - } + + return $this->resultFactory->create( + \Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT + ) + ->setUrl($invoice->getUrl()); } catch (\Exception $exception) { return $this->deleteOrderAndRedirectToCart($exception, $order); } catch (\Error $error) { @@ -229,7 +203,6 @@ private function setToPendingAndOverrideMagentoStatus(OrderInterface $order): Or * * @param OrderInterface $order * @param string|null $incrementId - * @param bool $modal * @param string $redirectUrl * @param string $baseUrl * @return DataObject @@ -237,7 +210,6 @@ private function setToPendingAndOverrideMagentoStatus(OrderInterface $order): Or private function getParams( OrderInterface $order, ?string $incrementId, - bool $modal, string $redirectUrl, string $baseUrl ): DataObject { @@ -251,7 +223,7 @@ private function getParams( 'currency' => $order['base_currency_code'], 'buyer' => $buyerInfo->getData(), 'orderId' => trim($incrementId), - 'redirectURL' => !$modal ? $redirectUrl . "&m=0" : $redirectUrl, + 'redirectURL' => $redirectUrl, 'notificationURL' => $baseUrl . 'rest/V1/bitpay-bpcheckout/ipn', 'closeURL' => $baseUrl . 'rest/V1/bitpay-bpcheckout/close?orderID=' . $incrementId, 'extendedNotifications' => true diff --git a/Model/Client.php b/Model/Client.php index 4fb542d..170bb08 100755 --- a/Model/Client.php +++ b/Model/Client.php @@ -39,7 +39,8 @@ public function initialize(): \BitPaySDK\Client $serializedTokenData = $this->serializer->unserialize($tokenData); $merchantToken = $serializedTokenData['data'][0]['token']; $tokens = new Tokens($merchantToken); + $platformInfo = 'BitPay_Magento2_v10.0.0'; - return \BitPaySDK\Client::createWithData($env, $privateKeyPath, $tokens, $password); + return \BitPaySDK\Client::createWithData($env, $privateKeyPath, $tokens, $password, null, $platformInfo); } } diff --git a/Model/Config.php b/Model/Config.php index 09215e9..1253e26 100755 --- a/Model/Config.php +++ b/Model/Config.php @@ -100,16 +100,6 @@ public function getBPCheckoutOrderStatus():? string return $this->scopeConfig->getValue(self::BPCHECKOUT_ORDER_STATUS, ScopeInterface::SCOPE_STORE); } - /** - * Get BitPay Ux - * - * @return string|null - */ - public function getBitpayUx():? string - { - return $this->scopeConfig->getValue(self::BITPAY_UX, ScopeInterface::SCOPE_STORE); - } - /** * Get BitPay CheckoutSuccess * diff --git a/Model/Config/Source/Ux.php b/Model/Config/Source/Ux.php deleted file mode 100755 index 77c630a..0000000 --- a/Model/Config/Source/Ux.php +++ /dev/null @@ -1,29 +0,0 @@ - 'Redirect', - 'modal' => 'Modal', - ]; - } -} diff --git a/Test/Integration/Block/IndexTest.php b/Test/Integration/Block/IndexTest.php index 28a4206..32befff 100755 --- a/Test/Integration/Block/IndexTest.php +++ b/Test/Integration/Block/IndexTest.php @@ -62,14 +62,6 @@ public function testGetBitpayEnv(): void $this->assertEquals('test', $this->index->getBitpayEnv()); } - public function testGetModalParam(): void - { - $requst = $this->context->getRequest(); - $requst->setParams(['m' => '1']); - - $this->assertEquals(1, $this->index->getModalParam()); - } - public function testOrderId(): void { $requst = $this->context->getRequest(); diff --git a/Test/Integration/Model/ConfigTest.php b/Test/Integration/Model/ConfigTest.php index 2afa36e..84e23e1 100755 --- a/Test/Integration/Model/ConfigTest.php +++ b/Test/Integration/Model/ConfigTest.php @@ -79,14 +79,6 @@ public function testGetBaseUrl(): void $this->assertEquals($url, $this->config->getBaseUrl()); } - /** - * @magentoConfigFixture current_store payment/bpcheckout/bitpay_ux modal - */ - public function testGetBitpayUx(): void - { - $this->assertEquals('modal', $this->config->getBitpayUx()); - } - /** * @magentoConfigFixture current_store payment/bpcheckout/bitpay_ipn_mapping pending */ diff --git a/Test/Unit/Block/IndexTest.php b/Test/Unit/Block/IndexTest.php index fe1f3a1..5b49c81 100755 --- a/Test/Unit/Block/IndexTest.php +++ b/Test/Unit/Block/IndexTest.php @@ -67,16 +67,6 @@ public function testGetBitpayEnv(): void $this->assertEquals(self::ENV, $this->index->getBitpayEnv()); } - public function testGetModalParam(): void - { - $this->request->expects($this->once()) - ->method('getParam') - ->with('m') - ->willReturn(1); - - $this->assertEquals(1, $this->index->getModalParam()); - } - public function testGetOrderId(): void { $this->request->expects($this->once())->method('getParam') diff --git a/Test/Unit/Model/BPRedirectTest.php b/Test/Unit/Model/BPRedirectTest.php index 9060660..39d8c94 100755 --- a/Test/Unit/Model/BPRedirectTest.php +++ b/Test/Unit/Model/BPRedirectTest.php @@ -142,12 +142,10 @@ public function setUp(): void } /** - * @param $ux * @return void * @throws \Exception - * @dataProvider getUxDataProvider */ - public function testExecute($ux): void + public function testExecute(): void { $incrementId = '0000012121'; $bitpayToken = 'A32nRffe34dF2312vmm'; @@ -192,29 +190,15 @@ public function testExecute($ux): void $this->bitpayInvoiceRepository->expects($this->once())->method('add'); $this->transactionRepository->expects($this->once())->method('add'); - if ($ux === 'modal') { - $this->prepareResponse(); - } else { - $result = $this->getMock(Redirect::class); - $result->expects($this->once())->method('setUrl')->willReturnSelf(); - $this->resultFactory->expects($this->once())->method('create')->willReturn($result); - } + $result = $this->getMock(Redirect::class); + $result->expects($this->once())->method('setUrl')->willReturnSelf(); + $this->resultFactory->expects($this->once())->method('create')->willReturn($result); $page = $this->getMock(\Magento\Framework\View\Result\Page::class); $this->bpRedirect->execute($page); } - /** - * @return array[] - */ - public function getUxDataProvider(): array - { - return [ - ['modal'], ['redirect'] - ]; - } - public function testExecuteNoOrderId(): void { $response = $this->getMock(\Magento\Framework\HTTP\PhpEnvironment\Response::class); @@ -341,7 +325,6 @@ private function getOrder(string $incrementId, MockObject $payment, MockObject $ private function prepareConfig(string $baseUrl, string $ux): void { $this->config->expects($this->once())->method('getBPCheckoutOrderStatus')->willReturn('pending'); - $this->config->expects($this->once())->method('getBitpayUx')->willReturn($ux); $this->config->expects($this->once())->method('getBaseUrl')->willReturn($baseUrl); } diff --git a/Test/Unit/Model/ConfigTest.php b/Test/Unit/Model/ConfigTest.php index ed9b00e..2df14d0 100755 --- a/Test/Unit/Model/ConfigTest.php +++ b/Test/Unit/Model/ConfigTest.php @@ -52,15 +52,6 @@ public function setUp(): void ); } - public function testGetBitpayUx(): void - { - $this->scopeConfig->expects($this->once()) - ->method('getValue') - ->with(Config::BITPAY_UX, ScopeInterface::SCOPE_STORE) - ->willReturn('modal'); - $this->assertEquals('modal', $this->config->getBitpayUx()); - } - public function testGetBitpayIpnMapping(): void { $this->scopeConfig->expects($this->once()) diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 332e396..ca61dbd 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -121,13 +121,6 @@ Bitpay\BPCheckout\Model\Config\Source\Cancelstatus - - - - Redirect, then the customer will be redirected to BitPay to checkout, and return to the checkout page once the payment is made.

If this is set to Modal, the user will stay on your e-commerce site and complete the transaction.]]>
- Bitpay\BPCheckout\Model\Config\Source\Ux -
- diff --git a/view/frontend/templates/index.phtml b/view/frontend/templates/index.phtml index a2e5107..94d4487 100644 --- a/view/frontend/templates/index.phtml +++ b/view/frontend/templates/index.phtml @@ -3,60 +3,24 @@ $configValue = $block->getBaseSecureUrl(); $env = $block->getBitpayEnv(); $order_id = $block->getOrderId(); -if ($block->getModalParam() === 1): ?> +?> +

Thank you for your purchase.

+
+ +
+ +

' . $order_id . ' ') ?>

+

+ +

+ - - -

- - - - - -

Thank you for your purchase.

-
- -
- -

' . $order_id . ' ') ?>

-

- -

- - - - +