Skip to content

Commit 3ab5227

Browse files
committed
addCreatePayoutForConnectedAccountToStripe
1 parent 7af169d commit 3ab5227

File tree

5 files changed

+31
-16
lines changed

5 files changed

+31
-16
lines changed

package-lock.json

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/integrations/gei-stripe/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gei-stripe",
3-
"version": "0.4.8",
3+
"version": "0.4.9",
44
"description": "Automatically generated by graphql-editor-cli",
55
"main": "lib/index.js",
66
"scripts": {
@@ -30,7 +30,7 @@
3030
"mailgun.js": "^8.0.6",
3131
"mongodb": "^5.1.0",
3232
"node-fetch": "^3.3.0",
33-
"stripe": "^11.4.0",
33+
"stripe": "^11.18.0",
3434
"stucco-js": "^0.10.18",
3535
"ws": "^8.12.0"
3636
}
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import Stripe from 'stripe';
1+
import { newStripe } from "../utils/stripeInit.js";
22
import { resolverFor } from '../zeus/index.js';
33
import { FieldResolveInput } from 'stucco-js';
44

5-
const stripe = new Stripe('YOUR_STRIPE_SECRET_KEY', {
6-
apiVersion: '2020-08-27',
7-
});
5+
86

97
export const createPayoutForConnectedAccount = async (input: FieldResolveInput) =>
108
resolverFor(
119
'Mutation',
1210
'createPayoutForConnectedAccount',
13-
async ({ payload: { accountId, amount, currency} }) => {
11+
async ({ payload: { accountId, amount, currency } }) => {
1412
try {
15-
const payout = await stripe.payouts.create({
13+
const stripe_account = process.env.STRIPE_ACCOUNT_ID || accountId
14+
if (!stripe_account) throw new Error('missing accountId');
15+
const payout = await newStripe().payouts.create({
1616
amount,
1717
currency,
18-
stripe_account: accountId,
18+
destination: stripe_account,
1919
});
2020

2121
if (payout) {
@@ -26,7 +26,8 @@ export const createPayoutForConnectedAccount = async (input: FieldResolveInput)
2626
} catch (error) {
2727
throw new Error('Error creating payout:' + JSON.stringify(error));
2828
}
29-
3029
})(input.arguments, input.source)
3130

31+
export default createPayoutForConnectedAccount;
32+
3233

packages/integrations/gei-stripe/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import webhookHandler from './Mutation/webhook.js';
44
import createCustomerPortalHandler from './Mutation/createCustomerPortal.js';
55
import createCheckoutSessionHandler from './Mutation/createCheckoutSession.js';
66
import createNewUserCheckoutSessionHandler from './Mutation/createNewUserCheckoutSession.js';
7+
import createPayoutForConnectedAccountHandler from './Mutation/createPayoutForConnectedAccount.js';
78
import productsHandler from './Query/products.js';
89
import productDefaultPriceHandler from './Product/default_price.js';
910
import productPricesHandler from './Product/prices.js';
@@ -76,6 +77,11 @@ export const integration = NewIntegration({
7677
description: 'Creates payment session for user that is not yet registered',
7778
handler: createNewUserCheckoutSessionHandler,
7879
},
80+
createPayoutForConnectedAccount: {
81+
name: 'createPayoutForConnectedAccount',
82+
description: 'Creates payout for one payment to connection account',
83+
handler: createPayoutForConnectedAccountHandler,
84+
},
7985
setDefaultPaymentMethod: {
8086
name: 'setDefaultPaymentMethod',
8187
description: 'Sets default user payment method',

packages/integrations/gei-stripe/stucco.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@
6363
"name": "Mutation.createConnectAccount.handler"
6464
}
6565
},
66+
"Mutation.createPayoutForConnectedAccount": {
67+
"name": "createPayoutForConnectedAccount",
68+
"description": "Creates payout for one payment to connection account",
69+
"resolve": {
70+
"name": "Mutation.createPayoutForConnectedAccount.handler"
71+
}
72+
},
6673
"Product.default_price": {
6774
"name": "default_price",
6875
"description": "Resolver for querying default price object",

0 commit comments

Comments
 (0)