#chronicsmoke
1 messages · Page 1 of 1 (latest)
Hi, you might want to start here: https://stripe.com/docs/development and read through how to set up your development environment.
ive done this and am basically done with my stripe integration, i just need to get tax calculations working
all the other stripe packaged work with import("github.com/stripe/stripe-go/v74"/%package_name%) exept for this one
ive tried /calculation and /tax_calculation...
What do you mean? Are you saying that making this call 'stripe.tax.calculations.create' on your server side is not working? Or something else?
that this packaged doesnt seem to exist...I cant get it with go get
module github.com/stripe/stripe-go/v74@upgrade found (v74.15.0), but does not contain package github.com/stripe/stripe-go/v74/tax_calculation
the docs have this example code: `// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://dashboard.stripe.com/apikeys
stripe.Key =
""
params := &stripe.TaxCalculationParams{
Currency: stripe.String(string(stripe.CurrencyUSD)),
LineItems: []*stripe.TaxCalculationLineItemParams{
&stripe.TaxCalculationLineItemParams{
Amount: stripe.Int64(1000),
Reference: stripe.String("L1"),
},
},
CustomerDetails: &stripe.TaxCalculationCustomerDetailsParams{
Address: &stripe.TaxCalculationCustomerDetailsAddressParams{
Line1: stripe.String("354 Oyster Point Blvd"),
City: stripe.String("South San Francisco"),
State: stripe.String("CA"),
PostalCode: stripe.String("94080"),
Country: stripe.String("US"),
},
AddressSource: stripe.String(string(stripe.TaxCalculationCustomerDetailsAddressSourceShipping)),
},
};
params.AddExpand("line_items.data.tax_breakdown")
result, _ := calculation.New(params);`
this call to calculation.New() doesnt seem to exist in any package I can find
Is this, https://github.com/stripe/stripe-go/blob/master/tax/calculation/client.go what you're looking for?
Looking at what you sent over, you should delete your secret test API from here as well.
I think this is what you want, can you try this?
import (
"net/http"
stripe "github.com/stripe/stripe-go/v74"
"github.com/stripe/stripe-go/v74/form"
)
doesnt seem to like that either....
in the case of other fuctions like paymentmethod.Get() its found in "github.com/stripe/stripe-go/v74/paymentmethod" .... this one should exist in "github.com/stripe/stripe-go/v74/calculation"
but that doesnt exist
Hmm.. Now I'm confused. Can you confirm what is missing from https://github.com/stripe/stripe-go/blob/master/tax/calculation/client.go ?
this is my code `package stripe
import (
cfg "master-blaster/config"
"github.com/stripe/stripe-go/v74"
"github.com/stripe/stripe-go/v74/calculation"
"github.com/stripe/stripe-go/v74/paymentmethod"
)
func CalculateTax(amount int64, pmID string) (int64, error) {
stripe.Key = cfg.Cfg.Stripe.SecretKey
pm, err := paymentmethod.Get(pmID, nil)
if err != nil {
return 0, err
}
params := &stripe.TaxCalculationParams{
Currency: stripe.String(string(stripe.CurrencyUSD)),
LineItems: []*stripe.TaxCalculationLineItemParams{
&stripe.TaxCalculationLineItemParams{
Amount: stripe.Int64(amount),
},
},
CustomerDetails: &stripe.TaxCalculationCustomerDetailsParams{
Address: &stripe.TaxCalculationCustomerDetailsAddressParams{
Line1: stripe.String(pm.BillingDetails.Address.Line1),
City: stripe.String(pm.BillingDetails.Address.City),
State: stripe.String(pm.BillingDetails.Address.State),
PostalCode: stripe.String(pm.BillingDetails.Address.PostalCode),
Country: stripe.String(pm.BillingDetails.Address.Country),
},
AddressSource: stripe.String(string(stripe.TaxCalculationCustomerDetailsAddressSourceShipping)),
},
}
params.AddExpand("line_items.data.tax_breakdown")
result, err := calculation.New(params)
return result.AmountTotal, err
}`
im getting error that &stripe.TaxCalculationCustomerDetailsAddressParams and "github.com/stripe/stripe-go/v74/calculation" dont exist
if i do go get "github.com/stripe/stripe-go/v74/calculation"
it returns: module github.com/stripe/stripe-go/v74@upgrade found (v74.15.0), but does not contain package github.com/stripe/stripe-go/v74/calculation
this calculation.New() function that is quoted in your docs doesnt seem to exist in any package I can find to import
and on the api doc page: https://stripe.com/docs/api/tax/calculations/create
it seems like this doesnt exist either as the only example is a curl
and its listed as a preview
but this page: https://stripe.com/docs/tax/custom presents it with go code as a thing that exists
how do I use the stripe API to calculate tax?
Grabbing someone who has a bit more Go experience
awesome. that seems to work. still have 1 error on the line Address: &stripe.TaxCalculationCustomerDetailsAddressParams{
TaxCalculationCustomerDetailsAddressParams undefined?
you can see everything in https://github.com/stripe/stripe-go/blob/master/tax_calculation.go
https://github.com/stripe/stripe-go/blob/master/tax_calculation.go#L124 seems you want AddressParams