I'm trying to charge a customer with one of the stored credit cards. I'm passing the customer id in the request and I'm getting the customer info from Stripe just fine. The problem is when trying to make the charge to one of the customer sources the library returns an error Must provide source or customer
. I checked the sc.Sources.Data[1]
(its hardcoded here just for this example) and it has an actual cutsomer source. Can anyone tell me what I'm doing wrong?
EDIT: If I use a tok_1212321 token it works fine, but I don't find a way to retrieve the token id from stripe, only the cliente sources.
stripe.Key = os.Getenv("STRIPE_KEY")
sc, _ := stripeCustomer(request)
params := &stripe.ChargeParams{
Amount: stripe.Int64(int64(order.total * 100)),
Currency: stripe.String(string(stripe.CurrencyUSD)),
Description: stripe.String("Order Number " + order.ID),
}
params.SetSource(sc.Sources.Data[1])
if _, err := charge.New(params); err != nil {
return nil, err
}