From 9a47fa3e59e7a4f4c36bb0baccee2318d61e71b9 Mon Sep 17 00:00:00 2001 From: Maciej Kwiatkowski Date: Tue, 7 Jan 2025 09:51:42 +0100 Subject: [PATCH] SP-1103 Removed unused modal code, added test:codeception composer script --- BitPayLib/class-bitpaypages.php | 53 -------------------------- BitPayLib/class-bitpaypluginsetup.php | 6 --- composer.json | 3 ++ js/bitpay_thank_you.js | 54 --------------------------- 4 files changed, 3 insertions(+), 113 deletions(-) delete mode 100644 BitPayLib/class-bitpaypages.php delete mode 100644 js/bitpay_thank_you.js diff --git a/BitPayLib/class-bitpaypages.php b/BitPayLib/class-bitpaypages.php deleted file mode 100644 index c710971..0000000 --- a/BitPayLib/class-bitpaypages.php +++ /dev/null @@ -1,53 +0,0 @@ -bitpay_payment_settings = $bitpay_payment_settings; - } - - public function checkout_thank_you( int $order_id ): void { - global $woocommerce; - $order = new \WC_Order( $order_id ); - if ( $order->get_payment_method() !== 'bitpay_checkout_gateway' ) { - return; - } - - $restore_url = get_home_url() . '/wp-json/bitpay/cartfix/restore'; - - $test_mode = false; - $js_script = 'https://bitpay.com/bitpay.min.js'; - if ( $this->bitpay_payment_settings->get_bitpay_environment() === 'test' ) { - $test_mode = true; - $js_script = 'https://test.bitpay.com/bitpay.min.js'; - } - - $invoice_id = $_COOKIE[BitPayPluginSetup::COOKIE_INVOICE_ID_NAME] ?? null; // phpcs:ignore - - wp_enqueue_script('remote-bitpay-js', $js_script, null, null, false ); // phpcs:ignore - wp_enqueue_script('bitpay_thank_you', plugins_url( '../../js/bitpay_thank_you.js', __FILE__ ), null, BitPayPluginSetup::VERSION, false ); // phpcs:ignore - ?> - - bitpay_cancel_order->execute( $request ); } - public function bitpay_checkout_thankyou_page( $order_id ): void { - $page = new BitPayPages( $this->bitpay_payment_settings ); - $page->checkout_thank_you( (int) $order_id ); - } - public function bitpay_checkout_custom_message( $order_id ): void { $this->bitpay_payment_settings->redirect_after_purchase( $order_id ); } diff --git a/composer.json b/composer.json index 1ab0626..5bf5f33 100644 --- a/composer.json +++ b/composer.json @@ -40,6 +40,9 @@ ], "phpcbf": [ "./vendor/bin/phpcbf BitPayLib" + ], + "test:codeception": [ + "./vendor/bin/codecept run" ] }, "config": { diff --git a/js/bitpay_thank_you.js b/js/bitpay_thank_you.js deleted file mode 100644 index 1733314..0000000 --- a/js/bitpay_thank_you.js +++ /dev/null @@ -1,54 +0,0 @@ -function showBitPayInvoice(testMode, invoiceID, orderId, cartUrl, restoreUrl) { - - jQuery( "#primary" ).hide() - let payment_status = null; - let is_paid = false - window.addEventListener( - "message", - function (event) { - payment_status = event.data.status; - if (payment_status === 'paid') { - is_paid = true - } - }, - false - ); - - // hide the order info. - bitpay.onModalWillEnter( - function () { - jQuery( "primary" ).hide() - } - ); - - // show the order info. - bitpay.onModalWillLeave( - function () { - if (is_paid === true) { - jQuery( "#primary" ).fadeIn( "slow" ); - } else { - const myKeyVals = { - invoiceid: invoiceID - } - - jQuery.ajax( - { - type: 'POST', - url: restoreUrl, - data: myKeyVals, - dataType: "text", - success: function (resultData) { - window.location = cartUrl; - } - } - ); - } - } - ); - - if ( testMode === "1" ) { - bitpay.enableTestMode(); - } - - bitpay.showInvoice( invoiceID ); -} \ No newline at end of file