I have been working in PHP and I have done this easily in that but currently passing certain code to Go but having some issues.
This below is the parameters definition with go package for stripe
params := &stripe.CouponParams{
Duration: stripe.String(c.Duration),
DurationInMonths: stripe.Int64(c.DurationInMonths),
//PercentOff: stripe.Float64(c.PercentOff),
AmountOff: stripe.Int64(c.AmountOff),
Currency: stripe.String(strings.ToLower(c.Currency)), //ISO code for the currency
ID: stripe.String(c.ID),
MaxRedemptions: stripe.Int64(c.MaxRedemptions),
//Name: stripe.String(c.Name),
AppliesTo: &stripe.CouponAppliesToParams{
Products: c.AppliesTo.Products,
},
CurrencyOptions: map[string]*stripe.CouponCurrencyOptionsParams{
//"eur": {AmountOff: stripe.Int64(9000)},
"jpy": {AmountOff: stripe.Int64(12000)},
},
}
in PHP i would just have an array and i could manipulate it easily but with GO and my low knowledge i am currently stuck. Is there a way to make this conditionally? I have a few fields obligatory but there are few combinations that i'll need to make.
if c.Name != "" {//c is the struct from json body similar to the stripe but used with a validator
//add it
}