suioutkit 1.1.1 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  Browser SDK for SuiOutKit checkout: create sessions, open a ready-made payment modal, or build a custom UI with helpers.
11
11
 
12
- Uses the **hosted SuiOutKit API** at `https://api.suioutkit.xyz` by default (all routes under `/v1/`). The SDK does not perform settlement, treasury checks, or provider calls itself.
12
+ Defaults to the **hosted SuiOutKit API** at `https://api.suioutkit.xyz` (`mode: "live"`). Switch with `mode: "test"` or `mode: "local"` for development. All routes under `/v1/`. The SDK does not perform settlement, treasury checks, or provider calls itself.
13
13
 
14
14
  | Resource | Link |
15
15
  |----------|------|
@@ -47,7 +47,7 @@ import { SuiOutKit } from "suioutkit";
47
47
 
48
48
  const sdk = new SuiOutKit({
49
49
  merchantAddress: "0xYOUR_MERCHANT_SUI_ADDRESS",
50
- // backendUrl optional - defaults to https://api.suioutkit.xyz
50
+ // mode optional - defaults to "live" (https://api.suioutkit.xyz, mainnet)
51
51
  });
52
52
 
53
53
  export function PayButton() {
@@ -86,14 +86,10 @@ For simple demos you can serve the built SDK bundle from any static host. Build
86
86
  | Option | Type | Required | Description |
87
87
  |--------|------|----------|-------------|
88
88
  | `merchantAddress` | `string` | Yes | Sui address that receives settlement |
89
- | `backendUrl` | `string` | No | API origin (no trailing slash). Default: `https://api.suioutkit.xyz`. Use `http://localhost:5000` only for local development. |
89
+ | `mode` | `"local" \| "test" \| "live"` | No | Default: `"live"`. `"local"` `http://localhost:5000` (testnet), `"test"` `https://api.staging.suioutkit.xyz` (testnet), `"live"` `https://api.suioutkit.xyz` (mainnet). |
90
+ | `backendUrl` | `string` | No | Override API origin (no trailing slash). Takes precedence over `mode`. |
90
91
 
91
- ### Network (crypto flows)
92
- The modal reads `window.SuiOutKitNetwork` - set to `"mainnet"` or `"testnet"` before opening the modal if you need a specific network for wallet / outPay flows.
93
-
94
- ```html
95
- <script>window.SuiOutKitNetwork = "testnet";</script>
96
- ```
92
+ The SDK automatically sets `window.SuiOutKitNetwork` to the correct Sui network based on `mode` - no manual `<script>` tag needed.
97
93
 
98
94
  ## API reference
99
95
  ### `initCheckout(options)`
@@ -103,6 +99,7 @@ Creates a checkout session on the backend.
103
99
  const session = await sdk.initCheckout({
104
100
  amount: 45000, // integer in major units (e.g. 45000 NGN)
105
101
  currency: "NGN", // e.g. "NGN"
102
+ coinType?: "0x2::sui::SUI", // optional: override settlement coin
106
103
  metadata?: { orderId: "ORDER-123" },
107
104
  });
108
105
  ```
@@ -116,6 +113,7 @@ const session = await sdk.initCheckout({
116
113
  | `amount`, `currency` | Checkout totals |
117
114
  | `merchantAddress` | Normalized Sui address |
118
115
  | `coinType` | Settlement coin type (from backend config) |
116
+ | `supportedCoins` | Array of `{ symbol, type, decimals }` for available settlement coins |
119
117
  | `estimatedRate` | FX preview (NGN → token) when applicable |
120
118
  | `packageId`, `cryptoRegistryId`, `cryptoRegistryName` | On-chain config for crypto paths |
121
119
 
@@ -158,6 +156,7 @@ Binds checkout to a DOM button.
158
156
  | `selector` | `string` | CSS selector (e.g. `"#pay-btn"`) |
159
157
  | `options.amount` | `number` | Checkout amount |
160
158
  | `options.currency` | `string` | e.g. `"NGN"` |
159
+ | `options.coinType` | `string` | Optional settlement coin type override |
161
160
  | `options.metadata` | `object` | Optional passthrough to `initCheckout` |
162
161
 
163
162
  ---
@@ -270,7 +269,7 @@ Webhooks (`/v1/checkout/webhook`, `/v1/checkout/stripe-webhook`) are server-to-p
270
269
  | `409 Treasury insufficient` | Operator vault underfunded for FX settlement amount |
271
270
  | Modal stuck on “waiting for settlement” | Webhook not reaching backend (Flutterwave hash, Stripe CLI, or ngrok) |
272
271
  | Stripe card errors on small NGN amounts | Backend enforces ~$0.50 USD equivalent minimum |
273
- | Crypto connect fails | Wrong `window.SuiOutKitNetwork` or registry env on backend |
272
+ | Crypto connect fails | Wrong `mode` or registry env on backend |
274
273
  | Styles missing | Backend not serving `/style.css` or wrong `backendUrl` |
275
274
 
276
275
  See also [Developer Guide - Troubleshooting](/docs/developer-guide.md#troubleshooting).
@@ -278,9 +277,9 @@ See also [Developer Guide - Troubleshooting](/docs/developer-guide.md#troublesho
278
277
 
279
278
 
280
279
  ## Security
281
- - Only `merchantAddress` and `backendUrl` belong in browser code.
280
+ - Only `merchantAddress`, `mode`, and `backendUrl` belong in browser code.
282
281
  - Never embed operator keys, Flutterwave secrets, or Stripe secret keys in the client.
283
- - Use **HTTPS** for `backendUrl` in production.
282
+ - Use **HTTPS** for the API endpoint in production (default when `mode: "live"`).
284
283
 
285
284
  Report vulnerabilities through your project’s private security channel (do not file public issues with key material).
286
285
 
@@ -1,5 +1,5 @@
1
- /** Production SuiOutKit API origin (versioned paths under /v1/). */
2
- export declare const DEFAULT_API_ORIGIN = "http://localhost:5000";
1
+ /** Production SuiOutKit API origin (versioned paths under /v1/). Use `mode` config to switch between local/test/live. */
2
+ export declare const DEFAULT_API_ORIGIN = "https://api.suioutkit.xyz";
3
3
  /** API version prefix - all checkout and payment routes live under this path. */
4
4
  export declare const API_V1_PREFIX = "/v1";
5
5
  export declare function joinApiPath(origin: string, ...segments: string[]): string;
@@ -0,0 +1,6 @@
1
+ export type SuiOutKitMode = "local" | "test" | "live";
2
+ export interface ModeConfig {
3
+ backendUrl: string;
4
+ suiNetwork: "mainnet" | "testnet";
5
+ }
6
+ export declare const MODE_MAP: Record<SuiOutKitMode, ModeConfig>;
package/dist/index.d.ts CHANGED
@@ -1,13 +1,10 @@
1
- import { CheckoutSession, CheckoutSessionOptions, CryptoConfirmResponse, SuiOutKitModalOptions } from "./types/index.js";
1
+ import { CheckoutSession, CheckoutSessionOptions, CryptoConfirmResponse, SuiOutKitModalOptions, SuiOutKitConfig } from "./types/index.js";
2
2
  import { SuiOutKitModal } from "./components/modal.js";
3
3
  export { DEFAULT_API_ORIGIN, API_V1_PREFIX } from "./config/api.js";
4
4
  export declare class SuiOutKit {
5
5
  private backendUrl;
6
6
  private merchantAddress;
7
- constructor(config: {
8
- merchantAddress: string;
9
- backendUrl?: string;
10
- });
7
+ constructor(config: SuiOutKitConfig);
11
8
  /**
12
9
  * Initializes a brand-new isolated checkout session from the backend.
13
10
  */
package/dist/index.js CHANGED
@@ -51981,7 +51981,7 @@ var loadStripe = function loadStripe2() {
51981
51981
  var import_react = __toESM(require_react());
51982
51982
 
51983
51983
  // src/config/api.ts
51984
- var DEFAULT_API_ORIGIN = "http://localhost:5000";
51984
+ var DEFAULT_API_ORIGIN = "https://api.suioutkit.xyz";
51985
51985
  var API_V1_PREFIX = "/v1";
51986
51986
  function joinApiPath(origin, ...segments) {
51987
51987
  const base = origin.replace(/\/+$/, "");
@@ -52741,7 +52741,7 @@ var SuiOutKitModal = class {
52741
52741
  return;
52742
52742
  }
52743
52743
  const paymentUri = this.buildPaymentUri(this.cryptoIntent);
52744
- const qrCodeUrl = await import_qrcode.default.toDataURL(paymentUri, { width: 180, margin: 1 });
52744
+ const qrCodeUrl = await import_qrcode.default.toDataURL(paymentUri, { width: 300, margin: 2 });
52745
52745
  container.innerHTML = `
52746
52746
  <button class="suioutkit-back" id="sok-back-btn">\u2190 Back to Sui options</button>
52747
52747
  <div class="suioutkit-panel">
@@ -52912,6 +52912,13 @@ var SuiOutKitModal = class {
52912
52912
  }
52913
52913
  };
52914
52914
 
52915
+ // src/config/modes.ts
52916
+ var MODE_MAP = {
52917
+ local: { backendUrl: "http://localhost:5000", suiNetwork: "testnet" },
52918
+ test: { backendUrl: "https://api.staging.suioutkit.xyz", suiNetwork: "testnet" },
52919
+ live: { backendUrl: "https://api.suioutkit.xyz", suiNetwork: "mainnet" }
52920
+ };
52921
+
52915
52922
  // src/utils/http.ts
52916
52923
  var HttpError = class extends Error {
52917
52924
  constructor(message, status = null, body = null) {
@@ -53012,8 +53019,11 @@ var SuiOutKit = class {
53012
53019
  if (!config.merchantAddress) {
53013
53020
  throw new Error("SuiOutKit Error: merchantAddress is required.");
53014
53021
  }
53015
- this.backendUrl = (config.backendUrl || DEFAULT_API_ORIGIN).replace(/\/+$/, "");
53022
+ const mode = config.mode || "live";
53023
+ const modeCfg = MODE_MAP[mode];
53024
+ this.backendUrl = (config.backendUrl || modeCfg.backendUrl).replace(/\/+$/, "");
53016
53025
  this.merchantAddress = config.merchantAddress;
53026
+ window.SuiOutKitNetwork = modeCfg.suiNetwork;
53017
53027
  }
53018
53028
  /**
53019
53029
  * Initializes a brand-new isolated checkout session from the backend.
@@ -1,4 +1,9 @@
1
- export type SomeType = any;
1
+ export type SuiOutKitMode = "local" | "test" | "live";
2
+ export interface SuiOutKitConfig {
3
+ merchantAddress: string;
4
+ mode?: SuiOutKitMode;
5
+ backendUrl?: string;
6
+ }
2
7
  export interface SupportedCoin {
3
8
  symbol: string;
4
9
  type: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suioutkit",
3
- "version": "1.1.1",
3
+ "version": "1.2.1",
4
4
  "description": "Premium Universal Payment Gateway SDK for instant settlement on Sui",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -835,7 +835,7 @@ export class SuiOutKitModal {
835
835
  }
836
836
 
837
837
  const paymentUri = this.buildPaymentUri(this.cryptoIntent);
838
- const qrCodeUrl = await QRCode.toDataURL(paymentUri, { width: 180, margin: 1 });
838
+ const qrCodeUrl = await QRCode.toDataURL(paymentUri, { width: 300, margin: 2 });
839
839
 
840
840
  container.innerHTML = `
841
841
  <button class="suioutkit-back" id="sok-back-btn">← Back to Sui options</button>
@@ -428,20 +428,20 @@
428
428
 
429
429
  .sok-qr-frame {
430
430
  background: #ffffff;
431
- padding: 10px;
431
+ padding: 12px;
432
432
  border-radius: 14px;
433
433
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
434
434
  position: relative;
435
435
  overflow: hidden;
436
436
  margin-bottom: 10px;
437
- width: 180px;
438
- height: 180px;
437
+ width: 260px;
438
+ height: 260px;
439
439
  box-sizing: border-box;
440
440
  }
441
441
 
442
442
  .sok-qr-img {
443
- width: 160px;
444
- height: 160px;
443
+ width: 236px;
444
+ height: 236px;
445
445
  display: block;
446
446
  }
447
447
 
@@ -742,13 +742,13 @@
742
742
  }
743
743
 
744
744
  .sok-qr-frame {
745
- width: 160px;
746
- height: 160px;
745
+ width: 220px;
746
+ height: 220px;
747
747
  }
748
748
 
749
749
  .sok-qr-img {
750
- width: 140px;
751
- height: 140px;
750
+ width: 196px;
751
+ height: 196px;
752
752
  }
753
753
 
754
754
  .sok-success-details {
package/src/config/api.ts CHANGED
@@ -2,9 +2,8 @@
2
2
  // Copyright (c) 2026 The3rdWebLabs (https://github.com/the3rdweblabs)
3
3
  // Author: @CYBWithFlourish (https://github.com/CYBWithFlourish)
4
4
 
5
- /** Production SuiOutKit API origin (versioned paths under /v1/). */
6
- //export const DEFAULT_API_ORIGIN = "https://api.suioutkit.xyz";
7
- export const DEFAULT_API_ORIGIN = "http://localhost:5000";
5
+ /** Production SuiOutKit API origin (versioned paths under /v1/). Use `mode` config to switch between local/test/live. */
6
+ export const DEFAULT_API_ORIGIN = "https://api.suioutkit.xyz";
8
7
 
9
8
  /** API version prefix - all checkout and payment routes live under this path. */
10
9
  export const API_V1_PREFIX = "/v1";
@@ -0,0 +1,16 @@
1
+ // SPDX-License-Identifier: GPL-3.0
2
+ // Copyright (c) 2026 The3rdWebLabs (https://github.com/the3rdweblabs)
3
+ // Author: @CYBWithFlourish (https://github.com/CYBWithFlourish)
4
+
5
+ export type SuiOutKitMode = "local" | "test" | "live";
6
+
7
+ export interface ModeConfig {
8
+ backendUrl: string;
9
+ suiNetwork: "mainnet" | "testnet";
10
+ }
11
+
12
+ export const MODE_MAP: Record<SuiOutKitMode, ModeConfig> = {
13
+ local: { backendUrl: "http://localhost:5000", suiNetwork: "testnet" },
14
+ test: { backendUrl: "https://api.staging.suioutkit.xyz", suiNetwork: "testnet" },
15
+ live: { backendUrl: "https://api.suioutkit.xyz", suiNetwork: "mainnet" },
16
+ };
package/src/index.ts CHANGED
@@ -2,9 +2,10 @@
2
2
  // Copyright (c) 2026 The3rdWebLabs (https://github.com/the3rdweblabs)
3
3
  // Author: @CYBWithFlourish (https://github.com/CYBWithFlourish)
4
4
 
5
- import { CheckoutSession, CheckoutSessionOptions, CryptoConfirmResponse, SuiOutKitModalOptions } from "./types/index.js";
5
+ import { CheckoutSession, CheckoutSessionOptions, CryptoConfirmResponse, SuiOutKitModalOptions, SuiOutKitConfig, SuiOutKitMode } from "./types/index.js";
6
6
  import { SuiOutKitModal } from "./components/modal.js";
7
- import { DEFAULT_API_ORIGIN, joinApiPath } from "./config/api.js";
7
+ import { joinApiPath, DEFAULT_API_ORIGIN } from "./config/api.js";
8
+ import { MODE_MAP } from "./config/modes.js";
8
9
 
9
10
  export { DEFAULT_API_ORIGIN, API_V1_PREFIX } from "./config/api.js";
10
11
 
@@ -12,13 +13,15 @@ export class SuiOutKit {
12
13
  private backendUrl: string;
13
14
  private merchantAddress: string;
14
15
 
15
- constructor(config: { merchantAddress: string; backendUrl?: string }) {
16
+ constructor(config: SuiOutKitConfig) {
16
17
  if (!config.merchantAddress) {
17
18
  throw new Error("SuiOutKit Error: merchantAddress is required.");
18
19
  }
19
- // Strip trailing slashes and provide default fallback
20
- this.backendUrl = (config.backendUrl || DEFAULT_API_ORIGIN).replace(/\/+$/, "");
20
+ const mode: SuiOutKitMode = config.mode || "live";
21
+ const modeCfg = MODE_MAP[mode];
22
+ this.backendUrl = (config.backendUrl || modeCfg.backendUrl).replace(/\/+$/, "");
21
23
  this.merchantAddress = config.merchantAddress;
24
+ (window as any).SuiOutKitNetwork = modeCfg.suiNetwork;
22
25
  }
23
26
 
24
27
  /**
@@ -2,7 +2,13 @@
2
2
  // Copyright (c) 2026 The3rdWebLabs (https://github.com/the3rdweblabs)
3
3
  // Author: @CYBWithFlourish (https://github.com/CYBWithFlourish)
4
4
 
5
- export type SomeType = any;
5
+ export type SuiOutKitMode = "local" | "test" | "live";
6
+
7
+ export interface SuiOutKitConfig {
8
+ merchantAddress: string;
9
+ mode?: SuiOutKitMode;
10
+ backendUrl?: string;
11
+ }
6
12
 
7
13
  export interface SupportedCoin {
8
14
  symbol: string;