Skip to content

Commit 2034059

Browse files
authored
Use account.charges_enabled to show if Stripe payments are available (#2342)
* Use account.charges_enabled to show if Stripe payments are available. Partially fixes #2175 * Added 'charges_enabled' Stripe account property to JS mocks This is a continuation to fixes for #2175. Also removed now unneeded mock(s). * Don't check for payout schedule to determine if Stripe payouts enabled Fixes #2175. Some merchants have payouts "enabled" but do not have a payout schedule configured in Stripe -- presumably they are triggering their payouts manually in these cases. This change makes the Stripe settings show payouts as Enabled if the `payouts_enabled` property is true in their Stripe account even if they do not have a payout schedule set up. * Add changelog entry for #2175 fix
1 parent 1f0085f commit 2034059

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
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
= 6.4.0 - 2022-xx-xx =
4+
* Fix - Changed logic for how 'Enabled/Disabled' statuses are shown for payments and payouts capabilities in settings.
45

56
= 6.3.0 - 2022-03-10 =
67
* Tweak - Remove html from translatable strings.

client/settings/account-details/__tests__/account-details.test.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ jest.mock( 'wcstripe/data/account-keys', () => ( {
1616

1717
describe( 'AccountDetails', () => {
1818
it( 'renders enabled payments and payouts on account', () => {
19-
useGetCapabilities.mockReturnValue( {
20-
card_payments: 'active',
21-
} );
2219
useAccount.mockReturnValue( {
2320
data: {
2421
account: {
@@ -28,6 +25,7 @@ describe( 'AccountDetails', () => {
2825
},
2926
},
3027
payouts_enabled: true,
28+
charges_enabled: true,
3129
},
3230
},
3331
} );
@@ -53,16 +51,14 @@ describe( 'AccountDetails', () => {
5351
} );
5452

5553
it( 'renders disabled payouts and payments on account', () => {
56-
useGetCapabilities.mockReturnValue( {
57-
card_payments: 'disabled',
58-
} );
5954
useAccount.mockReturnValue( {
6055
data: {
6156
account: {
6257
settings: {
6358
payouts: {},
6459
},
6560
payouts_enabled: false,
61+
charges_enabled: false,
6662
},
6763
},
6864
} );

client/settings/account-details/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ import { Button, ExternalLink } from '@wordpress/components';
66
import interpolateComponents from 'interpolate-components';
77
import useWebhookStateMessage from './use-webhook-state-message';
88
import SectionStatus from './section-status';
9-
import { useAccount, useGetCapabilities } from 'wcstripe/data/account';
9+
import { useAccount } from 'wcstripe/data/account';
1010
import {
1111
useAccountKeysTestWebhookSecret,
1212
useAccountKeysWebhookSecret,
1313
} from 'wcstripe/data/account-keys';
1414
import { WebhookInformation } from 'wcstripe/components/webhook-information';
1515

16-
const useIsCardPaymentsEnabled = () =>
17-
useGetCapabilities().card_payments === 'active';
16+
const useIsCardPaymentsEnabled = () => {
17+
const { data } = useAccount();
18+
19+
return data.account?.charges_enabled;
20+
};
1821

1922
const useArePayoutsEnabled = () => {
2023
const { data } = useAccount();
2124

22-
return (
23-
data.account?.payouts_enabled &&
24-
Boolean( data.account?.settings?.payouts?.schedule?.interval )
25-
);
25+
return data.account?.payouts_enabled;
2626
};
2727

2828
const PaymentsSection = () => {

readme.txt

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

131131
= 6.4.0 - 2022-xx-xx =
132+
* Fix - Changed logic for how 'Enabled/Disabled' statuses are shown for payments and payouts capabilities in settings.
132133

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

0 commit comments

Comments
 (0)