Skip to content

The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.

fix(payout): reconcile stripe account forward instead of orphaning on failure (#1266)

Viktor Holik3fb24e57c743
diff --git a/packages/core/src/modules/payout/services/payout-module-service.ts b/packages/core/src/modules/payout/services/payout-module-service.ts
index 6b8f6c6bd..b5ecdc864 100644
--- a/packages/core/src/modules/payout/services/payout-module-service.ts
+++ b/packages/core/src/modules/payout/services/payout-module-service.ts
@@ -92,7 +92,16 @@ export default class PayoutModuleService extends MedusaService({
sharedContext
)
} catch (error) {
- if (payoutAccount?.id) {
+ if (providerAccount && payoutAccount?.id) {
+ await this.updatePayoutAccounts(
+ {
+ id: payoutAccount.id,
+ data: providerAccount.data,
+ status: providerAccount.status,
+ },
+ sharedContext
+ ).catch(() => null)
+ } else if (payoutAccount?.id) {
await this.deletePayoutAccounts(payoutAccount.id, sharedContext)
}
throw error