Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PAY-645] Add a route to start a stripe session in SDK #3878

Merged
merged 4 commits into from
Sep 20, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions libs/src/services/identity/IdentityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ type InAppAudioPurchaseMetadata = {
cleanupTransactionId?: string
}

type CreateStripeSessionRequest = {
destinationWallet: string
amount: string
}

type CreateStripeSessionResponse = {
id: string
client_secret: string
status: string
}

// Only probabilistically capture 50% of relay captchas
const RELAY_CAPTCHA_SAMPLE_RATE = 0.5

Expand Down Expand Up @@ -556,6 +567,19 @@ export class IdentityService {
})
}

async createStripeSession(
data: CreateStripeSessionRequest
): Promise<CreateStripeSessionResponse> {
const headers = await this._signData()

return await this._makeRequest({
url: '/stripe/session',
method: 'post',
data,
headers
})
}

/* ------- INTERNAL FUNCTIONS ------- */

async _makeRequest<T = unknown>(axiosRequestObj: AxiosRequestConfig) {
Expand Down