@reevit/react 0.2.2 → 0.2.4
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/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +14 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -41,6 +41,8 @@ interface ReevitCheckoutProps extends ReevitCheckoutConfig, ReevitCheckoutCallba
|
|
|
41
41
|
autoOpen?: boolean;
|
|
42
42
|
/** Custom theme */
|
|
43
43
|
theme?: ReevitTheme;
|
|
44
|
+
/** Custom API base URL (for testing or self-hosted deployments) */
|
|
45
|
+
apiBaseUrl?: string;
|
|
44
46
|
}
|
|
45
47
|
type CheckoutState = 'idle' | 'loading' | 'ready' | 'method_selected' | 'processing' | 'success' | 'failed' | 'closed';
|
|
46
48
|
interface PaymentResult {
|
|
@@ -130,7 +132,7 @@ interface ReevitContextValue {
|
|
|
130
132
|
currency: string;
|
|
131
133
|
}
|
|
132
134
|
declare function useReevitContext(): ReevitContextValue;
|
|
133
|
-
declare function ReevitCheckout({ publicKey, amount, currency, email, phone, reference, metadata, paymentMethods, onSuccess, onError, onClose, onStateChange, children, autoOpen, theme, }: ReevitCheckoutProps): react_jsx_runtime.JSX.Element;
|
|
135
|
+
declare function ReevitCheckout({ publicKey, amount, currency, email, phone, reference, metadata, paymentMethods, onSuccess, onError, onClose, onStateChange, children, autoOpen, theme, apiBaseUrl, }: ReevitCheckoutProps): react_jsx_runtime.JSX.Element;
|
|
134
136
|
|
|
135
137
|
interface PaymentMethodSelectorProps {
|
|
136
138
|
methods: PaymentMethod[];
|
package/dist/index.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ interface ReevitCheckoutProps extends ReevitCheckoutConfig, ReevitCheckoutCallba
|
|
|
41
41
|
autoOpen?: boolean;
|
|
42
42
|
/** Custom theme */
|
|
43
43
|
theme?: ReevitTheme;
|
|
44
|
+
/** Custom API base URL (for testing or self-hosted deployments) */
|
|
45
|
+
apiBaseUrl?: string;
|
|
44
46
|
}
|
|
45
47
|
type CheckoutState = 'idle' | 'loading' | 'ready' | 'method_selected' | 'processing' | 'success' | 'failed' | 'closed';
|
|
46
48
|
interface PaymentResult {
|
|
@@ -130,7 +132,7 @@ interface ReevitContextValue {
|
|
|
130
132
|
currency: string;
|
|
131
133
|
}
|
|
132
134
|
declare function useReevitContext(): ReevitContextValue;
|
|
133
|
-
declare function ReevitCheckout({ publicKey, amount, currency, email, phone, reference, metadata, paymentMethods, onSuccess, onError, onClose, onStateChange, children, autoOpen, theme, }: ReevitCheckoutProps): react_jsx_runtime.JSX.Element;
|
|
135
|
+
declare function ReevitCheckout({ publicKey, amount, currency, email, phone, reference, metadata, paymentMethods, onSuccess, onError, onClose, onStateChange, children, autoOpen, theme, apiBaseUrl, }: ReevitCheckoutProps): react_jsx_runtime.JSX.Element;
|
|
134
136
|
|
|
135
137
|
interface PaymentMethodSelectorProps {
|
|
136
138
|
methods: PaymentMethod[];
|
package/dist/index.js
CHANGED
|
@@ -85,7 +85,7 @@ var API_BASE_URL_PRODUCTION = "https://api.reevit.io";
|
|
|
85
85
|
var API_BASE_URL_SANDBOX = "https://sandbox-api.reevit.io";
|
|
86
86
|
var DEFAULT_TIMEOUT = 3e4;
|
|
87
87
|
function isSandboxKey(publicKey) {
|
|
88
|
-
return publicKey.startsWith("pk_test_") || publicKey.startsWith("pk_sandbox_");
|
|
88
|
+
return publicKey.startsWith("pk_test_") || publicKey.startsWith("pk_sandbox_") || publicKey.startsWith("pfk_test_") || publicKey.startsWith("pfk_sandbox_");
|
|
89
89
|
}
|
|
90
90
|
function createPaymentError(response, errorData) {
|
|
91
91
|
return {
|
|
@@ -109,15 +109,19 @@ var ReevitAPIClient = class {
|
|
|
109
109
|
async request(method, path, body) {
|
|
110
110
|
const controller = new AbortController();
|
|
111
111
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
112
|
+
const headers = {
|
|
113
|
+
"Content-Type": "application/json",
|
|
114
|
+
"X-Reevit-Key": this.publicKey,
|
|
115
|
+
"X-Reevit-Client": "@reevit/react",
|
|
116
|
+
"X-Reevit-Client-Version": "0.2.3"
|
|
117
|
+
};
|
|
118
|
+
if (method === "POST" || method === "PATCH" || method === "PUT") {
|
|
119
|
+
headers["Idempotency-Key"] = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
|
|
120
|
+
}
|
|
112
121
|
try {
|
|
113
122
|
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
114
123
|
method,
|
|
115
|
-
headers
|
|
116
|
-
"Content-Type": "application/json",
|
|
117
|
-
"Authorization": `Bearer ${this.publicKey}`,
|
|
118
|
-
"X-Reevit-Client": "@reevit/react",
|
|
119
|
-
"X-Reevit-Client-Version": "1.0.0"
|
|
120
|
-
},
|
|
124
|
+
headers,
|
|
121
125
|
body: body ? JSON.stringify(body) : void 0,
|
|
122
126
|
signal: controller.signal
|
|
123
127
|
});
|
|
@@ -739,7 +743,8 @@ function ReevitCheckout({
|
|
|
739
743
|
// UI
|
|
740
744
|
children,
|
|
741
745
|
autoOpen = false,
|
|
742
|
-
theme
|
|
746
|
+
theme,
|
|
747
|
+
apiBaseUrl
|
|
743
748
|
}) {
|
|
744
749
|
const [isOpen, setIsOpen] = react.useState(autoOpen);
|
|
745
750
|
const [showPSPBridge, setShowPSPBridge] = react.useState(false);
|
|
@@ -759,6 +764,7 @@ function ReevitCheckout({
|
|
|
759
764
|
isComplete
|
|
760
765
|
} = useReevit({
|
|
761
766
|
config: { publicKey, amount, currency, email, phone, reference, metadata, paymentMethods },
|
|
767
|
+
apiBaseUrl,
|
|
762
768
|
onSuccess: (result2) => {
|
|
763
769
|
onSuccess?.(result2);
|
|
764
770
|
setTimeout(() => {
|