Skip to content

Commit 49a6084

Browse files
committed
Merge remote-tracking branch 'origin/release/6.9.0' into trunk
2 parents c1aba13 + df33de5 commit 49a6084

16 files changed

+142
-135
lines changed

assets/js/stripe-admin.min.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
*** Changelog ***
22

3+
= 6.9.0 - 2022-10-19 =
4+
* Tweak - Remove remaining traces of old Stripe settings.
5+
* Add - Add Boleto expiration setting.
6+
* Add - Declare incompatibility with HPOS.
7+
38
= 6.8.0 - 2022-09-28 =
49
* Fix - Minor adjustments for Custom Order Tables compatibility.
510
* Fix - Upgrade from Payment Element beta.

client/data/payment-gateway/hooks.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,8 @@ export const usePaymentGatewayDescription = makePaymentGatewayHook(
8484
makeFieldName( '%s_description' ),
8585
''
8686
);
87+
88+
export const usePaymentGatewayExpiration = makePaymentGatewayHook(
89+
makeFieldName( '%s_expiration' ),
90+
''
91+
);

client/settings/payment-gateway-manager/constants.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { __ } from '@wordpress/i18n';
2+
import { TextControl } from '@wordpress/components';
3+
import { usePaymentGatewayExpiration } from '../../data/payment-gateway/hooks';
24

35
export const gatewaysInfo = {
46
stripe_sepa: {
@@ -91,6 +93,38 @@ export const gatewaysInfo = {
9193
),
9294
guide:
9395
'https://stripe.com/docs/payments/payment-methods/overview#vouchers',
96+
Fields: () => {
97+
const [
98+
gatewayExpiration,
99+
setGatewayExpiration,
100+
] = usePaymentGatewayExpiration();
101+
102+
return (
103+
<>
104+
<h4>
105+
{ __(
106+
'Voucher settings',
107+
'woocommerce-gateway-stripe'
108+
) }
109+
</h4>
110+
<TextControl
111+
type="number"
112+
min="0"
113+
max="60"
114+
help={ __(
115+
'Set the number of days until expiration from 0 to 60 days. The default is 3 days.',
116+
'woocommerce-gateway-stripe'
117+
) }
118+
label={ __(
119+
'Expiration',
120+
'woocommerce-gateway-stripe'
121+
) }
122+
value={ gatewayExpiration }
123+
onChange={ setGatewayExpiration }
124+
/>
125+
</>
126+
);
127+
},
94128
},
95129
stripe_oxxo: {
96130
title: __( 'OXXO', 'woocommerce-gateway-stripe' ),

client/settings/payment-gateway-section/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const StyledCheckboxLabel = styled.span`
3434
const PaymentGatewaySection = () => {
3535
const { section } = getQuery();
3636
const info = gatewaysInfo[ section ];
37+
const { Fields } = info;
3738
const [ enableGateway, setEnableGateway ] = useEnabledPaymentGateway();
3839
const [ gatewayName, setGatewayName ] = usePaymentGatewayName();
3940
const [
@@ -106,6 +107,7 @@ const PaymentGatewaySection = () => {
106107
value={ gatewayDescription }
107108
onChange={ setGatewayDescription }
108109
/>
110+
{ Fields && <Fields /> }
109111
<h4>
110112
{ __(
111113
'Webhook endpoints',

includes/abstracts/abstract-wc-stripe-payment-gateway-voucher.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,19 @@ public function create_or_update_payment_intent( $order ) {
306306
$intent_to_be_updated = '/' . $intent->id;
307307
}
308308

309+
$body = [
310+
'amount' => WC_Stripe_Helper::get_stripe_amount( $amount, strtolower( $currency ) ),
311+
'currency' => strtolower( $currency ),
312+
'payment_method_types' => [ $this->stripe_id ],
313+
'description' => __( 'stripe - Order', 'woocommerce-gateway-stripe' ) . ' ' . $order->get_id(),
314+
];
315+
316+
if ( method_exists( $this, 'update_request_body_on_create_or_update_payment_intent' ) ) {
317+
$body = $this->update_request_body_on_create_or_update_payment_intent( $body );
318+
}
319+
309320
$payment_intent = WC_Stripe_API::request(
310-
[
311-
'amount' => WC_Stripe_Helper::get_stripe_amount( $amount, strtolower( $currency ) ),
312-
'currency' => strtolower( $currency ),
313-
'payment_method_types' => [ $this->stripe_id ],
314-
'description' => __( 'stripe - Order', 'woocommerce-gateway-stripe' ) . ' ' . $order->get_id(),
315-
],
321+
$body,
316322
'payment_intents' . $intent_to_be_updated
317323
);
318324

includes/admin/class-wc-rest-stripe-payment-gateway-controller.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,15 @@ public function get_payment_gateway_settings( $request = null ) {
8686
try {
8787
$id = $request->get_param( 'payment_gateway_id' );
8888
$this->instantiate_gateway( $id );
89-
return new WP_REST_Response(
90-
[
91-
'is_' . $id . '_enabled' => $this->gateway->is_enabled(),
92-
$id . '_name' => $this->gateway->get_option( 'title' ),
93-
$id . '_description' => $this->gateway->get_option( 'description' ),
94-
]
95-
);
89+
$settings = [
90+
'is_' . $id . '_enabled' => $this->gateway->is_enabled(),
91+
$id . '_name' => $this->gateway->get_option( 'title' ),
92+
$id . '_description' => $this->gateway->get_option( 'description' ),
93+
];
94+
if ( method_exists( $this->gateway, 'get_unique_settings' ) ) {
95+
$settings = $this->gateway->get_unique_settings( $settings );
96+
}
97+
return new WP_REST_Response( $settings );
9698
} catch ( Exception $exception ) {
9799
return new WP_REST_Response( [ 'result' => 'bad_request' ], 400 );
98100
}
@@ -110,7 +112,9 @@ public function update_payment_gateway_settings( WP_REST_Request $request ) {
110112
$this->update_is_gateway_enabled( $request );
111113
$this->update_gateway_name( $request );
112114
$this->update_gateway_description( $request );
113-
115+
if ( method_exists( $this->gateway, 'update_unique_settings' ) ) {
116+
$this->gateway->update_unique_settings( $request );
117+
}
114118
return new WP_REST_Response( [], 200 );
115119
} catch ( Exception $exception ) {
116120
return new WP_REST_Response( [ 'result' => 'bad_request' ], 400 );
@@ -155,7 +159,7 @@ private function update_gateway_name( WP_REST_Request $request ) {
155159
}
156160

157161
/**
158-
* Updates payment gateway title.
162+
* Updates payment gateway description.
159163
*
160164
* @param WP_REST_Request $request Request object.
161165
*/

includes/admin/stripe-boleto-settings.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040
'default' => __( "You'll be able to download or print the Boleto after checkout.", 'woocommerce-gateway-stripe' ),
4141
'desc_tip' => true,
4242
],
43+
'expiration' => [
44+
'title' => __( 'Expiration', 'woocommerce-gateway-stripe' ),
45+
'type' => 'number',
46+
'description' => __( 'This controls the expiration in number of days for the voucher.', 'woocommerce-gateway-stripe' ),
47+
'default' => 3,
48+
'desc_tip' => true,
49+
],
4350
'webhook' => [
4451
'title' => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ),
4552
'type' => 'title',

includes/class-wc-gateway-stripe.php

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,50 +1037,6 @@ public function settings_api_sanitized_fields( $settings ) {
10371037
return $settings;
10381038
}
10391039

1040-
/**
1041-
* This is overloading the title type so the oauth url is only fetched if we are on the settings page.
1042-
*
1043-
* @param string $key Field key.
1044-
* @param array $data Field data.
1045-
* @return string
1046-
*/
1047-
public function generate_stripe_account_keys_html( $key, $data ) {
1048-
if ( woocommerce_gateway_stripe()->connect->is_connected() ) {
1049-
$reset_link = add_query_arg(
1050-
[
1051-
'_wpnonce' => wp_create_nonce( 'reset_stripe_api_credentials' ),
1052-
'reset_stripe_api_credentials' => true,
1053-
],
1054-
admin_url( 'admin.php?page=wc-settings&tab=checkout&section=stripe' )
1055-
);
1056-
1057-
$api_credentials_text = sprintf(
1058-
/* translators: %1, %2, %3, and %4 are all HTML markup tags */
1059-
__( '%1$sClear all Stripe account keys.%2$s %3$sThis will disable any connection to Stripe.%4$s', 'woocommerce-gateway-stripe' ),
1060-
'<a id="wc_stripe_connect_button" href="' . $reset_link . '" class="button button-secondary">',
1061-
'</a>',
1062-
'<span style="color:red;">',
1063-
'</span>'
1064-
);
1065-
} else {
1066-
$oauth_url = woocommerce_gateway_stripe()->connect->get_oauth_url();
1067-
1068-
if ( ! is_wp_error( $oauth_url ) ) {
1069-
$api_credentials_text = sprintf(
1070-
/* translators: %1, %2 and %3 are all HTML markup tags */
1071-
__( '%1$sSet up or link an existing Stripe account.%2$s By clicking this button you agree to the %3$sTerms of Service%2$s. Or, manually enter Stripe account keys below.', 'woocommerce-gateway-stripe' ),
1072-
'<a id="wc_stripe_connect_button" href="' . $oauth_url . '" class="button button-primary">',
1073-
'</a>',
1074-
'<a href="https://wordpress.com/tos">'
1075-
);
1076-
} else {
1077-
$api_credentials_text = __( 'Manually enter Stripe keys below.', 'woocommerce-gateway-stripe' );
1078-
}
1079-
}
1080-
$data['description'] = $api_credentials_text;
1081-
return $this->generate_title_html( $key, $data );
1082-
}
1083-
10841040
/**
10851041
* Checks whether the gateway is enabled.
10861042
*

includes/connect/class-wc-stripe-connect.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -89,28 +89,7 @@ public function maybe_handle_redirect() {
8989
$response = $this->connect_oauth( wc_clean( wp_unslash( $_GET['wcs_stripe_state'] ) ), wc_clean( wp_unslash( $_GET['wcs_stripe_code'] ) ) );
9090
wp_safe_redirect( esc_url_raw( remove_query_arg( [ 'wcs_stripe_state', 'wcs_stripe_code' ] ) ) );
9191
exit;
92-
93-
// redirect from credentials reset
94-
} elseif ( isset( $_GET['reset_stripe_api_credentials'], $_GET['_wpnonce'] ) ) {
95-
96-
if ( ! wp_verify_nonce( wc_clean( wp_unslash( $_GET['_wpnonce'] ) ), 'reset_stripe_api_credentials' ) ) {
97-
die( __( 'You are not authorized to clear Stripe account keys.', 'woocommerce-gateway-stripe' ) );
98-
}
99-
100-
$this->clear_stripe_keys();
101-
wp_safe_redirect(
102-
esc_url_raw(
103-
remove_query_arg(
104-
[
105-
'_wpnonce',
106-
'reset_stripe_api_credentials',
107-
]
108-
)
109-
)
110-
);
111-
exit;
11292
}
113-
11493
}
11594

11695
/**

0 commit comments

Comments
 (0)