0

Apple Pay Session

by
Published Oct 17, 2025

Apple Pay Session

Script basis_theory Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Basistheory = {
3
  apiKey: string;
4
};
5
/**
6
 * Apple Pay Session
7
 * Apple Pay Session
8
 */
9
export async function main(
10
  auth: Basistheory,
11
  body: { display_name?: string; domain?: string; validation_url?: string },
12
) {
13
  const url = new URL(
14
    `https://api.basistheory.com/connections/apple-pay/session`,
15
  );
16

17
  const response = await fetch(url, {
18
    method: "POST",
19
    headers: {
20
      "Content-Type": "application/json",
21
      "BT-API-KEY": auth.apiKey,
22
    },
23
    body: JSON.stringify(body),
24
  });
25
  if (!response.ok) {
26
    const text = await response.text();
27
    throw new Error(`${response.status} ${text}`);
28
  }
29
  return await response.text();
30
}
31