使用 Go 将运输信息附加到 Stripe Charge

Attach shipping information to Stripe Charge using Go

我正在尝试通过 Go API 创建新的费用。我有一个送货地址和一个支付令牌。但是 the Go API doesn't seem to support sending the shipping address. The documentation 表明它应该支持它,但是在文档中描述的参数和 Go ChargeParams 参数之间没有直接映射,并且有些缺失。

type ChargeParams struct {
    Params
    Amount                 uint64
    Currency               Currency
    Customer, Token        string
    Desc, Statement, Email string
    NoCapture              bool
    Fee                    uint64
    Fraud                  FraudReport
    Source                 *SourceParams
}

是否有其他方法可以添加我丢失的地址?

我对 Stripe 的 API 一无所知,但如果你遵循结构的字段,你会发现 ChargeSourceCardAddress1, Address2, City, State, Zip, Country .这就是你想要的吗?

来自 Stripe 支持人员的回答。

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!

以下是如何使用 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"),
    }
})