21

I am unable to charge the amount $49.99 in stripe. I am going through the following links but nothing workout

Stripe Checkout Price error - Invalid Integer

Stripe Rails: Invalid integer: 1.06

I would like to charge the amount as it is. I don't want to round off the payment

 stripe.charges.create({
    // Charge the customer in stripe
// amount: req.query.amount,
    amount: 49.99,
    currency: 'usd',
    customer: req.customer
  }).then(function(charge) {
    // Use and save the charge info in our db
    var successTransaction = {
      stripeId: charge.customer,
      transactionId: charge.id,
      amount: charge.amount,
      currency: charge.currency,
      message: charge.outcome.seller_message,
      paidStatus: charge.paid,
      summary: charge
    };
Sam
  • 5,040
  • 12
  • 43
  • 95

3 Answers3

42

Stripe allow only integer value in price so need to change your price (amount) into cent by (*100 ) so now your code amount is 499 and in stripe sdashboard you see the 49.99 for more details check the link :

https://stripe.com/docs/api#charges

In other words, Stripe's API always takes smallest supported unit as input (without need to configure anything), for example, amount of 1 means 1-Cent not 1-Dollar.

Top-Master
  • 7,611
  • 5
  • 39
  • 71
Priyanka Sankhala
  • 808
  • 1
  • 9
  • 25
9

You can use the following method as it will help you to use the decimal value as the amount and display the same amount in the invoice and during payment.

amount: Math.round(49.99 * 100)

Ajay Mistry
  • 951
  • 1
  • 14
  • 30
Vatsal Rajgor
  • 91
  • 1
  • 2
0

Stripe allows integer value as price, if you want to charge $49.99 then multiply it with 100.

Smallest price unit allowed by stripe is cent.

599 cents = $5.99

Prem Sagar
  • 147
  • 2
  • 8