type Stripe = {
token: string;
};
/**
* Post identity verification sessions session
* Updates a VerificationSession object.
When the session status is requires_input, you can use this method to update the
verification check and options.
*/
export async function main(
auth: Stripe,
session: string,
body: {
expand?: string[];
metadata?: { [k: string]: string };
options?: {
document?:
| {
allowed_types?: ("driving_license" | "id_card" | "passport")[];
require_id_number?: boolean;
require_live_capture?: boolean;
require_matching_selfie?: boolean;
[k: string]: unknown;
}
| "";
[k: string]: unknown;
};
type?: "document" | "id_number";
}
) {
const url = new URL(
`https://api.stripe.com/v1/identity/verification_sessions/${session}`
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Authorization: "Bearer " + auth.token,
},
body: encodeParams(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
function encodeParams(o: any) {
function iter(o: any, path: string) {
if (Array.isArray(o)) {
o.forEach(function (a) {
iter(a, path + "[]");
});
return;
}
if (o !== null && typeof o === "object") {
Object.keys(o).forEach(function (k) {
iter(o[k], path + "[" + k + "]");
});
return;
}
data.push(path + "=" + o);
}
const data: string[] = [];
Object.keys(o).forEach(function (k) {
if (o[k] !== undefined) {
iter(o[k], k);
}
});
return new URLSearchParams(data.join("&"));
}
Submitted by hugo697 368 days ago
type Stripe = {
token: string;
};
/**
* Post identity verification sessions session
* Updates a VerificationSession object.
When the session status is requires_input, you can use this method to update the
verification check and options.
*/
export async function main(
auth: Stripe,
session: string,
body: {
expand?: string[];
metadata?: { [k: string]: string };
options?: {
document?:
| {
allowed_types?: ("driving_license" | "id_card" | "passport")[];
require_id_number?: boolean;
require_live_capture?: boolean;
require_matching_selfie?: boolean;
[k: string]: unknown;
}
| "";
[k: string]: unknown;
};
type?: "document" | "id_number";
}
) {
const url = new URL(
`https://api.stripe.com/v1/identity/verification_sessions/${session}`
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Authorization: "Bearer " + auth.token,
},
body: encodeParams(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
function encodeParams(o: any) {
function iter(o: any, path: string) {
if (Array.isArray(o)) {
o.forEach(function (a) {
iter(a, path + "[]");
});
return;
}
if (o !== null && typeof o === "object") {
Object.keys(o).forEach(function (k) {
iter(o[k], path + "[" + k + "]");
});
return;
}
data.push(path + "=" + o);
}
const data: string[] = [];
Object.keys(o).forEach(function (k) {
if (o[k] !== undefined) {
iter(o[k], k);
}
});
return new URLSearchParams(data.join("&"));
}
Submitted by hugo697 795 days ago
type Stripe = {
token: string;
};
/**
* Post identity verification sessions session
* <p>Updates a VerificationSession object.</p>
<p>When the session status is <code>requires_input</code>, you can use this method to update the
verification check and options.</p>
*/
export async function main(
auth: Stripe,
session: string,
body: {
expand?: string[];
metadata?: { [k: string]: string };
options?: {
document?:
| {
allowed_types?: ("driving_license" | "id_card" | "passport")[];
require_id_number?: boolean;
require_live_capture?: boolean;
require_matching_selfie?: boolean;
[k: string]: unknown;
}
| "";
[k: string]: unknown;
};
type?: "document" | "id_number";
}
) {
const url = new URL(
`https://api.stripe.com/v1/identity/verification_sessions/${session}`
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Authorization: "Bearer " + auth.token,
},
body: encodeParams(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
function encodeParams(o: any) {
function iter(o: any, path: string) {
if (Array.isArray(o)) {
o.forEach(function (a) {
iter(a, path + "[]");
});
return;
}
if (o !== null && typeof o === "object") {
Object.keys(o).forEach(function (k) {
iter(o[k], path + "[" + k + "]");
});
return;
}
data.push(path + "=" + o);
}
const data: string[] = [];
Object.keys(o).forEach(function (k) {
if (o[k] !== undefined) {
iter(o[k], k);
}
});
return new URLSearchParams(data.join("&"));
}
Submitted by hugo697 922 days ago