Skip to content

Commit

Permalink
addCreatePayoutForConnectedAccountToStripe
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelbrui committed Mar 12, 2024
1 parent 7af169d commit 3ab5227
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 16 deletions.
13 changes: 7 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/integrations/gei-stripe/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gei-stripe",
"version": "0.4.8",
"version": "0.4.9",
"description": "Automatically generated by graphql-editor-cli",
"main": "lib/index.js",
"scripts": {
Expand Down Expand Up @@ -30,7 +30,7 @@
"mailgun.js": "^8.0.6",
"mongodb": "^5.1.0",
"node-fetch": "^3.3.0",
"stripe": "^11.4.0",
"stripe": "^11.18.0",
"stucco-js": "^0.10.18",
"ws": "^8.12.0"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import Stripe from 'stripe';
import { newStripe } from "../utils/stripeInit.js";
import { resolverFor } from '../zeus/index.js';
import { FieldResolveInput } from 'stucco-js';

const stripe = new Stripe('YOUR_STRIPE_SECRET_KEY', {
apiVersion: '2020-08-27',
});


export const createPayoutForConnectedAccount = async (input: FieldResolveInput) =>
resolverFor(
'Mutation',
'createPayoutForConnectedAccount',
async ({ payload: { accountId, amount, currency} }) => {
async ({ payload: { accountId, amount, currency } }) => {
try {
const payout = await stripe.payouts.create({
const stripe_account = process.env.STRIPE_ACCOUNT_ID || accountId
if (!stripe_account) throw new Error('missing accountId');
const payout = await newStripe().payouts.create({
amount,
currency,
stripe_account: accountId,
destination: stripe_account,
});

if (payout) {
Expand All @@ -26,7 +26,8 @@ export const createPayoutForConnectedAccount = async (input: FieldResolveInput)
} catch (error) {
throw new Error('Error creating payout:' + JSON.stringify(error));
}

})(input.arguments, input.source)

export default createPayoutForConnectedAccount;


6 changes: 6 additions & 0 deletions packages/integrations/gei-stripe/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import webhookHandler from './Mutation/webhook.js';
import createCustomerPortalHandler from './Mutation/createCustomerPortal.js';
import createCheckoutSessionHandler from './Mutation/createCheckoutSession.js';
import createNewUserCheckoutSessionHandler from './Mutation/createNewUserCheckoutSession.js';
import createPayoutForConnectedAccountHandler from './Mutation/createPayoutForConnectedAccount.js';
import productsHandler from './Query/products.js';
import productDefaultPriceHandler from './Product/default_price.js';
import productPricesHandler from './Product/prices.js';
Expand Down Expand Up @@ -76,6 +77,11 @@ export const integration = NewIntegration({
description: 'Creates payment session for user that is not yet registered',
handler: createNewUserCheckoutSessionHandler,
},
createPayoutForConnectedAccount: {
name: 'createPayoutForConnectedAccount',
description: 'Creates payout for one payment to connection account',
handler: createPayoutForConnectedAccountHandler,
},
setDefaultPaymentMethod: {
name: 'setDefaultPaymentMethod',
description: 'Sets default user payment method',
Expand Down
7 changes: 7 additions & 0 deletions packages/integrations/gei-stripe/stucco.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@
"name": "Mutation.createConnectAccount.handler"
}
},
"Mutation.createPayoutForConnectedAccount": {
"name": "createPayoutForConnectedAccount",
"description": "Creates payout for one payment to connection account",
"resolve": {
"name": "Mutation.createPayoutForConnectedAccount.handler"
}
},
"Product.default_price": {
"name": "default_price",
"description": "Resolver for querying default price object",
Expand Down

0 comments on commit 3ab5227

Please sign in to comment.