英文:
Attach shipping information to Stripe Charge using Go
问题
我正在尝试通过Go API创建一个新的收费。我有一个送货地址和一个支付令牌。但是Go API似乎不支持发送送货地址。文档表明它应该支持,但是文档中描述的参数与Go的ChargeParams
参数之间没有直接映射,并且有一些参数缺失。
有没有其他方法可以添加我缺失的地址呢?
英文:
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?
答案1
得分: 1
我对Stripe的API一无所知,但是如果你按照结构体的字段,你会找到Charge
➜ Source
➜ Card
➜ Address1, Address2, City, State, Zip, Country
。这是你想要的吗?
英文:
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?
答案2
得分: 1
来自Stripe支持团队的回答。
> 感谢您联系我们,我很乐意帮助!不幸的是,我们的go绑定目前不支持该参数,这就是为什么您在源代码中找不到它的原因。临时解决方案是,在需要将运输详细信息与收费一起发送时,自己创建POST请求。
>
> 我已经内部转发了这个问题,以确保在将来得到解决,但不幸的是,我目前没有任何时间表可以与您分享。我们绝对欢迎我们的用户提交拉取请求,所以如果您愿意自己构建这个功能,那将是很棒的!
英文:
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!
答案3
得分: 0
这是如何使用ChargeParams
来包含运输信息的示例代码: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"),
}
})
英文:
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"),
}
})
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论