For Stripe's new checkout, it's required to redirect to an external URL after creating a session.
def create_checkout_session
Stripe.api_key = "sk_test_"
session = Stripe::Checkout::Session.create({
line_items: [{
price_data: {
currency: 'usd',
product_data: {
name: 'KYC services',
},
unit_amount: 1000,
},
quantity: 1,
}],
mode: 'payment',
# These placeholder URLs will be replaced in a following step.
success_url: 'https://example.com/success',
cancel_url: 'https://example.com/cancel'
})
redirect_to session.url, status: 303, allow_other_host: true
My redirect_to does not take me anywhere, and there is no error in the terminal. If I don't include the allow_other_host: true I get an error saying Unsafe redirect to "https://checkout.stripe.com.
How do I enforce a redirect_to to an external URL in Rails 7? For the sake of this demo app, I don't mind vulnerabilities.