5

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

2
  • I don't know this gem but apparently the customer object that you are trying to create is invalid, check the validations of that object. Feb 21, 2015 at 19:37
  • @MohammadAbuShady It was my user.js. I've missed out a + operator! lol Took 4hrs to find it. It now works!
    – Sylar
    Feb 21, 2015 at 20:29

1 Answer 1

3

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.