@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.mjs
CHANGED
|
@@ -83,7 +83,7 @@ var API_BASE_URL_PRODUCTION = "https://api.reevit.io";
|
|
|
83
83
|
var API_BASE_URL_SANDBOX = "https://sandbox-api.reevit.io";
|
|
84
84
|
var DEFAULT_TIMEOUT = 3e4;
|
|
85
85
|
function isSandboxKey(publicKey) {
|
|
86
|
-
return publicKey.startsWith("pk_test_") || publicKey.startsWith("pk_sandbox_");
|
|
86
|
+
return publicKey.startsWith("pk_test_") || publicKey.startsWith("pk_sandbox_") || publicKey.startsWith("pfk_test_") || publicKey.startsWith("pfk_sandbox_");
|
|
87
87
|
}
|
|
88
88
|
function createPaymentError(response, errorData) {
|
|
89
89
|
return {
|
|
@@ -107,15 +107,19 @@ var ReevitAPIClient = class {
|
|
|
107
107
|
async request(method, path, body) {
|
|
108
108
|
const controller = new AbortController();
|
|
109
109
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
110
|
+
const headers = {
|
|
111
|
+
"Content-Type": "application/json",
|
|
112
|
+
"X-Reevit-Key": this.publicKey,
|
|
113
|
+
"X-Reevit-Client": "@reevit/react",
|
|
114
|
+
"X-Reevit-Client-Version": "0.2.3"
|
|
115
|
+
};
|
|
116
|
+
if (method === "POST" || method === "PATCH" || method === "PUT") {
|
|
117
|
+
headers["Idempotency-Key"] = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
|
|
118
|
+
}
|
|
110
119
|
try {
|
|
111
120
|
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
112
121
|
method,
|
|
113
|
-
headers
|
|
114
|
-
"Content-Type": "application/json",
|
|
115
|
-
"Authorization": `Bearer ${this.publicKey}`,
|
|
116
|
-
"X-Reevit-Client": "@reevit/react",
|
|
117
|
-
"X-Reevit-Client-Version": "1.0.0"
|
|
118
|
-
},
|
|
122
|
+
headers,
|
|
119
123
|
body: body ? JSON.stringify(body) : void 0,
|
|
120
124
|
signal: controller.signal
|
|
121
125
|
});
|
|
@@ -737,7 +741,8 @@ function ReevitCheckout({
|
|
|
737
741
|
// UI
|
|
738
742
|
children,
|
|
739
743
|
autoOpen = false,
|
|
740
|
-
theme
|
|
744
|
+
theme,
|
|
745
|
+
apiBaseUrl
|
|
741
746
|
}) {
|
|
742
747
|
const [isOpen, setIsOpen] = useState(autoOpen);
|
|
743
748
|
const [showPSPBridge, setShowPSPBridge] = useState(false);
|
|
@@ -757,6 +762,7 @@ function ReevitCheckout({
|
|
|
757
762
|
isComplete
|
|
758
763
|
} = useReevit({
|
|
759
764
|
config: { publicKey, amount, currency, email, phone, reference, metadata, paymentMethods },
|
|
765
|
+
apiBaseUrl,
|
|
760
766
|
onSuccess: (result2) => {
|
|
761
767
|
onSuccess?.(result2);
|
|
762
768
|
setTimeout(() => {
|