From 8862685bdbdc21f98e2aebe17d18454c2292dff8 Mon Sep 17 00:00:00 2001
From: Jorge Aguirre Gonzalez <95381655+jorgea-stripe@users.noreply.github.com>
Date: Fri, 19 Apr 2024 13:34:16 -0400
Subject: [PATCH] Update FurEver to use the GA SDK interface and only allow
standard accounts, fully embedded accounts, and custom accounts (#109)
* Old PArams
* Use the GA APIs for creating accounts
* Update stripe.ts
* Update stripe.ts
* Adjust language
---
client/components/CompleteProfile.tsx | 15 +++---
package.json | 2 +-
server/routes/stripe.ts | 75 +++++++++++++++++----------
yarn.lock | 8 +--
4 files changed, 63 insertions(+), 37 deletions(-)
diff --git a/client/components/CompleteProfile.tsx b/client/components/CompleteProfile.tsx
index 908fa7d..ec76b05 100644
--- a/client/components/CompleteProfile.tsx
+++ b/client/components/CompleteProfile.tsx
@@ -358,16 +358,19 @@ export const CompleteProfile = () => {
}
>
diff --git a/package.json b/package.json
index 0661f65..f7a94d7 100644
--- a/package.json
+++ b/package.json
@@ -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": {
diff --git a/server/routes/stripe.ts b/server/routes/stripe.ts
index 3bbbf24..aaee56d 100644
--- a/server/routes/stripe.ts
+++ b/server/routes/stripe.ts
@@ -162,7 +162,7 @@ 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,
},
@@ -170,11 +170,21 @@ function getAccountParams(
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 = {
@@ -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 {
@@ -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,
},
@@ -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: {
@@ -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,
diff --git a/yarn.lock b/yarn.lock
index 2228191..46ece95 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -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"