I have a Squarespace app that has collected charges for customers, however Squarespace does not create customer objects, it just stores charges.
My goal: When a user makes a purchase, create a Customer object with a subscription plan attached so we can make recurring charges to the card.
I can pull up a list of charges via the stripe test API and each charge has a source
in it that contains a card token. So to my understanding I should be able to create a customer and pass in the source or source Id and it will add the source to that customer.
Here's what my code looks like:
customer = Stripe::Customer.create(
:email => customerEmail,
:plan => customerPlanId,
:source => charge[:source],
:description => customerName
)
I'm doing this in the stripe sandbox. I can clearly see the card stored in the source object within the charge, however stripe throws the error:
`handle_api_error': No such token: card_19NXFMKm5fnTITnyYdk6shyj (Stripe::InvalidRequestError)
Thanks in advance!