#paarth bajaj

1 messages · Page 1 of 1 (latest)

pine troutBOT
last lily
#

Is the any chance you can redirect from backend?

strange yarrow
#

No sir

#

Error

Access to fetch at 'https://checkout-cookies.stripe.com/api/get-cookie' from origin 'https://checkout.stripe.com' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'.

GET https://checkout-cookies.stripe.com/api/get-cookie net::ERR_FAILED 200


Uncaught (in promise) FetchError: Error fetching https://checkout-cookies.stripe.com/api/get-cookie: Failed to fetch
    at cs_test_a1Hsojvb...................
#

Backend code

try {
let reqFields = ["customerId", "paymentMode", "priceId", "success_url", "cancel_url", "distinctName", "productId", "planId"];
const payload = JSON.parse(event.body) || {};


const user = await getUser(event.headers.Authorization);
        const userId = user.UserAttributes["custom:dbUserID"];

const { customerId, paymentMode, priceId, success_url, cancel_url, productId, distinctName, planId} = payload;

const session = await stripe.checkout.sessions.create({
customer: customerId,
line_items: [{ price: priceId, quantity: 1 }],
mode: paymentMode,
success_url,
cancel_url,
metadata: {
distinctName,
productId,
planId,
userId
}
});

console.log(session);

_HTTP_201_CREATED["body"] = JSON.stringify({
status: "success",
data: {url: session.url} ,
message: "",
});
return _HTTP_201_CREATED;
} catch (e) {
console.log(e);
return _HTTP_500_INTERNAL_SERVER_ERROR;
}

#

This is network call

#

Strange thing is this is completely random and sometime error occurs and some time it doesn't

last lily
#

(Not sure if this is callable from JS)

strange yarrow
#

Ok so you want me to redirect to checkout page from backend?

last lily
#

No this is redirection from frontend. I just want to test to narrow down the issue

strange yarrow
#

Oh ok
I need to install stripe at frontend as well

last lily
#

Um I just tested and window.open works fine for me. Can you try a simple integration without React?

strange yarrow
#

Till now, I haven't included stripe at frontend

strange yarrow
last lily
#

Um all of this would be way easier if you just use the form and redirection from backend

#

What is the main reason prevent you to do so:?

strange yarrow
last lily
#

Form and redirection is the default behavior we support, so I believe it should have less CORS quirk (hopefully)

strange yarrow
#

Ok let me do it from the backend then