Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to charge a particular card on a customer with Stripe.com

A customer object can have many cards in Stripe.com. How do you charge an existing card?

I've tried a few things, but the stripe api for some reason borks when to get an old customer token and a new card token instead of just creating a new card on that customer. So I've gone the route of retrieving all the customer's cards, then selecting one by radio button, then submitting the token of the chosen card into a charge

      charge = Stripe::Charge.create(         :amount => "#{@subscription.price}",         :currency => "usd",         :card => params[:existing_card_id],         :description => "Subscription for #{current_user.email}"       ) 

but I get the error

Stripe::InvalidRequestError: Invalid token id: card_24j3i2390s9df 
like image 259
ajbraus Avatar asked Nov 27 '13 15:11

ajbraus


People also ask

Can I pass Stripe fees to customer?

You can pass your Stripe fees on to your customers by including the fee into the final charge amount. It is important to ensure that this action complies with any applicable laws that pertain to your business.

How do you charge a guest on Stripe?

How to charge a guest in Stripe Follow. Login to Stripe > Click on Customers > Locate the customer and click on it. Scroll down to make sure a card has been added and locate the Create Payment button. Enter the correct amount, description and charge the card.

How do you charge a one time payment on Stripe?

To include a one-time charge or discount to the first subscription invoice, you can do so by adding an invoice item to the customer before creating the subscription. This can be done using the API or directly in the Stripe Dashboard.


1 Answers

I figured this out.

With existing card tokens you have to send in the customer token as well

     charge = Stripe::Charge.create(         :amount => "#{@subscription.price}",         :currency => "usd",         :customer => current_user.stripe_customer_id,         :card => params[:existing_card_id],         :description => "Subscription for #{current_user.email}"       ) 
like image 72
ajbraus Avatar answered Sep 19 '22 00:09

ajbraus