简体   繁体   中英

How to send JWT header when using Stripe checkout

I am trying to have an html page (later a vue.js one) have a stripe checkout form/script/button and then I want to be able to submit that form with an action I set that would then go back to my server (currently local only) and would have an auth token included.

Pretty much what I have is an api gateway that checks if requests are valid via my auth service which is using passport.js JWT strategy. So with each request, I need to send an authorization/bearer token.

My issue is that I am unable to figure out how to send that from a simple HTML page.

The only thing on this test page is the stripe checkout form. I've included the body/form below minus my API key.

I was hoping someone could tell me how to submit the form and have stripe do it's thing while I get the required JWT sent to my Node server.

The best I found was this link but it still doesn't seem to make sense how to do it. How Set Authorization headers at HTML Form or at A href

<form action="http://localhost:8090/billing/updateCard" method="POST">
        <script
          src="https://checkout.stripe.com/v2/checkout.js" class="stripe-button"
          data-key="<api key>"
          data-amount="cd"
          data-name="Add card"
          data-description="Tagline"
          data-image="../../../favicon.ico"
          data-locale="auto"
          data-currency="usd"
          data-label="Update Card"
          data-panel-label="Update Card"
          data-zip-code="false"
          data-allow-remember-me="false"
          data-email="john.doe@example.com"
          > Update Card
        </script>
      </form>

I would like it so that the form is submitted with my auth token. For now, it can be hard-coded into the page and doesn't need to come from the browser.

最好的选择是使用“ 自定义(Javascript)Checkout”集成,因为这将使您可以控制将哪些数据(以及如何)准确地发布到Node.js服务器。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM