From 8ccf005d1d4408d8ba215371b530ff63ee7e32cf Mon Sep 17 00:00:00 2001 From: Matnabru Date: Wed, 2 Aug 2023 20:40:22 +0200 Subject: [PATCH] gei-stripe 0.3.0 with collecting payment method and stripe connect --- packages/integrations/gei-stripe/package.json | 2 +- .../integrations/gei-stripe/schema.graphql | 103 ++++- .../src/Mutation/attachPaymentMethod.ts | 18 + ...entSession.ts => createCheckoutSession.ts} | 2 +- .../src/Mutation/createConnectAccount.ts | 35 ++ .../Mutation/createNewUserCheckoutSession.ts | 85 ++++ .../Mutation/createNewUserPaymentSession.ts | 79 ---- .../src/Mutation/setDefaultPaymentMethod.ts | 20 + .../gei-stripe/src/Mutation/webhook.ts | 16 +- .../integrations/gei-stripe/src/db/orm.ts | 2 + packages/integrations/gei-stripe/src/index.ts | 39 +- .../src/utils/externalAccountEvents.ts | 21 + .../integrations/gei-stripe/src/zeus/const.ts | 58 ++- .../integrations/gei-stripe/src/zeus/index.ts | 259 ++++++++++-- packages/integrations/gei-stripe/stucco.json | 40 +- .../gei-stripe-sandbox/schema.graphql | 124 ++++-- .../src/models/CustomerModel.ts | 3 + .../src/models/ItemModel.ts | 3 + .../src/models/SubscriptionModel.ts | 3 + .../gei-stripe-sandbox/src/models/index.ts | 12 +- .../gei-stripe-sandbox/src/zeus/const.ts | 90 ++-- .../gei-stripe-sandbox/src/zeus/index.ts | 388 +++++++++++++----- .../sandboxes/gei-stripe-sandbox/stucco.json | 12 +- 23 files changed, 1064 insertions(+), 350 deletions(-) create mode 100644 packages/integrations/gei-stripe/src/Mutation/attachPaymentMethod.ts rename packages/integrations/gei-stripe/src/Mutation/{createPaymentSession.ts => createCheckoutSession.ts} (96%) create mode 100644 packages/integrations/gei-stripe/src/Mutation/createConnectAccount.ts create mode 100644 packages/integrations/gei-stripe/src/Mutation/createNewUserCheckoutSession.ts delete mode 100644 packages/integrations/gei-stripe/src/Mutation/createNewUserPaymentSession.ts create mode 100644 packages/integrations/gei-stripe/src/Mutation/setDefaultPaymentMethod.ts create mode 100644 packages/integrations/gei-stripe/src/utils/externalAccountEvents.ts create mode 100644 packages/sandboxes/gei-stripe-sandbox/src/models/CustomerModel.ts create mode 100644 packages/sandboxes/gei-stripe-sandbox/src/models/ItemModel.ts create mode 100644 packages/sandboxes/gei-stripe-sandbox/src/models/SubscriptionModel.ts diff --git a/packages/integrations/gei-stripe/package.json b/packages/integrations/gei-stripe/package.json index 711eeb1..5145954 100644 --- a/packages/integrations/gei-stripe/package.json +++ b/packages/integrations/gei-stripe/package.json @@ -1,6 +1,6 @@ { "name": "gei-stripe", - "version": "0.2.2", + "version": "0.3.0", "description": "Automatically generated by graphql-editor-cli", "main": "lib/index.js", "scripts": { diff --git a/packages/integrations/gei-stripe/schema.graphql b/packages/integrations/gei-stripe/schema.graphql index 7e20e48..34e4431 100644 --- a/packages/integrations/gei-stripe/schema.graphql +++ b/packages/integrations/gei-stripe/schema.graphql @@ -10,24 +10,92 @@ type Query{ } type Mutation{ + """ + Creates stripe customer for further purchases, links with user "email" field in UserCollection + """ initStripeCustomer( initStripeCustomerInput: InitStripeCustomerInput! ): Boolean! - createPaymentSession( - payload: CreatePaymentSessionPayload! + createCheckoutSession( + payload: CreateCheckoutSessionInput! ): String! - createNewUserPaymentSession( - payload: CreateNewUserPaymentSessionPayload! + createNewUserCheckoutSession( + payload: CreateNewUserCheckoutSessionInput! ): String! createCustomerPortal( - payload: CreateCustomerPortalPayload! + payload: CreateCustomerPortalInput! ): String! + createConnectAccount( + payload: CreateConnectAccountInput! + ): Boolean! + """ + Gather payment method id using Stripe.js or a pre-built solution like Stripe Elements + """ + attachPaymentMethod( + payload: AttachPaymentMethodInput! + ): Boolean! + setDefaultPaymentMethod( + payload: setDefaultPaymentMethodInput! + ): Boolean! """ entry point for Weebhooks. """ webhook: String } +input setDefaultPaymentMethodInput{ + attachedPaymentMethodId: String! + customerId: String! +} + +input AttachPaymentMethodInput { + paymentMethodId: String! + customerId: String! +} + +input CreateConnectAccountInput { + type: ConnectAccountType! + country: String! + email: String! + business_type: ConnectAccountBusinessType! + bankAccount: BankAccountInput! +} + +enum ConnectAccountBusinessType{ + company + government_entity + individual + non_profit +} + +enum ConnectAccountType { + standard + express + custom +} + +input BankAccountInput { + country: String! + """ + Required supported currency for the country https://stripe.com/docs/payouts + """ + currency: String! + """ + IBAN account number + """ + account_number: String! + """ + Required when attaching the bank account to a Customer + """ + account_holder_name: String! + account_holder_type: BankAccountHolderType! +} + +enum BankAccountHolderType { + individual + company +} + input SubscriptionFilter { customerId: String } @@ -76,16 +144,20 @@ input InitStripeCustomerInput{ address: AddressInput } -input CreateNewUserPaymentSessionPayload{ +input CreateNewUserCheckoutSessionInput{ """ Return url after successful transaction """ successUrl: String! cancelUrl: String! products: [ProductInput!]! + """ + Define amount to transfer into stripe connect account and set the rest for application fees + """ + applicationFee: ApplicationFeeInput } -input CreatePaymentSessionPayload{ +input CreateCheckoutSessionInput{ userEmail: String! """ Return url after successful transaction @@ -93,6 +165,21 @@ input CreatePaymentSessionPayload{ successUrl: String! cancelUrl: String! products: [ProductInput!]! + """ + Define amount to transfer into stripe connect account and set the rest for application fees + """ + applicationFee: ApplicationFeeInput +} + +input ApplicationFeeInput { + """ + Value from 0-100 + """ + feePercentage: Int! + """ + Connect Account (not stripe customer) id + """ + connectAccountId: String! } input ProductInput{ @@ -100,7 +187,7 @@ input ProductInput{ quantity: Int! } -input CreateCustomerPortalPayload{ +input CreateCustomerPortalInput{ userEmail: String! returnUrl: String! } diff --git a/packages/integrations/gei-stripe/src/Mutation/attachPaymentMethod.ts b/packages/integrations/gei-stripe/src/Mutation/attachPaymentMethod.ts new file mode 100644 index 0000000..d74f3a3 --- /dev/null +++ b/packages/integrations/gei-stripe/src/Mutation/attachPaymentMethod.ts @@ -0,0 +1,18 @@ +import { FieldResolveInput } from 'stucco-js'; +import { resolverFor } from '../zeus/index.js'; +import { newStripe } from '../utils/utils.js'; + +export const handler = async (input: FieldResolveInput) => + resolverFor( + 'Mutation', + 'attachPaymentMethod', + async ({ payload: { customerId, paymentMethodId } }) => { + const stripe = newStripe(); + + const attachedPaymentMethod = await stripe.paymentMethods.attach(paymentMethodId, { + customer: customerId, + }); + + return true; + }, + )(input.arguments, input.source); diff --git a/packages/integrations/gei-stripe/src/Mutation/createPaymentSession.ts b/packages/integrations/gei-stripe/src/Mutation/createCheckoutSession.ts similarity index 96% rename from packages/integrations/gei-stripe/src/Mutation/createPaymentSession.ts rename to packages/integrations/gei-stripe/src/Mutation/createCheckoutSession.ts index ca55943..36e2593 100644 --- a/packages/integrations/gei-stripe/src/Mutation/createPaymentSession.ts +++ b/packages/integrations/gei-stripe/src/Mutation/createCheckoutSession.ts @@ -7,7 +7,7 @@ type item = { quantity?: number; }; export const handler = async (input: FieldResolveInput) => - resolverFor('Mutation', 'createPaymentSession', async ({ payload: { successUrl, cancelUrl, products, userEmail } }) => { + resolverFor('Mutation', 'createCheckoutSession', async ({ payload: { successUrl, cancelUrl, products, userEmail } }) => { const stripe = newStripe(); const user = await MongoOrb('UserCollection').collection.findOne( { email: userEmail }, diff --git a/packages/integrations/gei-stripe/src/Mutation/createConnectAccount.ts b/packages/integrations/gei-stripe/src/Mutation/createConnectAccount.ts new file mode 100644 index 0000000..aa05d84 --- /dev/null +++ b/packages/integrations/gei-stripe/src/Mutation/createConnectAccount.ts @@ -0,0 +1,35 @@ +import { FieldResolveInput } from 'stucco-js'; +import { resolverFor } from '../zeus/index.js'; +import { newStripe } from '../utils/utils.js'; + +export const handler = async (input: FieldResolveInput) => + resolverFor( + 'Mutation', + 'createConnectAccount', + async ({ payload: { type, country, email, bankAccount, business_type } }) => { + const stripe = newStripe(); + + const account = await stripe.accounts.create({ + type: type, + country, + email, + business_type, + }); + + const accountToken = await stripe.tokens.create({ + bank_account: { + country, + currency: bankAccount.currency, + account_holder_name: bankAccount.account_holder_name, + account_holder_type: bankAccount.account_holder_type, + account_number: bankAccount.account_number, + }, + }); + + const stripeBankAccount = await stripe.accounts.createExternalAccount(account.id, { + external_account: accountToken.id, + }); + + return true; + }, + )(input.arguments, input.source); diff --git a/packages/integrations/gei-stripe/src/Mutation/createNewUserCheckoutSession.ts b/packages/integrations/gei-stripe/src/Mutation/createNewUserCheckoutSession.ts new file mode 100644 index 0000000..957124d --- /dev/null +++ b/packages/integrations/gei-stripe/src/Mutation/createNewUserCheckoutSession.ts @@ -0,0 +1,85 @@ +import Stripe from 'stripe'; +import { newStripe } from '../utils/utils.js'; +import { resolverFor } from '../zeus/index.js'; +import { FieldResolveInput } from 'stucco-js'; +type item = { + price: string; + quantity?: number; +}; +export const handler = async (input: FieldResolveInput) => + resolverFor( + 'Mutation', + 'createNewUserCheckoutSession', + async ({ payload: { successUrl, cancelUrl, products, applicationFee } }) => { + const stripe = newStripe(); + const subscriptionItems: item[] = []; + const oneTimePaymentItems: item[] = []; + + let totalAmount = 0; + + await Promise.all( + products.map(async (product) => { + let price; + if (product.productId.startsWith('price_')) { + price = await stripe.prices.retrieve(product.productId); + } else if (product.productId.startsWith('prod_')) { + const { default_price } = await stripe.products.retrieve(product.productId); + if (!default_price) { + throw new Error('Cannot find product ' + product.productId + ' default price'); + } + price = + typeof default_price === 'string' + ? await stripe.prices.retrieve(default_price) + : await stripe.prices.retrieve(default_price.id); + } else { + throw new Error('Invalid product ID: ' + product.productId); + } + + const quantity = price.type === 'recurring' || price.recurring?.usage_type === 'metered' ? 1 : product.quantity; + const item = { price: price.id, ...(quantity && { quantity }) }; + + totalAmount += (price.unit_amount || 0) * (quantity || 0); + + if (price.type === 'recurring') { + subscriptionItems.push(item); + } else { + oneTimePaymentItems.push(item); + } + }), + ); + + const applicationFeeAmount = applicationFee ? Math.round((totalAmount * applicationFee.feePercentage) / 100) : 0; + + if (subscriptionItems.length > 0 && oneTimePaymentItems.length > 0) { + throw new Error('Cannot handle subscription items and one-time payment items in the same request'); + } + + if (subscriptionItems.length > 0 || oneTimePaymentItems.length > 0) { + const lineItems = subscriptionItems.length > 0 ? subscriptionItems : oneTimePaymentItems; + const mode = subscriptionItems.length > 0 ? 'subscription' : 'payment'; + + const sessionData: Stripe.Checkout.SessionCreateParams = { + success_url: successUrl, + cancel_url: cancelUrl, + line_items: lineItems, + mode: mode, + tax_id_collection: { enabled: true }, + automatic_tax: { enabled: true }, + billing_address_collection: 'required', + }; + + if (applicationFeeAmount > 0 && applicationFee) { + sessionData.payment_intent_data = { + application_fee_amount: applicationFeeAmount, + transfer_data: { + destination: applicationFee.connectAccountId, + }, + }; + } + + const session = await stripe.checkout.sessions.create(sessionData); + return session.url; + } + }, + )(input.arguments, input.source); + diff --git a/packages/integrations/gei-stripe/src/Mutation/createNewUserPaymentSession.ts b/packages/integrations/gei-stripe/src/Mutation/createNewUserPaymentSession.ts deleted file mode 100644 index b55b256..0000000 --- a/packages/integrations/gei-stripe/src/Mutation/createNewUserPaymentSession.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { newStripe } from '../utils/utils.js'; -import { resolverFor } from '../zeus/index.js'; -import { FieldResolveInput } from 'stucco-js'; -type item = { - price: string; - quantity?: number; -}; -export const handler = async (input: FieldResolveInput) => - resolverFor('Mutation', 'createNewUserPaymentSession', async ({ payload: { successUrl, cancelUrl, products } }) => { - const stripe = newStripe(); - const subscriptionItems: item[] = []; - const oneTimePaymentItems: item[] = []; - - await Promise.all( - products.map(async (product) => { - let price; - if (product.productId.startsWith('price_')) { - price = await stripe.prices.retrieve(product.productId); - } else if (product.productId.startsWith('prod_')) { - const { default_price } = await stripe.products.retrieve(product.productId); - if (!default_price) { - throw new Error('Cannot find product ' + product.productId + ' default price'); - } - price = - typeof default_price === 'string' - ? await stripe.prices.retrieve(default_price) - : await stripe.prices.retrieve(default_price.id); - } else { - throw new Error('Invalid product ID: ' + product.productId); - } - - const item = { - price: price.id, - ...(!price.recurring - ? { quantity: product.quantity } - : price.recurring.usage_type !== 'metered' && { quantity: 1 }), - }; - - if (price.type === 'recurring') { - subscriptionItems.push(item); - } else { - oneTimePaymentItems.push(item); - } - }), - ); - - if (subscriptionItems.length > 0 && oneTimePaymentItems.length > 0) { - throw new Error('Cannot handle subscription items and one-time payment items in the same request'); - } - if (subscriptionItems.length > 0) { - const session = await stripe.checkout.sessions.create({ - success_url: successUrl, - cancel_url: cancelUrl, - line_items: subscriptionItems, - mode: 'subscription', - tax_id_collection: { enabled: true }, - automatic_tax: { - enabled: true, - }, - billing_address_collection: 'required', - }); - return session.url; - } - - if (oneTimePaymentItems.length > 0) { - const session = await stripe.checkout.sessions.create({ - success_url: successUrl, - cancel_url: cancelUrl, - line_items: oneTimePaymentItems, - mode: 'payment', - tax_id_collection: { enabled: true }, - automatic_tax: { - enabled: true, - }, - billing_address_collection: 'required', - }); - return session.url; - } - })(input.arguments, input.source); diff --git a/packages/integrations/gei-stripe/src/Mutation/setDefaultPaymentMethod.ts b/packages/integrations/gei-stripe/src/Mutation/setDefaultPaymentMethod.ts new file mode 100644 index 0000000..355a7b6 --- /dev/null +++ b/packages/integrations/gei-stripe/src/Mutation/setDefaultPaymentMethod.ts @@ -0,0 +1,20 @@ +import { FieldResolveInput } from 'stucco-js'; +import { resolverFor } from '../zeus/index.js'; +import { newStripe } from '../utils/utils.js'; + +export const handler = async (input: FieldResolveInput) => + resolverFor( + 'Mutation', + 'setDefaultPaymentMethod', + async ({ payload: { customerId, attachedPaymentMethodId } }) => { + const stripe = newStripe(); + + await stripe.customers.update(customerId, { + invoice_settings: { + default_payment_method: attachedPaymentMethodId, + }, + }); + + return true; + }, + )(input.arguments, input.source); diff --git a/packages/integrations/gei-stripe/src/Mutation/webhook.ts b/packages/integrations/gei-stripe/src/Mutation/webhook.ts index 6273bfe..f963f19 100644 --- a/packages/integrations/gei-stripe/src/Mutation/webhook.ts +++ b/packages/integrations/gei-stripe/src/Mutation/webhook.ts @@ -26,6 +26,12 @@ import { invoiceUpcoming, } from '../utils/invoiceEvents.js'; import { customerDelete, customerInsert, customerUpdate } from '../utils/customerEvents.js'; +import { + ExternalAccount, + externalAccountDelete, + externalAccountInsert, + externalAccountUpdate, +} from '../utils/externalAccountEvents.js'; export const handler = async (input: FieldResolveInput) => resolverFor('Mutation', 'webhook', async (args) => { @@ -85,8 +91,14 @@ export const handler = async (input: FieldResolveInput) => return customerInsert(ev.data.object as Stripe.Customer); case 'customer.deleted': return customerDelete(ev.data.object as Stripe.Customer); - case 'customer.updated': - return customerUpdate(ev.data.object as Stripe.Customer); + case 'customer.updated': + return customerUpdate(ev.data.object as Stripe.Customer); + case 'account.external_account.created': + return externalAccountInsert(ev.data.object as ExternalAccount); + case 'account.external_account.deleted': + return externalAccountDelete(ev.data.object as ExternalAccount); + case 'account.external_account.updated': + return externalAccountUpdate(ev.data.object as ExternalAccount); } } catch (e) { throw new Error('cannot authorize request'); diff --git a/packages/integrations/gei-stripe/src/db/orm.ts b/packages/integrations/gei-stripe/src/db/orm.ts index ced8b0f..39efd2a 100644 --- a/packages/integrations/gei-stripe/src/db/orm.ts +++ b/packages/integrations/gei-stripe/src/db/orm.ts @@ -2,6 +2,7 @@ import { iGraphQL } from 'i-graphql'; import { ObjectId } from 'mongodb'; import Stripe from 'stripe'; import { UserModel } from '../models/UserModel'; +import { ExternalAccount } from '../utils/externalAccountEvents'; export const orm = async () => { return iGraphQL< @@ -15,6 +16,7 @@ export const orm = async () => { StripeInvoiceCollection: Stripe.Invoice, UserCollection: UserModel StripeCustomerCollection: Stripe.Customer + StripeExternalAccount: ExternalAccount }, { _id: () => string; diff --git a/packages/integrations/gei-stripe/src/index.ts b/packages/integrations/gei-stripe/src/index.ts index 8123c01..7dba7b9 100644 --- a/packages/integrations/gei-stripe/src/index.ts +++ b/packages/integrations/gei-stripe/src/index.ts @@ -2,13 +2,14 @@ import { NewIntegration } from 'graphql-editor-cli'; import { handler as initStripeCustomerHandler } from './Mutation/initStripeCustomer.js'; import { handler as webhookHandler } from './Mutation/webhook.js'; import { handler as createCustomerPortalHandler } from './Mutation/createCustomerPortal.js'; -import { handler as createPaymentSessionHandler } from './Mutation/createPaymentSession.js'; -import { handler as createNewUserPaymentSessionHandler } from './Mutation/createNewUserPaymentSession.js'; +import { handler as createCheckoutSessionHandler } from './Mutation/createCheckoutSession.js'; +import { handler as createNewUserCheckoutSessionHandler } from './Mutation/createNewUserCheckoutSession.js'; import { handler as productsHandler } from './Query/products.js'; import { handler as productDefaultPriceHandler } from './StripeProduct/default_price.js'; import { handler as productPricesHandler } from './StripeProduct/prices.js'; import { handler as subscriptionsHandler } from './Query/subscriptions.js'; - +import { handler as attachPaymentMethodHandler } from './Mutation/attachPaymentMethod.js'; +import { handler as createConnectAccountHandler } from './Mutation/createConnectAccount.js'; export const integration = NewIntegration({ Query: { products: { @@ -23,25 +24,35 @@ export const integration = NewIntegration({ } }, Mutation: { - initStripeCustomer: { - name: 'initStripeCustomer', - description: 'Init stripe customer', - handler: initStripeCustomerHandler, + attachPaymentMethod: { + name: 'attachPaymentMethod', + description: 'attach payment method created on the frontend to existing stripe customer', + handler: attachPaymentMethodHandler, + }, + createCheckoutSession: { + name: 'createCheckoutSession', + description: 'Creates payment session for already existing user', + handler: createCheckoutSessionHandler, + }, + createConnectAccount: { + name: 'createConnectAccount', + description: 'Creates stripe connect account for specific payments design with application fees or custom withdrawals', + handler: createConnectAccountHandler, }, createCustomerPortal: { name: 'createCustomerPortal', description: 'Creates customer portal for managing account and subscriptions', handler: createCustomerPortalHandler, }, - createPaymentSession: { - name: 'createPaymentSession', - description: 'Creates payment session for already existing user', - handler: createPaymentSessionHandler, + initStripeCustomer: { + name: 'initStripeCustomer', + description: 'Init stripe customer', + handler: initStripeCustomerHandler, }, - createNewUserPaymentSession: { - name: 'createNewUserPaymentSession', + createNewUserCheckoutSession: { + name: 'reateNewUserCheckoutSession', description: 'Creates payment session for user that is not yet registered', - handler: createNewUserPaymentSessionHandler, + handler: createNewUserCheckoutSessionHandler, }, webhook: { name: 'webhook', diff --git a/packages/integrations/gei-stripe/src/utils/externalAccountEvents.ts b/packages/integrations/gei-stripe/src/utils/externalAccountEvents.ts new file mode 100644 index 0000000..aeea2d0 --- /dev/null +++ b/packages/integrations/gei-stripe/src/utils/externalAccountEvents.ts @@ -0,0 +1,21 @@ +import Stripe from "stripe"; +import { MongoOrb } from "../db/orm.js"; +export type ExternalAccount = Stripe.BankAccount | Stripe.Card; + +export const externalAccountInsert = async (subEvent: ExternalAccount) => { + return await MongoOrb('StripeExternalAccount').collection.insertOne({ + ...subEvent + }); + }; + + export const externalAccountUpdate = async (subEvent: ExternalAccount) => { + const { id, ...subEventWithoutId } = subEvent; + return await MongoOrb('StripeExternalAccount').collection.updateOne( + { id: subEvent.id }, + { $set: subEventWithoutId } + );; + }; + + export const externalAccountDelete = async (subEvent: ExternalAccount) => { + return await MongoOrb('StripeExternalAccount').collection.deleteOne({ id: subEvent.id }); + }; \ No newline at end of file diff --git a/packages/integrations/gei-stripe/src/zeus/const.ts b/packages/integrations/gei-stripe/src/zeus/const.ts index 36169a9..df102ed 100644 --- a/packages/integrations/gei-stripe/src/zeus/const.ts +++ b/packages/integrations/gei-stripe/src/zeus/const.ts @@ -13,16 +13,42 @@ export const AllTypesProps: Record = { initStripeCustomer:{ initStripeCustomerInput:"InitStripeCustomerInput" }, - createPaymentSession:{ - payload:"CreatePaymentSessionPayload" + createCheckoutSession:{ + payload:"CreateCheckoutSessionInput" }, - createNewUserPaymentSession:{ - payload:"CreateNewUserPaymentSessionPayload" + createNewUserCheckoutSession:{ + payload:"CreateNewUserCheckoutSessionInput" }, createCustomerPortal:{ - payload:"CreateCustomerPortalPayload" + payload:"CreateCustomerPortalInput" + }, + createConnectAccount:{ + payload:"CreateConnectAccountInput" + }, + attachPaymentMethod:{ + payload:"AttachPaymentMethodInput" + }, + setDefaultPaymentMethod:{ + payload:"setDefaultPaymentMethodInput" } }, + setDefaultPaymentMethodInput:{ + + }, + AttachPaymentMethodInput:{ + + }, + CreateConnectAccountInput:{ + type:"ConnectAccountType", + business_type:"ConnectAccountBusinessType", + bankAccount:"BankAccountInput" + }, + ConnectAccountBusinessType: "enum" as const, + ConnectAccountType: "enum" as const, + BankAccountInput:{ + account_holder_type:"BankAccountHolderType" + }, + BankAccountHolderType: "enum" as const, SubscriptionFilter:{ }, @@ -30,16 +56,21 @@ export const AllTypesProps: Record = { InitStripeCustomerInput:{ address:"AddressInput" }, - CreateNewUserPaymentSessionPayload:{ - products:"ProductInput" + CreateNewUserCheckoutSessionInput:{ + products:"ProductInput", + applicationFee:"ApplicationFeeInput" }, - CreatePaymentSessionPayload:{ - products:"ProductInput" + CreateCheckoutSessionInput:{ + products:"ProductInput", + applicationFee:"ApplicationFeeInput" + }, + ApplicationFeeInput:{ + }, ProductInput:{ }, - CreateCustomerPortalPayload:{ + CreateCustomerPortalInput:{ }, AddressInput:{ @@ -82,9 +113,12 @@ export const ReturnTypes: Record = { }, Mutation:{ initStripeCustomer:"Boolean", - createPaymentSession:"String", - createNewUserPaymentSession:"String", + createCheckoutSession:"String", + createNewUserCheckoutSession:"String", createCustomerPortal:"String", + createConnectAccount:"Boolean", + attachPaymentMethod:"Boolean", + setDefaultPaymentMethod:"Boolean", webhook:"String" }, Subscription:{ diff --git a/packages/integrations/gei-stripe/src/zeus/index.ts b/packages/integrations/gei-stripe/src/zeus/index.ts index 61252c6..120c02e 100644 --- a/packages/integrations/gei-stripe/src/zeus/index.ts +++ b/packages/integrations/gei-stripe/src/zeus/index.ts @@ -842,13 +842,44 @@ subscriptions?: [{ filter?: ValueTypes["SubscriptionFilter"] | undefined | null }>; ["Mutation"]: AliasType<{ initStripeCustomer?: [{ initStripeCustomerInput: ValueTypes["InitStripeCustomerInput"] | Variable},boolean | `@${string}`], -createPaymentSession?: [{ payload: ValueTypes["CreatePaymentSessionPayload"] | Variable},boolean | `@${string}`], -createNewUserPaymentSession?: [{ payload: ValueTypes["CreateNewUserPaymentSessionPayload"] | Variable},boolean | `@${string}`], -createCustomerPortal?: [{ payload: ValueTypes["CreateCustomerPortalPayload"] | Variable},boolean | `@${string}`], +createCheckoutSession?: [{ payload: ValueTypes["CreateCheckoutSessionInput"] | Variable},boolean | `@${string}`], +createNewUserCheckoutSession?: [{ payload: ValueTypes["CreateNewUserCheckoutSessionInput"] | Variable},boolean | `@${string}`], +createCustomerPortal?: [{ payload: ValueTypes["CreateCustomerPortalInput"] | Variable},boolean | `@${string}`], +createConnectAccount?: [{ payload: ValueTypes["CreateConnectAccountInput"] | Variable},boolean | `@${string}`], +attachPaymentMethod?: [{ payload: ValueTypes["AttachPaymentMethodInput"] | Variable},boolean | `@${string}`], +setDefaultPaymentMethod?: [{ payload: ValueTypes["setDefaultPaymentMethodInput"] | Variable},boolean | `@${string}`], /** entry point for Weebhooks. */ webhook?:boolean | `@${string}`, __typename?: boolean | `@${string}` }>; + ["setDefaultPaymentMethodInput"]: { + attachedPaymentMethodId: string | Variable, + customerId: string | Variable +}; + ["AttachPaymentMethodInput"]: { + paymentMethodId: string | Variable, + customerId: string | Variable +}; + ["CreateConnectAccountInput"]: { + type: ValueTypes["ConnectAccountType"] | Variable, + country: string | Variable, + email: string | Variable, + business_type: ValueTypes["ConnectAccountBusinessType"] | Variable, + bankAccount: ValueTypes["BankAccountInput"] | Variable +}; + ["ConnectAccountBusinessType"]:ConnectAccountBusinessType; + ["ConnectAccountType"]:ConnectAccountType; + ["BankAccountInput"]: { + country: string | Variable, + /** Required supported currency for the country https://stripe.com/docs/payouts */ + currency: string | Variable, + /** IBAN account number */ + account_number: string | Variable, + /** Required when attaching the bank account to a Customer */ + account_holder_name: string | Variable, + account_holder_type: ValueTypes["BankAccountHolderType"] | Variable +}; + ["BankAccountHolderType"]:BankAccountHolderType; ["SubscriptionFilter"]: { customerId?: string | undefined | null | Variable }; @@ -886,24 +917,34 @@ createCustomerPortal?: [{ payload: ValueTypes["CreateCustomerPortalPayload"] | V phone?: string | undefined | null | Variable, address?: ValueTypes["AddressInput"] | undefined | null | Variable }; - ["CreateNewUserPaymentSessionPayload"]: { + ["CreateNewUserCheckoutSessionInput"]: { /** Return url after successful transaction */ successUrl: string | Variable, cancelUrl: string | Variable, - products: Array | Variable + products: Array | Variable, + /** Define amount to transfer into stripe connect account and set the rest for application fees */ + applicationFee?: ValueTypes["ApplicationFeeInput"] | undefined | null | Variable }; - ["CreatePaymentSessionPayload"]: { + ["CreateCheckoutSessionInput"]: { userEmail: string | Variable, /** Return url after successful transaction */ successUrl: string | Variable, cancelUrl: string | Variable, - products: Array | Variable + products: Array | Variable, + /** Define amount to transfer into stripe connect account and set the rest for application fees */ + applicationFee?: ValueTypes["ApplicationFeeInput"] | undefined | null | Variable +}; + ["ApplicationFeeInput"]: { + /** Value from 0-100 */ + feePercentage: number | Variable, + /** Connect Account (not stripe customer) id */ + connectAccountId: string | Variable }; ["ProductInput"]: { productId: string | Variable, quantity: number | Variable }; - ["CreateCustomerPortalPayload"]: { + ["CreateCustomerPortalInput"]: { userEmail: string | Variable, returnUrl: string | Variable }; @@ -1063,13 +1104,44 @@ subscriptions?: [{ filter?: ResolverInputTypes["SubscriptionFilter"] | undefined }>; ["Mutation"]: AliasType<{ initStripeCustomer?: [{ initStripeCustomerInput: ResolverInputTypes["InitStripeCustomerInput"]},boolean | `@${string}`], -createPaymentSession?: [{ payload: ResolverInputTypes["CreatePaymentSessionPayload"]},boolean | `@${string}`], -createNewUserPaymentSession?: [{ payload: ResolverInputTypes["CreateNewUserPaymentSessionPayload"]},boolean | `@${string}`], -createCustomerPortal?: [{ payload: ResolverInputTypes["CreateCustomerPortalPayload"]},boolean | `@${string}`], +createCheckoutSession?: [{ payload: ResolverInputTypes["CreateCheckoutSessionInput"]},boolean | `@${string}`], +createNewUserCheckoutSession?: [{ payload: ResolverInputTypes["CreateNewUserCheckoutSessionInput"]},boolean | `@${string}`], +createCustomerPortal?: [{ payload: ResolverInputTypes["CreateCustomerPortalInput"]},boolean | `@${string}`], +createConnectAccount?: [{ payload: ResolverInputTypes["CreateConnectAccountInput"]},boolean | `@${string}`], +attachPaymentMethod?: [{ payload: ResolverInputTypes["AttachPaymentMethodInput"]},boolean | `@${string}`], +setDefaultPaymentMethod?: [{ payload: ResolverInputTypes["setDefaultPaymentMethodInput"]},boolean | `@${string}`], /** entry point for Weebhooks. */ webhook?:boolean | `@${string}`, __typename?: boolean | `@${string}` }>; + ["setDefaultPaymentMethodInput"]: { + attachedPaymentMethodId: string, + customerId: string +}; + ["AttachPaymentMethodInput"]: { + paymentMethodId: string, + customerId: string +}; + ["CreateConnectAccountInput"]: { + type: ResolverInputTypes["ConnectAccountType"], + country: string, + email: string, + business_type: ResolverInputTypes["ConnectAccountBusinessType"], + bankAccount: ResolverInputTypes["BankAccountInput"] +}; + ["ConnectAccountBusinessType"]:ConnectAccountBusinessType; + ["ConnectAccountType"]:ConnectAccountType; + ["BankAccountInput"]: { + country: string, + /** Required supported currency for the country https://stripe.com/docs/payouts */ + currency: string, + /** IBAN account number */ + account_number: string, + /** Required when attaching the bank account to a Customer */ + account_holder_name: string, + account_holder_type: ResolverInputTypes["BankAccountHolderType"] +}; + ["BankAccountHolderType"]:BankAccountHolderType; ["SubscriptionFilter"]: { customerId?: string | undefined | null }; @@ -1107,24 +1179,34 @@ createCustomerPortal?: [{ payload: ResolverInputTypes["CreateCustomerPortalPaylo phone?: string | undefined | null, address?: ResolverInputTypes["AddressInput"] | undefined | null }; - ["CreateNewUserPaymentSessionPayload"]: { + ["CreateNewUserCheckoutSessionInput"]: { /** Return url after successful transaction */ successUrl: string, cancelUrl: string, - products: Array + products: Array, + /** Define amount to transfer into stripe connect account and set the rest for application fees */ + applicationFee?: ResolverInputTypes["ApplicationFeeInput"] | undefined | null }; - ["CreatePaymentSessionPayload"]: { + ["CreateCheckoutSessionInput"]: { userEmail: string, /** Return url after successful transaction */ successUrl: string, cancelUrl: string, - products: Array + products: Array, + /** Define amount to transfer into stripe connect account and set the rest for application fees */ + applicationFee?: ResolverInputTypes["ApplicationFeeInput"] | undefined | null +}; + ["ApplicationFeeInput"]: { + /** Value from 0-100 */ + feePercentage: number, + /** Connect Account (not stripe customer) id */ + connectAccountId: string }; ["ProductInput"]: { productId: string, quantity: number }; - ["CreateCustomerPortalPayload"]: { + ["CreateCustomerPortalInput"]: { userEmail: string, returnUrl: string }; @@ -1282,13 +1364,46 @@ export type ModelTypes = { subscriptions?: Array | undefined }; ["Mutation"]: { - initStripeCustomer: boolean, - createPaymentSession: string, - createNewUserPaymentSession: string, + /** Creates stripe customer for further purchases, links with user "email" field in UserCollection */ + initStripeCustomer: boolean, + createCheckoutSession: string, + createNewUserCheckoutSession: string, createCustomerPortal: string, + createConnectAccount: boolean, + /** Gather payment method id using Stripe.js or a pre-built solution like Stripe Elements */ + attachPaymentMethod: boolean, + setDefaultPaymentMethod: boolean, /** entry point for Weebhooks. */ webhook?: string | undefined }; + ["setDefaultPaymentMethodInput"]: { + attachedPaymentMethodId: string, + customerId: string +}; + ["AttachPaymentMethodInput"]: { + paymentMethodId: string, + customerId: string +}; + ["CreateConnectAccountInput"]: { + type: ModelTypes["ConnectAccountType"], + country: string, + email: string, + business_type: ModelTypes["ConnectAccountBusinessType"], + bankAccount: ModelTypes["BankAccountInput"] +}; + ["ConnectAccountBusinessType"]:ConnectAccountBusinessType; + ["ConnectAccountType"]:ConnectAccountType; + ["BankAccountInput"]: { + country: string, + /** Required supported currency for the country https://stripe.com/docs/payouts */ + currency: string, + /** IBAN account number */ + account_number: string, + /** Required when attaching the bank account to a Customer */ + account_holder_name: string, + account_holder_type: ModelTypes["BankAccountHolderType"] +}; + ["BankAccountHolderType"]:BankAccountHolderType; ["SubscriptionFilter"]: { customerId?: string | undefined }; @@ -1323,24 +1438,34 @@ export type ModelTypes = { phone?: string | undefined, address?: ModelTypes["AddressInput"] | undefined }; - ["CreateNewUserPaymentSessionPayload"]: { + ["CreateNewUserCheckoutSessionInput"]: { /** Return url after successful transaction */ successUrl: string, cancelUrl: string, - products: Array + products: Array, + /** Define amount to transfer into stripe connect account and set the rest for application fees */ + applicationFee?: ModelTypes["ApplicationFeeInput"] | undefined }; - ["CreatePaymentSessionPayload"]: { + ["CreateCheckoutSessionInput"]: { userEmail: string, /** Return url after successful transaction */ successUrl: string, cancelUrl: string, - products: Array + products: Array, + /** Define amount to transfer into stripe connect account and set the rest for application fees */ + applicationFee?: ModelTypes["ApplicationFeeInput"] | undefined +}; + ["ApplicationFeeInput"]: { + /** Value from 0-100 */ + feePercentage: number, + /** Connect Account (not stripe customer) id */ + connectAccountId: string }; ["ProductInput"]: { productId: string, quantity: number }; - ["CreateCustomerPortalPayload"]: { + ["CreateCustomerPortalInput"]: { userEmail: string, returnUrl: string }; @@ -1491,13 +1616,46 @@ export type GraphQLTypes = { }; ["Mutation"]: { __typename: "Mutation", + /** Creates stripe customer for further purchases, links with user "email" field in UserCollection */ initStripeCustomer: boolean, - createPaymentSession: string, - createNewUserPaymentSession: string, + createCheckoutSession: string, + createNewUserCheckoutSession: string, createCustomerPortal: string, + createConnectAccount: boolean, + /** Gather payment method id using Stripe.js or a pre-built solution like Stripe Elements */ + attachPaymentMethod: boolean, + setDefaultPaymentMethod: boolean, /** entry point for Weebhooks. */ webhook?: string | undefined }; + ["setDefaultPaymentMethodInput"]: { + attachedPaymentMethodId: string, + customerId: string +}; + ["AttachPaymentMethodInput"]: { + paymentMethodId: string, + customerId: string +}; + ["CreateConnectAccountInput"]: { + type: GraphQLTypes["ConnectAccountType"], + country: string, + email: string, + business_type: GraphQLTypes["ConnectAccountBusinessType"], + bankAccount: GraphQLTypes["BankAccountInput"] +}; + ["ConnectAccountBusinessType"]: ConnectAccountBusinessType; + ["ConnectAccountType"]: ConnectAccountType; + ["BankAccountInput"]: { + country: string, + /** Required supported currency for the country https://stripe.com/docs/payouts */ + currency: string, + /** IBAN account number */ + account_number: string, + /** Required when attaching the bank account to a Customer */ + account_holder_name: string, + account_holder_type: GraphQLTypes["BankAccountHolderType"] +}; + ["BankAccountHolderType"]: BankAccountHolderType; ["SubscriptionFilter"]: { customerId?: string | undefined }; @@ -1535,24 +1693,34 @@ export type GraphQLTypes = { phone?: string | undefined, address?: GraphQLTypes["AddressInput"] | undefined }; - ["CreateNewUserPaymentSessionPayload"]: { + ["CreateNewUserCheckoutSessionInput"]: { /** Return url after successful transaction */ successUrl: string, cancelUrl: string, - products: Array + products: Array, + /** Define amount to transfer into stripe connect account and set the rest for application fees */ + applicationFee?: GraphQLTypes["ApplicationFeeInput"] | undefined }; - ["CreatePaymentSessionPayload"]: { + ["CreateCheckoutSessionInput"]: { userEmail: string, /** Return url after successful transaction */ successUrl: string, cancelUrl: string, - products: Array + products: Array, + /** Define amount to transfer into stripe connect account and set the rest for application fees */ + applicationFee?: GraphQLTypes["ApplicationFeeInput"] | undefined +}; + ["ApplicationFeeInput"]: { + /** Value from 0-100 */ + feePercentage: number, + /** Connect Account (not stripe customer) id */ + connectAccountId: string }; ["ProductInput"]: { productId: string, quantity: number }; - ["CreateCustomerPortalPayload"]: { + ["CreateCustomerPortalInput"]: { userEmail: string, returnUrl: string }; @@ -1703,6 +1871,21 @@ export type GraphQLTypes = { endingBefore?: string | undefined } } +export const enum ConnectAccountBusinessType { + company = "company", + government_entity = "government_entity", + individual = "individual", + non_profit = "non_profit" +} +export const enum ConnectAccountType { + standard = "standard", + express = "express", + custom = "custom" +} +export const enum BankAccountHolderType { + individual = "individual", + company = "company" +} export const enum SubStatus { incomplete = "incomplete", incomplete_expired = "incomplete_expired", @@ -1751,13 +1934,21 @@ export const enum Type { } type ZEUS_VARIABLES = { + ["setDefaultPaymentMethodInput"]: ValueTypes["setDefaultPaymentMethodInput"]; + ["AttachPaymentMethodInput"]: ValueTypes["AttachPaymentMethodInput"]; + ["CreateConnectAccountInput"]: ValueTypes["CreateConnectAccountInput"]; + ["ConnectAccountBusinessType"]: ValueTypes["ConnectAccountBusinessType"]; + ["ConnectAccountType"]: ValueTypes["ConnectAccountType"]; + ["BankAccountInput"]: ValueTypes["BankAccountInput"]; + ["BankAccountHolderType"]: ValueTypes["BankAccountHolderType"]; ["SubscriptionFilter"]: ValueTypes["SubscriptionFilter"]; ["SubStatus"]: ValueTypes["SubStatus"]; ["InitStripeCustomerInput"]: ValueTypes["InitStripeCustomerInput"]; - ["CreateNewUserPaymentSessionPayload"]: ValueTypes["CreateNewUserPaymentSessionPayload"]; - ["CreatePaymentSessionPayload"]: ValueTypes["CreatePaymentSessionPayload"]; + ["CreateNewUserCheckoutSessionInput"]: ValueTypes["CreateNewUserCheckoutSessionInput"]; + ["CreateCheckoutSessionInput"]: ValueTypes["CreateCheckoutSessionInput"]; + ["ApplicationFeeInput"]: ValueTypes["ApplicationFeeInput"]; ["ProductInput"]: ValueTypes["ProductInput"]; - ["CreateCustomerPortalPayload"]: ValueTypes["CreateCustomerPortalPayload"]; + ["CreateCustomerPortalInput"]: ValueTypes["CreateCustomerPortalInput"]; ["AddressInput"]: ValueTypes["AddressInput"]; ["ProductFilter"]: ValueTypes["ProductFilter"]; ["RecurringFilter"]: ValueTypes["RecurringFilter"]; diff --git a/packages/integrations/gei-stripe/stucco.json b/packages/integrations/gei-stripe/stucco.json index 86c6fc0..91ecc27 100644 --- a/packages/integrations/gei-stripe/stucco.json +++ b/packages/integrations/gei-stripe/stucco.json @@ -21,18 +21,18 @@ "name": "Mutation.createCustomerPortal.handler" } }, - "Mutation.createPaymentSession": { - "name": "createPaymentSession", + "Mutation.createCheckoutSession": { + "name": "createCheckoutSession", "description": "Creates payment session for already existing user", "resolve": { - "name": "Mutation.createPaymentSession.handler" + "name": "Mutation.createCheckoutSession.handler" } }, - "Mutation.createNewUserPaymentSession": { - "name": "createNewUserPaymentSession", + "Mutation.createNewUserCheckoutSession": { + "name": "reateNewUserCheckoutSession", "description": "Creates payment session for user that is not yet registered", "resolve": { - "name": "Mutation.createNewUserPaymentSession.handler" + "name": "Mutation.createNewUserCheckoutSession.handler" } }, "Query.products": { @@ -62,6 +62,34 @@ "resolve": { "name": "StripeProduct.prices.handler" } + }, + "Mutation.attachPaymentMethod": { + "name": "attachPaymentMethod", + "description": "attach payment method created on the frontend to existing stripe customer", + "resolve": { + "name": "Mutation.attachPaymentMethod.handler" + } + }, + "Mutation.createConnectAccount": { + "name": "createConnectAccount", + "description": "Creates stripe connect account for specific payments design with application fees or custom withdrawals", + "resolve": { + "name": "Mutation.createConnectAccount.handler" + } + }, + "Product.default_price": { + "name": "default_price", + "description": "Resolver for querying default price object", + "resolve": { + "name": "Product.default_price.handler" + } + }, + "Product.prices": { + "name": "prices", + "description": "Resolver for querying prices objects", + "resolve": { + "name": "Product.prices.handler" + } } }, "azureOpts": { diff --git a/packages/sandboxes/gei-stripe-sandbox/schema.graphql b/packages/sandboxes/gei-stripe-sandbox/schema.graphql index a266495..e7a1c80 100644 --- a/packages/sandboxes/gei-stripe-sandbox/schema.graphql +++ b/packages/sandboxes/gei-stripe-sandbox/schema.graphql @@ -2,50 +2,85 @@ type Query{ products( - filter: StripeProductFilter - ): StripeProductsPage + filter: ProductFilter + ): ProductsPage subscriptions( - filter: StripeSubscriptionFilter - ): [StripeSubscription!] + filter: SubscriptionFilter + ): [Subscription!] } type Mutation{ + """ + Creates stripe customer for further purchases, links with user "email" field in UserCollection + """ initStripeCustomer( initStripeCustomerInput: InitStripeCustomerInput! ): Boolean! - createPaymentSession( - payload: CreatePaymentSessionPayload! + createCheckoutSession( + payload: CreateCheckoutSessionInput! ): String! - createNewUserPaymentSession( - payload: CreateNewUserPaymentSessionPayload! + createNewUserCheckoutSession( + payload: CreateNewUserCheckoutSessionInput! ): String! createCustomerPortal( - payload: CreateCustomerPortalPayload! + payload: CreateCustomerPortalInput! ): String! + createConnectAccount( + payload: CreateConnectAccountInput! + ): Boolean! """ entry point for Weebhooks. """ webhook: String } -input StripeSubscriptionFilter { +input CreateConnectAccountInput { + type: String! + country: String! + email: String! + business_type: String! + bankAccount: BankAccountInput! +} + +input BankAccountInput { + country: String! + """ + Required supported currency for the country https://stripe.com/docs/payouts + """ + currency: String! + """ + IBAN account number + """ + account_number: String! + """ + Required when attaching the bank account to a Customer + """ + account_holder_name: String! +} + +enum BankAccountHolderType { + individual + company +} + +input SubscriptionFilter { customerId: String } -type StripeSubscription { +type Subscription { id: String! cancel_at_period_end: Boolean! current_period_end: Timestamp! current_period_start: Timestamp! customer: String! description: String - items:[StripeItem!]! + items:[Item!]! quantity: Int! start: Timestamp! - status: StripeSubStatus! + status: SubStatus! } -enum StripeSubStatus{ +enum SubStatus{ incomplete incomplete_expired trialing @@ -55,16 +90,16 @@ enum StripeSubStatus{ unpaid } -type StripeItem { +type Item { id: String! created: Timestamp! metadata: AnyObject - price: StripePrice! + price: Price! quantity: Int! subscription: String! } -type StripeUser{ +type User{ stripeId: String email: String! } @@ -73,39 +108,54 @@ input InitStripeCustomerInput{ email: String! name: String phone: String - address: StripeAddressInput + address: AddressInput } -input CreateNewUserPaymentSessionPayload{ +input CreateNewUserCheckoutSessionInput{ """ Return url after successful transaction """ successUrl: String! cancelUrl: String! - products: [StripeProductInput!]! + products: [ProductInput!]! } -input CreatePaymentSessionPayload{ +input CreateCheckoutSessionInput{ userEmail: String! """ Return url after successful transaction """ successUrl: String! cancelUrl: String! - products: [StripeProductInput!]! + products: [ProductInput!]! + """ + Define amount to transfer into stripe connect account and set the rest for application fees + """ + applicationFee: ApplicationFeeInput +} + +input ApplicationFeeInput { + """ + Value from 0-100 + """ + application_fee: Int! + """ + Connect Account (not stripe customer) id + """ + connectAccountId: String! } -input StripeProductInput{ +input ProductInput{ productId: String! quantity: Int! } -input CreateCustomerPortalPayload{ +input CreateCustomerPortalInput{ userEmail: String! returnUrl: String! } -input StripeAddressInput{ +input AddressInput{ """ City, district, suburb, town, village, or ward. """ @@ -132,14 +182,14 @@ input StripeAddressInput{ state: String! } -type StripeCustomer{ +type Customer{ customerId: String! email: String! name: String - address: StripeAddress + address: Address } -type StripeAddress{ +type Address{ city: String country: String line1: String @@ -148,7 +198,7 @@ type StripeAddress{ state: String } -input StripeProductFilter{ +input ProductFilter{ active: Boolean created: TimestampFilter limit: Int @@ -164,7 +214,7 @@ input RecurringFilter{ usageType: UsageType } -input StripePriceFilter{ +input PriceFilter{ active: Boolean currency: String product: ID @@ -183,11 +233,11 @@ type Dimensions{ width: Float } -type StripeProduct{ +type Product{ id: ID! active: Boolean! created: Timestamp - default_price: StripePrice + default_price: Price description: String images: [String!] livemode: Boolean @@ -200,7 +250,7 @@ type StripeProduct{ unitLabel: String updated: Timestamp url: String - prices: [StripePrice!] + prices: [Price!] } enum BillingScheme{ @@ -284,7 +334,7 @@ enum Type{ ONE_TIME } -type StripePrice{ +type Price{ id: ID! active: Boolean billing_scheme: BillingScheme @@ -295,7 +345,7 @@ type StripePrice{ lookup_key: String metadata: AnyObject nickname: String - product: StripeProduct + product: Product recurring: PriceRecurring tax_behavior: TaxBehaviour tiers_mode: TiersMode @@ -305,8 +355,8 @@ type StripePrice{ unit_amount_decimal: String } -type StripeProductsPage{ - products: [StripeProduct!] +type ProductsPage{ + products: [Product!] startingAfter: ID endingBefore: ID } diff --git a/packages/sandboxes/gei-stripe-sandbox/src/models/CustomerModel.ts b/packages/sandboxes/gei-stripe-sandbox/src/models/CustomerModel.ts new file mode 100644 index 0000000..a152184 --- /dev/null +++ b/packages/sandboxes/gei-stripe-sandbox/src/models/CustomerModel.ts @@ -0,0 +1,3 @@ +import { ModelTypes } from '../zeus/index.js'; + +export type CustomerModel = ModelTypes['Customer']; \ No newline at end of file diff --git a/packages/sandboxes/gei-stripe-sandbox/src/models/ItemModel.ts b/packages/sandboxes/gei-stripe-sandbox/src/models/ItemModel.ts new file mode 100644 index 0000000..9bea65d --- /dev/null +++ b/packages/sandboxes/gei-stripe-sandbox/src/models/ItemModel.ts @@ -0,0 +1,3 @@ +import { ModelTypes } from '../zeus/index.js'; + +export type ItemModel = ModelTypes['Item']; \ No newline at end of file diff --git a/packages/sandboxes/gei-stripe-sandbox/src/models/SubscriptionModel.ts b/packages/sandboxes/gei-stripe-sandbox/src/models/SubscriptionModel.ts new file mode 100644 index 0000000..4f309ec --- /dev/null +++ b/packages/sandboxes/gei-stripe-sandbox/src/models/SubscriptionModel.ts @@ -0,0 +1,3 @@ +import { ModelTypes } from '../zeus/index.js'; + +export type SubscriptionModel = ModelTypes['Subscription']; \ No newline at end of file diff --git a/packages/sandboxes/gei-stripe-sandbox/src/models/index.ts b/packages/sandboxes/gei-stripe-sandbox/src/models/index.ts index 153dcfc..b6b5e09 100644 --- a/packages/sandboxes/gei-stripe-sandbox/src/models/index.ts +++ b/packages/sandboxes/gei-stripe-sandbox/src/models/index.ts @@ -1,9 +1,9 @@ import { QueryModel } from './QueryModel.js' -import { StripeCustomerQueryOpsModel } from './StripeCustomerQueryOpsModel.js' import { MutationModel } from './MutationModel.js' +import { SubscriptionModel } from './SubscriptionModel.js' +import { ItemModel } from './ItemModel.js' import { UserModel } from './UserModel.js' -import { StripeCustomerMutationOpsModel } from './StripeCustomerMutationOpsModel.js' -import { StripeCustomerModel } from './StripeCustomerModel.js' +import { CustomerModel } from './CustomerModel.js' import { AddressModel } from './AddressModel.js' import { DimensionsModel } from './DimensionsModel.js' import { ProductModel } from './ProductModel.js' @@ -16,11 +16,11 @@ import { ProductsPageModel } from './ProductsPageModel.js' export type Models = { QueryModel: QueryModel; - StripeCustomerQueryOpsModel: StripeCustomerQueryOpsModel; MutationModel: MutationModel; + SubscriptionModel: SubscriptionModel; + ItemModel: ItemModel; UserModel: UserModel; - StripeCustomerMutationOpsModel: StripeCustomerMutationOpsModel; - StripeCustomerModel: StripeCustomerModel; + CustomerModel: CustomerModel; AddressModel: AddressModel; DimensionsModel: DimensionsModel; ProductModel: ProductModel; diff --git a/packages/sandboxes/gei-stripe-sandbox/src/zeus/const.ts b/packages/sandboxes/gei-stripe-sandbox/src/zeus/const.ts index 267cb95..7e6ddac 100644 --- a/packages/sandboxes/gei-stripe-sandbox/src/zeus/const.ts +++ b/packages/sandboxes/gei-stripe-sandbox/src/zeus/const.ts @@ -5,51 +5,55 @@ export const AllTypesProps: Record = { products:{ filter:"ProductFilter" }, - stripeCustomerQueryOps:{ - + subscriptions:{ + filter:"SubscriptionFilter" } }, Mutation:{ initStripeCustomer:{ initStripeCustomerInput:"InitStripeCustomerInput" }, - stripeCustomerMutationOps:{ - - }, - createPaymentSession:{ - payload:"CreatePaymentSessionPayload" + createCheckoutSession:{ + payload:"CreateCheckoutSessionInput" }, - createNewUserPaymentSession:{ - payload:"CreateNewUserPaymentSessionPayload" + createNewUserCheckoutSession:{ + payload:"CreateNewUserCheckoutSessionInput" }, createCustomerPortal:{ - payload:"CreateCustomerPortalPayload" + payload:"CreateCustomerPortalInput" + }, + createConnectAccount:{ + payload:"CreateConnectAccountInput" } }, - StripeCustomerMutationOps:{ - generateBillingPortal:{ + CreateConnectAccountInput:{ + bankAccount:"BankAccountInput" + }, + BankAccountInput:{ - }, - generateCheckoutSession:{ - generateCheckoutSessionInput:"GenerateCheckoutSessionInput" - } }, - GenerateCheckoutSessionInput:{ + BankAccountHolderType: "enum" as const, + SubscriptionFilter:{ }, + SubStatus: "enum" as const, InitStripeCustomerInput:{ address:"AddressInput" }, - CreateNewUserPaymentSessionPayload:{ - products:"StripeProductInput" + CreateNewUserCheckoutSessionInput:{ + products:"ProductInput" + }, + CreateCheckoutSessionInput:{ + products:"ProductInput", + applicationFee:"ApplicationFeeInput" }, - CreatePaymentSessionPayload:{ - products:"StripeProductInput" + ApplicationFeeInput:{ + }, - StripeProductInput:{ + ProductInput:{ }, - CreateCustomerPortalPayload:{ + CreateCustomerPortalInput:{ }, AddressInput:{ @@ -88,28 +92,41 @@ export const AllTypesProps: Record = { export const ReturnTypes: Record = { Query:{ products:"ProductsPage", - stripeCustomerQueryOps:"StripeCustomerQueryOps" - }, - StripeCustomerQueryOps:{ - getCustomerInfo:"StripeCustomer" + subscriptions:"Subscription" }, Mutation:{ initStripeCustomer:"Boolean", - stripeCustomerMutationOps:"StripeCustomerMutationOps", - createPaymentSession:"String", - createNewUserPaymentSession:"String", + createCheckoutSession:"String", + createNewUserCheckoutSession:"String", createCustomerPortal:"String", + createConnectAccount:"Boolean", webhook:"String" }, + Subscription:{ + id:"String", + cancel_at_period_end:"Boolean", + current_period_end:"Timestamp", + current_period_start:"Timestamp", + customer:"String", + description:"String", + items:"Item", + quantity:"Int", + start:"Timestamp", + status:"SubStatus" + }, + Item:{ + id:"String", + created:"Timestamp", + metadata:"AnyObject", + price:"Price", + quantity:"Int", + subscription:"String" + }, User:{ stripeId:"String", email:"String" }, - StripeCustomerMutationOps:{ - generateBillingPortal:"String", - generateCheckoutSession:"String" - }, - StripeCustomer:{ + Customer:{ customerId:"String", email:"String", name:"String", @@ -195,5 +212,6 @@ export const ReturnTypes: Record = { export const Ops = { query: "Query" as const, - mutation: "Mutation" as const + mutation: "Mutation" as const, + subscription: "Subscription" as const } \ No newline at end of file diff --git a/packages/sandboxes/gei-stripe-sandbox/src/zeus/index.ts b/packages/sandboxes/gei-stripe-sandbox/src/zeus/index.ts index 2d1557c..6225272 100644 --- a/packages/sandboxes/gei-stripe-sandbox/src/zeus/index.ts +++ b/packages/sandboxes/gei-stripe-sandbox/src/zeus/index.ts @@ -837,61 +837,99 @@ type ZEUS_UNIONS = never export type ValueTypes = { ["Query"]: AliasType<{ products?: [{ filter?: ValueTypes["ProductFilter"] | undefined | null | Variable},ValueTypes["ProductsPage"]], -stripeCustomerQueryOps?: [{ customerId: string | Variable},ValueTypes["StripeCustomerQueryOps"]], - __typename?: boolean | `@${string}` -}>; - ["StripeCustomerQueryOps"]: AliasType<{ - getCustomerInfo?:ValueTypes["StripeCustomer"], +subscriptions?: [{ filter?: ValueTypes["SubscriptionFilter"] | undefined | null | Variable},ValueTypes["Subscription"]], __typename?: boolean | `@${string}` }>; ["Mutation"]: AliasType<{ initStripeCustomer?: [{ initStripeCustomerInput: ValueTypes["InitStripeCustomerInput"] | Variable},boolean | `@${string}`], -stripeCustomerMutationOps?: [{ customerId: string | Variable},ValueTypes["StripeCustomerMutationOps"]], -createPaymentSession?: [{ payload: ValueTypes["CreatePaymentSessionPayload"] | Variable},boolean | `@${string}`], -createNewUserPaymentSession?: [{ payload: ValueTypes["CreateNewUserPaymentSessionPayload"] | Variable},boolean | `@${string}`], -createCustomerPortal?: [{ payload: ValueTypes["CreateCustomerPortalPayload"] | Variable},boolean | `@${string}`], +createCheckoutSession?: [{ payload: ValueTypes["CreateCheckoutSessionInput"] | Variable},boolean | `@${string}`], +createNewUserCheckoutSession?: [{ payload: ValueTypes["CreateNewUserCheckoutSessionInput"] | Variable},boolean | `@${string}`], +createCustomerPortal?: [{ payload: ValueTypes["CreateCustomerPortalInput"] | Variable},boolean | `@${string}`], +createConnectAccount?: [{ payload: ValueTypes["CreateConnectAccountInput"] | Variable},boolean | `@${string}`], /** entry point for Weebhooks. */ webhook?:boolean | `@${string}`, __typename?: boolean | `@${string}` +}>; + ["CreateConnectAccountInput"]: { + type: string | Variable, + country: string | Variable, + email: string | Variable, + business_type: string | Variable, + bankAccount: ValueTypes["BankAccountInput"] | Variable +}; + ["BankAccountInput"]: { + country: string | Variable, + /** Required supported currency for the country https://stripe.com/docs/payouts */ + currency: string | Variable, + /** IBAN account number */ + account_number: string | Variable, + /** Required when attaching the bank account to a Customer */ + account_holder_name: string | Variable +}; + ["BankAccountHolderType"]:BankAccountHolderType; + ["SubscriptionFilter"]: { + customerId?: string | undefined | null | Variable +}; + ["Subscription"]: AliasType<{ + id?:boolean | `@${string}`, + cancel_at_period_end?:boolean | `@${string}`, + current_period_end?:boolean | `@${string}`, + current_period_start?:boolean | `@${string}`, + customer?:boolean | `@${string}`, + description?:boolean | `@${string}`, + items?:ValueTypes["Item"], + quantity?:boolean | `@${string}`, + start?:boolean | `@${string}`, + status?:boolean | `@${string}`, + __typename?: boolean | `@${string}` +}>; + ["SubStatus"]:SubStatus; + ["Item"]: AliasType<{ + id?:boolean | `@${string}`, + created?:boolean | `@${string}`, + metadata?:boolean | `@${string}`, + price?:ValueTypes["Price"], + quantity?:boolean | `@${string}`, + subscription?:boolean | `@${string}`, + __typename?: boolean | `@${string}` }>; ["User"]: AliasType<{ stripeId?:boolean | `@${string}`, email?:boolean | `@${string}`, __typename?: boolean | `@${string}` }>; - ["StripeCustomerMutationOps"]: AliasType<{ -generateBillingPortal?: [{ returnUrl: string | Variable},boolean | `@${string}`], -generateCheckoutSession?: [{ generateCheckoutSessionInput: ValueTypes["GenerateCheckoutSessionInput"] | Variable},boolean | `@${string}`], - __typename?: boolean | `@${string}` -}>; - ["GenerateCheckoutSessionInput"]: { - productIds: Array | Variable, - success_url: string | Variable, - cancel_url: string | Variable -}; ["InitStripeCustomerInput"]: { email: string | Variable, name?: string | undefined | null | Variable, phone?: string | undefined | null | Variable, address?: ValueTypes["AddressInput"] | undefined | null | Variable }; - ["CreateNewUserPaymentSessionPayload"]: { + ["CreateNewUserCheckoutSessionInput"]: { + /** Return url after successful transaction */ successUrl: string | Variable, cancelUrl: string | Variable, - products: Array | Variable + products: Array | Variable }; - ["CreatePaymentSessionPayload"]: { + ["CreateCheckoutSessionInput"]: { userEmail: string | Variable, /** Return url after successful transaction */ successUrl: string | Variable, cancelUrl: string | Variable, - products: Array | Variable + products: Array | Variable, + /** Define amount to transfer into stripe connect account and set the rest for application fees */ + applicationFee?: ValueTypes["ApplicationFeeInput"] | undefined | null | Variable +}; + ["ApplicationFeeInput"]: { + /** Value from 0-100 */ + application_fee: number | Variable, + /** Connect Account (not stripe customer) id */ + connectAccountId: string | Variable }; - ["StripeProductInput"]: { + ["ProductInput"]: { productId: string | Variable, quantity: number | Variable }; - ["CreateCustomerPortalPayload"]: { + ["CreateCustomerPortalInput"]: { userEmail: string | Variable, returnUrl: string | Variable }; @@ -909,7 +947,7 @@ generateCheckoutSession?: [{ generateCheckoutSessionInput: ValueTypes["GenerateC /** State, county, province, prefecture, or region. */ state: string | Variable }; - ["StripeCustomer"]: AliasType<{ + ["Customer"]: AliasType<{ customerId?:boolean | `@${string}`, email?:boolean | `@${string}`, name?:boolean | `@${string}`, @@ -1046,61 +1084,99 @@ generateCheckoutSession?: [{ generateCheckoutSessionInput: ValueTypes["GenerateC export type ResolverInputTypes = { ["Query"]: AliasType<{ products?: [{ filter?: ResolverInputTypes["ProductFilter"] | undefined | null},ResolverInputTypes["ProductsPage"]], -stripeCustomerQueryOps?: [{ customerId: string},ResolverInputTypes["StripeCustomerQueryOps"]], - __typename?: boolean | `@${string}` -}>; - ["StripeCustomerQueryOps"]: AliasType<{ - getCustomerInfo?:ResolverInputTypes["StripeCustomer"], +subscriptions?: [{ filter?: ResolverInputTypes["SubscriptionFilter"] | undefined | null},ResolverInputTypes["Subscription"]], __typename?: boolean | `@${string}` }>; ["Mutation"]: AliasType<{ initStripeCustomer?: [{ initStripeCustomerInput: ResolverInputTypes["InitStripeCustomerInput"]},boolean | `@${string}`], -stripeCustomerMutationOps?: [{ customerId: string},ResolverInputTypes["StripeCustomerMutationOps"]], -createPaymentSession?: [{ payload: ResolverInputTypes["CreatePaymentSessionPayload"]},boolean | `@${string}`], -createNewUserPaymentSession?: [{ payload: ResolverInputTypes["CreateNewUserPaymentSessionPayload"]},boolean | `@${string}`], -createCustomerPortal?: [{ payload: ResolverInputTypes["CreateCustomerPortalPayload"]},boolean | `@${string}`], +createCheckoutSession?: [{ payload: ResolverInputTypes["CreateCheckoutSessionInput"]},boolean | `@${string}`], +createNewUserCheckoutSession?: [{ payload: ResolverInputTypes["CreateNewUserCheckoutSessionInput"]},boolean | `@${string}`], +createCustomerPortal?: [{ payload: ResolverInputTypes["CreateCustomerPortalInput"]},boolean | `@${string}`], +createConnectAccount?: [{ payload: ResolverInputTypes["CreateConnectAccountInput"]},boolean | `@${string}`], /** entry point for Weebhooks. */ webhook?:boolean | `@${string}`, __typename?: boolean | `@${string}` +}>; + ["CreateConnectAccountInput"]: { + type: string, + country: string, + email: string, + business_type: string, + bankAccount: ResolverInputTypes["BankAccountInput"] +}; + ["BankAccountInput"]: { + country: string, + /** Required supported currency for the country https://stripe.com/docs/payouts */ + currency: string, + /** IBAN account number */ + account_number: string, + /** Required when attaching the bank account to a Customer */ + account_holder_name: string +}; + ["BankAccountHolderType"]:BankAccountHolderType; + ["SubscriptionFilter"]: { + customerId?: string | undefined | null +}; + ["Subscription"]: AliasType<{ + id?:boolean | `@${string}`, + cancel_at_period_end?:boolean | `@${string}`, + current_period_end?:boolean | `@${string}`, + current_period_start?:boolean | `@${string}`, + customer?:boolean | `@${string}`, + description?:boolean | `@${string}`, + items?:ResolverInputTypes["Item"], + quantity?:boolean | `@${string}`, + start?:boolean | `@${string}`, + status?:boolean | `@${string}`, + __typename?: boolean | `@${string}` +}>; + ["SubStatus"]:SubStatus; + ["Item"]: AliasType<{ + id?:boolean | `@${string}`, + created?:boolean | `@${string}`, + metadata?:boolean | `@${string}`, + price?:ResolverInputTypes["Price"], + quantity?:boolean | `@${string}`, + subscription?:boolean | `@${string}`, + __typename?: boolean | `@${string}` }>; ["User"]: AliasType<{ stripeId?:boolean | `@${string}`, email?:boolean | `@${string}`, __typename?: boolean | `@${string}` }>; - ["StripeCustomerMutationOps"]: AliasType<{ -generateBillingPortal?: [{ returnUrl: string},boolean | `@${string}`], -generateCheckoutSession?: [{ generateCheckoutSessionInput: ResolverInputTypes["GenerateCheckoutSessionInput"]},boolean | `@${string}`], - __typename?: boolean | `@${string}` -}>; - ["GenerateCheckoutSessionInput"]: { - productIds: Array, - success_url: string, - cancel_url: string -}; ["InitStripeCustomerInput"]: { email: string, name?: string | undefined | null, phone?: string | undefined | null, address?: ResolverInputTypes["AddressInput"] | undefined | null }; - ["CreateNewUserPaymentSessionPayload"]: { + ["CreateNewUserCheckoutSessionInput"]: { + /** Return url after successful transaction */ successUrl: string, cancelUrl: string, - products: Array + products: Array }; - ["CreatePaymentSessionPayload"]: { + ["CreateCheckoutSessionInput"]: { userEmail: string, /** Return url after successful transaction */ successUrl: string, cancelUrl: string, - products: Array + products: Array, + /** Define amount to transfer into stripe connect account and set the rest for application fees */ + applicationFee?: ResolverInputTypes["ApplicationFeeInput"] | undefined | null +}; + ["ApplicationFeeInput"]: { + /** Value from 0-100 */ + application_fee: number, + /** Connect Account (not stripe customer) id */ + connectAccountId: string }; - ["StripeProductInput"]: { + ["ProductInput"]: { productId: string, quantity: number }; - ["CreateCustomerPortalPayload"]: { + ["CreateCustomerPortalInput"]: { userEmail: string, returnUrl: string }; @@ -1118,7 +1194,7 @@ generateCheckoutSession?: [{ generateCheckoutSessionInput: ResolverInputTypes["G /** State, county, province, prefecture, or region. */ state: string }; - ["StripeCustomer"]: AliasType<{ + ["Customer"]: AliasType<{ customerId?:boolean | `@${string}`, email?:boolean | `@${string}`, name?:boolean | `@${string}`, @@ -1255,32 +1331,62 @@ generateCheckoutSession?: [{ generateCheckoutSessionInput: ResolverInputTypes["G export type ModelTypes = { ["Query"]: { products?: ModelTypes["ProductsPage"] | undefined, - stripeCustomerQueryOps?: ModelTypes["StripeCustomerQueryOps"] | undefined -}; - ["StripeCustomerQueryOps"]: { - getCustomerInfo?: ModelTypes["StripeCustomer"] | undefined + subscriptions?: Array | undefined }; ["Mutation"]: { - initStripeCustomer: boolean, - stripeCustomerMutationOps?: ModelTypes["StripeCustomerMutationOps"] | undefined, - createPaymentSession: string, - createNewUserPaymentSession: string, + /** Creates stripe customer for further purchases, links with user "email" field in UserCollection */ + initStripeCustomer: boolean, + createCheckoutSession: string, + createNewUserCheckoutSession: string, createCustomerPortal: string, + createConnectAccount: boolean, /** entry point for Weebhooks. */ webhook?: string | undefined +}; + ["CreateConnectAccountInput"]: { + type: string, + country: string, + email: string, + business_type: string, + bankAccount: ModelTypes["BankAccountInput"] +}; + ["BankAccountInput"]: { + country: string, + /** Required supported currency for the country https://stripe.com/docs/payouts */ + currency: string, + /** IBAN account number */ + account_number: string, + /** Required when attaching the bank account to a Customer */ + account_holder_name: string +}; + ["BankAccountHolderType"]:BankAccountHolderType; + ["SubscriptionFilter"]: { + customerId?: string | undefined +}; + ["Subscription"]: { + id: string, + cancel_at_period_end: boolean, + current_period_end: ModelTypes["Timestamp"], + current_period_start: ModelTypes["Timestamp"], + customer: string, + description?: string | undefined, + items: Array, + quantity: number, + start: ModelTypes["Timestamp"], + status: ModelTypes["SubStatus"] +}; + ["SubStatus"]:SubStatus; + ["Item"]: { + id: string, + created: ModelTypes["Timestamp"], + metadata?: ModelTypes["AnyObject"] | undefined, + price: ModelTypes["Price"], + quantity: number, + subscription: string }; ["User"]: { stripeId?: string | undefined, email: string -}; - ["StripeCustomerMutationOps"]: { - generateBillingPortal?: string | undefined, - generateCheckoutSession?: string | undefined -}; - ["GenerateCheckoutSessionInput"]: { - productIds: Array, - success_url: string, - cancel_url: string }; ["InitStripeCustomerInput"]: { email: string, @@ -1288,23 +1394,32 @@ export type ModelTypes = { phone?: string | undefined, address?: ModelTypes["AddressInput"] | undefined }; - ["CreateNewUserPaymentSessionPayload"]: { + ["CreateNewUserCheckoutSessionInput"]: { + /** Return url after successful transaction */ successUrl: string, cancelUrl: string, - products: Array + products: Array }; - ["CreatePaymentSessionPayload"]: { + ["CreateCheckoutSessionInput"]: { userEmail: string, /** Return url after successful transaction */ successUrl: string, cancelUrl: string, - products: Array + products: Array, + /** Define amount to transfer into stripe connect account and set the rest for application fees */ + applicationFee?: ModelTypes["ApplicationFeeInput"] | undefined +}; + ["ApplicationFeeInput"]: { + /** Value from 0-100 */ + application_fee: number, + /** Connect Account (not stripe customer) id */ + connectAccountId: string }; - ["StripeProductInput"]: { + ["ProductInput"]: { productId: string, quantity: number }; - ["CreateCustomerPortalPayload"]: { + ["CreateCustomerPortalInput"]: { userEmail: string, returnUrl: string }; @@ -1322,7 +1437,7 @@ export type ModelTypes = { /** State, county, province, prefecture, or region. */ state: string }; - ["StripeCustomer"]: { + ["Customer"]: { customerId: string, email: string, name?: string | undefined, @@ -1451,36 +1566,66 @@ export type GraphQLTypes = { ["Query"]: { __typename: "Query", products?: GraphQLTypes["ProductsPage"] | undefined, - stripeCustomerQueryOps?: GraphQLTypes["StripeCustomerQueryOps"] | undefined -}; - ["StripeCustomerQueryOps"]: { - __typename: "StripeCustomerQueryOps", - getCustomerInfo?: GraphQLTypes["StripeCustomer"] | undefined + subscriptions?: Array | undefined }; ["Mutation"]: { __typename: "Mutation", + /** Creates stripe customer for further purchases, links with user "email" field in UserCollection */ initStripeCustomer: boolean, - stripeCustomerMutationOps?: GraphQLTypes["StripeCustomerMutationOps"] | undefined, - createPaymentSession: string, - createNewUserPaymentSession: string, + createCheckoutSession: string, + createNewUserCheckoutSession: string, createCustomerPortal: string, + createConnectAccount: boolean, /** entry point for Weebhooks. */ webhook?: string | undefined +}; + ["CreateConnectAccountInput"]: { + type: string, + country: string, + email: string, + business_type: string, + bankAccount: GraphQLTypes["BankAccountInput"] +}; + ["BankAccountInput"]: { + country: string, + /** Required supported currency for the country https://stripe.com/docs/payouts */ + currency: string, + /** IBAN account number */ + account_number: string, + /** Required when attaching the bank account to a Customer */ + account_holder_name: string +}; + ["BankAccountHolderType"]: BankAccountHolderType; + ["SubscriptionFilter"]: { + customerId?: string | undefined +}; + ["Subscription"]: { + __typename: "Subscription", + id: string, + cancel_at_period_end: boolean, + current_period_end: GraphQLTypes["Timestamp"], + current_period_start: GraphQLTypes["Timestamp"], + customer: string, + description?: string | undefined, + items: Array, + quantity: number, + start: GraphQLTypes["Timestamp"], + status: GraphQLTypes["SubStatus"] +}; + ["SubStatus"]: SubStatus; + ["Item"]: { + __typename: "Item", + id: string, + created: GraphQLTypes["Timestamp"], + metadata?: GraphQLTypes["AnyObject"] | undefined, + price: GraphQLTypes["Price"], + quantity: number, + subscription: string }; ["User"]: { __typename: "User", stripeId?: string | undefined, email: string -}; - ["StripeCustomerMutationOps"]: { - __typename: "StripeCustomerMutationOps", - generateBillingPortal?: string | undefined, - generateCheckoutSession?: string | undefined -}; - ["GenerateCheckoutSessionInput"]: { - productIds: Array, - success_url: string, - cancel_url: string }; ["InitStripeCustomerInput"]: { email: string, @@ -1488,23 +1633,32 @@ export type GraphQLTypes = { phone?: string | undefined, address?: GraphQLTypes["AddressInput"] | undefined }; - ["CreateNewUserPaymentSessionPayload"]: { - successUrl: string, + ["CreateNewUserCheckoutSessionInput"]: { + /** Return url after successful transaction */ + successUrl: string, cancelUrl: string, - products: Array + products: Array }; - ["CreatePaymentSessionPayload"]: { + ["CreateCheckoutSessionInput"]: { userEmail: string, /** Return url after successful transaction */ successUrl: string, cancelUrl: string, - products: Array + products: Array, + /** Define amount to transfer into stripe connect account and set the rest for application fees */ + applicationFee?: GraphQLTypes["ApplicationFeeInput"] | undefined +}; + ["ApplicationFeeInput"]: { + /** Value from 0-100 */ + application_fee: number, + /** Connect Account (not stripe customer) id */ + connectAccountId: string }; - ["StripeProductInput"]: { + ["ProductInput"]: { productId: string, quantity: number }; - ["CreateCustomerPortalPayload"]: { + ["CreateCustomerPortalInput"]: { userEmail: string, returnUrl: string }; @@ -1522,8 +1676,8 @@ export type GraphQLTypes = { /** State, county, province, prefecture, or region. */ state: string }; - ["StripeCustomer"]: { - __typename: "StripeCustomer", + ["Customer"]: { + __typename: "Customer", customerId: string, email: string, name?: string | undefined, @@ -1655,6 +1809,19 @@ export type GraphQLTypes = { endingBefore?: string | undefined } } +export const enum BankAccountHolderType { + individual = "individual", + company = "company" +} +export const enum SubStatus { + incomplete = "incomplete", + incomplete_expired = "incomplete_expired", + trialing = "trialing", + active = "active", + past_due = "past_due", + canceled = "canceled", + unpaid = "unpaid" +} export const enum BillingScheme { PER_UNIT = "PER_UNIT", TIERED = "TIERED" @@ -1694,12 +1861,17 @@ export const enum Type { } type ZEUS_VARIABLES = { - ["GenerateCheckoutSessionInput"]: ValueTypes["GenerateCheckoutSessionInput"]; + ["CreateConnectAccountInput"]: ValueTypes["CreateConnectAccountInput"]; + ["BankAccountInput"]: ValueTypes["BankAccountInput"]; + ["BankAccountHolderType"]: ValueTypes["BankAccountHolderType"]; + ["SubscriptionFilter"]: ValueTypes["SubscriptionFilter"]; + ["SubStatus"]: ValueTypes["SubStatus"]; ["InitStripeCustomerInput"]: ValueTypes["InitStripeCustomerInput"]; - ["CreateNewUserPaymentSessionPayload"]: ValueTypes["CreateNewUserPaymentSessionPayload"]; - ["CreatePaymentSessionPayload"]: ValueTypes["CreatePaymentSessionPayload"]; - ["StripeProductInput"]: ValueTypes["StripeProductInput"]; - ["CreateCustomerPortalPayload"]: ValueTypes["CreateCustomerPortalPayload"]; + ["CreateNewUserCheckoutSessionInput"]: ValueTypes["CreateNewUserCheckoutSessionInput"]; + ["CreateCheckoutSessionInput"]: ValueTypes["CreateCheckoutSessionInput"]; + ["ApplicationFeeInput"]: ValueTypes["ApplicationFeeInput"]; + ["ProductInput"]: ValueTypes["ProductInput"]; + ["CreateCustomerPortalInput"]: ValueTypes["CreateCustomerPortalInput"]; ["AddressInput"]: ValueTypes["AddressInput"]; ["ProductFilter"]: ValueTypes["ProductFilter"]; ["RecurringFilter"]: ValueTypes["RecurringFilter"]; diff --git a/packages/sandboxes/gei-stripe-sandbox/stucco.json b/packages/sandboxes/gei-stripe-sandbox/stucco.json index f1f41be..707da16 100644 --- a/packages/sandboxes/gei-stripe-sandbox/stucco.json +++ b/packages/sandboxes/gei-stripe-sandbox/stucco.json @@ -10,24 +10,24 @@ "name": "gei-stripe@Mutation.initStripeCustomer" } }, - "Mutation.createNewUserPaymentSession": { + "Mutation.createNewUserCheckoutSession": { "noCode": { "package": "gei-stripe", "version": "0.2.0", - "resolver": "createNewUserPaymentSession" + "resolver": "createNewUserCheckoutSession" }, "resolve": { - "name": "gei-stripe@Mutation.createNewUserPaymentSession" + "name": "gei-stripe@Mutation.createNewUserCheckoutSession" } }, - "Mutation.createPaymentSession": { + "Mutation.createCheckoutSession": { "noCode": { "package": "gei-stripe", "version": "0.2.0", - "resolver": "createPaymentSession" + "resolver": "createCheckoutSession" }, "resolve": { - "name": "gei-stripe@Mutation.createPaymentSession" + "name": "gei-stripe@Mutation.createCheckoutSession" } }, "Mutation.webhook": {