started payouts
This commit is contained in:
@@ -45,113 +45,76 @@ class StripeService {
|
||||
}
|
||||
}
|
||||
|
||||
// static async createConnectedAccount({ email, country = "US" }) {
|
||||
// try {
|
||||
// const account = await stripe.accounts.create({
|
||||
// type: "standard",
|
||||
// email,
|
||||
// country,
|
||||
// controller: {
|
||||
// stripe_dashboard: {
|
||||
// type: "full",
|
||||
// },
|
||||
// },
|
||||
// capabilities: {
|
||||
// transfers: { requested: true },
|
||||
// },
|
||||
// });
|
||||
static async createConnectedAccount({ email, country = "US" }) {
|
||||
try {
|
||||
const account = await stripe.accounts.create({
|
||||
type: "standard",
|
||||
email,
|
||||
country,
|
||||
capabilities: {
|
||||
transfers: { requested: true },
|
||||
},
|
||||
});
|
||||
|
||||
// return account;
|
||||
// } catch (error) {
|
||||
// console.error("Error creating connected account:", error);
|
||||
// throw error;
|
||||
// }
|
||||
// }
|
||||
return account;
|
||||
} catch (error) {
|
||||
console.error("Error creating connected account:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// static async createAccountLink(accountId, refreshUrl, returnUrl) {
|
||||
// try {
|
||||
// const accountLink = await stripe.accountLinks.create({
|
||||
// account: accountId,
|
||||
// refresh_url: refreshUrl,
|
||||
// return_url: returnUrl,
|
||||
// type: "account_onboarding",
|
||||
// });
|
||||
static async createAccountLink(accountId, refreshUrl, returnUrl) {
|
||||
try {
|
||||
const accountLink = await stripe.accountLinks.create({
|
||||
account: accountId,
|
||||
refresh_url: refreshUrl,
|
||||
return_url: returnUrl,
|
||||
type: "account_onboarding",
|
||||
});
|
||||
|
||||
// return accountLink;
|
||||
// } catch (error) {
|
||||
// console.error("Error creating account link:", error);
|
||||
// throw error;
|
||||
// }
|
||||
// }
|
||||
return accountLink;
|
||||
} catch (error) {
|
||||
console.error("Error creating account link:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// static async getAccountStatus(accountId) {
|
||||
// try {
|
||||
// const account = await stripe.accounts.retrieve(accountId);
|
||||
// return {
|
||||
// id: account.id,
|
||||
// details_submitted: account.details_submitted,
|
||||
// payouts_enabled: account.payouts_enabled,
|
||||
// capabilities: account.capabilities,
|
||||
// requirements: account.requirements,
|
||||
// };
|
||||
// } catch (error) {
|
||||
// console.error("Error retrieving account status:", error);
|
||||
// throw error;
|
||||
// }
|
||||
// }
|
||||
static async getAccountStatus(accountId) {
|
||||
try {
|
||||
const account = await stripe.accounts.retrieve(accountId);
|
||||
return {
|
||||
id: account.id,
|
||||
details_submitted: account.details_submitted,
|
||||
payouts_enabled: account.payouts_enabled,
|
||||
capabilities: account.capabilities,
|
||||
requirements: account.requirements,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error retrieving account status:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// static async createPaymentIntent({
|
||||
// amount,
|
||||
// currency = "usd",
|
||||
// connectedAccountId,
|
||||
// applicationFeeAmount,
|
||||
// metadata = {},
|
||||
// }) {
|
||||
// try {
|
||||
// const paymentIntent = await stripe.paymentIntents.create({
|
||||
// amount,
|
||||
// currency,
|
||||
// transfer_data: {
|
||||
// destination: connectedAccountId,
|
||||
// },
|
||||
// application_fee_amount: applicationFeeAmount,
|
||||
// metadata,
|
||||
// automatic_payment_methods: {
|
||||
// enabled: true,
|
||||
// },
|
||||
// });
|
||||
static async createTransfer({
|
||||
amount,
|
||||
currency = "usd",
|
||||
destination,
|
||||
metadata = {},
|
||||
}) {
|
||||
try {
|
||||
const transfer = await stripe.transfers.create({
|
||||
amount: Math.round(amount * 100), // Convert to cents
|
||||
currency,
|
||||
destination,
|
||||
metadata,
|
||||
});
|
||||
|
||||
// return paymentIntent;
|
||||
// } catch (error) {
|
||||
// console.error("Error creating payment intent:", error);
|
||||
// throw error;
|
||||
// }
|
||||
// }
|
||||
|
||||
// static async confirmPaymentIntent(paymentIntentId, paymentMethodId) {
|
||||
// try {
|
||||
// const paymentIntent = await stripe.paymentIntents.confirm(
|
||||
// paymentIntentId,
|
||||
// {
|
||||
// payment_method: paymentMethodId,
|
||||
// }
|
||||
// );
|
||||
|
||||
// return paymentIntent;
|
||||
// } catch (error) {
|
||||
// console.error("Error confirming payment intent:", error);
|
||||
// throw error;
|
||||
// }
|
||||
// }
|
||||
|
||||
// static async retrievePaymentIntent(paymentIntentId) {
|
||||
// try {
|
||||
// return await stripe.paymentIntents.retrieve(paymentIntentId);
|
||||
// } catch (error) {
|
||||
// console.error("Error retrieving payment intent:", error);
|
||||
// throw error;
|
||||
// }
|
||||
// }
|
||||
return transfer;
|
||||
} catch (error) {
|
||||
console.error("Error creating transfer:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = StripeService;
|
||||
|
||||
Reference in New Issue
Block a user