fix(payment): Idempotent cancellation and proper creationg fail handling (#10135)

RESOLVES SUP-188

**What**
Two changes are happening here
- In the stripe payment provider, idempotent cancellation action, if not id is provided then return the existing data unchanged
- Payment module should not try to cancel a session that have failed to be created in the first place
This commit is contained in:
Adrien de Peretti
2024-11-18 17:45:13 +00:00
committed by GitHub
parent 47ca1d4b54
commit b1b7a4abf1
4 changed files with 102 additions and 16 deletions
@@ -186,6 +186,11 @@ abstract class StripeBase extends AbstractPaymentProvider<StripeOptions> {
): Promise<PaymentProviderError | PaymentProviderSessionResponse["data"]> {
try {
const id = paymentSessionData.id as string
if (!id) {
return paymentSessionData
}
return (await this.stripe_.paymentIntents.cancel(
id
)) as unknown as PaymentProviderSessionResponse["data"]