fix(payment): Partial refunds (#8603)

* fix(payment): Partial payment provider refunds

* add tests
This commit is contained in:
Oli Juhl
2024-08-15 19:01:22 +02:00
committed by GitHub
parent c92aa3e397
commit 9de9b3825f
3 changed files with 168 additions and 26 deletions
@@ -685,6 +685,52 @@ moduleIntegrationTestRunner<IPaymentModuleService>({
)
})
it("should fully refund a payment through two refunds", async () => {
await service.capturePayment({
amount: 100,
payment_id: "pay-id-2",
})
const refundedPaymentOne = await service.refundPayment({
amount: 50,
payment_id: "pay-id-2",
})
const refundedPaymentTwo = await service.refundPayment({
amount: 50,
payment_id: "pay-id-2",
})
expect(refundedPaymentOne).toEqual(
expect.objectContaining({
id: "pay-id-2",
amount: 100,
refunds: [
expect.objectContaining({
created_by: null,
amount: 50,
}),
],
})
)
expect(refundedPaymentTwo).toEqual(
expect.objectContaining({
id: "pay-id-2",
amount: 100,
refunds: [
expect.objectContaining({
created_by: null,
amount: 50,
}),
expect.objectContaining({
created_by: null,
amount: 50,
}),
],
})
)
})
it("should throw if refund is greater than captured amount", async () => {
await service.capturePayment({
amount: 50,