Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stripe with Rails 4: This customer has no attached payment source [duplicate]

Has anyone experienced this error when using Stripe (test mode) with rails 4: "This customer has no attached payment source"? It triggers line (customer = ) in my user.rb model:

attr_accessor :stripe_card_token

def save_with_payment
  if valid?
    customer = Stripe::Customer.create(description: email, plan: plan_id, card: stripe_card_token)
    self.stripe_customer_token = customer.id
    save!
  end
end

I have rechecked my form and my users.js and I see nothing wrong; spellings are perfect. My rails version is 4.2.0; ruby: 2.1.3p242

like image 449
Sylar Avatar asked Oct 20 '22 17:10

Sylar


1 Answers

Please try the below code: (Just replace the "card: stripe_card_token" => "source: stripe_card_token")

attr_accessor :stripe_card_token

def save_with_payment
  if valid?
    customer = Stripe::Customer.create(description: email, plan: plan_id, source: stripe_card_token)
    self.stripe_customer_token = customer.id
    save!
  end
end
like image 170
Jitendra Bansal Avatar answered Oct 24 '22 20:10

Jitendra Bansal