Tipsi-stripe: How to charge card after getting token

Created on 24 May 2017  路  2Comments  路  Source: tipsi/tipsi-stripe

Hi
I am trying to work out how you actually charge the card after the token is return from stripe.

I have tried to use but get error about .create function

// Charge the user's card:
var charge = stripe.charges.create({
amount: 1000,
currency: "aud",
description: "Example charge",
metadata: {order_id: 6735},
source: token,
}, function(err, charge) {
// asynchronously called
});

question

Most helpful comment

The token needs to be passed to your backend servers and charged via Stripe from there. This should never be done from the app itself.

All 2 comments

The token needs to be passed to your backend servers and charged via Stripe from there. This should never be done from the app itself.

Hi @pmcguane

According to your example in question on StackOverflow, I believe you make mistake, tipsi-stripe does not support charges. It is just a react-native wrapper for stripe-iosand stripe-android native libraries which used to generate tokens in your iOS/Android application.

To make a charge you should send received token to your own server:

Once you've securely collected and tokenized your customer's credit card using Checkout or Elements, you can charge the card. Unlike collection, which occurs in the browser, charge attempts are made from your server, normally using one of our client libraries. If you haven't already, install the library for your favorite language now. This tutorial shows code for Ruby, PHP, Python, and Node, but we also have libraries for Java and Go.

Was this page helpful?
0 / 5 - 0 ratings