Skip to content

Commit 6428bcc

Browse files
authored
Merge branch 'develop' into add/amazon-pay-payment-method
2 parents fcf70df + a3c43ab commit 6428bcc

8 files changed

+63
-15
lines changed

.husky/post-merge

+24
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,27 @@ npx --no-install yarnhook
66

77
# make sure the autoload files are regenerated
88
composer dumpautoload
9+
10+
DEV_TOOLS_PLUGIN_PATH=${LOCAL_STRIPE_DEV_TOOLS_PLUGIN_REPO_PATH:-"docker/wordpress/wp-content/plugins/woocommerce-gateway-stripe-dev-tools"}
11+
if [ ! -d $DEV_TOOLS_PLUGIN_PATH ]; then
12+
echo
13+
echo "\033[33mCouldn't find the '$DEV_TOOLS_PLUGIN_PATH' directory. Skipping the auto-update for the Stripe Dev Tools plugin...\033[0m"
14+
else
15+
if [ "$(cd $DEV_TOOLS_PLUGIN_PATH && git rev-parse --show-toplevel 2>/dev/null)" = "$(cd $DEV_TOOLS_PLUGIN_PATH && pwd)" ]; then
16+
echo
17+
echo "\033[32mDetermining if there is an update for the Stripe Dev Tools plugin...\033[0m"
18+
19+
DEV_TOOLS_BRANCH=$(cd $DEV_TOOLS_PLUGIN_PATH && git branch --show-current)
20+
if [[ $DEV_TOOLS_BRANCH = "trunk" ]]; then
21+
echo " \033[32mThe current branch is $DEV_TOOLS_BRANCH. Check if we are safe to pull from origin/$DEV_TOOLS_BRANCH...\033[0m"
22+
if [[ `cd $DEV_TOOLS_PLUGIN_PATH && git status --porcelain` ]]; then
23+
echo "\033[33m There are uncommitted local changes on the Stripe Dev Tools repo. Skipping any attempt to update it.\033[0m"
24+
else
25+
echo " \033[32mPulling the latest changes from origin/$DEV_TOOLS_BRANCH, if any...\033[0m"
26+
cd $DEV_TOOLS_PLUGIN_PATH && git pull
27+
fi
28+
else
29+
echo "\033[33m The Stripe Dev Tools local clone is not on the trunk branch. Skipping any attempt to update it.\033[0m"
30+
fi
31+
fi
32+
fi

bin/docker-setup.sh

+11
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,17 @@ cli wp import wp-content/plugins/woocommerce/sample-data/sample_products.xml --a
114114
echo "Activating the WooCommerce Stripe Payment Gateway plugin..."
115115
cli wp plugin activate woocommerce-gateway-stripe
116116

117+
echo "Installing dev tools plugin..."
118+
set +e
119+
git clone [email protected]:woocommerce/woocommerce-gateway-stripe-dev-tools.git docker/wordpress/wp-content/plugins/woocommerce-gateway-stripe-dev-tools
120+
if [[ $? -eq 0 ]]; then
121+
cli wp plugin activate woocommerce-gateway-stripe-dev-tools
122+
else
123+
echo
124+
echo "WARN: Could not clone the dev tools repository. Skipping the install."
125+
fi
126+
set -e
127+
117128
echo
118129
echo "SUCCESS! You should now be able to access http://${SITE_URL}/wp-admin/"
119130
echo "You can login by using the username and password both as 'admin'"

changelog.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
*** Changelog ***
22

33
= 9.3.0 - xxxx-xx-xx =
4+
* Fix - Improves the checking for existing customer attribute when retrieving a payment method that may be detached from a subscription.
5+
* Fix - Reverts the default value for the `capture_method` property to avoid breaking Amazon Pay when creating a payment intent.
46
* Add - Adds a new feature flag to handle the Single Payment Element feature.
57
* Dev - Moves the method to check if the subscriptions extension is enabled to a new helper class.
68
* Dev - Moves and refactor some of the UPE-related code to make Single Payment Element development easier.
@@ -32,6 +34,7 @@
3234
* Fix - ACSS: Handle errors and edge cases.
3335
* Add - Add subscriptions support to Bacs.
3436
* Update - Add tracks events for payment method settings updates.
37+
* Fix - Fix issue where Legacy Checkout settings get overwritten with old value.
3538
* Add - Add WooCommerce Pre-Orders support to Bacs.
3639
* Tweak - Fix background in express checkout settings.
3740
* Add - Add Amazon Pay payment method class.

includes/admin/class-wc-rest-stripe-settings-controller.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -527,15 +527,12 @@ private function update_is_upe_enabled( WP_REST_Request $request ) {
527527
return;
528528
}
529529

530-
$settings = WC_Stripe_Helper::get_stripe_settings();
531-
532530
// If the new UPE is enabled, we need to remove the flag to ensure legacy SEPA tokens are updated flag.
533531
if ( $is_upe_enabled && ! WC_Stripe_Feature_Flags::is_upe_checkout_enabled() ) {
534532
delete_option( 'woocommerce_stripe_subscriptions_legacy_sepa_tokens_updated' );
535533
}
536534

537-
$settings[ WC_Stripe_Feature_Flags::UPE_CHECKOUT_FEATURE_ATTRIBUTE_NAME ] = $is_upe_enabled ? 'yes' : 'disabled';
538-
WC_Stripe_Helper::update_main_stripe_settings( $settings );
535+
$this->gateway->update_option( WC_Stripe_Feature_Flags::UPE_CHECKOUT_FEATURE_ATTRIBUTE_NAME, $is_upe_enabled ? 'yes' : 'disabled' );
539536

540537
// including the class again because otherwise it's not present.
541538
if ( WC_Stripe_Inbox_Notes::are_inbox_notes_supported() ) {

includes/compat/class-wc-stripe-subscriptions-helper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static function get_detached_subscriptions() {
4848
$source_id = $subscription->get_meta( '_stripe_source_id' );
4949
if ( $source_id ) {
5050
$payment_method = WC_Stripe_API::get_payment_method( $source_id );
51-
if ( ! $payment_method->customer ) {
51+
if ( empty( $payment_method->customer ) ) {
5252
$detached_subscriptions[] = [
5353
'id' => $subscription->get_id(),
5454
'customer_id' => $subscription->get_meta( '_stripe_customer_id' ),

includes/payment-methods/class-wc-stripe-upe-payment-gateway.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -2213,7 +2213,6 @@ protected function prepare_payment_information_from_request( WC_Order $order ) {
22132213
'payment_method' => '',
22142214
'payment_method_details' => [],
22152215
'payment_type' => 'single', // single | recurring.
2216-
'capture_method' => $capture_method,
22172216
];
22182217

22192218
if ( 'us_bank_account' === $selected_payment_type ) {
@@ -2230,6 +2229,7 @@ protected function prepare_payment_information_from_request( WC_Order $order ) {
22302229
$order,
22312230
$payment_method_details
22322231
);
2232+
$payment_information['capture_method'] = $capture_method;
22332233
} else {
22342234
$confirmation_token_id = sanitize_text_field( wp_unslash( $_POST['wc-stripe-confirmation-token'] ?? '' ) );
22352235
$payment_information['confirmation_token'] = $confirmation_token_id;
@@ -2243,6 +2243,8 @@ protected function prepare_payment_information_from_request( WC_Order $order ) {
22432243
'capture_method' => 'manual',
22442244
],
22452245
];
2246+
} else {
2247+
$payment_information['capture_method'] = $capture_method;
22462248
}
22472249

22482250
// When using confirmation tokens for subscriptions, we need to set the setup_future_usage parameter under payment method options.

includes/payment-methods/class-wc-stripe-upe-payment-method-bacs-debit.php

+17-9
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,14 @@ public function __construct() {
3030
$this->accept_only_domestic_payment = true;
3131
$this->label = __( 'Bacs Direct Debit', 'woocommerce-gateway-stripe' );
3232
$this->description = __( 'Bacs Direct Debit enables customers in the UK to pay by providing their bank account details.', 'woocommerce-gateway-stripe' );
33+
$this->supports[] = 'tokenization';
3334

3435
// Check if subscriptions are enabled and add support for them.
3536
$this->maybe_init_subscriptions();
3637

3738
// Add support for pre-orders.
3839
$this->maybe_init_pre_orders();
3940

40-
// Remove Bacs from the “Add Payment Method” page for now, as its implementation will be handled later.
41-
if ( is_wc_endpoint_url( 'add-payment-method' ) ) {
42-
unset( $this->supports['tokenization'] );
43-
}
44-
4541
$this->maybe_hide_bacs_payment_gateway();
4642
}
4743

@@ -105,7 +101,8 @@ public function maybe_hide_bacs_payment_gateway() {
105101
function ( $available_gateways ) {
106102
if (
107103
$this->should_hide_bacs_for_pre_orders_charge_upon_release() ||
108-
$this->should_hide_bacs_for_subscriptions_with_free_trials()
104+
$this->should_hide_bacs_for_subscriptions_with_free_trials() ||
105+
$this->should_hide_bacs_on_add_payment_method_page()
109106
) {
110107
unset( $available_gateways['stripe_bacs_debit'] );
111108
}
@@ -114,6 +111,19 @@ function ( $available_gateways ) {
114111
);
115112
}
116113

114+
/**
115+
* Determines whether the Bacs payment gateway should be hidden on the "Add Payment Method" page.
116+
*
117+
* @return bool True if the Bacs payment gateway should be hidden, false otherwise.
118+
*/
119+
public function should_hide_bacs_on_add_payment_method_page() {
120+
if ( is_wc_endpoint_url( 'add-payment-method' ) ) {
121+
return true;
122+
}
123+
124+
return false;
125+
}
126+
117127
/**
118128
* Determines whether the Bacs payment gateway should be hidden for pre-orders that are charged upon release.
119129
*
@@ -143,10 +153,8 @@ public function should_hide_bacs_for_pre_orders_charge_upon_release() {
143153
* @return bool True if Bacs should be hidden, false otherwise.
144154
*/
145155
public function should_hide_bacs_for_subscriptions_with_free_trials() {
146-
global $post;
147-
$is_checkout_shortcode_page = wc_post_content_has_shortcode( 'woocommerce_checkout' ) || has_block( 'woocommerce/classic-shortcode', $post );
148156
$is_update_order_review_ajax_request = defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_REQUEST['wc-ajax'] ) && 'update_order_review' === $_REQUEST['wc-ajax'];
149-
if ( $is_checkout_shortcode_page || $is_update_order_review_ajax_request ) {
157+
if ( is_checkout() || $is_update_order_review_ajax_request ) {
150158
// Checking if the amount is zero allows us to process orders that include subscriptions with a free trial,
151159
// as long as another product increases the total amount, ensuring compatibility with Bacs.
152160
if ( class_exists( 'WC_Subscriptions_Cart' ) && WC_Subscriptions_Cart::cart_contains_free_trial() && (float) WC()->cart->total === 0.00 ) {

readme.txt

+3
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
111111
== Changelog ==
112112

113113
= 9.3.0 - xxxx-xx-xx =
114+
* Fix - Improves the checking for existing customer attribute when retrieving a payment method that may be detached from a subscription.
115+
* Fix - Reverts the default value for the `capture_method` property to avoid breaking Amazon Pay when creating a payment intent.
114116
* Add - Adds a new feature flag to handle the Single Payment Element feature.
115117
* Dev - Moves the method to check if the subscriptions extension is enabled to a new helper class.
116118
* Dev - Moves and refactor some of the UPE-related code to make Single Payment Element development easier.
@@ -142,6 +144,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
142144
* Fix - ACSS: Handle errors and edge cases.
143145
* Add - Add subscriptions support to Bacs.
144146
* Update - Add tracks events for payment method settings updates.
147+
* Fix - Fix issue where Legacy Checkout settings get overwritten with old value.
145148
* Add - Add WooCommerce Pre-Orders support to Bacs.
146149
* Tweak - Fix background in express checkout settings.
147150
* Add - Add Amazon Pay payment method class.

0 commit comments

Comments
 (0)