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.

feat: pass account_id metadata to Stripe and use it in webhook results

vholik0e50d44f632b
diff --git a/packages/core-plugin/src/modules/payout/services/payout-module-service.ts b/packages/core-plugin/src/modules/payout/services/payout-module-service.ts
index d706c4a89..2f91bb4b5 100644
--- a/packages/core-plugin/src/modules/payout/services/payout-module-service.ts
+++ b/packages/core-plugin/src/modules/payout/services/payout-module-service.ts
@@ -77,7 +77,10 @@ export default class PayoutModuleService extends MedusaService({
idempotency_key: payoutAccount.id,
...input.context
},
- data: input.data
+ data: {
+ ...input.data,
+ account_id: payoutAccount.id,
+ }
})
payoutAccount = await this.updatePayoutAccounts(
diff --git a/packages/providers/payout-stripe-connect/src/services/stripe-connect.ts b/packages/providers/payout-stripe-connect/src/services/stripe-connect.ts
index 68004f24a..bb693534b 100644
--- a/packages/providers/payout-stripe-connect/src/services/stripe-connect.ts
+++ b/packages/providers/payout-stripe-connect/src/services/stripe-connect.ts
@@ -56,6 +56,7 @@ class StripeConnectProviderService implements IPayoutProvider {
private getWebhookResultFromAccount_(
account: Stripe.Account
): PayoutWebhookResult {
+ const accountId = account.metadata?.account_id!
const validation = {
...DEFAULT_ACCOUNT_VALIDATION,
...this.config_.accountValidation,
@@ -76,7 +77,7 @@ class StripeConnectProviderService implements IPayoutProvider {
return {
action: "account.rejected",
data: {
- id: account.id,
+ id: accountId,
},
}
}
@@ -91,7 +92,7 @@ class StripeConnectProviderService implements IPayoutProvider {
return {
action: "account.activated",
data: {
- id: account.id,
+ id: accountId,
},
}
}
@@ -100,7 +101,7 @@ class StripeConnectProviderService implements IPayoutProvider {
return {
action: "account.restricted",
data: {
- id: account.id,
+ id: accountId,
},
}
}
@@ -108,7 +109,7 @@ class StripeConnectProviderService implements IPayoutProvider {
return {
action: "account.restricted",
data: {
- id: account.id,
+ id: accountId,
},
}
}
@@ -171,6 +172,9 @@ class StripeConnectProviderService implements IPayoutProvider {
const response = await this.stripe_.accounts.create({
type: 'express',
country,
+ metadata: {
+ account_id: data?.account_id as string,
+ },
}, {
idempotencyKey: input.context?.idempotency_key
})