#chronicsmoke

1 messages · Page 1 of 1 (latest)

gloomy wedgeBOT
ivory ore
outer bay
#

ive done this and am basically done with my stripe integration, i just need to get tax calculations working

#

ive tried /calculation and /tax_calculation...

ivory ore
#

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?

outer bay
#

that this packaged doesnt seem to exist...I cant get it with go get

#

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

ivory ore
#

Looking at what you sent over, you should delete your secret test API from here as well.

outer bay
#

this is from your website

ivory ore
#

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"

)

outer bay
#

doesnt seem to like that either....

#

but that doesnt exist

ivory ore
outer bay
#

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

}`

#

this calculation.New() function that is quoted in your docs doesnt seem to exist in any package I can find to import

#

it seems like this doesnt exist either as the only example is a curl

#

and its listed as a preview

#

how do I use the stripe API to calculate tax?

ivory ore
#

Grabbing someone who has a bit more Go experience

burnt ermine
#

👋

#

you want "github.com/stripe/stripe-go/v74/tax/calculation"

outer bay
#

awesome. that seems to work. still have 1 error on the line Address: &stripe.TaxCalculationCustomerDetailsAddressParams{

#

TaxCalculationCustomerDetailsAddressParams undefined?

burnt ermine