I'd like to create a URL that I can share in my newsletter that sends people directly to a Stripe Checkout form to make a small (fixed amount) payment.
With the new Stripe Checkout I can generate the HTML Code to build a button that I can include in a website. I'd like to avoid sending people to a website where they have to click that button, but send them straight to the payment form based on the parameters in a URL. Is this possible?
Edit: This is now possible with the launch of Payment Links! Check it out here: Stripe Payment Links
This is unfortunately not possible. Stripe.js
generates a unique redirect page for each redirectToCheckout
call using your publishable key. This ensures that the page is unique to each customer so it can be tracked easier.
You can't really get around sending your customers to a website as even legacy Checkout requires the use of JavaScript to generate the payment form.
You can make an Invoice on stripe.com which will generate an e-mail with link to the payment. Using that, you don't need any webserver.
Yes,
This can be done with a custom script on your end. As mentioned earlier each page has a unique ID used for tracking, therefore it cant be reused.
But with something like a simple PHP script which initiates this payment you can surely use the URL to the php script as a "constant" url to the payment.
The php would and JS would look something like this after having imported the stripe PHP SDK using composer and stripe.js
<?php
$stripecheckout = \Stripe\Checkout\Session::create([
'success_url' => 'https://success.url',
'cancel_url' => 'https://cancel.url',
'payment_method_types' => ['card'],
'line_items' => [
[
'amount' => 100,
'currency' => 'usd',
'name' => '1 item',
'description' => 'This is my item description',
'quantity' => 1,
],
]
]);
?>
and then this javascript
<script>
var stripe = Stripe('pk_test_XXXXXXXXXXXXXXX');
stripe.redirectToCheckout({
sessionId: '<?php echo $stripecheckout->id; ?>'
}).then(function (result) {
// If `redirectToCheckout` fails due to a browser or network
// error, display the localized error message to your customer
// using `result.error.message`.
});
</script>
This will require some customization and error handling from your end, but in my opinion would be the best solution
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With