Making Your First Charge

In this tutorial you'll make your first charge through Stripe. If you need help, check out our answers to common questions or chat live with other developers in #stripe on freenode.

You've got the token for your user's credit card details, now what? Now you charge them money. This happens on your server, and the fastest way to do it is by using one of our client libraries. If you haven't already, install your favorite language now. In this tutorial, we'll show code for Ruby, PHP, Python, and Node.

In your web server, grab the Stripe token in the POST parameters submitted by your form. Once you do, it's one simple call to charge the card with Stripe:

Also note that we've placed your test secret API key in the code. This will authenticate you to Stripe, and it's separate from your publishable key — keep it secret and keep it safe. Remember to replace the test key with your live key in production. You can get all your keys from your account page.

That's it! If the charge creation request succeeds, and doesn't throw an error, the card has been successfully charged. You will receive your money in two days.

Saving credit card details for later

Stripe tokens can only be used once, but that doesn't mean you can't save payment information for your users. Stripe provides a Customer abstraction that makes it easy to save this information for later.

Instead of charging the card immediately, you can create a new Customer object and save the card to that customer. This will let you charge the user at any point in the future:

In this example, right after we created the customer we still created a new charge by passing in the customer, rather than the card. You can always provide either a card or a customer when creating a new charge.

Next up

Congrats! You've gone through the basics of using Stripe. Some things you might want to see next: