I have a website on MERN STACK in which I have Stripe implemented, the problem is when I try to pay through Stripe on a desktop/PC it works fine but when I try the same thing on a browser using mobile it redirects me to Stripe website and says an error occurred.
This image shows the redirected link when using Stripe payment on mobile.
Below is the code for Stripe:
The request:
const [stripeToken, setStripeToken] = useState(null);
// const navigate = useNavigate();
const onToken = (token) => {
setStripeToken(token);
// console.log(token);
};
useEffect(() => {
const makeRequest = async () => {
try {
const res = await userRequest.post("/checkout/payment", {
tokenId: stripeToken.id,
// amount: order.totalPrice,
amount: 172500,
});
history.push("/success", {
stripeData: res.data,
// products: cart,
});
} catch (err) {
console.log(err);
}
};
stripeToken && makeRequest();
}, [stripeToken, history]);
const orderId = match.params.id;
<StripeCheckout
name="CCBS Shop"
billingAddress
shippingAddress
description={`Your total is ${order.totalPrice}`}
amount={172500}
token={onToken}
stripeKey={KEY}
>