-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: ECE copy for tokenized cart implementation #9730
chore: ECE copy for tokenized cart implementation #9730
Conversation
Test the buildOption 1. Jetpack Beta
Option 2. Jurassic Ninja - available for logged-in A12s🚀 Launch a JN site with this branch 🚀 ℹ️ Install this Tampermonkey script to get more options. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
Size Change: -3.93 kB (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
@@ -22,7 +22,10 @@ import { | |||
expressCheckoutElementApplePay, | |||
expressCheckoutElementGooglePay, | |||
} from '../../express-checkout/blocks'; | |||
import tokenizedCartPaymentRequestPaymentMethod from '../../tokenized-payment-request/blocks'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left the old JS there to reduce the number of changes & so it can be removed later.
I replaced it with the copy of the ECE implementation (from client/express-checkout
to client/tokenized-express-checkout
).
@@ -0,0 +1,154 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from client/express-checkout/blocks/components/express-checkout-component.js
@@ -0,0 +1,42 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from client/express-checkout/blocks/components/express-checkout-container.js
@@ -0,0 +1,108 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from client/express-checkout/blocks/components/express-checkout-preview.js
@@ -0,0 +1,23 @@ | |||
// Cart Block |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from client/express-checkout/blocks/express-checkout-element.scss
@@ -0,0 +1,44 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from client/express-checkout/utils/test/index.ts
$script_dependencies = [ 'stripe' ]; | ||
|
||
if ( WC_Payments_Features::is_tokenized_cart_ece_enabled() && ( is_cart() || is_checkout() || is_product() || has_block( 'woocommerce/checkout' ) || has_block( 'woocommerce/cart' ) ) ) { | ||
$script_dependencies[] = 'WCPAY_PAYMENT_REQUEST'; | ||
} | ||
|
||
WC_Payments::register_script_with_dependencies( 'WCPAY_BLOCKS_CHECKOUT', 'dist/blocks-checkout', $script_dependencies ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how the PRBs were enqueued. The ECE is enqueued differently, we're keeping it that way.
So this block with the WCPAY_PAYMENT_REQUEST
script has become deprecated, and can now be simplified.
|
||
$express_checkout_ajax_handler = new WC_Payments_Express_Checkout_Ajax_Handler( self::get_express_checkout_helper() ); | ||
$express_checkout_element_button_handler = new WC_Payments_Express_Checkout_Button_Handler( self::$account, self::get_gateway(), self::get_express_checkout_helper(), $express_checkout_ajax_handler ); | ||
$express_checkout_button_display_handler = new WC_Payments_Express_Checkout_Button_Display_Handler( self::get_gateway(), $payment_request_button_handler, $woopay_button_handler, $express_checkout_element_button_handler, $express_checkout_ajax_handler, self::get_express_checkout_helper() ); | ||
$express_checkout_button_display_handler = new WC_Payments_Express_Checkout_Button_Display_Handler( self::get_gateway(), $woopay_button_handler, $express_checkout_element_button_handler, $express_checkout_ajax_handler, self::get_express_checkout_helper() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I removed the WC_Payments_Payment_Request_Button_Handler
as part of the dependencies of WC_Payments_Express_Checkout_Button_Display_Handler
. We won't need that in the ECE.
But I'm keeping the file for future reference.
I marked the WC_Payments_Payment_Request_Button_Handler
as @deprecated
, but it's not enqueued anywhere.
@@ -21,13 +21,6 @@ class WC_Payments_Express_Checkout_Button_Display_Handler { | |||
*/ | |||
private $gateway; | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above - removed WC_Payments_Payment_Request_Button_Handler
as part of the dependencies of WC_Payments_Express_Checkout_Button_Display_Handler
@@ -260,14 +260,39 @@ public function scripts() { | |||
'is_checkout_page' => $this->express_checkout_helper->is_checkout(), | |||
]; | |||
|
|||
WC_Payments::register_script_with_dependencies( 'WCPAY_EXPRESS_CHECKOUT_ECE', 'dist/express-checkout', [ 'jquery', 'stripe' ] ); | |||
if ( WC_Payments_Features::is_tokenized_cart_ece_enabled() ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating some branching logic to enqueue the "tokenized" ECE vs the non-tokenized ECE.
The "tokenized" ECE is the copy of the files, all part of this PR.
They're not "tokenized" yet - they're just a copy of the ECE implementation.
The tokenization efforts are part of #9722
@@ -442,7 +442,6 @@ public static function init() { | |||
include_once __DIR__ . '/express-checkout/class-wc-payments-express-checkout-ajax-handler.php'; | |||
include_once __DIR__ . '/express-checkout/class-wc-payments-express-checkout-button-display-handler.php'; | |||
include_once __DIR__ . '/express-checkout/class-wc-payments-express-checkout-button-handler.php'; | |||
include_once __DIR__ . '/class-wc-payments-payment-request-button-handler.php'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I deprecated the class, I figured I'd also remove its include_once
.
It is still included in the tests/unit/bootstrap.php
PHPunit bootstrap file, but just because there's a UT that still exists.
public function test_display_express_checkout_buttons_only_payment_request() { | ||
$this->mock_woopay_button_handler | ||
->method( 'should_show_woopay_button' ) | ||
->willReturn( false ); | ||
|
||
$this->mock_payment_request_button_handler | ||
->method( 'should_show_payment_request_button' ) | ||
->willReturn( true ); | ||
|
||
$this->mock_express_checkout_helper | ||
->method( 'is_checkout' ) | ||
->willReturn( true ); | ||
|
||
ob_start(); | ||
$this->express_checkout_button_display_handler->display_express_checkout_buttons(); | ||
|
||
$this->assertStringContainsString( 'wcpay-express-checkout-button-separator', ob_get_contents() ); | ||
$this->assertStringContainsString( 'display:none;', ob_get_contents() ); | ||
ob_end_clean(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole test case is no longer needed because the payment_request_button_handler
has been removed.
…kenized-feature-flag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good and the tokenized-express-checkout
script is enqueued as expected. 🚢
Fixes #9721
Changes proposed in this Pull Request
Continuing the groundwork to pave the path for a modification of the ECE to leverage the Store API.
I'm creating a copy of the ECE JS, so it can be modified.
This allows us to modify it in isolation, making safe changes.
Testing instructions
npm run start
)tokenized-express-checkout
JS should be enqueued, indicating that the new scripts are being usednpm run changelog
to add a changelog file, choosepatch
to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge