I'm trying to create a new charge via the Go API. I have a shipping address and a payment token. But the Go API doesn't seem to support sending the shipping address. The documentation indicates that it should support it but there isn't a direct mapping between the arguments described in the docs and the Go ChargeParams
arguments and some are missing.
type ChargeParams struct {
Params
Amount uint64
Currency Currency
Customer, Token string
Desc, Statement, Email string
NoCapture bool
Fee uint64
Fraud FraudReport
Source *SourceParams
}
Is there some other way that I'm supposed to add the address that I'm missing?
Answer from Stripe support.
Thanks for writing in about this, I'm happy to help! Unfortunately our go bindings don't support that parameter at the moment which is why you couldn't find it in the source. The temporary solution would be to create the POST request yourself when you need to send the shipping details along with the charge.
I've forwarded this internally to make sure it gets addressed in the future but unfortunately I don't have any timeline to share with you at the moment. We are definitely open to a Pull Request from one of our users so if that's something you'd feel comfortable building yourself that would be awesome!
I know nothing about Stripe's API but if you follow the fields of the struct, you find Charge
➜ Source
➜ Card
➜ Address1, Address2, City, State, Zip, Country
. Is that what you are after?
Here's how to use ChargeParams
to include shipping infomation https://github.com/stripe/stripe-go/blob/master/charge/client_test.go
charge, err := New(&stripe.ChargeParams{
Amount: stripe.Int64(11700),
Currency: stripe.String(string(stripe.CurrencyUSD)),
Source: &stripe.SourceParams{Token: stripe.String("src_123")},
Shipping: &stripe.ShippingDetailsParams{
Address: &stripe.AddressParams{
Line1: stripe.String("line1"),
City: stripe.String("city"),
},
Carrier: stripe.String("carrier"),
Name: stripe.String("name"),
}
})