From 3c7b1155c4e3db7e8dbe5cb70cccf19a1fc40ae9 Mon Sep 17 00:00:00 2001 From: Zvonimir Maglica Date: Fri, 20 Dec 2024 11:00:47 +0100 Subject: [PATCH] Invalidate transactions store when transaction is captured (#10015) --- .../fix-9735-render-transactions-correctly-on-capture | 4 ++++ client/data/authorizations/actions.ts | 7 +++++++ client/data/authorizations/test/actions.test.ts | 8 ++++++++ 3 files changed, 19 insertions(+) create mode 100644 changelog/fix-9735-render-transactions-correctly-on-capture diff --git a/changelog/fix-9735-render-transactions-correctly-on-capture b/changelog/fix-9735-render-transactions-correctly-on-capture new file mode 100644 index 00000000000..9ed7f628e4c --- /dev/null +++ b/changelog/fix-9735-render-transactions-correctly-on-capture @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Ensure captured transactions appear in the Transactions tab without requiring a page refresh. diff --git a/client/data/authorizations/actions.ts b/client/data/authorizations/actions.ts index 0885da1cbfe..ace7f3c6fed 100644 --- a/client/data/authorizations/actions.ts +++ b/client/data/authorizations/actions.ts @@ -196,6 +196,13 @@ export function* submitCaptureAuthorization( 'getPaymentIntent' ); + // Need to invalidate transactions tab to update newly captured transaction if needed. + yield controls.dispatch( + STORE_NAME, + 'invalidateResolutionForStoreSelector', + 'getTransactions' + ); + // Create success notice. yield controls.dispatch( 'core/notices', diff --git a/client/data/authorizations/test/actions.test.ts b/client/data/authorizations/test/actions.test.ts index 171ef6dd5ad..36527d1836a 100644 --- a/client/data/authorizations/test/actions.test.ts +++ b/client/data/authorizations/test/actions.test.ts @@ -118,6 +118,14 @@ describe( 'Authorizations actions', () => { ) ); + expect( generator.next().value ).toEqual( + controls.dispatch( + 'wc/payments', + 'invalidateResolutionForStoreSelector', + 'getTransactions' + ) + ); + expect( generator.next().value ).toEqual( controls.dispatch( 'core/notices',