问题
Is it possible to redirect to a new webpage after the stripe charge completes? I am using .NET C#
Here is code below:
<form action="/charge" method="POST">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_6pRNASCoBOKtIshFeQd4XMUh"
data-image="/img/documentation/checkout/marketplace.png"
data-name="Stripe.com"
data-description="2 widgets"
data-amount="2000"
data-locale="auto">
</script>
</form>
After, all I want to do is redirect to another page on my website.
Thanks!
回答1:
This client-side code will only turn the card information into a token -- it won't actually create a charge.
When you submit the form, the parameters (including the card token) will be sent to /charge
(because that's what you set as the action
attribute for the <form>
tag). You then need to use these parameters to create a charge. You can find out more in this tutorial.
Once the charge has been created, you can redirect the user to another page using whatever method is appropriate for your language and framework, e.g. in PHP you'd simply do:
header('Location: /success');
to redirect the user to /success
.
来源:https://stackoverflow.com/questions/34758565/redirect-to-new-page-after-stripe-charge