@flopay/react 0.4.1 → 0.4.3
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 +31 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +31 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -2506,7 +2506,7 @@ function FloPayCheckout({
|
|
|
2506
2506
|
)
|
|
2507
2507
|
] }) }) });
|
|
2508
2508
|
}
|
|
2509
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(FloPayProvider, { flopay, options: providerOptions, children: [
|
|
2509
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(FloPayProvider, { flopay, paypalFlopay, options: providerOptions, children: [
|
|
2510
2510
|
modeError && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2511
2511
|
"div",
|
|
2512
2512
|
{
|
|
@@ -2822,6 +2822,7 @@ function CheckoutFormInner({
|
|
|
2822
2822
|
innerRef
|
|
2823
2823
|
}) {
|
|
2824
2824
|
const flopay = useFloPay();
|
|
2825
|
+
const paypalFlopay = usePayPalFloPay();
|
|
2825
2826
|
const elements = useElements();
|
|
2826
2827
|
const contextBillingUrl = useBillingApiUrl();
|
|
2827
2828
|
const [processing, setProcessing] = (0, import_react8.useState)(false);
|
|
@@ -2906,20 +2907,35 @@ function CheckoutFormInner({
|
|
|
2906
2907
|
return;
|
|
2907
2908
|
}
|
|
2908
2909
|
if (json?.type === "paypal_redirect_required") {
|
|
2909
|
-
const secret = json["clientSecret"];
|
|
2910
|
+
const secret = json["threeDSecureToken"] ?? json["clientSecret"];
|
|
2910
2911
|
const pmId = json["paymentMethodId"];
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2912
|
+
const paypalStripe = (paypalFlopay ?? flopay)?.getRawProvider();
|
|
2913
|
+
if (!paypalStripe || !secret) {
|
|
2914
|
+
const message = "PayPal is not available.";
|
|
2915
|
+
updateError(message);
|
|
2916
|
+
onDecline?.(buildDeclineEvent("paypal", message));
|
|
2917
|
+
return;
|
|
2918
|
+
}
|
|
2919
|
+
localStorage.setItem(WALLET_RESUME_KEY2, JSON.stringify({
|
|
2920
|
+
sessionId,
|
|
2921
|
+
paymentIntentId: "",
|
|
2922
|
+
tokenType: "card",
|
|
2923
|
+
tokenId: pmId ?? "",
|
|
2924
|
+
status: "pending_redirect"
|
|
2925
|
+
}));
|
|
2926
|
+
const confirmParams = {
|
|
2927
|
+
return_url: window.location.href
|
|
2928
|
+
};
|
|
2929
|
+
if (pmId) confirmParams["payment_method"] = pmId;
|
|
2930
|
+
const { error: confirmError } = await paypalStripe.confirmPayment({
|
|
2931
|
+
clientSecret: secret,
|
|
2932
|
+
confirmParams,
|
|
2933
|
+
redirect: "if_required"
|
|
2934
|
+
});
|
|
2935
|
+
if (confirmError) {
|
|
2936
|
+
const message = confirmError.message ?? "PayPal payment failed.";
|
|
2937
|
+
updateError(message);
|
|
2938
|
+
onDecline?.(buildDeclineEvent("paypal", message, { code: confirmError.code }));
|
|
2923
2939
|
}
|
|
2924
2940
|
return;
|
|
2925
2941
|
}
|
|
@@ -2935,7 +2951,7 @@ function CheckoutFormInner({
|
|
|
2935
2951
|
setProcessing(false);
|
|
2936
2952
|
}
|
|
2937
2953
|
},
|
|
2938
|
-
[baseUrl, sessionId, userId, email, firstName, lastName, chv, flopay, onComplete, onError, updateError, emitDecline]
|
|
2954
|
+
[baseUrl, sessionId, userId, email, firstName, lastName, chv, flopay, paypalFlopay, onComplete, onError, onDecline, updateError, emitDecline]
|
|
2939
2955
|
);
|
|
2940
2956
|
const dispatchTokenizedBody = (0, import_react8.useCallback)(
|
|
2941
2957
|
(tokenizedBody) => {
|