Redirect To New Page After Stripe Charge

落花浮王杯 提交于 2019-12-23 05:12:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!