type Stripe = {
token: string;
};
/**
* Post customers customer funding instructions
* Retrieve funding instructions for a customer cash balance. If funding instructions do not yet exist for the customer, new
funding instructions will be created. If funding instructions have already been created for a given customer, the same
funding instructions will be retrieved. In other words, we will return the same funding instructions each time.
*/
export async function main(
auth: Stripe,
customer: string,
body: {
bank_transfer: {
eu_bank_transfer?: { country: string; [k: string]: unknown };
requested_address_types?: ("iban" | "sort_code" | "spei" | "zengin")[];
type:
| "eu_bank_transfer"
| "gb_bank_transfer"
| "jp_bank_transfer"
| "mx_bank_transfer"
| "us_bank_transfer";
[k: string]: unknown;
};
currency: string;
expand?: string[];
funding_type: "bank_transfer";
}
) {
const url = new URL(
`https://api.stripe.com/v1/customers/${customer}/funding_instructions`
);
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 customers customer funding instructions
* Retrieve funding instructions for a customer cash balance. If funding instructions do not yet exist for the customer, new
funding instructions will be created. If funding instructions have already been created for a given customer, the same
funding instructions will be retrieved. In other words, we will return the same funding instructions each time.
*/
export async function main(
auth: Stripe,
customer: string,
body: {
bank_transfer: {
eu_bank_transfer?: { country: string; [k: string]: unknown };
requested_address_types?: ("iban" | "sort_code" | "spei" | "zengin")[];
type:
| "eu_bank_transfer"
| "gb_bank_transfer"
| "jp_bank_transfer"
| "mx_bank_transfer"
| "us_bank_transfer";
[k: string]: unknown;
};
currency: string;
expand?: string[];
funding_type: "bank_transfer";
}
) {
const url = new URL(
`https://api.stripe.com/v1/customers/${customer}/funding_instructions`
);
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 customers customer funding instructions
* <p>Retrieve funding instructions for a customer cash balance. If funding instructions do not yet exist for the customer, new
funding instructions will be created. If funding instructions have already been created for a given customer, the same
funding instructions will be retrieved. In other words, we will return the same funding instructions each time.</p>
*/
export async function main(
auth: Stripe,
customer: string,
body: {
bank_transfer: {
eu_bank_transfer?: { country: string; [k: string]: unknown };
requested_address_types?: ("iban" | "sort_code" | "spei" | "zengin")[];
type:
| "eu_bank_transfer"
| "gb_bank_transfer"
| "jp_bank_transfer"
| "mx_bank_transfer"
| "us_bank_transfer";
[k: string]: unknown;
};
currency: string;
expand?: string[];
funding_type: "bank_transfer";
}
) {
const url = new URL(
`https://api.stripe.com/v1/customers/${customer}/funding_instructions`
);
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