Skip to content

Commit

Permalink
Update FurEver to use the GA SDK interface and only allow standard ac…
Browse files Browse the repository at this point in the history
…counts, fully embedded accounts, and custom accounts (#109)

* Old PArams

* Use the GA APIs for creating accounts

* Update stripe.ts

* Update stripe.ts

* Adjust language
  • Loading branch information
jorgea-stripe committed Apr 19, 2024
1 parent b600db4 commit 8862685
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 37 deletions.
15 changes: 9 additions & 6 deletions client/components/CompleteProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -358,16 +358,19 @@ export const CompleteProfile = () => {
}
>
<option value="no_dashboard_soll">
No Stripe dashboard access + Stripe owns loss liability (fully
embedded, stripe managed)
Connected account without Stripe dashboard access + Stripe is
liable for paying back negative balances + Stripe collects fees
directly from connected accounts
</option>
<option value="no_dashboard_poll">
No Stripe dashboard access + Platform owns loss liability
(custom)
Connected account without Stripe dashboard access + FurEver is
liable for paying back negative balances + Stripe collects fees
from FurEver
</option>
<option value="dashboard_soll">
Stripe standard dashboard access + Stripe owns loss liability
(standard dashboard, stripe managed)
Connected account with Stripe Dashboard access + Stripe is
liable for paying back negative balances + Stripe collects fees
directly from Connected accounts
</option>
</SelectInput>
</FormBlock>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"react-dom": "^18.2.0",
"react-query": "^3.39.3",
"react-router-dom": "^6.11.1",
"stripe": "^14.23.0-beta.1",
"stripe": "15.4.0-beta.1",
"typescript": "^4.5.5"
},
"devDependencies": {
Expand Down
75 changes: 49 additions & 26 deletions server/routes/stripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,29 @@ function getAccountParams(
accountConfiguration: string
): Stripe.AccountCreateParams {
let type: Stripe.Account.Type | undefined = undefined;
let capabilities: any = {
let capabilities: Stripe.AccountCreateParams.Capabilities | undefined = {
card_payments: {
requested: true,
},
transfers: {
requested: true,
},
};
let controller = undefined;
let controller: Stripe.AccountCreateParams.Controller | undefined = undefined;
switch (accountConfiguration) {
case 'no_dashboard_poll':
type = 'custom' as const;
controller = undefined;
controller = {
losses: {
payments: 'application', // platform owns loss liability
},
requirement_collection: 'application', // platform is onboarding owner
fees: {
payer: 'application', // The platform is the pricing owner
},
stripe_dashboard: {
type: 'none', // The connected account will not have access to dashboard
},
};

// Issuing and Banking products only work on accounts where the platform owns requirements collection
capabilities = {
Expand All @@ -190,28 +200,34 @@ function getAccountParams(
case 'dashboard_soll':
capabilities = undefined;
controller = {
application: {
loss_liable: false, // Stripe owns loss liability
onboarding_owner: false, // Stripe is the onboarding owner
pricing_controls: true, // The platform is the pricing owner
losses: {
payments: 'stripe', // Stripe owns loss liability
},
dashboard: {
type: 'full' as const, // Standard dash
requirement_collection: 'stripe', // Stripe is onboarding owner
fees: {
payer: 'account', // Stripe is the pricing owner
},
stripe_dashboard: {
type: 'full', // Standard dashboard
},
};
break;
default:
// "no_dashboard_soll"
case 'no_dashboard_soll':
controller = {
application: {
loss_liable: false, // Stripe owns loss liability
onboarding_owner: false, // Stripe is the onboarding owner
pricing_controls: true, // The platform is the pricing owner
losses: {
payments: 'stripe', // stripe owns loss liability
},
requirement_collection: 'stripe', // stripe is onboarding owner
fees: {
payer: 'application', // The platform is the pricing owner
},
dashboard: {
type: 'none' as const, // The connected account will not have access to dashboard
stripe_dashboard: {
type: 'none', // The connected account will not have access to dashboard
},
};
break;
default:
throw new Error('Invalid account configuration:' + accountConfiguration);
}

return {
Expand Down Expand Up @@ -447,10 +463,9 @@ function getStripeAccountId(req: any) {
*/
app.post('/account_session', stripeAccountRequired, async (req, res) => {
try {
const accountSession = await stripe.accountSessions.create({
account: getStripeAccountId(req),
// This should contain a list of all components used in FurEver, otherwise they will be disabled when rendering
components: {
// This should contain a list of all components used in FurEver
const accountSessionComponentsParams: Stripe.AccountSessionCreateParams.Components =
{
account_management: {
enabled: true,
},
Expand All @@ -466,9 +481,6 @@ app.post('/account_session', stripeAccountRequired, async (req, res) => {
payouts: {
enabled: true,
},
payment_method_settings: {
enabled: true,
},
issuing_cards_list: {
enabled: true,
features: {
Expand All @@ -488,7 +500,18 @@ app.post('/account_session', stripeAccountRequired, async (req, res) => {
card_spend_dispute_management: true,
},
},
} as any, // Some of these components are in private beta, so they aren't published in the beta SDK
};

// TODO: Move up once payment_method_settings is in the beta SDK
const accountSessionComponentsParamsAsAny =
accountSessionComponentsParams as any;
accountSessionComponentsParamsAsAny.payment_method_settings = {
enabled: true,
};

const accountSession = await stripe.accountSessions.create({
account: getStripeAccountId(req),
components: accountSessionComponentsParamsAsAny,
});
res.json({
client_secret: accountSession.client_secret,
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3126,10 +3126,10 @@ strip-ansi@^6.0.0, strip-ansi@^6.0.1:
dependencies:
ansi-regex "^5.0.1"

stripe@^14.23.0-beta.1:
version "14.23.0-beta.1"
resolved "https://registry.yarnpkg.com/stripe/-/stripe-14.23.0-beta.1.tgz#03b23a79331cd95ebf6c24f9ccd9528702ef571f"
integrity sha512-qf7Ad6HXsWwXXG5qaQgAilQPBxU9cueW2nSfa52GxXGonzlwZxz041ihNuRpUxoBhM4jOxXkliQ50EHpgL+rNw==
stripe@15.4.0-beta.1:
version "15.4.0-beta.1"
resolved "https://registry.yarnpkg.com/stripe/-/stripe-15.4.0-beta.1.tgz#244856c24c6af5bff5998530b765d407d817b8fc"
integrity sha512-PGcx1oJgXpz1S/e9k2HfGf6NIkE3GSZuw3Fc3LUjXXP21eYOrrNejJKktuZPn0cWpzMyYfTtod/MbtiHHYzy6A==
dependencies:
"@types/node" ">=8.1.0"
qs "^6.11.0"
Expand Down

0 comments on commit 8862685

Please sign in to comment.