feat(checkout): add completePurchase method and update PurchaseStatusResponse
This commit is contained in:
@@ -38,4 +38,20 @@ describe('CheckoutService', () => {
|
|||||||
|
|
||||||
await expect(purchasePromise).resolves.toMatchObject({ id: 55 });
|
await expect(purchasePromise).resolves.toMatchObject({ id: 55 });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('preserves checkout timing fields when completing a purchase', async () => {
|
||||||
|
const purchasePromise = service.completePurchase('desfile', 55);
|
||||||
|
const request = httpMock.expectOne(`${environment.url}tenants/desfile/compras/55/complete`);
|
||||||
|
const response = {
|
||||||
|
status: 'pending_payment',
|
||||||
|
expires_at: '2026-08-26T20:00:00.000Z',
|
||||||
|
expires_in_seconds: 900,
|
||||||
|
server_time: '2026-08-26T19:45:00.000Z',
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(request.request.method).toBe('POST');
|
||||||
|
request.flush({ data: response });
|
||||||
|
|
||||||
|
await expect(purchasePromise).resolves.toEqual(response);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -70,6 +70,9 @@ export type StartCheckoutPayload =
|
|||||||
|
|
||||||
export interface PurchaseStatusResponse {
|
export interface PurchaseStatusResponse {
|
||||||
status: string | null;
|
status: string | null;
|
||||||
|
expires_at: string | null;
|
||||||
|
expires_in_seconds: number | null;
|
||||||
|
server_time: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PurchaseSummaryResponse extends PurchaseStatusResponse {
|
export interface PurchaseSummaryResponse extends PurchaseStatusResponse {
|
||||||
@@ -106,7 +109,6 @@ export interface PurchaseDetailResponse extends PurchaseStatusResponse {
|
|||||||
user_id: number;
|
user_id: number;
|
||||||
created_at: string | null;
|
created_at: string | null;
|
||||||
payment_method: string | null;
|
payment_method: string | null;
|
||||||
expires_at: string | null;
|
|
||||||
dni: string | null;
|
dni: string | null;
|
||||||
transfer_payer_dni: string | null;
|
transfer_payer_dni: string | null;
|
||||||
telefono: string | null;
|
telefono: string | null;
|
||||||
@@ -200,9 +202,7 @@ export class CheckoutService extends BaseApiService {
|
|||||||
throw new Error('Error al finalizar la compra.');
|
throw new Error('Error al finalizar la compra.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return purchase;
|
||||||
status: purchase.status ?? null,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async submitPurchaseForReview(
|
async submitPurchaseForReview(
|
||||||
@@ -221,7 +221,7 @@ export class CheckoutService extends BaseApiService {
|
|||||||
throw new Error('Error al enviar la compra a revisi\u00f3n.');
|
throw new Error('Error al enviar la compra a revisi\u00f3n.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return { status: purchase.status ?? null };
|
return purchase;
|
||||||
}
|
}
|
||||||
|
|
||||||
async cancelPurchase(tenantCode: string, purchaseId: number): Promise<PurchaseStatusResponse> {
|
async cancelPurchase(tenantCode: string, purchaseId: number): Promise<PurchaseStatusResponse> {
|
||||||
@@ -237,7 +237,7 @@ export class CheckoutService extends BaseApiService {
|
|||||||
throw new Error('Error al cancelar la compra.');
|
throw new Error('Error al cancelar la compra.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return { status: purchase.status ?? null };
|
return purchase;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getPurchases(
|
async getPurchases(
|
||||||
|
|||||||
Reference in New Issue
Block a user