DEV Community

Discussion on: How does the stripe 7 lines of code work? Like just paste the code and it magically seems to connect( Dev beginner here!)

Collapse
 
kovah profile image
Kevin Woblick

Ah, the Stripe Checkout.
What this does is to load the checkout.js script file directly from Stripe. This script has probably more than 7 lines and uses the other information you provided to build a new button or checkout form. data-amount="999" specifies how much something should cost, data-name="Product name" what the item is called, and so on. If you know Javascript you could take a look at the script itself, but you probably won't find out too much because it's hard to work with those generated scripts. What it probably does it so check if the API key (data-key="...") is valid by sending a request to the Stripe API. After that it does whatever is needed to get the button or form running with the details.

Thread Thread
 
theamk25 profile image
TheAmk25

Thanks!