Skip to content

Commit

Permalink
Merge branch 'develop' into update-billing-address-saved-card
Browse files Browse the repository at this point in the history
  • Loading branch information
timur27 authored May 6, 2024
2 parents 6bc77ce + 1d5b91a commit f25dd7c
Show file tree
Hide file tree
Showing 53 changed files with 663 additions and 151 deletions.
4 changes: 4 additions & 0 deletions changelog/fix-6497-advanced-fraud-settings-empty
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Add notice when no rules are enabled in advanced fraud settings
5 changes: 5 additions & 0 deletions changelog/fix-8702-fix-refunds-view-report-link
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: The PR fixes the correct landing links on `View report` for the Refunds tile in Payment activity widget. Changes are behind a feature flag.


5 changes: 5 additions & 0 deletions changelog/fix-8705-charges-view-report
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: Behind fPayment Activity Card feature flag, fix View Report link of Charges tile.


5 changes: 5 additions & 0 deletions changelog/fix-8732-qit-warning
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: Fix QIT warning for discouraged function.


5 changes: 5 additions & 0 deletions changelog/fix-8742-merchant-timezone-payment-activity
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Adding some fixes to the Payment Activity component, reporting controller aand associated classes.


5 changes: 5 additions & 0 deletions changelog/fix-update-request-classes-docs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Updated the parent link in request classes documentation


4 changes: 4 additions & 0 deletions changelog/terminal-payment-subscription-support
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: add

Support for starting auto-renewing subscriptions for In-Person Payments.
30 changes: 25 additions & 5 deletions client/components/payment-activity/payment-activity-data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ const searchTermsForViewReportLink = {
'dispute_reversal',
'card_reader_fee',
],

charge: [ 'charge', 'payment' ],

refunds: [
'refund',
'refund_failure',
'payment_refund',
'payment_failure_refund',
],
};

const getSearchParams = ( searchTerms: string[] ) => {
Expand All @@ -56,9 +65,10 @@ const getSearchParams = ( searchTerms: string[] ) => {
};

const PaymentActivityData: React.FC = () => {
const { paymentActivityData, isLoading } = usePaymentActivityData(
getDateRange()
);
const { paymentActivityData, isLoading } = usePaymentActivityData( {
...getDateRange(),
timezone: moment( new Date() ).format( 'Z' ),
} );

const totalPaymentVolume = paymentActivityData?.total_payment_volume ?? 0;
const charges = paymentActivityData?.charges ?? 0;
Expand Down Expand Up @@ -153,7 +163,15 @@ const PaymentActivityData: React.FC = () => {
page: 'wc-admin',
path: '/payments/transactions',
filter: 'advanced',
type_is: 'charge',
'date_between[0]': moment(
getDateRange().date_start
).format( 'YYYY-MM-DD' ),
'date_between[1]': moment(
getDateRange().date_end
).format( 'YYYY-MM-DD' ),
...getSearchParams(
searchTermsForViewReportLink.charge
),
} ) }
tracksSource="charges"
isLoading={ isLoading }
Expand All @@ -167,13 +185,15 @@ const PaymentActivityData: React.FC = () => {
page: 'wc-admin',
path: '/payments/transactions',
filter: 'advanced',
type_is: 'refund',
'date_between[0]': moment(
getDateRange().date_start
).format( 'YYYY-MM-DD' ),
'date_between[1]': moment(
getDateRange().date_end
).format( 'YYYY-MM-DD' ),
...getSearchParams(
searchTermsForViewReportLink.refunds
),
} ) }
tracksSource="refunds"
isLoading={ isLoading }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ exports[`PaymentActivity component should render 1`] = `
</p>
<a
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions&filter=advanced&type_is=charge"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions&filter=advanced&date_between%5B0%5D=2024-04-02&date_between%5B1%5D=2024-04-08&search%5B0%5D=charge&search%5B1%5D=payment"
>
View report
</a>
Expand Down Expand Up @@ -165,7 +165,7 @@ exports[`PaymentActivity component should render 1`] = `
</p>
<a
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions&filter=advanced&type_is=refund&date_between%5B0%5D=2024-04-02&date_between%5B1%5D=2024-04-08"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions&filter=advanced&date_between%5B0%5D=2024-04-02&date_between%5B1%5D=2024-04-08&search%5B0%5D=refund&search%5B1%5D=refund_failure&search%5B2%5D=payment_refund&search%5B3%5D=payment_failure_refund"
>
View report
</a>
Expand Down
1 change: 1 addition & 0 deletions client/data/payment-activity/test/hooks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe( 'usePaymentActivityData', () => {
const result = usePaymentActivityData( {
date_start: '2021-01-01',
date_end: '2021-01-31',
timezone: 'UTC',
} );

expect( result ).toEqual( {
Expand Down
3 changes: 2 additions & 1 deletion client/data/payment-activity/test/resolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ import { getPaymentActivityData } from '../resolvers';
const query = {
date_start: '2020-04-29T04:00:00',
date_end: '2020-04-29T03:59:59',
timezone: '+2:30',
};

describe( 'getPaymentActivityData resolver', () => {
const successfulResponse: any = { amount: 3000 };
const expectedQueryString =
'date_start=2020-04-29T04%3A00%3A00&date_end=2020-04-29T03%3A59%3A59';
'date_start=2020-04-29T04%3A00%3A00&date_end=2020-04-29T03%3A59%3A59&timezone=%2B2%3A30';
const errorResponse = new Error(
'Error retrieving payment activity data.'
);
Expand Down
2 changes: 1 addition & 1 deletion client/data/payment-activity/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ export interface PaymentActivityQuery {
/** The date range end datetime used to calculate transaction data, e.g. 2024-04-29T16:19:29 */
date_end: string;
/** The timezone used to calculate the transaction data date range, e.g. 'UTC' */
timezone?: string;
timezone: string;
}
110 changes: 71 additions & 39 deletions client/settings/fraud-protection/advanced-settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,28 @@ const observerEventMapping: Record< string, string > = {
};

const Breadcrumb = () => (
<h2 className="fraud-protection-header-breadcrumb">
<Link
type="wp-admin"
href={ getAdminUrl( {
page: 'wc-settings',
tab: 'checkout',
section: 'woocommerce_payments',
} ) }
>
{ 'WooPayments' }
</Link>
&nbsp;&gt;&nbsp;
{ __( 'Advanced fraud protection', 'woocommerce-payments' ) }
</h2>
<>
<h2 className="fraud-protection-header-breadcrumb">
<Link
type="wp-admin"
href={ getAdminUrl( {
page: 'wc-settings',
tab: 'checkout',
section: 'woocommerce_payments',
} ) }
>
{ 'WooPayments' }
</Link>
&nbsp;&gt;&nbsp;
{ __( 'Advanced fraud protection', 'woocommerce-payments' ) }
</h2>
<p className="fraud-protection-advanced-settings-notice">
{ __(
'At least one risk filter needs to be enabled for advanced protection.',
'woocommerce-payments'
) }
</p>
</>
);

const SaveFraudProtectionSettingsButton: React.FC = ( { children } ) => {
Expand Down Expand Up @@ -154,42 +162,66 @@ const FraudProtectionAdvancedSettingsPage: React.FC = () => {
.every( Boolean );
};

const checkAnyRuleFilterEnabled = (
settings: ProtectionSettingsUI
): boolean => {
return Object.values( settings ).some( ( setting ) => setting.enabled );
};

const handleSaveSettings = () => {
if ( validateSettings( protectionSettingsUI ) ) {
if ( ProtectionLevel.ADVANCED !== currentProtectionLevel ) {
updateProtectionLevel( ProtectionLevel.ADVANCED );
dispatch( 'core/notices' ).createSuccessNotice(
if ( ! validateSettings( protectionSettingsUI ) ) {
window.scrollTo( {
top: 0,
} );
return;
}

if ( ! checkAnyRuleFilterEnabled( protectionSettingsUI ) ) {
if ( ProtectionLevel.BASIC === currentProtectionLevel ) {
dispatch( 'core/notices' ).createErrorNotice(
__(
'Current protection level is set to "advanced".',
'At least one risk filter needs to be enabled for advanced protection.',
'woocommerce-payments'
)
);
return;
}

const settings = writeRuleset( protectionSettingsUI );
updateProtectionLevel( ProtectionLevel.BASIC );
dispatch( 'core/notices' ).createErrorNotice(
__(
'Current protection level is set to "basic". At least one risk filter needs to be enabled for advanced protection.',
'woocommerce-payments'
)
);
} else if ( ProtectionLevel.ADVANCED !== currentProtectionLevel ) {
updateProtectionLevel( ProtectionLevel.ADVANCED );
dispatch( 'core/notices' ).createSuccessNotice(
__(
'Current protection level is set to "advanced".',
'woocommerce-payments'
)
);
}

// Persist the AVS verification setting until the account cache is updated locally.
if (
wcpaySettings?.accountStatus?.fraudProtection
?.declineOnAVSFailure
) {
wcpaySettings.accountStatus.fraudProtection.declineOnAVSFailure = settings.some(
( setting ) => setting.key === 'avs_verification'
);
}
const settings = writeRuleset( protectionSettingsUI );

updateAdvancedFraudProtectionSettings( settings );
// Persist the AVS verification setting until the account cache is updated locally.
if (
wcpaySettings?.accountStatus?.fraudProtection?.declineOnAVSFailure
) {
wcpaySettings.accountStatus.fraudProtection.declineOnAVSFailure = settings.some(
( setting ) => setting.key === 'avs_verification'
);
}

saveSettings();
updateAdvancedFraudProtectionSettings( settings );

recordEvent( 'wcpay_fraud_protection_advanced_settings_saved', {
settings: JSON.stringify( settings ),
} );
} else {
window.scrollTo( {
top: 0,
} );
}
saveSettings();

recordEvent( 'wcpay_fraud_protection_advanced_settings_saved', {
settings: JSON.stringify( settings ),
} );
};

// Hack to make "Payments > Settings" the active selected menu item.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ Object {
 &gt; 
Advanced fraud protection
</h2>
<p
class="fraud-protection-advanced-settings-notice"
>
At least one risk filter needs to be enabled for advanced protection.
</p>
<div
class="fraud-protection-advanced-settings-error-notice"
>
Expand Down Expand Up @@ -1066,6 +1071,11 @@ Object {
 &gt; 
Advanced fraud protection
</h2>
<p
class="fraud-protection-advanced-settings-notice"
>
At least one risk filter needs to be enabled for advanced protection.
</p>
<div
class="fraud-protection-advanced-settings-error-notice"
>
Expand Down Expand Up @@ -2149,6 +2159,11 @@ Object {
 &gt; 
Advanced fraud protection
</h2>
<p
class="fraud-protection-advanced-settings-notice"
>
At least one risk filter needs to be enabled for advanced protection.
</p>
<div
class="fraud-protection-advanced-settings-error-notice"
>
Expand Down Expand Up @@ -3006,6 +3021,11 @@ Object {
 &gt; 
Advanced fraud protection
</h2>
<p
class="fraud-protection-advanced-settings-notice"
>
At least one risk filter needs to be enabled for advanced protection.
</p>
<div
class="fraud-protection-advanced-settings-error-notice"
>
Expand Down Expand Up @@ -3926,6 +3946,11 @@ Object {
 &gt; 
Advanced fraud protection
</h2>
<p
class="fraud-protection-advanced-settings-notice"
>
At least one risk filter needs to be enabled for advanced protection.
</p>
<div
class="components-surface components-card fraud-protection-rule-card css-nsno0f-View-Surface-getBorders-primary-Card-rounded em57xhy0"
data-wp-c16t="true"
Expand Down Expand Up @@ -4746,6 +4771,11 @@ Object {
 &gt; 
Advanced fraud protection
</h2>
<p
class="fraud-protection-advanced-settings-notice"
>
At least one risk filter needs to be enabled for advanced protection.
</p>
<div
class="components-surface components-card fraud-protection-rule-card css-nsno0f-View-Surface-getBorders-primary-Card-rounded em57xhy0"
data-wp-c16t="true"
Expand Down Expand Up @@ -5666,6 +5696,11 @@ Object {
 &gt; 
Advanced fraud protection
</h2>
<p
class="fraud-protection-advanced-settings-notice"
>
At least one risk filter needs to be enabled for advanced protection.
</p>
<div
class="components-surface components-card fraud-protection-rule-card css-nsno0f-View-Surface-getBorders-primary-Card-rounded em57xhy0"
data-wp-c16t="true"
Expand Down Expand Up @@ -6586,6 +6621,11 @@ Object {
 &gt; 
Advanced fraud protection
</h2>
<p
class="fraud-protection-advanced-settings-notice"
>
At least one risk filter needs to be enabled for advanced protection.
</p>
<div
class="components-surface components-card fraud-protection-rule-card css-nsno0f-View-Surface-getBorders-primary-Card-rounded em57xhy0"
data-wp-c16t="true"
Expand Down
Loading

0 comments on commit f25dd7c

Please sign in to comment.