Skip to content

Stripe Connect Marketplace Setup & Guide

The stripe_connect provider enables multi-sided marketplace platforms to onboard sellers and service providers via Stripe Express, collect custom platform application fees, and route payments as destination charges.


No extra install: the provider calls Stripe’s REST API over Kirak’s own async HTTP client, so pip install kirak is all it needs.


Stripe Connect shares the same platform Stripe account as standard Stripe, but is configured as its own provider instance with dedicated webhook signing secrets and marketplace fee settings.

{
"payments": {
"providers": {
"stripe_connect": {
"type": "stripe_connect",
"refresh_url": "/connect/onboard/refresh",
"return_url": "/connect/onboard/return",
"platform_fee_percent": 10.0,
"success_url": "https://your-domain.com/payment/success",
"cancel_url": "https://your-domain.com/payment/cancel",
"timeout": 15
}
}
}
}
Setting Type Default Description
platform_fee_percent number 10.0 Default platform take rate (0 to 100) deducted from merchant earnings
refresh_url string "/connect/onboard/refresh" URL Stripe returns a merchant to if their onboarding link expires
return_url string "/connect/onboard/return" URL Stripe redirects the merchant to after finishing onboarding
Terminal window
KIRAK_PAYMENT_STRIPE_CONNECT_SECRET_KEY=sk_test_...
KIRAK_PAYMENT_STRIPE_CONNECT_WEBHOOK_SECRET=whsec_connected_... # From Connected Accounts Webhook
KIRAK_PAYMENT_STRIPE_CONNECT_PLATFORM_WEBHOOK_SECRET=whsec_platform_... # From Platform Webhook

Stripe partitions platform events and connected account events into two separate streams. Configure two endpoints in the Stripe Dashboard (Developers $\rightarrow$ Webhooks), both pointing to https://your-domain.com/payments/webhook/stripe_connect:

flowchart TD
subgraph StripeEvents["Stripe Webhook Subscriptions"]
ConnEp["Endpoint 1: Connected Accounts\n(Listen to connected accounts: YES)"]
PlatEp["Endpoint 2: Platform Account\n(Listen to connected accounts: NO)"]
end
subgraph KirakReceiver["POST /payments/webhook/stripe_connect"]
Router["Webhook Dispatcher"]
V1["Verify with CONNECT_WEBHOOK_SECRET"]
V2["Verify with PLATFORM_WEBHOOK_SECRET"]
end
ConnEp -->|"account.updated\naccount.application.deauthorized"| Router
PlatEp -->|"checkout.session.completed\npayment_intent.succeeded\ncharge.refunded"| Router
Router --> V1
Router --> V2
V1 --> UpdateMerchant["Sync merchant_accounts Table"]
V2 --> UpdateTx["Sync payments_transactions Table"]
  1. Connected Accounts Webhook:
    • Under Listen to, select Events on Connected accounts.
    • Events: account.updated, account.application.deauthorized.
    • Copy signing secret into KIRAK_PAYMENT_STRIPE_CONNECT_WEBHOOK_SECRET.
  2. Platform Account Webhook:
    • Under Listen to, select Events on your account.
    • Events: checkout.session.completed, checkout.session.async_payment_succeeded, checkout.session.async_payment_failed, charge.refunded, payment_intent.succeeded, payment_intent.payment_failed, payment_method.detached, payment_method.updated, customer.updated.
    • Copy signing secret into KIRAK_PAYMENT_STRIPE_CONNECT_PLATFORM_WEBHOOK_SECRET.

Creates a Stripe Express connected account and returns the hosted onboarding link:

result = await kirak.payments.onboard_merchant({
"user_id": "merchant_usr_42",
"country": "US",
"business_type": "individual", # "individual" or "company"
})
onboarding_url = result["data"]["url"]
# Redirect merchant to onboarding_url

[!WARNING] Fee Tampering Prevention: A merchant cannot set their own platform fee rate during self-onboarding. Passing platform_fee_percent to onboard_merchant is ignored unless the caller holds admin or system permissions.

Section titled “4.2 Refreshing Expired Onboarding Links (create_onboarding_link)”

If a merchant abandons their onboarding session, generate a fresh link:

result = await kirak.payments.create_onboarding_link({
"user_id": "merchant_usr_42",
})
fresh_url = result["data"]["url"]

4.3 Live Status Check (get_merchant_status)

Section titled “4.3 Live Status Check (get_merchant_status)”

Syncs live status from Stripe and updates merchant_accounts:

status = await kirak.payments.get_merchant_status({
"user_id": "merchant_usr_42",
})
charges_enabled = status["data"]["charges_enabled"]
payouts_enabled = status["data"]["payouts_enabled"]

5. Marketplace Checkout (connect_checkout)

Section titled “5. Marketplace Checkout (connect_checkout)”

Creates a Checkout session on behalf of the connected merchant. The platform fee is automatically deducted based on merchant_accounts.platform_fee_percent:

result = await kirak.payments.connect_checkout({
"user_id": "buyer_usr_99",
"merchant_user_id": "merchant_usr_42",
"amount": 10000, # $100.00 USD total charge
"currency": "USD",
"name": "Custom Handcrafted Table",
"type": "one_time",
"idempotency_key": "mkt-tx-99-42-order1",
})
checkout_url = result["data"]["url"]

For a $100.00 charge with a 10% platform fee:

  • Buyer Pays: $100.00
  • Platform Fee Collected: $10.00 (transferred directly to platform account balance)
  • Merchant Earnings: $90.00 (less Stripe processing fees, transferred to merchant’s Express balance)

5.1 Setting Custom Platform Fees (update_merchant_fee)

Section titled “5.1 Setting Custom Platform Fees (update_merchant_fee)”

Platform fees can be customized per merchant (e.g. negotiated VIP rates). Admin / System only:

await kirak.payments.update_merchant_fee({
"user_id": "merchant_usr_42",
"platform_fee_percent": 7.5, # 7.5% platform fee
})

Normalized event Gateway Events Description
merchant_account_updated account.updated Connected account requirements, payouts, or charges updated
merchant_deauthorized account.application.deauthorized Merchant revoked platform access
payment_completed checkout.session.completed, payment_intent.succeeded Destination payment settled
payment_failed payment_intent.payment_failed Payment declined
refund_completed charge.refunded Refund processed (fee reversed proportionally)