@reevit/react 0.2.5 → 0.2.7
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.js +22 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -111,7 +111,7 @@ var ReevitAPIClient = class {
|
|
|
111
111
|
"Content-Type": "application/json",
|
|
112
112
|
"X-Reevit-Key": this.publicKey,
|
|
113
113
|
"X-Reevit-Client": "@reevit/react",
|
|
114
|
-
"X-Reevit-Client-Version": "0.2.
|
|
114
|
+
"X-Reevit-Client-Version": "0.2.5"
|
|
115
115
|
};
|
|
116
116
|
if (method === "POST" || method === "PATCH" || method === "PUT") {
|
|
117
117
|
headers["Idempotency-Key"] = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
|
|
@@ -668,9 +668,18 @@ function PaystackBridge({
|
|
|
668
668
|
const initialized = useRef(false);
|
|
669
669
|
const startPayment = useCallback(async () => {
|
|
670
670
|
try {
|
|
671
|
+
if (!publicKey) {
|
|
672
|
+
throw new Error("Paystack public key is required but was empty");
|
|
673
|
+
}
|
|
674
|
+
if (!email) {
|
|
675
|
+
throw new Error("Email is required for Paystack payments");
|
|
676
|
+
}
|
|
677
|
+
if (!amount || amount <= 0) {
|
|
678
|
+
throw new Error("Valid amount is required for Paystack payments");
|
|
679
|
+
}
|
|
671
680
|
await loadPaystackScript();
|
|
672
681
|
if (!window.PaystackPop) {
|
|
673
|
-
throw new Error("Paystack not available");
|
|
682
|
+
throw new Error("Paystack script loaded but PaystackPop not available");
|
|
674
683
|
}
|
|
675
684
|
const handler = window.PaystackPop.setup({
|
|
676
685
|
key: publicKey,
|
|
@@ -702,9 +711,10 @@ function PaystackBridge({
|
|
|
702
711
|
});
|
|
703
712
|
handler.openIframe();
|
|
704
713
|
} catch (err) {
|
|
714
|
+
const errorMessage = err instanceof Error ? err.message : "Failed to initialize Paystack";
|
|
705
715
|
const error = {
|
|
706
716
|
code: "PSP_ERROR",
|
|
707
|
-
message:
|
|
717
|
+
message: errorMessage,
|
|
708
718
|
recoverable: true,
|
|
709
719
|
originalError: err
|
|
710
720
|
};
|
|
@@ -876,10 +886,16 @@ function ReevitCheckout({
|
|
|
876
886
|
{
|
|
877
887
|
publicKey: pspKey,
|
|
878
888
|
email,
|
|
879
|
-
amount,
|
|
880
|
-
currency,
|
|
889
|
+
amount: paymentIntent?.amount ?? amount,
|
|
890
|
+
currency: paymentIntent?.currency ?? currency,
|
|
881
891
|
reference,
|
|
882
|
-
metadata
|
|
892
|
+
metadata: {
|
|
893
|
+
...metadata,
|
|
894
|
+
// Override with correct payment intent ID for webhook routing
|
|
895
|
+
// This ensures Paystack webhook includes the correct ID to find the payment
|
|
896
|
+
payment_id: paymentIntent?.id,
|
|
897
|
+
connection_id: paymentIntent?.connectionId ?? metadata?.connection_id
|
|
898
|
+
},
|
|
883
899
|
channels: selectedMethod === "mobile_money" ? ["mobile_money"] : ["card"],
|
|
884
900
|
onSuccess: handlePSPSuccess,
|
|
885
901
|
onError: handlePSPError,
|