#drewbie
1 messages · Page 1 of 1 (latest)
Here's where I'm at so far -
export async function calculateStripeTax(checkout: Checkouts, address: Addresses) {
const stripeClient = new Stripe(Deno.env.get("STRIPE_SECRET_KEY") as string, {
apiVersion: "2022-11-15 tax_calc_beta=v1;tax_txns_beta=v1;" as "2022-11-15",
httpClient: Stripe.createFetchHttpClient(),
});
const stripeResource = stripeClient.StripeResource;
const stripeResourceWithExtend = Object.assign(stripeResource, {
// deno-lint-ignore-line
extend(properties: any) {
return Object.assign({}, this, properties);
},
// deno-lint-ignore-line
method(properties: any) {
return Object.assign({}, this, properties);
},
});
const taxCalculateResource = stripeResourceWithExtend.extend({
request: stripeResourceWithExtend.method({
method: "POST",
path: "tax/calculations",
}),
});
const taxCalculationResult = await new taxCalculateResource(
stripeResourceWithExtend
).request({
reference: checkout.id,
currency: "USD",
line_items: [
{
reference: "uuid1234",
amount: 123,
quantity: 1,
},
],
customer_details: {
address: {
country: address.addressCountryCode,
state: address.addressStateProvince,
postal_code: address.addressPostalCode,
city: address.addressCityLocality,
line2: address.addressLineTwo,
line1: address.addressLineOne,
},
address_source: "billing",
},
});
console.log("tax calc?", taxCalculationResult);
}
And it's giving the error - Error in createCheckout TypeError: taxCalculateResource is not a constructor
Hi 👋 apologies, but we are typically not familiar with flows that are in a beta phase. Most of our access to betas includes a support contact to reach out to if you run into problems, and I would suggest reaching out to them.
Is there a way to just create a fetch client with Stripe that doesnt use the sdk and allow me to pass params as raw json vs params? Really just need one endpoint to be called with this thats responsible for calculating tax. I started down that rabbit hole trying to get the request working in Postman but realized that with using x-www-form-urlendcoded type, passing array params was getting cumbersome and didnt know if there was a way to pass it raw json for the params instead?
No, you can interact with our API directly without using an SDK, but doing so does require using form-encoded parameters.