feat: use stripe connect for payments

This commit is contained in:
swve 2024-11-09 16:54:43 +01:00
parent cdd893ca6f
commit a8ba053447
17 changed files with 835 additions and 364 deletions

View file

@ -20,9 +20,9 @@ export async function checkPaidAccess(courseId: number, orgId: number, access_to
return res;
}
export async function createPaymentConfig(orgId: number, data: any, access_token: string) {
export async function initializePaymentConfig(orgId: number, data: any, provider: string, access_token: string) {
const result = await fetch(
`${getAPIUrl()}payments/${orgId}/config`,
`${getAPIUrl()}payments/${orgId}/config?provider=${provider}`,
RequestBodyWithAuthHeader('POST', data, null, access_token)
);
const res = await errorHandling(result);
@ -38,6 +38,24 @@ export async function updatePaymentConfig(orgId: number, id: string, data: any,
return res;
}
export async function updateStripeAccountID(orgId: number, data: any, access_token: string) {
const result = await fetch(
`${getAPIUrl()}payments/${orgId}/stripe/account?stripe_account_id=${data.stripe_account_id}`,
RequestBodyWithAuthHeader('PUT', data, null, access_token)
);
const res = await errorHandling(result);
return res;
}
export async function getStripeOnboardingLink(orgId: number, access_token: string, redirect_uri: string) {
const result = await fetch(
`${getAPIUrl()}payments/${orgId}/stripe/connect/link?redirect_uri=${redirect_uri}`,
RequestBodyWithAuthHeader('POST', null, null, access_token)
);
const res = await errorHandling(result);
return res;
}
export async function deletePaymentConfig(orgId: number, id: string, access_token: string) {
const result = await fetch(
`${getAPIUrl()}payments/${orgId}/config?id=${id}`,