Skip to content

Instantly share code, notes, and snippets.

@andresprogra
Created May 17, 2018 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andresprogra/72dc7ddbb2aa52c4a93390c0fb127e65 to your computer and use it in GitHub Desktop.
Save andresprogra/72dc7ddbb2aa52c4a93390c0fb127e65 to your computer and use it in GitHub Desktop.
Function CreatePlanStripe
func CreatePlanStripe(planObj Plan) (*stripe.Plan, error){
stripe.Key = "key"
params := &stripe.PlanParams{
Amount: planObj.Amount,
// planObj.Period es de tipo string pero me da error, dice:
// cannot use planObj.Period (type string) as type stripe.PlanInterval in field value
// pero si yo le pongo directamente un string ("month") no da error.
Interval: planObj.Period,
// El mismo error que con Interval
Currency: planObj.Currency,
IntervalCount: planObj.IntervalCount,
TrialPeriod: planObj.TrialPeriodDays,
Product: &stripe.PlanProductParams{
Name: planObj.Name + " - " + string(planObj.LimitUsers) + " USERS",
},
}
p, err := plan.New(params)
return p, err
}
@umarquez
Copy link

umarquez commented May 17, 2018

Hola Andrés!

La línea 8 debería ser más o menos así:

Interval: stripe.PlanInterval(planObj.Period),

Lo que pasa es que seguramente el tipo de dato stripe.PlanInterval está declarado como alias de string y por tanto Interval no puede recibir una cadena plana como valor, pues espera un stripe.PlanInterval; lo mismo debe pasar con Currency; debe esperar un tipo de datos stripe.PlanCurrency o algo similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment