Skip to content

Commit bb7a674

Browse files
committed
Use settings statement descriptor in account summary API
1 parent ede3e40 commit bb7a674

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

changelog.txt

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

33
= 6.2.0 - 2022-xx-xx =
4-
4+
* Fix - Missing statement descriptor in account summary API when not set in Stripe.
55

66
= 6.1.0 - 2022-01-26 =
77
* Tweak - Use the newly exposed LoadableMask component provided by WooCommerce Blocks to trigger the loading state for Payment Request Buttons.

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,15 @@ class WC_REST_Stripe_Account_Controller extends WC_Stripe_REST_Base_Controller {
2525
*/
2626
private $account;
2727

28-
public function __construct( WC_Stripe_Account $account ) {
28+
/**
29+
* Stripe payment gateway.
30+
*
31+
* @var WC_Gateway_Stripe
32+
*/
33+
private $gateway;
34+
35+
public function __construct( WC_Gateway_Stripe $gateway, WC_Stripe_Account $account ) {
36+
$this->gateway = $gateway;
2937
$this->account = $account;
3038
}
3139

@@ -98,13 +106,19 @@ public function get_account() {
98106
public function get_account_summary() {
99107
$account = $this->account->get_cached_account_data();
100108

109+
// Use statement descriptor from settings, falling back to Stripe account statement descriptor if needed.
110+
$statement_descriptor = WC_Stripe_Helper::clean_statement_descriptor( $this->gateway->get_option( 'statement_descriptor' ) );
111+
if ( empty( $statement_descriptor ) ) {
112+
$statement_descriptor = $account['settings']['payments']['statement_descriptor'] ?? '';
113+
}
114+
101115
return new WP_REST_Response(
102116
[
103117
'has_pending_requirements' => $this->account->has_pending_requirements(),
104118
'has_overdue_requirements' => $this->account->has_overdue_requirements(),
105119
'current_deadline' => $account['requirements']['current_deadline'] ?? null,
106120
'status' => $this->account->get_account_status(),
107-
'statement_descriptor' => $account['settings']['payments']['statement_descriptor'] ?? '',
121+
'statement_descriptor' => $statement_descriptor,
108122
'store_currencies' => [
109123
'default' => $account['default_currency'] ?? get_woocommerce_currency(),
110124
'supported' => $this->account->get_supported_store_currencies(),

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ If you get stuck, you can ask for help in the Plugin Forum.
129129
== Changelog ==
130130

131131
= 6.2.0 - 2022-xx-xx =
132+
* Fix - Missing statement descriptor in account summary API when not set in Stripe.
132133

133134

134135
[See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).

woocommerce-gateway-stripe.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ public function register_routes() {
592592
$stripe_tokens_controller = new WC_REST_Stripe_Tokens_Controller();
593593
$oauth_init = new WC_Stripe_Connect_REST_Oauth_Init_Controller( $this->connect, $this->api );
594594
$oauth_connect = new WC_Stripe_Connect_REST_Oauth_Connect_Controller( $this->connect, $this->api );
595-
$stripe_account_controller = new WC_REST_Stripe_Account_Controller( $this->account );
595+
$stripe_account_controller = new WC_REST_Stripe_Account_Controller( $this->get_main_stripe_gateway(), $this->account );
596596

597597
$connection_tokens_controller->register_routes();
598598
$locations_controller->register_routes();

0 commit comments

Comments
 (0)