#krish4029_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1437885050392805496
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Where did you get "Error: Clover version is not supported" error from?
https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=embedded-components&client=react:
Install React Stripe.js and the Stripe.js loader from the npm public registry. You need at least version 5.0.0 for React Stripe.js and version 8.0.0 for the Stripe.js loader.
For stripe-ruby, your existing version stripe-ruby 15.5.0 should work since your server can create the Checkout Session successfully in https://dashboard.stripe.com/acct_1HNM8gJ8Rm1u8ptB/test/logs/req_82rdU6eyS0zOzr
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
The error is from my browser console - seems to originate from stripe.js.
this a small snippet with of my front end code.
import { CheckoutProvider } from "@stripe/react-stripe-js/checkout";
import { loadStripe } from "@stripe/stripe-js";
<CheckoutProvider stripe={stripePromise}
options={{
clientSecret: clientSecret,
elementsOptions: {appearance},
}}
>
<CheckoutSessionPayment {...{checkoutSessionId, creditBundlePaymentId, onSuccess, onError}} />
</CheckoutProvider>
contents of CheckoutSessionPayment:
import {
PaymentElement
} from '@stripe/react-stripe-js/checkout';
import {
useCheckout
} from '@stripe/react-stripe-js/checkout';
<div className="checkout-session-container">
<form onSubmit={handleSubmit}>
<PaymentElement />
</form>
</div>
Could you share the code where you create stripePromise? Which version of react-stripe-js and stripe-js are you using?
versions:
"@stripe/react-stripe-js": "^5.0.0",
"@stripe/stripe-js": "^8.0.0",
I'll post the complete files if it isn't too much:
CheckoutSessionWrapper is the outer wrapper where IoadStripe and call backend to create the checkout session. From the client_Secret of this checkout session, I initialize CheckoutProvider. CheckoutSessionPayment is the child component which has the PaymentElement.
Try removing your package.json.lock file and running npm update
just in case you're running an older version of those libs
CheckoutSessionWrapper.tsx - outer component
import React, { useState, useEffect } from "react";
import { CheckoutProvider } from "@stripe/react-stripe-js/checkout";
import { loadStripe } from "@stripe/stripe-js";
import CheckoutSessionPayment from "./CheckoutSessionPayment";
const CheckoutSessionWrapper = () => {
const [stripePromise, setStripePromise] = useState(null);
const [clientSecret, setClientSecret] = useState(null);
const [checkoutSessionId, setCheckoutSessionId] = useState(null);
const getStripeKey = async () => {
try {
const response = await AxiosAPIUtils.get(Routes.FETCH_STRIPE_KEY);
return response["publishable_key"];
}
};
const initializeCheckoutSession = async () => {
try {
const response = await AxiosAPIUtils.post(
Routes.CREATE_CHECKOUT_SESSION
);
setClientSecret(response.clientSecret);
setCheckoutSessionId(response.checkoutSessionId);
}
};
useEffect(() => {
const setupStripe = async () => {
const stripeKey = await getStripeKey();
if (stripeKey) {
setStripePromise(loadStripe(stripeKey, { betas: ["custom_checkout_beta_5"] }));
} else {
setLoading(false);
}
};
setupStripe();
}, []);
useEffect(() => {
if (stripePromise) {
initializeCheckoutSession();
}
}, [stripePromise]);
if (loading || !stripePromise || !clientSecret) {
return (
<div className="center">
<Spinner size="large" speed="slow" className="spinner" />
</div>
);
}
return (
<>
{ stripePromise && clientSecret && <div className="checkout-session-container">
<CheckoutProvider stripe={stripePromise}
options={{
clientSecret: clientSecret
}}
>
<CheckoutSessionPayment {...{checkoutSessionId, creditBundlePaymentId, onSuccess, onError}} />
</CheckoutProvider>
</div>}
</>
);
};
export default CheckoutSessionWrapper;
ok will try that
I use yarn i did clear cache, remove node_modules folder and ran yarn install. Let me delete the lock file and try again
Gotcha. Yeah try that and se if that makes a difference
I tried deleting yarn.lock. but got the same error. APi request for creating checkout session - req_lp3IfPzQwlCT5E
Browser console error: Error: Clover version is not supported from stripe.js.
i see a minified version of stripe.js in Sources. If it helps, it originates from this function:
_attachCustomCheckoutMethods
hmm, can you try removing custom_checkout_beta_5 header?
The feature is GA so you don't need that value