@@ -42,11 +42,13 @@ import {
4242 currenyListMapper ,
4343 userResponseMapper ,
4444 orderListSummaryResponseMapper ,
45- loginMapper
45+ loginMapper ,
46+ orderSummaryResponseMapper
4647} from '$lib/mappers' ;
4748import { OrderCache , ProductCache } from '$lib/cache' ;
4849import type { CreateProductInput , UpdateCategoryInput , UpdateProductInput } from '$lib/types' ;
4950import { categoryResponseMapper } from '$lib/mappers/category.mapper' ;
51+ import { paymentResponseMapper } from '$lib/mappers/payments.mapper' ;
5052
5153/**
5254 * Cached API client wrapper that adds caching to API operations
@@ -252,20 +254,59 @@ export class CachedCommercifyApiClient {
252254 ) ,
253255
254256 updateOrderStatus : async ( id : string , status : UpdateOrderStatusRequest ) => {
255- const result = await this . client . orders . updateOrderStatus ( id , status , orderResponseMapper ) ;
257+ const result = await this . client . orders . updateOrderStatus (
258+ id ,
259+ status ,
260+ orderSummaryResponseMapper
261+ ) ;
262+ // Invalidate both specific order and order lists cache
256263 CacheInvalidator . invalidateOrder ( id ) ;
264+ await CacheInvalidator . invalidateOrderLists ( ) ;
257265 return result ;
258266 }
259267 } ;
260268 }
261269
262270 get payments ( ) {
263271 return {
264- capture : ( paymentId : string , options : CapturePaymentRequest ) =>
265- this . client . admin . capturePayment ( paymentId , options ) ,
266- cancel : ( paymentId : string ) => this . client . admin . cancelPayment ( paymentId ) ,
267- refund : ( paymentId : string , options : RefundPaymentRequest ) =>
268- this . client . admin . refundPayment ( paymentId , options )
272+ capture : async ( paymentId : string , options : CapturePaymentRequest , orderId ?: string ) => {
273+ const result = await this . client . admin . capturePayment (
274+ paymentId ,
275+ options ,
276+ paymentResponseMapper
277+ ) ;
278+ // Invalidate order lists cache since payment status affects order listings
279+ await CacheInvalidator . invalidateOrderLists ( ) ;
280+ // If order ID is provided, also invalidate specific order cache
281+ if ( orderId ) {
282+ CacheInvalidator . invalidateOrder ( orderId ) ;
283+ }
284+ return result ;
285+ } ,
286+ cancel : async ( paymentId : string , orderId ?: string ) => {
287+ const result = await this . client . admin . cancelPayment ( paymentId , paymentResponseMapper ) ;
288+ // Invalidate order lists cache since payment status affects order listings
289+ await CacheInvalidator . invalidateOrderLists ( ) ;
290+ // If order ID is provided, also invalidate specific order cache
291+ if ( orderId ) {
292+ CacheInvalidator . invalidateOrder ( orderId ) ;
293+ }
294+ return result ;
295+ } ,
296+ refund : async ( paymentId : string , options : RefundPaymentRequest , orderId ?: string ) => {
297+ const result = await this . client . admin . refundPayment (
298+ paymentId ,
299+ options ,
300+ paymentResponseMapper
301+ ) ;
302+ // Invalidate order lists cache since payment status affects order listings
303+ await CacheInvalidator . invalidateOrderLists ( ) ;
304+ // If order ID is provided, also invalidate specific order cache
305+ if ( orderId ) {
306+ CacheInvalidator . invalidateOrder ( orderId ) ;
307+ }
308+ return result ;
309+ }
269310 } ;
270311 }
271312
0 commit comments