@clockpay/react-native 1.0.0
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 +113 -0
- package/lib/commonjs/api/client.js +73 -0
- package/lib/commonjs/api/client.js.map +1 -0
- package/lib/commonjs/api/endpoints.js +11 -0
- package/lib/commonjs/api/endpoints.js.map +1 -0
- package/lib/commonjs/components/bottom-sheet.js +137 -0
- package/lib/commonjs/components/bottom-sheet.js.map +1 -0
- package/lib/commonjs/components/icons.js +129 -0
- package/lib/commonjs/components/icons.js.map +1 -0
- package/lib/commonjs/components/payment-button.js +106 -0
- package/lib/commonjs/components/payment-button.js.map +1 -0
- package/lib/commonjs/components/payment-sheet.js +156 -0
- package/lib/commonjs/components/payment-sheet.js.map +1 -0
- package/lib/commonjs/components/views/status-view.js +109 -0
- package/lib/commonjs/components/views/status-view.js.map +1 -0
- package/lib/commonjs/components/views/transfer-view.js +162 -0
- package/lib/commonjs/components/views/transfer-view.js.map +1 -0
- package/lib/commonjs/components/views/verify-view.js +98 -0
- package/lib/commonjs/components/views/verify-view.js.map +1 -0
- package/lib/commonjs/hooks/use-countdown.js +24 -0
- package/lib/commonjs/hooks/use-countdown.js.map +1 -0
- package/lib/commonjs/index.js +13 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/internal/constants.js +42 -0
- package/lib/commonjs/internal/constants.js.map +1 -0
- package/lib/commonjs/internal/format.js +29 -0
- package/lib/commonjs/internal/format.js.map +1 -0
- package/lib/commonjs/internal/theme.js +24 -0
- package/lib/commonjs/internal/theme.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types.js +6 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/api/client.js +67 -0
- package/lib/module/api/client.js.map +1 -0
- package/lib/module/api/endpoints.js +7 -0
- package/lib/module/api/endpoints.js.map +1 -0
- package/lib/module/components/bottom-sheet.js +133 -0
- package/lib/module/components/bottom-sheet.js.map +1 -0
- package/lib/module/components/icons.js +120 -0
- package/lib/module/components/icons.js.map +1 -0
- package/lib/module/components/payment-button.js +103 -0
- package/lib/module/components/payment-button.js.map +1 -0
- package/lib/module/components/payment-sheet.js +152 -0
- package/lib/module/components/payment-sheet.js.map +1 -0
- package/lib/module/components/views/status-view.js +105 -0
- package/lib/module/components/views/status-view.js.map +1 -0
- package/lib/module/components/views/transfer-view.js +157 -0
- package/lib/module/components/views/transfer-view.js.map +1 -0
- package/lib/module/components/views/verify-view.js +94 -0
- package/lib/module/components/views/verify-view.js.map +1 -0
- package/lib/module/hooks/use-countdown.js +21 -0
- package/lib/module/hooks/use-countdown.js.map +1 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/internal/constants.js +37 -0
- package/lib/module/internal/constants.js.map +1 -0
- package/lib/module/internal/format.js +24 -0
- package/lib/module/internal/format.js.map +1 -0
- package/lib/module/internal/theme.js +21 -0
- package/lib/module/internal/theme.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/api/client.d.ts +17 -0
- package/lib/typescript/api/client.d.ts.map +1 -0
- package/lib/typescript/api/endpoints.d.ts +5 -0
- package/lib/typescript/api/endpoints.d.ts.map +1 -0
- package/lib/typescript/components/bottom-sheet.d.ts +18 -0
- package/lib/typescript/components/bottom-sheet.d.ts.map +1 -0
- package/lib/typescript/components/icons.d.ts +12 -0
- package/lib/typescript/components/icons.d.ts.map +1 -0
- package/lib/typescript/components/payment-button.d.ts +7 -0
- package/lib/typescript/components/payment-button.d.ts.map +1 -0
- package/lib/typescript/components/payment-sheet.d.ts +17 -0
- package/lib/typescript/components/payment-sheet.d.ts.map +1 -0
- package/lib/typescript/components/views/status-view.d.ts +12 -0
- package/lib/typescript/components/views/status-view.d.ts.map +1 -0
- package/lib/typescript/components/views/transfer-view.d.ts +13 -0
- package/lib/typescript/components/views/transfer-view.d.ts.map +1 -0
- package/lib/typescript/components/views/verify-view.d.ts +10 -0
- package/lib/typescript/components/views/verify-view.d.ts.map +1 -0
- package/lib/typescript/hooks/use-countdown.d.ts +8 -0
- package/lib/typescript/hooks/use-countdown.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +3 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/internal/constants.d.ts +20 -0
- package/lib/typescript/internal/constants.d.ts.map +1 -0
- package/lib/typescript/internal/format.d.ts +7 -0
- package/lib/typescript/internal/format.d.ts.map +1 -0
- package/lib/typescript/internal/theme.d.ts +13 -0
- package/lib/typescript/internal/theme.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +67 -0
- package/lib/typescript/types.d.ts.map +1 -0
- package/package.json +70 -0
- package/src/api/client.ts +76 -0
- package/src/api/endpoints.ts +4 -0
- package/src/components/bottom-sheet.tsx +144 -0
- package/src/components/icons.tsx +90 -0
- package/src/components/payment-button.tsx +112 -0
- package/src/components/payment-sheet.tsx +149 -0
- package/src/components/views/status-view.tsx +61 -0
- package/src/components/views/transfer-view.tsx +112 -0
- package/src/components/views/verify-view.tsx +69 -0
- package/src/hooks/use-countdown.ts +20 -0
- package/src/index.ts +10 -0
- package/src/internal/constants.ts +34 -0
- package/src/internal/format.ts +21 -0
- package/src/internal/theme.ts +28 -0
- package/src/types.ts +73 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { DEFAULT_ACCENT } from './constants';
|
|
4
|
+
|
|
5
|
+
/** Concrete colours/values resolved from an {@link ClockPayAppearance}. */
|
|
6
|
+
|
|
7
|
+
/** Resolves an appearance object into concrete style values for the RN UI. */
|
|
8
|
+
export function resolveTheme(appearance) {
|
|
9
|
+
const a = appearance ?? {};
|
|
10
|
+
const variant = a.variant ?? 'outline';
|
|
11
|
+
const accent = a.buttonColor ?? DEFAULT_ACCENT;
|
|
12
|
+
return {
|
|
13
|
+
accent: a.modalAccentColor ?? accent,
|
|
14
|
+
radius: a.borderRadius ?? 8,
|
|
15
|
+
buttonBg: variant === 'solid' ? accent : '#ffffff',
|
|
16
|
+
buttonFg: a.buttonTextColor ?? (variant === 'solid' ? '#ffffff' : accent),
|
|
17
|
+
buttonBorder: accent,
|
|
18
|
+
fontFamily: a.fontFamily
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DEFAULT_ACCENT","resolveTheme","appearance","a","variant","accent","buttonColor","modalAccentColor","radius","borderRadius","buttonBg","buttonFg","buttonTextColor","buttonBorder","fontFamily"],"sourceRoot":"..\\..\\..\\src","sources":["internal/theme.ts"],"mappings":";;AACA,SAASA,cAAc,QAAQ,aAAa;;AAE5C;;AAUA;AACA,OAAO,SAASC,YAAYA,CAACC,UAA+B,EAAiB;EAC3E,MAAMC,CAAC,GAAGD,UAAU,IAAI,CAAC,CAAC;EAC1B,MAAME,OAAO,GAAGD,CAAC,CAACC,OAAO,IAAI,SAAS;EACtC,MAAMC,MAAM,GAAGF,CAAC,CAACG,WAAW,IAAIN,cAAc;EAE9C,OAAO;IACLK,MAAM,EAAEF,CAAC,CAACI,gBAAgB,IAAIF,MAAM;IACpCG,MAAM,EAAEL,CAAC,CAACM,YAAY,IAAI,CAAC;IAC3BC,QAAQ,EAAEN,OAAO,KAAK,OAAO,GAAGC,MAAM,GAAG,SAAS;IAClDM,QAAQ,EAAER,CAAC,CAACS,eAAe,KAAKR,OAAO,KAAK,OAAO,GAAG,SAAS,GAAGC,MAAM,CAAC;IACzEQ,YAAY,EAAER,MAAM;IACpBS,UAAU,EAAEX,CAAC,CAACW;EAChB,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"..\\..\\src","sources":["types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CheckoutResponse, VerifyCryptoPayload, VerifyCryptoResponse } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* A small, typed wrapper around the ClockPay REST API.
|
|
4
|
+
*
|
|
5
|
+
* Each client carries its own public key on a dedicated axios instance. The base
|
|
6
|
+
* URL is selected from the key's environment prefix (`cpay_test_pk_` → dev
|
|
7
|
+
* gateway, `cpay_live_pk_` → live gateway) unless `apiBaseUrl` overrides it.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ClockPayClient {
|
|
10
|
+
private readonly http;
|
|
11
|
+
constructor(publicKey: string, apiBaseUrl?: string);
|
|
12
|
+
/** Initiates a checkout for the given client secret. */
|
|
13
|
+
initiatePayment(clientSecret: string): Promise<CheckoutResponse>;
|
|
14
|
+
/** Verifies an on-chain transaction by hash. */
|
|
15
|
+
verifyCrypto(payload: VerifyCryptoPayload): Promise<VerifyCryptoResponse>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/api/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,UAAU,CAAC;AAclB;;;;;;GAMG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAgB;gBAEzB,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;IAclD,wDAAwD;IAClD,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAetE,gDAAgD;IAC1C,YAAY,CAChB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,oBAAoB,CAAC;CAWjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../../src/api/endpoints.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;;;EAGpB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
interface BottomSheetProps {
|
|
3
|
+
visible: boolean;
|
|
4
|
+
/** Called when the user requests to close (backdrop, drag, hardware back). */
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
/** Called after the exit animation completes — safe to unmount/reset here. */
|
|
7
|
+
onClosed?: () => void;
|
|
8
|
+
/** When false, tapping the dimmed backdrop will not dismiss the sheet. Defaults to true. */
|
|
9
|
+
closeOnBackdropPress?: boolean;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A Stripe-style bottom sheet: slides up from the bottom over a dimmed backdrop,
|
|
14
|
+
* with drag-to-dismiss on the handle. Built on RN primitives — no native deps.
|
|
15
|
+
*/
|
|
16
|
+
export declare function BottomSheet({ visible, onClose, onClosed, closeOnBackdropPress, children, }: BottomSheetProps): import("react").JSX.Element;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=bottom-sheet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bottom-sheet.d.ts","sourceRoot":"","sources":["../../../src/components/bottom-sheet.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAWpE,UAAU,gBAAgB;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,8EAA8E;IAC9E,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,4FAA4F;IAC5F,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAKD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAC1B,OAAO,EACP,OAAO,EACP,QAAQ,EACR,oBAA2B,EAC3B,QAAQ,GACT,EAAE,gBAAgB,+BA6FlB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface IconProps {
|
|
2
|
+
size?: number;
|
|
3
|
+
color?: string;
|
|
4
|
+
}
|
|
5
|
+
/** ClockPay brandmark. */
|
|
6
|
+
export declare function LogoIcon({ size }: IconProps): import("react").JSX.Element;
|
|
7
|
+
export declare function CloseIcon({ size, color }: IconProps): import("react").JSX.Element;
|
|
8
|
+
export declare function CopyIcon({ size, color }: IconProps): import("react").JSX.Element;
|
|
9
|
+
export declare function InfoIcon({ size }: IconProps): import("react").JSX.Element;
|
|
10
|
+
export declare function CheckIcon({ size }: IconProps): import("react").JSX.Element;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=icons.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../../src/components/icons.tsx"],"names":[],"mappings":"AAEA,UAAU,SAAS;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,0BAA0B;AAC1B,wBAAgB,QAAQ,CAAC,EAAE,IAAS,EAAE,EAAE,SAAS,+BAahD;AAED,wBAAgB,SAAS,CAAC,EAAE,IAAS,EAAE,KAAiB,EAAE,EAAE,SAAS,+BAiBpE;AAED,wBAAgB,QAAQ,CAAC,EAAE,IAAS,EAAE,KAAiB,EAAE,EAAE,SAAS,+BAmBnE;AAED,wBAAgB,QAAQ,CAAC,EAAE,IAAS,EAAE,EAAE,SAAS,+BAWhD;AAED,wBAAgB,SAAS,CAAC,EAAE,IAAS,EAAE,EAAE,SAAS,+BAajD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PaymentButtonProps } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Drop-in payment button for React Native. Renders a "Pay with Clockpay" trigger
|
|
4
|
+
* that initiates a checkout and opens a Stripe-style bottom-sheet payment modal.
|
|
5
|
+
*/
|
|
6
|
+
export declare function PaymentButton({ publicKey, clientSecret, appearance, label, disabled, apiBaseUrl, redirectUrl, onSuccess, onError, onClose, }: PaymentButtonProps): import("react").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=payment-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-button.d.ts","sourceRoot":"","sources":["../../../src/components/payment-button.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgB,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAMjE;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAC5B,SAAS,EACT,YAAY,EACZ,UAAU,EACV,KAA2B,EAC3B,QAAQ,EACR,UAAU,EACV,WAAW,EACX,SAAS,EACT,OAAO,EACP,OAAO,GACR,EAAE,kBAAkB,+BA2EpB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CheckoutData, VerifyCryptoResponse } from '../types';
|
|
2
|
+
import type { ResolvedTheme } from '../internal/theme';
|
|
3
|
+
interface PaymentSheetProps {
|
|
4
|
+
visible: boolean;
|
|
5
|
+
checkout: CheckoutData;
|
|
6
|
+
publicKey: string;
|
|
7
|
+
apiBaseUrl?: string;
|
|
8
|
+
theme: ResolvedTheme;
|
|
9
|
+
redirectUrl?: string;
|
|
10
|
+
onRequestClose: () => void;
|
|
11
|
+
onClosed: () => void;
|
|
12
|
+
onSuccess?: (data: VerifyCryptoResponse) => void;
|
|
13
|
+
onError?: (error: Error) => void;
|
|
14
|
+
}
|
|
15
|
+
export declare function PaymentSheet({ visible, checkout, publicKey, apiBaseUrl, theme, redirectUrl, onRequestClose, onClosed, onSuccess, onError, }: PaymentSheetProps): import("react").JSX.Element;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=payment-sheet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-sheet.d.ts","sourceRoot":"","sources":["../../../src/components/payment-sheet.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAavD,UAAU,iBAAiB;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,aAAa,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACjD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,QAAQ,EACR,SAAS,EACT,UAAU,EACV,KAAK,EACL,WAAW,EACX,cAAc,EACd,QAAQ,EACR,SAAS,EACT,OAAO,GACR,EAAE,iBAAiB,+BA6FnB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ResolvedTheme } from '../../internal/theme';
|
|
2
|
+
interface StatusViewProps {
|
|
3
|
+
theme: ResolvedTheme;
|
|
4
|
+
busy: boolean;
|
|
5
|
+
success: boolean;
|
|
6
|
+
error: string | null;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
}
|
|
9
|
+
/** Terminal step: processing spinner, success confirmation, or an error. */
|
|
10
|
+
export declare function StatusView({ theme, busy, success, error, onClose }: StatusViewProps): import("react").JSX.Element;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=status-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-view.d.ts","sourceRoot":"","sources":["../../../../src/components/views/status-view.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,UAAU,eAAe;IACvB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,4EAA4E;AAC5E,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,eAAe,+BAsCnF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CheckoutData } from '../../types';
|
|
2
|
+
import type { ResolvedTheme } from '../../internal/theme';
|
|
3
|
+
interface TransferViewProps {
|
|
4
|
+
checkout: CheckoutData;
|
|
5
|
+
theme: ResolvedTheme;
|
|
6
|
+
formattedTime: string;
|
|
7
|
+
expired: boolean;
|
|
8
|
+
onNext: () => void;
|
|
9
|
+
}
|
|
10
|
+
/** Manual-transfer flow: QR + deposit address + notes + countdown. */
|
|
11
|
+
export declare function TransferView({ checkout, theme, formattedTime, expired, onNext, }: TransferViewProps): import("react").JSX.Element;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=transfer-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer-view.d.ts","sourceRoot":"","sources":["../../../../src/components/views/transfer-view.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,UAAU,iBAAiB;IACzB,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,EAAE,aAAa,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,sEAAsE;AACtE,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,KAAK,EACL,aAAa,EACb,OAAO,EACP,MAAM,GACP,EAAE,iBAAiB,+BA2DnB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ResolvedTheme } from '../../internal/theme';
|
|
2
|
+
interface VerifyViewProps {
|
|
3
|
+
theme: ResolvedTheme;
|
|
4
|
+
busy: boolean;
|
|
5
|
+
onSubmit: (trxHash: string) => void;
|
|
6
|
+
}
|
|
7
|
+
/** Step where the buyer pastes their transaction hash to confirm the transfer. */
|
|
8
|
+
export declare function VerifyView({ theme, busy, onSubmit }: VerifyViewProps): import("react").JSX.Element;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=verify-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-view.d.ts","sourceRoot":"","sources":["../../../../src/components/views/verify-view.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,UAAU,eAAe;IACvB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAED,kFAAkF;AAClF,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,eAAe,+BAuCpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-countdown.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-countdown.ts"],"names":[],"mappings":"AAGA,qDAAqD;AACrD,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM;;;;;EAe3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** API gateway for test keys (`cpay_test_pk_…`). */
|
|
2
|
+
export declare const TEST_API_BASE_URL = "https://api.dev.theclockchain.io/api/v1";
|
|
3
|
+
/** API gateway for live keys (`cpay_live_pk_…`). */
|
|
4
|
+
export declare const LIVE_API_BASE_URL = "https://api.theclockchain.io/api/v1";
|
|
5
|
+
/** ClockPay brand blue. */
|
|
6
|
+
export declare const DEFAULT_ACCENT = "#27AAE1";
|
|
7
|
+
/** How long the buyer has to complete a transfer, in seconds. */
|
|
8
|
+
export declare const COUNTDOWN_SECONDS = 300;
|
|
9
|
+
/**
|
|
10
|
+
* Picks the API gateway from the public key's environment prefix, unless an
|
|
11
|
+
* explicit `override` (the `apiBaseUrl` prop) is provided. Unknown prefixes fall
|
|
12
|
+
* back to the test gateway.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveApiBaseUrl(publicKey: string, override?: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Maps a coin's settlement network to its on-chain id, used when verifying a
|
|
17
|
+
* crypto transaction. Falls back to the `networkCode` from the checkout payload.
|
|
18
|
+
*/
|
|
19
|
+
export declare const NETWORK_CODES: Record<string, string>;
|
|
20
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/internal/constants.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,eAAO,MAAM,iBAAiB,4CAA4C,CAAC;AAE3E,oDAAoD;AACpD,eAAO,MAAM,iBAAiB,wCAAwC,CAAC;AAEvE,2BAA2B;AAC3B,eAAO,MAAM,cAAc,YAAY,CAAC;AAExC,iEAAiE;AACjE,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAI9E;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAMhD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Formats a number of seconds as `MM:SS`. */
|
|
2
|
+
export declare function formatTime(totalSeconds: number): string;
|
|
3
|
+
/** Resolves the on-chain code used to verify a transaction for a given checkout. */
|
|
4
|
+
export declare function resolveNetworkCode(network?: string, fallback?: string): string;
|
|
5
|
+
/** Truncates a long address for compact display: `0x1234…abcd`. */
|
|
6
|
+
export declare function truncateMiddle(value: string, lead?: number, tail?: number): string;
|
|
7
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/internal/format.ts"],"names":[],"mappings":"AAEA,8CAA8C;AAC9C,wBAAgB,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAKvD;AAED,oFAAoF;AACpF,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAG9E;AAED,mEAAmE;AACnE,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,SAAK,EAAE,IAAI,SAAI,GAAG,MAAM,CAGzE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ClockPayAppearance } from '../types';
|
|
2
|
+
/** Concrete colours/values resolved from an {@link ClockPayAppearance}. */
|
|
3
|
+
export interface ResolvedTheme {
|
|
4
|
+
accent: string;
|
|
5
|
+
radius: number;
|
|
6
|
+
buttonBg: string;
|
|
7
|
+
buttonFg: string;
|
|
8
|
+
buttonBorder: string;
|
|
9
|
+
fontFamily?: string;
|
|
10
|
+
}
|
|
11
|
+
/** Resolves an appearance object into concrete style values for the RN UI. */
|
|
12
|
+
export declare function resolveTheme(appearance?: ClockPayAppearance): ResolvedTheme;
|
|
13
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/internal/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGnD,2EAA2E;AAC3E,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,8EAA8E;AAC9E,wBAAgB,YAAY,CAAC,UAAU,CAAC,EAAE,kBAAkB,GAAG,aAAa,CAa3E"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Visual customization for the ClockPay button and bottom-sheet modal.
|
|
4
|
+
* Mirrors the web SDK's Stripe-style appearance API.
|
|
5
|
+
*/
|
|
6
|
+
export interface ClockPayAppearance {
|
|
7
|
+
/** Button fill strategy. Defaults to `'outline'`. */
|
|
8
|
+
variant?: 'solid' | 'outline';
|
|
9
|
+
/** Primary brand colour. Defaults to `#27AAE1`. */
|
|
10
|
+
buttonColor?: string;
|
|
11
|
+
/** Overrides the button label colour. */
|
|
12
|
+
buttonTextColor?: string;
|
|
13
|
+
/** Corner radius for the button and primary actions. Defaults to `8`. */
|
|
14
|
+
borderRadius?: number;
|
|
15
|
+
/** Font family applied to SDK surfaces. */
|
|
16
|
+
fontFamily?: string;
|
|
17
|
+
/** Accent colour used inside the sheet (QR border, links, timer). Defaults to `buttonColor`. */
|
|
18
|
+
modalAccentColor?: string;
|
|
19
|
+
}
|
|
20
|
+
/** The environment a public key belongs to. */
|
|
21
|
+
export type ClockPayEnvironment = 'test' | 'live';
|
|
22
|
+
/** Payload returned by the checkout endpoint and rendered inside the sheet. */
|
|
23
|
+
export interface CheckoutData {
|
|
24
|
+
reference: string;
|
|
25
|
+
address: string;
|
|
26
|
+
network: string;
|
|
27
|
+
networkCode: string;
|
|
28
|
+
coin: string;
|
|
29
|
+
amount: number;
|
|
30
|
+
contractAddress: string;
|
|
31
|
+
}
|
|
32
|
+
export interface CheckoutResponse {
|
|
33
|
+
message: string;
|
|
34
|
+
data: CheckoutData;
|
|
35
|
+
}
|
|
36
|
+
export interface VerifyCryptoPayload {
|
|
37
|
+
reference: string;
|
|
38
|
+
trxHash: string;
|
|
39
|
+
code: string;
|
|
40
|
+
}
|
|
41
|
+
export interface VerifyCryptoResponse {
|
|
42
|
+
message: string;
|
|
43
|
+
}
|
|
44
|
+
/** Props for the public {@link PaymentButton} component. */
|
|
45
|
+
export interface PaymentButtonProps {
|
|
46
|
+
/** Public key from the business developer dashboard (e.g. `cpay_test_pk_...`). Required. */
|
|
47
|
+
publicKey: string;
|
|
48
|
+
/** Client secret returned from your server-side checkout call. Required. */
|
|
49
|
+
clientSecret: string;
|
|
50
|
+
/** Visual customization for the button and sheet. */
|
|
51
|
+
appearance?: ClockPayAppearance;
|
|
52
|
+
/** Button label. Defaults to "Pay with Clockpay". */
|
|
53
|
+
label?: ReactNode;
|
|
54
|
+
/** Disables the button. */
|
|
55
|
+
disabled?: boolean;
|
|
56
|
+
/** Override the API base URL. Defaults to the gateway matching the key prefix. */
|
|
57
|
+
apiBaseUrl?: string;
|
|
58
|
+
/** URL to open (via Linking) after a successful payment. Optional. */
|
|
59
|
+
redirectUrl?: string;
|
|
60
|
+
/** Called once the payment is confirmed on-chain. */
|
|
61
|
+
onSuccess?: (data: VerifyCryptoResponse) => void;
|
|
62
|
+
/** Called when initiating or verifying the payment fails. */
|
|
63
|
+
onError?: (error: Error) => void;
|
|
64
|
+
/** Called whenever the sheet closes, regardless of outcome. */
|
|
65
|
+
onClose?: () => void;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,qDAAqD;IACrD,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yCAAyC;IACzC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yEAAyE;IACzE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gGAAgG;IAChG,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,+CAA+C;AAC/C,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,MAAM,CAAC;AAElD,+EAA+E;AAC/E,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,4DAA4D;AAC5D,MAAM,WAAW,kBAAkB;IACjC,4FAA4F;IAC5F,SAAS,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,YAAY,EAAE,MAAM,CAAC;IACrB,qDAAqD;IACrD,UAAU,CAAC,EAAE,kBAAkB,CAAC;IAChC,qDAAqD;IACrD,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kFAAkF;IAClF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qDAAqD;IACrD,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACjD,6DAA6D;IAC7D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@clockpay/react-native",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A type-safe React Native SDK for accepting crypto payments with ClockPay — a Stripe-style bottom-sheet payment modal.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "ClockPay",
|
|
7
|
+
"homepage": "https://www.theclockchain.io/",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/Clocked-Ecosystem/clockpay-react-native"
|
|
11
|
+
},
|
|
12
|
+
"main": "lib/commonjs/index.js",
|
|
13
|
+
"module": "lib/module/index.js",
|
|
14
|
+
"types": "lib/typescript/index.d.ts",
|
|
15
|
+
"react-native": "src/index.ts",
|
|
16
|
+
"source": "src/index.ts",
|
|
17
|
+
"files": [
|
|
18
|
+
"src",
|
|
19
|
+
"lib",
|
|
20
|
+
"!**/__tests__",
|
|
21
|
+
"!**/__fixtures__"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "bob build",
|
|
25
|
+
"typecheck": "tsc --noEmit",
|
|
26
|
+
"prepublishOnly": "npm run build",
|
|
27
|
+
"release": "npm publish"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"react-native",
|
|
34
|
+
"clockpay",
|
|
35
|
+
"payment",
|
|
36
|
+
"crypto",
|
|
37
|
+
"usdt",
|
|
38
|
+
"bottom-sheet",
|
|
39
|
+
"b2b"
|
|
40
|
+
],
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"react": ">=18",
|
|
43
|
+
"react-native": ">=0.72",
|
|
44
|
+
"@react-native-clipboard/clipboard": ">=1.11",
|
|
45
|
+
"react-native-qrcode-svg": ">=6",
|
|
46
|
+
"react-native-svg": ">=13"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"axios": "^1.7.2"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@react-native-clipboard/clipboard": "^1.14.1",
|
|
53
|
+
"@types/react": "^18.3.12",
|
|
54
|
+
"react": "^18.3.1",
|
|
55
|
+
"react-native": "^0.75.4",
|
|
56
|
+
"react-native-builder-bob": "^0.30.3",
|
|
57
|
+
"react-native-qrcode-svg": "^6.3.2",
|
|
58
|
+
"react-native-svg": "^15.6.0",
|
|
59
|
+
"typescript": "~5.6.2"
|
|
60
|
+
},
|
|
61
|
+
"react-native-builder-bob": {
|
|
62
|
+
"source": "src",
|
|
63
|
+
"output": "lib",
|
|
64
|
+
"targets": [
|
|
65
|
+
"module",
|
|
66
|
+
"commonjs",
|
|
67
|
+
"typescript"
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import axios, { AxiosError, type AxiosInstance } from 'axios';
|
|
2
|
+
import { endpoints } from './endpoints';
|
|
3
|
+
import { resolveApiBaseUrl } from '../internal/constants';
|
|
4
|
+
import type {
|
|
5
|
+
CheckoutResponse,
|
|
6
|
+
VerifyCryptoPayload,
|
|
7
|
+
VerifyCryptoResponse,
|
|
8
|
+
} from '../types';
|
|
9
|
+
|
|
10
|
+
/** Normalizes an unknown thrown value into a useful `Error`. */
|
|
11
|
+
function toError(error: unknown, fallback: string): Error {
|
|
12
|
+
if (error instanceof AxiosError) {
|
|
13
|
+
const message =
|
|
14
|
+
(error.response?.data as { message?: string } | undefined)?.message ??
|
|
15
|
+
error.message;
|
|
16
|
+
return new Error(message || fallback);
|
|
17
|
+
}
|
|
18
|
+
if (error instanceof Error) return error;
|
|
19
|
+
return new Error(fallback);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A small, typed wrapper around the ClockPay REST API.
|
|
24
|
+
*
|
|
25
|
+
* Each client carries its own public key on a dedicated axios instance. The base
|
|
26
|
+
* URL is selected from the key's environment prefix (`cpay_test_pk_` → dev
|
|
27
|
+
* gateway, `cpay_live_pk_` → live gateway) unless `apiBaseUrl` overrides it.
|
|
28
|
+
*/
|
|
29
|
+
export class ClockPayClient {
|
|
30
|
+
private readonly http: AxiosInstance;
|
|
31
|
+
|
|
32
|
+
constructor(publicKey: string, apiBaseUrl?: string) {
|
|
33
|
+
if (!publicKey) {
|
|
34
|
+
throw new Error('ClockPay: a publicKey is required.');
|
|
35
|
+
}
|
|
36
|
+
this.http = axios.create({
|
|
37
|
+
baseURL: resolveApiBaseUrl(publicKey, apiBaseUrl),
|
|
38
|
+
headers: {
|
|
39
|
+
Accept: 'application/json',
|
|
40
|
+
'Content-Type': 'application/json',
|
|
41
|
+
'clock-pub-key': publicKey,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Initiates a checkout for the given client secret. */
|
|
47
|
+
async initiatePayment(clientSecret: string): Promise<CheckoutResponse> {
|
|
48
|
+
if (!clientSecret) {
|
|
49
|
+
throw new Error('ClockPay: a clientSecret is required.');
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const { data } = await this.http.post<CheckoutResponse>(
|
|
53
|
+
endpoints.initiatePayment,
|
|
54
|
+
{ clientSecret }
|
|
55
|
+
);
|
|
56
|
+
return data;
|
|
57
|
+
} catch (error) {
|
|
58
|
+
throw toError(error, 'Failed to initiate payment.');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Verifies an on-chain transaction by hash. */
|
|
63
|
+
async verifyCrypto(
|
|
64
|
+
payload: VerifyCryptoPayload
|
|
65
|
+
): Promise<VerifyCryptoResponse> {
|
|
66
|
+
try {
|
|
67
|
+
const { data } = await this.http.post<VerifyCryptoResponse>(
|
|
68
|
+
endpoints.verifyCrypto,
|
|
69
|
+
payload
|
|
70
|
+
);
|
|
71
|
+
return data;
|
|
72
|
+
} catch (error) {
|
|
73
|
+
throw toError(error, 'Failed to verify transaction.');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|