more fixes web + mobile
This commit is contained in:
@@ -6,7 +6,6 @@ import {
|
||||
} from "@stripe/react-stripe-js";
|
||||
import { loadStripe } from "@stripe/stripe-js";
|
||||
import * as WebBrowser from "expo-web-browser";
|
||||
|
||||
import Overlay from "../components/Overlay";
|
||||
import Button from "../components/Button";
|
||||
import useLayoutType from "../hooks/useLayoutType";
|
||||
@@ -125,45 +124,42 @@ const StripeProvider = ({ children }) => {
|
||||
setClientSecret(null);
|
||||
}, []);
|
||||
|
||||
const redirectToCheckout = React.useCallback(
|
||||
async (checkoutUrl, { safariWindow } = {}) => {
|
||||
if (!checkoutUrl) {
|
||||
throw new Error("Session Stripe introuvable.");
|
||||
}
|
||||
const redirectToCheckout = React.useCallback(async (checkoutUrl = {}) => {
|
||||
if (!checkoutUrl) {
|
||||
throw new Error("Session Stripe introuvable.");
|
||||
}
|
||||
|
||||
if (isWeb) {
|
||||
throw new Error(
|
||||
"Impossible d'ouvrir le paiement Stripe sans checkout intégré.",
|
||||
if (isWeb) {
|
||||
throw new Error(
|
||||
"Impossible d'ouvrir le paiement Stripe sans checkout intégré.",
|
||||
);
|
||||
}
|
||||
|
||||
const isMobileApp = Platform.OS === "ios" || Platform.OS === "android";
|
||||
|
||||
if (isMobileApp) {
|
||||
try {
|
||||
await WebBrowser.openBrowserAsync(checkoutUrl, {
|
||||
enableDefaultShareMenu: false,
|
||||
dismissButtonStyle: "close",
|
||||
presentationStyle:
|
||||
WebBrowser?.WebBrowserPresentationStyle?.PAGE_SHEET,
|
||||
});
|
||||
return;
|
||||
} catch (webBrowserError) {
|
||||
console.warn(
|
||||
"[StripeProvider] WebBrowser checkout fallback",
|
||||
webBrowserError,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const isMobileApp = Platform.OS === "ios" || Platform.OS === "android";
|
||||
|
||||
if (isMobileApp) {
|
||||
try {
|
||||
await WebBrowser.openBrowserAsync(checkoutUrl, {
|
||||
enableDefaultShareMenu: false,
|
||||
dismissButtonStyle: "close",
|
||||
presentationStyle:
|
||||
WebBrowser?.WebBrowserPresentationStyle?.PAGE_SHEET,
|
||||
});
|
||||
return;
|
||||
} catch (webBrowserError) {
|
||||
console.warn(
|
||||
"[StripeProvider] WebBrowser checkout fallback",
|
||||
webBrowserError,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const canOpen = await Linking.canOpenURL(checkoutUrl);
|
||||
if (!canOpen) {
|
||||
throw new Error("Impossible d'ouvrir l'URL de paiement.");
|
||||
}
|
||||
await Linking.openURL(checkoutUrl);
|
||||
},
|
||||
[],
|
||||
);
|
||||
const canOpen = await Linking.canOpenURL(checkoutUrl);
|
||||
if (!canOpen) {
|
||||
throw new Error("Impossible d'ouvrir l'URL de paiement.");
|
||||
}
|
||||
await Linking.openURL(checkoutUrl);
|
||||
}, []);
|
||||
|
||||
const runCheckoutSession = React.useCallback(
|
||||
async ({ callableName, payload, logTag, useEmbeddedFlow = false }) => {
|
||||
|
||||
Reference in New Issue
Block a user