From 1e1835660e74a137059cfc304124aa2c625e2315 Mon Sep 17 00:00:00 2001 From: adrien2p Date: Thu, 26 Jan 2023 09:29:19 +0100 Subject: [PATCH] chore: add updateSessionData unsupported error --- packages/medusa/src/services/payment-provider.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/medusa/src/services/payment-provider.ts b/packages/medusa/src/services/payment-provider.ts index b4f0e87f10b0e..01b2092eeb966 100644 --- a/packages/medusa/src/services/payment-provider.ts +++ b/packages/medusa/src/services/payment-provider.ts @@ -573,11 +573,17 @@ export default class PaymentProviderService extends TransactionBaseService { const provider = this.retrieveProvider(paymentSession.provider_id) - // TODO: Waiting discussion output before taking care of the processor support - session.data = await provider - .withTransaction(transactionManager) - .updatePaymentData(paymentSession.data, data) - session.status = paymentSession.status + if (provider instanceof AbstractPaymentProcessor) { + throw new MedusaError( + MedusaError.Types.NOT_ALLOWED, + `Updating payment session data is not supported by the provider ${paymentSession.provider_id}.` + ) + } else { + session.data = await provider + .withTransaction(transactionManager) + .updatePaymentData(paymentSession.data, data) + session.status = paymentSession.status + } const sessionRepo = transactionManager.getCustomRepository( this.paymentSessionRepository_