Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ loadStripe("YOUR_PUBLISHABLE_KEY", None);

The script URL is determined based on your environment and key:

- **Custom:** if you provide a URL starting with `http://` or `https://` it will be used directly.
- **Sandbox:** `https://beta.hyperswitch.io/v1/HyperLoader.js`
- **Production:** `https://checkout.hyperswitch.io/v0/HyperLoader.js`
- **Fallback:** Determines based on the prefix of the provided key (`pk_prd_`).
Expand Down
23 changes: 16 additions & 7 deletions src/Index.res
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,22 @@ let loadHyper = (hyperObject: JSON.t, option: option<JSON.t>) => {
Promise.make((resolve, reject) => {
let sessionID = generateSessionID()
let timeStamp = Date.now()
let scriptURL = switch getEnv(option) {
| "SANDBOX" => "https://beta.hyperswitch.io/v1/HyperLoader.js"
| "PROD" => "https://checkout.hyperswitch.io/v0/HyperLoader.js"
| _ =>
str->String.startsWith("pk_prd_")
? "https://checkout.hyperswitch.io/v0/HyperLoader.js"
: "https://beta.hyperswitch.io/v1/HyperLoader.js"
let scriptURL = {
let isFullUrl = str => str->String.startsWith("https://") || str->String.startsWith("http://")
switch true {
| _ when isFullUrl(str) => str
| _ =>
switch getEnv(option) {
| "SANDBOX" => "https://beta.hyperswitch.io/v1/HyperLoader.js"
| "PROD" => "https://checkout.hyperswitch.io/v0/HyperLoader.js"
| _ =>
if str->String.startsWith("pk_prd_") {
"https://checkout.hyperswitch.io/v0/HyperLoader.js"
} else {
"https://beta.hyperswitch.io/v1/HyperLoader.js"
}
}
}
}
let analyticsObj =
[
Expand Down
Loading