David Kimura PRO
Joined 7/18/2015
Drifting Ruby Owner
David Kimura PRO said over 5 years ago on Payment Gateway Basics with Stripe :
  Can you drill into the Starter plan, there should be an ID in there which is what you need to use within your code.

David Kimura PRO said over 5 years ago on Payment Gateway Basics with Stripe :
Stripe::Plan.create(
  { 
    product: { 
      name: 'Pro',               
      id: 'pro'
    }, 
    id: 'pro',
    interval: 'month', 
    currency: 'usd', 
    amount: 1500
  }
)

This is what I use to create the Product/Plan

David Kimura PRO said over 5 years ago on Payment Gateway Basics with Stripe :
what happens when you call customer.save after you set the customer.default_source?

David Kimura PRO said over 5 years ago on Payment Gateway Basics with Stripe :
Ah, okay, I thought that Stripe created the source, but it looks like they're just verifying that the source would be valid.

source = Stripe::Source.create(token: params[:stripeToken])
customer.default_source = source
customer.save

David Kimura PRO said over 5 years ago on Payment Gateway Basics with Stripe :
  I am really trying to help guide you without giving all of the answers because there is so much in learning to troubleshoot these issues. In your particular case, the Stripe::Source.create has a required parameter called type. Since it would be impossible (or improbable) for anyone to know what that means except for the Stripe developers, it's important to look at their provided documentation. In this case, the Stripe::Source.create points to this reference in the documentation. https://stripe.com/docs/api/sources/create#create_source-type

Since they don't give much meaning to what the type parameter is as far as the available values, we need to look at the source object. https://stripe.com/docs/api/sources/object#source_object-type

Since you're taking in credit cards, you would use the type "card"

So your code should look like

source = Stripe::Source.create(type: 'card', token: params[:stripeToken])

I am not positive, but I would avoid the card_present option as that is typically when the card is physically present when entering the details.