Skip to content

Commit a1147b5

Browse files
authored
Fix incompatible notice in editor due missing style properties (#3564)
* Fix incompatible notice in editor due mssing style properties * Passing the style param only when rendering methods in the editor * Changelog and readme entries * Minor JS fix
1 parent 6636bf8 commit a1147b5

File tree

7 files changed

+54
-25
lines changed

7 files changed

+54
-25
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*** Changelog ***
22

33
= 9.1.0 - xxxx-xx-xx =
4+
* Fix - Fixes the incompatibility notice in editor due missing style property when instantiating Stripe payment methods.
45
* Dev - Updates the GitHub caching action (`actions/cache`) to v4 due deprecation.
56
* Fix - Don't update canceled order status to on-hold when a dispute is opened.
67
* Fix - Correctly sets the dispute opened note when a dispute does not require any further action.

client/blocks/credit-card/index.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ const StripeLabel = ( props ) => {
3939
};
4040

4141
const cardIcons = getStripeCreditCardIcons();
42+
const supports = {
43+
// Use `false` as fallback values in case server provided configuration is missing.
44+
showSavedCards: getBlocksConfiguration()?.showSavedCards ?? false,
45+
showSaveOption: getBlocksConfiguration()?.showSaveOption ?? false,
46+
features: getBlocksConfiguration()?.supports ?? [],
47+
};
48+
if ( getBlocksConfiguration().isAdmin ?? false ) {
49+
supports.style = getBlocksConfiguration()?.style ?? [];
50+
}
4251
const stripeCcPaymentMethod = {
4352
name: PAYMENT_METHOD_NAME,
4453
label: <StripeLabel />,
@@ -53,12 +62,7 @@ const stripeCcPaymentMethod = {
5362
'Stripe Credit Card payment method',
5463
'woocommerce-gateway-stripe'
5564
),
56-
supports: {
57-
// Use `false` as fallback values in case server provided configuration is missing.
58-
showSavedCards: getBlocksConfiguration()?.showSavedCards ?? false,
59-
showSaveOption: getBlocksConfiguration()?.showSaveOption ?? false,
60-
features: getBlocksConfiguration()?.supports ?? [],
61-
},
65+
supports,
6266
};
6367

6468
export default stripeCcPaymentMethod;

client/blocks/express-checkout/index.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ import { PAYMENT_METHOD_LINK } from 'wcstripe/stripe-utils/constants';
1414

1515
const stripePromise = loadStripe();
1616

17+
const supports = {
18+
features: getBlocksConfiguration()?.supports ?? [],
19+
};
20+
if ( getBlocksConfiguration().isAdmin ?? false ) {
21+
supports.style = getBlocksConfiguration()?.style ?? [];
22+
}
23+
1724
const expressCheckoutElementsGooglePay = ( api ) => ( {
1825
name: PAYMENT_METHOD_EXPRESS_CHECKOUT_ELEMENT + '_googlePay',
1926
title: 'WooCommerce Stripe - Google Pay',
@@ -41,9 +48,7 @@ const expressCheckoutElementsGooglePay = ( api ) => ( {
4148
},
4249
paymentMethodId: PAYMENT_METHOD_EXPRESS_CHECKOUT_ELEMENT,
4350
gatewayId: 'stripe',
44-
supports: {
45-
features: getBlocksConfiguration()?.supports ?? [],
46-
},
51+
supports,
4752
} );
4853

4954
const expressCheckoutElementsApplePay = ( api ) => ( {
@@ -73,9 +78,7 @@ const expressCheckoutElementsApplePay = ( api ) => ( {
7378
},
7479
paymentMethodId: PAYMENT_METHOD_EXPRESS_CHECKOUT_ELEMENT,
7580
gatewayId: 'stripe',
76-
supports: {
77-
features: getBlocksConfiguration()?.supports ?? [],
78-
},
81+
supports,
7982
} );
8083

8184
const expressCheckoutElementsStripeLink = ( api ) => ( {
@@ -108,9 +111,7 @@ const expressCheckoutElementsStripeLink = ( api ) => ( {
108111
} );
109112
},
110113
paymentMethodId: PAYMENT_METHOD_EXPRESS_CHECKOUT_ELEMENT,
111-
supports: {
112-
features: getBlocksConfiguration()?.supports ?? [],
113-
},
114+
supports,
114115
} );
115116

116117
export {

client/blocks/payment-request/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ const ApplePayPreview = () => <img src={ applePayImage } alt="" />;
1313

1414
const componentStripePromise = loadStripe();
1515

16+
const supports = {
17+
features: getBlocksConfiguration()?.supports ?? [],
18+
};
19+
if ( getBlocksConfiguration().isAdmin ?? false ) {
20+
supports.style = getBlocksConfiguration()?.style ?? [];
21+
}
22+
1623
const paymentRequestPaymentMethod = {
1724
name: PAYMENT_METHOD_NAME,
1825
title: 'Stripe',
@@ -63,9 +70,7 @@ const paymentRequestPaymentMethod = {
6370
} );
6471
},
6572
paymentMethodId: 'stripe',
66-
supports: {
67-
features: getBlocksConfiguration()?.supports ?? [],
68-
},
73+
supports,
6974
};
7075

7176
export default paymentRequestPaymentMethod;

client/blocks/upe/index.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ Object.entries( paymentMethodsConfig )
5656
}
5757

5858
const Icon = Icons[ iconName ];
59+
const supports = {
60+
// Use `false` as fallback values in case server provided configuration is missing.
61+
showSavedCards: getBlocksConfiguration()?.showSavedCards ?? false,
62+
showSaveOption: upeConfig.showSaveOption ?? false,
63+
features: getBlocksConfiguration()?.supports ?? [],
64+
};
65+
if ( getBlocksConfiguration().isAdmin ?? false ) {
66+
supports.style = getBlocksConfiguration()?.style ?? [];
67+
}
5968

6069
registerPaymentMethod( {
6170
name: upeMethods[ upeName ],
@@ -95,13 +104,7 @@ Object.entries( paymentMethodsConfig )
95104
</>
96105
),
97106
ariaLabel: 'Stripe',
98-
supports: {
99-
// Use `false` as fallback values in case server provided configuration is missing.
100-
showSavedCards:
101-
getBlocksConfiguration()?.showSavedCards ?? false,
102-
showSaveOption: upeConfig.showSaveOption ?? false,
103-
features: getBlocksConfiguration()?.supports ?? [],
104-
},
107+
supports,
105108
} );
106109
} );
107110

includes/class-wc-stripe-blocks-support.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ public function get_payment_method_data() {
198198
'button' => [
199199
'customLabel' => $this->payment_request_configuration->get_button_label(),
200200
],
201+
'style' => $this->get_style(),
201202
]
202203
);
203204
}
@@ -250,6 +251,19 @@ private function should_show_payment_request_button() {
250251
return $this->payment_request_configuration->should_show_payment_request_button();
251252
}
252253

254+
/**
255+
* Returns an array of style properties supported by the payment method.
256+
* This method is used only when rendering the payment method in the editor.
257+
*
258+
* @return array Array of style properties.
259+
*/
260+
private function get_style() {
261+
return [
262+
'height',
263+
'borderRadius',
264+
];
265+
}
266+
253267
/**
254268
* Returns true if the ECE should be shown on the current page, false otherwise.
255269
*

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
111111
== Changelog ==
112112

113113
= 9.1.0 - xxxx-xx-xx =
114+
* Fix - Fixes the incompatibility notice in editor due missing style property when instantiating Stripe payment methods.
114115
* Dev - Updates the GitHub caching action (`actions/cache`) to v4 due deprecation.
115116
* Fix - Don't update canceled order status to on-hold when a dispute is opened.
116117
* Fix - Correctly sets the dispute opened note when a dispute does not require any further action.

0 commit comments

Comments
 (0)