@miden-npm/react 0.0.18 → 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/dist/index.cjs +98 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -3
- package/dist/index.d.ts +16 -3
- package/dist/index.js +98 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1783,7 +1783,8 @@ function BzpCheckoutIframe({
|
|
|
1783
1783
|
phoneNumber: "",
|
|
1784
1784
|
narration: "",
|
|
1785
1785
|
redirectUrl: "https://sandbox-merchant.buzapay.com/account/three-ds-status"
|
|
1786
|
-
}
|
|
1786
|
+
},
|
|
1787
|
+
onError
|
|
1787
1788
|
}) {
|
|
1788
1789
|
const containerRef = (0, import_react6.useRef)(null);
|
|
1789
1790
|
const iframeRef = (0, import_react6.useRef)(null);
|
|
@@ -1819,21 +1820,30 @@ function BzpCheckoutIframe({
|
|
|
1819
1820
|
return setMessage("Secret key is required.");
|
|
1820
1821
|
}
|
|
1821
1822
|
setLoading(true);
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1823
|
+
try {
|
|
1824
|
+
const response = await createPaymentLink(
|
|
1825
|
+
paymentObject,
|
|
1826
|
+
environment,
|
|
1827
|
+
secretKey
|
|
1828
|
+
);
|
|
1829
|
+
if (response?.isSuccessful) {
|
|
1830
|
+
setLaunchUrl(response.launchUrl ?? "");
|
|
1831
|
+
setMessage("Payment link created successfully");
|
|
1832
|
+
if (response.launchUrl) {
|
|
1833
|
+
setLoading(false);
|
|
1834
|
+
launchIframe(`${response.launchUrl}&merchantId=${btoa(secretKey)}`);
|
|
1835
|
+
}
|
|
1836
|
+
} else {
|
|
1831
1837
|
setLoading(false);
|
|
1832
|
-
|
|
1838
|
+
setMessage("Failed to create payment link");
|
|
1833
1839
|
}
|
|
1834
|
-
}
|
|
1840
|
+
} catch (e) {
|
|
1841
|
+
setMessage(e?.message || "Failed to create payment link");
|
|
1842
|
+
onError?.({
|
|
1843
|
+
errorMessage: message
|
|
1844
|
+
});
|
|
1845
|
+
} finally {
|
|
1835
1846
|
setLoading(false);
|
|
1836
|
-
setMessage("Failed to create payment link");
|
|
1837
1847
|
}
|
|
1838
1848
|
};
|
|
1839
1849
|
(0, import_react6.useEffect)(() => {
|
|
@@ -1860,7 +1870,8 @@ function BzpCheckoutButton({
|
|
|
1860
1870
|
narration: "",
|
|
1861
1871
|
redirectUrl: "https://sandbox-merchant.buzapay.com/account/three-ds-status"
|
|
1862
1872
|
},
|
|
1863
|
-
mode = "redirect"
|
|
1873
|
+
mode = "redirect",
|
|
1874
|
+
onError
|
|
1864
1875
|
}) {
|
|
1865
1876
|
const [message, setMessage] = (0, import_react7.useState)("");
|
|
1866
1877
|
const [launchUrl, setLaunchUrl] = (0, import_react7.useState)("");
|
|
@@ -1895,6 +1906,9 @@ function BzpCheckoutButton({
|
|
|
1895
1906
|
}
|
|
1896
1907
|
} catch (e) {
|
|
1897
1908
|
setMessage(e?.message || "Failed to create payment link");
|
|
1909
|
+
onError?.({
|
|
1910
|
+
errorMessage: message
|
|
1911
|
+
});
|
|
1898
1912
|
} finally {
|
|
1899
1913
|
setLoading(false);
|
|
1900
1914
|
}
|
|
@@ -1931,7 +1945,8 @@ function PayByCard({
|
|
|
1931
1945
|
secretKey,
|
|
1932
1946
|
paymentObject,
|
|
1933
1947
|
environment = "sandbox",
|
|
1934
|
-
onPaymentAuthorized
|
|
1948
|
+
onPaymentAuthorized,
|
|
1949
|
+
onError
|
|
1935
1950
|
}) {
|
|
1936
1951
|
const [formIndex, setFormIndex] = (0, import_react8.useState)(0);
|
|
1937
1952
|
const [message, setMessage] = (0, import_react8.useState)("");
|
|
@@ -2111,7 +2126,8 @@ function PayByCard({
|
|
|
2111
2126
|
paymentId: response.transactionReference,
|
|
2112
2127
|
paymentDate: response?.data?.updatedAt,
|
|
2113
2128
|
// optional if present
|
|
2114
|
-
paymentStatus: "
|
|
2129
|
+
paymentStatus: "authorized",
|
|
2130
|
+
message
|
|
2115
2131
|
});
|
|
2116
2132
|
}
|
|
2117
2133
|
setMessage("Card payment authorized successfully");
|
|
@@ -2122,7 +2138,8 @@ function PayByCard({
|
|
|
2122
2138
|
onPaymentAuthorized?.({
|
|
2123
2139
|
paymentId: response?.transactionReference,
|
|
2124
2140
|
paymentDate: response?.data?.updatedAt,
|
|
2125
|
-
paymentStatus: "
|
|
2141
|
+
paymentStatus: "payment failed",
|
|
2142
|
+
message
|
|
2126
2143
|
});
|
|
2127
2144
|
setIsMakingPayment(false);
|
|
2128
2145
|
} catch (err) {
|
|
@@ -2142,6 +2159,9 @@ function PayByCard({
|
|
|
2142
2159
|
}
|
|
2143
2160
|
setMessage(friendly);
|
|
2144
2161
|
setIsMakingPayment(false);
|
|
2162
|
+
onError?.({
|
|
2163
|
+
errorMessage: message
|
|
2164
|
+
});
|
|
2145
2165
|
}
|
|
2146
2166
|
}
|
|
2147
2167
|
};
|
|
@@ -2171,6 +2191,9 @@ function PayByCard({
|
|
|
2171
2191
|
}
|
|
2172
2192
|
} catch (e) {
|
|
2173
2193
|
setMessage(e?.message || "Failed to create payment link");
|
|
2194
|
+
onError?.({
|
|
2195
|
+
errorMessage: message
|
|
2196
|
+
});
|
|
2174
2197
|
} finally {
|
|
2175
2198
|
setLoading(false);
|
|
2176
2199
|
}
|
|
@@ -2192,6 +2215,9 @@ function PayByCard({
|
|
|
2192
2215
|
}
|
|
2193
2216
|
} catch (e) {
|
|
2194
2217
|
setMessage(e?.message || "Failed to get countries");
|
|
2218
|
+
onError?.({
|
|
2219
|
+
errorMessage: message
|
|
2220
|
+
});
|
|
2195
2221
|
} finally {
|
|
2196
2222
|
setLoadingCountries(false);
|
|
2197
2223
|
}
|
|
@@ -2216,6 +2242,9 @@ function PayByCard({
|
|
|
2216
2242
|
}
|
|
2217
2243
|
} catch (e) {
|
|
2218
2244
|
setMessage(e?.message || "Failed to get country states");
|
|
2245
|
+
onError?.({
|
|
2246
|
+
errorMessage: message
|
|
2247
|
+
});
|
|
2219
2248
|
} finally {
|
|
2220
2249
|
setLoadingStates(false);
|
|
2221
2250
|
}
|
|
@@ -2466,7 +2495,8 @@ var PayByTransfer = ({
|
|
|
2466
2495
|
paymentObject,
|
|
2467
2496
|
environment = "sandbox",
|
|
2468
2497
|
onPaymentAuthorized,
|
|
2469
|
-
onCancel
|
|
2498
|
+
onCancel,
|
|
2499
|
+
onError
|
|
2470
2500
|
}) => {
|
|
2471
2501
|
const [formIndex, setFormIndex] = (0, import_react9.useState)(0);
|
|
2472
2502
|
const [isMakingPayment, setIsMakingPayment] = (0, import_react9.useState)(false);
|
|
@@ -2523,6 +2553,9 @@ var PayByTransfer = ({
|
|
|
2523
2553
|
} catch (err) {
|
|
2524
2554
|
setIsMakingPayment(false);
|
|
2525
2555
|
setMessage(err.error.responseMessage || err.error.message);
|
|
2556
|
+
onError?.({
|
|
2557
|
+
errorMessage: message
|
|
2558
|
+
});
|
|
2526
2559
|
}
|
|
2527
2560
|
}
|
|
2528
2561
|
return;
|
|
@@ -2549,14 +2582,16 @@ var PayByTransfer = ({
|
|
|
2549
2582
|
onPaymentAuthorized?.({
|
|
2550
2583
|
paymentId: transactionReference,
|
|
2551
2584
|
paymentDate: response.data?.updatedAt,
|
|
2552
|
-
paymentStatus: "pending"
|
|
2585
|
+
paymentStatus: "pending",
|
|
2586
|
+
message
|
|
2553
2587
|
});
|
|
2554
2588
|
} else {
|
|
2555
2589
|
setPaymentReferenceStatus("confirmed");
|
|
2556
2590
|
onPaymentAuthorized?.({
|
|
2557
2591
|
paymentId: transactionReference,
|
|
2558
2592
|
paymentDate: response.data?.updatedAt,
|
|
2559
|
-
paymentStatus: "confirmed"
|
|
2593
|
+
paymentStatus: "confirmed",
|
|
2594
|
+
message
|
|
2560
2595
|
});
|
|
2561
2596
|
}
|
|
2562
2597
|
} else if (response.data?.finalTransactionStatus === "Success" || response.data?.paymentStatus === "Received" || response.data?.paymentStatus === "Payment Received") {
|
|
@@ -2566,7 +2601,8 @@ var PayByTransfer = ({
|
|
|
2566
2601
|
onPaymentAuthorized?.({
|
|
2567
2602
|
paymentId: transactionReference,
|
|
2568
2603
|
paymentDate: response.data?.updatedAt,
|
|
2569
|
-
paymentStatus: "confirmed"
|
|
2604
|
+
paymentStatus: "confirmed",
|
|
2605
|
+
message
|
|
2570
2606
|
});
|
|
2571
2607
|
}
|
|
2572
2608
|
} else if (!response?.isSuccessful && response?.responseCode === "119") {
|
|
@@ -2575,7 +2611,8 @@ var PayByTransfer = ({
|
|
|
2575
2611
|
onPaymentAuthorized?.({
|
|
2576
2612
|
paymentId: transactionReference,
|
|
2577
2613
|
paymentDate: null,
|
|
2578
|
-
paymentStatus: "used"
|
|
2614
|
+
paymentStatus: "used",
|
|
2615
|
+
message
|
|
2579
2616
|
});
|
|
2580
2617
|
}
|
|
2581
2618
|
} catch (err) {
|
|
@@ -2583,6 +2620,9 @@ var PayByTransfer = ({
|
|
|
2583
2620
|
setMessage(
|
|
2584
2621
|
err?.error?.responseMessage || err?.error?.message || "Something went wrong"
|
|
2585
2622
|
);
|
|
2623
|
+
onError?.({
|
|
2624
|
+
errorMessage: message
|
|
2625
|
+
});
|
|
2586
2626
|
} finally {
|
|
2587
2627
|
setIsFetchingPaymentDetails(false);
|
|
2588
2628
|
}
|
|
@@ -2613,6 +2653,9 @@ var PayByTransfer = ({
|
|
|
2613
2653
|
}
|
|
2614
2654
|
} catch (e) {
|
|
2615
2655
|
setMessage(e?.message || "Failed to create payment link");
|
|
2656
|
+
onError?.({
|
|
2657
|
+
errorMessage: message
|
|
2658
|
+
});
|
|
2616
2659
|
} finally {
|
|
2617
2660
|
setLoading(false);
|
|
2618
2661
|
}
|
|
@@ -2755,7 +2798,8 @@ var PayByStableCoin = ({
|
|
|
2755
2798
|
secretKey,
|
|
2756
2799
|
paymentObject,
|
|
2757
2800
|
environment = "sandbox",
|
|
2758
|
-
onPaymentAuthorized
|
|
2801
|
+
onPaymentAuthorized,
|
|
2802
|
+
onError
|
|
2759
2803
|
}) => {
|
|
2760
2804
|
const [formIndex, setFormIndex] = (0, import_react10.useState)(0);
|
|
2761
2805
|
const [message, setMessage] = (0, import_react10.useState)("");
|
|
@@ -2810,6 +2854,9 @@ var PayByStableCoin = ({
|
|
|
2810
2854
|
}
|
|
2811
2855
|
} catch (e) {
|
|
2812
2856
|
setMessage(e?.message || "Failed to create payment link");
|
|
2857
|
+
onError?.({
|
|
2858
|
+
errorMessage: message
|
|
2859
|
+
});
|
|
2813
2860
|
} finally {
|
|
2814
2861
|
setLoading(false);
|
|
2815
2862
|
}
|
|
@@ -2828,6 +2875,9 @@ var PayByStableCoin = ({
|
|
|
2828
2875
|
}
|
|
2829
2876
|
} catch (e) {
|
|
2830
2877
|
setMessage(e?.message || "Failed to generate address");
|
|
2878
|
+
onError?.({
|
|
2879
|
+
errorMessage: message
|
|
2880
|
+
});
|
|
2831
2881
|
} finally {
|
|
2832
2882
|
setGeneratingAddress(false);
|
|
2833
2883
|
}
|
|
@@ -2846,6 +2896,9 @@ var PayByStableCoin = ({
|
|
|
2846
2896
|
}
|
|
2847
2897
|
} catch (e) {
|
|
2848
2898
|
setMessage(e?.message || "Failed to get stable coins");
|
|
2899
|
+
onError?.({
|
|
2900
|
+
errorMessage: message
|
|
2901
|
+
});
|
|
2849
2902
|
} finally {
|
|
2850
2903
|
setLoadingStableCoins(false);
|
|
2851
2904
|
}
|
|
@@ -2867,6 +2920,9 @@ var PayByStableCoin = ({
|
|
|
2867
2920
|
}
|
|
2868
2921
|
} catch (e) {
|
|
2869
2922
|
setMessage(e?.message || "Failed to get stable coin networks");
|
|
2923
|
+
onError?.({
|
|
2924
|
+
errorMessage: message
|
|
2925
|
+
});
|
|
2870
2926
|
} finally {
|
|
2871
2927
|
setLoadingStableCoinNetworks(false);
|
|
2872
2928
|
}
|
|
@@ -2884,7 +2940,8 @@ var PayByStableCoin = ({
|
|
|
2884
2940
|
onPaymentAuthorized?.({
|
|
2885
2941
|
paymentId: transactionReference,
|
|
2886
2942
|
paymentDate: response.data?.updatedAt ?? "",
|
|
2887
|
-
paymentStatus: "pending"
|
|
2943
|
+
paymentStatus: "pending",
|
|
2944
|
+
message
|
|
2888
2945
|
});
|
|
2889
2946
|
} else if (response.data?.finalTransactionStatus === "Success" || response.data?.paymentStatus === "Payment Received") {
|
|
2890
2947
|
setMessage("Transaction confirmed !!");
|
|
@@ -2892,7 +2949,8 @@ var PayByStableCoin = ({
|
|
|
2892
2949
|
onPaymentAuthorized?.({
|
|
2893
2950
|
paymentId: transactionReference,
|
|
2894
2951
|
paymentDate: response.data?.updatedAt,
|
|
2895
|
-
paymentStatus: "confirmed"
|
|
2952
|
+
paymentStatus: "confirmed",
|
|
2953
|
+
message
|
|
2896
2954
|
});
|
|
2897
2955
|
}
|
|
2898
2956
|
} else if (!response?.isSuccessful && response?.responseCode === "119") {
|
|
@@ -2901,7 +2959,8 @@ var PayByStableCoin = ({
|
|
|
2901
2959
|
onPaymentAuthorized?.({
|
|
2902
2960
|
paymentId: transactionReference,
|
|
2903
2961
|
paymentDate: null,
|
|
2904
|
-
paymentStatus: "used"
|
|
2962
|
+
paymentStatus: "used",
|
|
2963
|
+
message
|
|
2905
2964
|
});
|
|
2906
2965
|
}
|
|
2907
2966
|
} catch (err) {
|
|
@@ -2909,6 +2968,9 @@ var PayByStableCoin = ({
|
|
|
2909
2968
|
setMessage(
|
|
2910
2969
|
err?.error?.responseMessage || err?.error?.message || "Something went wrong"
|
|
2911
2970
|
);
|
|
2971
|
+
onError?.({
|
|
2972
|
+
errorMessage: message
|
|
2973
|
+
});
|
|
2912
2974
|
} finally {
|
|
2913
2975
|
setIsConfirmingPayment(false);
|
|
2914
2976
|
}
|
|
@@ -3086,7 +3148,9 @@ function BzpCheckoutCard({
|
|
|
3086
3148
|
phoneNumber: "",
|
|
3087
3149
|
narration: "",
|
|
3088
3150
|
redirectUrl: "https://sandbox-merchant.buzapay.com/account/three-ds-status"
|
|
3089
|
-
}
|
|
3151
|
+
},
|
|
3152
|
+
onPaymentAuthorized,
|
|
3153
|
+
onError
|
|
3090
3154
|
}) {
|
|
3091
3155
|
const [checkoutState, setCheckoutState] = (0, import_react11.useState)("PENDING");
|
|
3092
3156
|
const paymentTypeOptions = [
|
|
@@ -3115,6 +3179,7 @@ function BzpCheckoutCard({
|
|
|
3115
3179
|
} else {
|
|
3116
3180
|
setCheckoutState("PENDING");
|
|
3117
3181
|
}
|
|
3182
|
+
onPaymentAuthorized?.(event);
|
|
3118
3183
|
};
|
|
3119
3184
|
(0, import_react11.useEffect)(() => {
|
|
3120
3185
|
let options2 = [];
|
|
@@ -3189,7 +3254,8 @@ function BzpCheckoutCard({
|
|
|
3189
3254
|
secretKey,
|
|
3190
3255
|
environment,
|
|
3191
3256
|
paymentObject,
|
|
3192
|
-
onPaymentAuthorized: setSuccess
|
|
3257
|
+
onPaymentAuthorized: setSuccess,
|
|
3258
|
+
onError
|
|
3193
3259
|
}
|
|
3194
3260
|
) : paymentType === "BANK_TRANSFER" ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
3195
3261
|
PayByTransfer,
|
|
@@ -3197,7 +3263,8 @@ function BzpCheckoutCard({
|
|
|
3197
3263
|
secretKey,
|
|
3198
3264
|
environment,
|
|
3199
3265
|
paymentObject,
|
|
3200
|
-
onPaymentAuthorized: setSuccess
|
|
3266
|
+
onPaymentAuthorized: setSuccess,
|
|
3267
|
+
onError
|
|
3201
3268
|
}
|
|
3202
3269
|
) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
3203
3270
|
PayByStableCoin,
|
|
@@ -3205,7 +3272,8 @@ function BzpCheckoutCard({
|
|
|
3205
3272
|
secretKey,
|
|
3206
3273
|
environment,
|
|
3207
3274
|
paymentObject,
|
|
3208
|
-
onPaymentAuthorized: setSuccess
|
|
3275
|
+
onPaymentAuthorized: setSuccess,
|
|
3276
|
+
onError
|
|
3209
3277
|
}
|
|
3210
3278
|
) }),
|
|
3211
3279
|
checkoutState === "SUCCESS" && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|