suioutkit 1.0.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 +277 -0
- package/assets/flutterwave.png +0 -0
- package/assets/opay.png +0 -0
- package/assets/stripe.png +0 -0
- package/assets/stripe_c.jpeg +0 -0
- package/assets/sui.png +0 -0
- package/assets/suioutkit.png +0 -0
- package/dist/components/PaymentStatusUI.d.ts +7 -0
- package/dist/components/ProgressStepper.d.ts +10 -0
- package/dist/components/StatusBadge.d.ts +7 -0
- package/dist/components/modal.d.ts +50 -0
- package/dist/config/api.d.ts +5 -0
- package/dist/hooks/usePaymentStatus.d.ts +12 -0
- package/dist/hooks/usePolling.d.ts +13 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +51124 -0
- package/dist/types/index.d.ts +57 -0
- package/dist/utils/format.d.ts +12 -0
- package/dist/utils/http.d.ts +11 -0
- package/package.json +40 -0
- package/src/components/PaymentStatusUI.tsx +58 -0
- package/src/components/ProgressStepper.tsx +23 -0
- package/src/components/StatusBadge.tsx +22 -0
- package/src/components/modal.ts +992 -0
- package/src/components/style.css +751 -0
- package/src/config/api.ts +16 -0
- package/src/declarations.d.ts +1 -0
- package/src/hooks/usePaymentStatus.ts +40 -0
- package/src/hooks/usePolling.ts +46 -0
- package/src/index.ts +139 -0
- package/src/types/index.ts +69 -0
- package/src/utils/format.ts +27 -0
- package/src/utils/http.ts +64 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export type SomeType = any;
|
|
2
|
+
export interface CheckoutSessionOptions {
|
|
3
|
+
amount: number;
|
|
4
|
+
currency: "NGN" | "SUI" | string;
|
|
5
|
+
merchantAddress: string;
|
|
6
|
+
metadata?: Record<string, any>;
|
|
7
|
+
}
|
|
8
|
+
export interface CheckoutSession {
|
|
9
|
+
token: string;
|
|
10
|
+
nonce: string;
|
|
11
|
+
amount: number;
|
|
12
|
+
currency: string;
|
|
13
|
+
merchantAddress: string;
|
|
14
|
+
walrusBlobId?: string;
|
|
15
|
+
packageId?: string;
|
|
16
|
+
cryptoRegistryId?: string;
|
|
17
|
+
cryptoRegistryName?: string;
|
|
18
|
+
coinType?: string;
|
|
19
|
+
estimatedRate?: number;
|
|
20
|
+
}
|
|
21
|
+
export type ChargeMethod = "bank_transfer" | "opay" | "crypto" | "sui_wallet" | "outpay" | "stripe";
|
|
22
|
+
export interface VirtualAccount {
|
|
23
|
+
accountNumber: string;
|
|
24
|
+
bankName: string;
|
|
25
|
+
amount: number;
|
|
26
|
+
expirySeconds: number;
|
|
27
|
+
}
|
|
28
|
+
export interface ChargeResponse {
|
|
29
|
+
status: "success" | "pending" | "error";
|
|
30
|
+
virtualAccount?: VirtualAccount;
|
|
31
|
+
opayPrompt?: string;
|
|
32
|
+
clientSecret?: string;
|
|
33
|
+
stripePublicKey?: string;
|
|
34
|
+
message?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface CryptoIntentResponse {
|
|
37
|
+
nonce: string;
|
|
38
|
+
receiverAddress: string;
|
|
39
|
+
amountBaseUnits: number;
|
|
40
|
+
coinType: string;
|
|
41
|
+
packageId?: string;
|
|
42
|
+
registryName?: string;
|
|
43
|
+
walrusBlobId?: string;
|
|
44
|
+
rate?: number;
|
|
45
|
+
}
|
|
46
|
+
export interface CryptoConfirmResponse {
|
|
47
|
+
status: "success" | "error";
|
|
48
|
+
txDigest?: string;
|
|
49
|
+
walrusBlobId?: string;
|
|
50
|
+
error?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface CheckoutStatusResponse {
|
|
53
|
+
status: "PENDING" | "PROCESSING" | "SETTLED" | "EXPIRED";
|
|
54
|
+
txDigest?: string;
|
|
55
|
+
walrusBlobId?: string;
|
|
56
|
+
error?: string;
|
|
57
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Format a Naira amount with currency symbol and grouping. */
|
|
2
|
+
export declare function formatNgn(amount: number): string;
|
|
3
|
+
/** Convert base integer units into token float given decimals. */
|
|
4
|
+
export declare function toTokenUnits(baseUnits: number, decimals?: number): number;
|
|
5
|
+
/** Format token amounts with fixed decimals and trimming. */
|
|
6
|
+
export declare function formatToken(amount: number, decimals?: number, digits?: number): string;
|
|
7
|
+
declare const _default: {
|
|
8
|
+
formatNgn: typeof formatNgn;
|
|
9
|
+
toTokenUnits: typeof toTokenUnits;
|
|
10
|
+
formatToken: typeof formatToken;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type RequestOptions = RequestInit & {
|
|
2
|
+
timeout?: number;
|
|
3
|
+
retries?: number;
|
|
4
|
+
};
|
|
5
|
+
export declare class HttpError extends Error {
|
|
6
|
+
status: number | null;
|
|
7
|
+
body: any | null;
|
|
8
|
+
constructor(message: string, status?: number | null, body?: any | null);
|
|
9
|
+
}
|
|
10
|
+
export declare function request<T = any>(input: string, opts?: RequestOptions): Promise<T>;
|
|
11
|
+
export default request;
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "suioutkit",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Premium Universal Payment Gateway SDK for instant settlement on Sui",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "esbuild src/index.ts --bundle --platform=browser --format=esm --outfile=dist/index.js && tsc --emitDeclarationOnly --declaration",
|
|
9
|
+
"build:types": "tsc --emitDeclarationOnly --declaration"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"sui",
|
|
13
|
+
"payment",
|
|
14
|
+
"fiat",
|
|
15
|
+
"nigeria",
|
|
16
|
+
"flutterwave",
|
|
17
|
+
"stripe",
|
|
18
|
+
"sdk"
|
|
19
|
+
],
|
|
20
|
+
"author": "@CYBWithFlourish (https://github.com/CYBWithFlourish/)",
|
|
21
|
+
"license": "GPL-3.0",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@mysten/dapp-kit-core": "^1.3.2",
|
|
24
|
+
"@mysten/payment-kit": "^0.1.11",
|
|
25
|
+
"@mysten/sui": "^2.17.0",
|
|
26
|
+
"@stripe/stripe-js": "^9.7.0",
|
|
27
|
+
"lucide-react": "^1.17.0",
|
|
28
|
+
"react": "^19.2.7",
|
|
29
|
+
"react-dom": "^19.2.7"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/react": "^19.2.16",
|
|
33
|
+
"@types/react-dom": "^19.2.3",
|
|
34
|
+
"esbuild": "^0.28.0",
|
|
35
|
+
"typescript": "^6.0.3"
|
|
36
|
+
},
|
|
37
|
+
"allowScripts": {
|
|
38
|
+
"esbuild@0.28.0": true
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
import React from "react";
|
|
6
|
+
import { usePaymentStatus } from "../hooks/usePaymentStatus";
|
|
7
|
+
import { ProgressStepper } from "./ProgressStepper";
|
|
8
|
+
|
|
9
|
+
type Props = {
|
|
10
|
+
backendUrl: string;
|
|
11
|
+
nonce: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default function PaymentStatusUI({ backendUrl, nonce }: Props) {
|
|
15
|
+
const update = usePaymentStatus(backendUrl, nonce);
|
|
16
|
+
|
|
17
|
+
const isProcessing = update.status === "PROCESSING";
|
|
18
|
+
const isSettled = update.status === "SETTLED";
|
|
19
|
+
const hasReceipt = !!update.walrusBlobId || isSettled;
|
|
20
|
+
|
|
21
|
+
const steps = [
|
|
22
|
+
{ label: "Transfer sent", completed: isProcessing || hasReceipt },
|
|
23
|
+
{ label: "Webhook received", completed: isProcessing || hasReceipt },
|
|
24
|
+
{ label: "Receipt minted", completed: hasReceipt },
|
|
25
|
+
{ label: "Settled on-chain", completed: isSettled },
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
// Determine badge status
|
|
29
|
+
let badgeStatus: "PENDING" | "PROCESSING" | "BANK_CONFIRMED" | "SETTLED" | "ERROR" = "PENDING";
|
|
30
|
+
if (update.error) {
|
|
31
|
+
badgeStatus = "ERROR";
|
|
32
|
+
} else if (update.status === "SETTLED") {
|
|
33
|
+
badgeStatus = "SETTLED";
|
|
34
|
+
} else if (update.status === "PROCESSING") {
|
|
35
|
+
badgeStatus = "PROCESSING";
|
|
36
|
+
} else if (update.walrusBlobId) {
|
|
37
|
+
badgeStatus = "BANK_CONFIRMED";
|
|
38
|
+
} else {
|
|
39
|
+
badgeStatus = "PENDING";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const copy = update.error
|
|
43
|
+
? "Payment monitoring lost connection."
|
|
44
|
+
: isSettled
|
|
45
|
+
? "Payment settled. Receipt has been generated and the on-chain transaction is complete."
|
|
46
|
+
: isProcessing
|
|
47
|
+
? "Bank transfer received. Webhook confirmed the payment and settlement is in progress..."
|
|
48
|
+
: hasReceipt
|
|
49
|
+
? "Receipt minted. Final settlement is being confirmed on-chain..."
|
|
50
|
+
: "Waiting for the bank transfer to arrive. Once received, the progress steps will advance automatically.";
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<div className="payment-status-ui" style={{ marginTop: "12px" }}>
|
|
54
|
+
<div className="payment-status-copy">{copy}</div>
|
|
55
|
+
<ProgressStepper steps={steps} />
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
import React from "react";
|
|
6
|
+
|
|
7
|
+
type Step = { label: string; completed?: boolean };
|
|
8
|
+
|
|
9
|
+
type Props = { steps: Step[] };
|
|
10
|
+
|
|
11
|
+
export function ProgressStepper({ steps }: Props) {
|
|
12
|
+
return (
|
|
13
|
+
<div className="stepper">
|
|
14
|
+
{steps.map((s, i) => (
|
|
15
|
+
<div className="step" key={i} id={`step-${i}`}>
|
|
16
|
+
<div className={`circle ${s.completed ? "filled" : ""}`}>{i + 1}</div>
|
|
17
|
+
<div className="label">{s.label}</div>
|
|
18
|
+
{i < steps.length - 1 && <div className="line" />}
|
|
19
|
+
</div>
|
|
20
|
+
))}
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
import React from "react";
|
|
6
|
+
import { Loader2, CheckCircle, XCircle } from "lucide-react";
|
|
7
|
+
import "./style.css";
|
|
8
|
+
|
|
9
|
+
type Props = {
|
|
10
|
+
status: "PENDING" | "PROCESSING" | "SUCCESS" | "ERROR" | "BANK_CONFIRMED" | "SETTLED";
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export function StatusBadge({ status }: Props) {
|
|
14
|
+
if (status === "SUCCESS" || status === "BANK_CONFIRMED" || status === "SETTLED") {
|
|
15
|
+
return <CheckCircle className="icon success" />;
|
|
16
|
+
}
|
|
17
|
+
if (status === "ERROR") {
|
|
18
|
+
return <XCircle className="icon error" />;
|
|
19
|
+
}
|
|
20
|
+
// pending spinner
|
|
21
|
+
return <Loader2 className="icon spin" />;
|
|
22
|
+
}
|