#blackoutapp

1 messages · Page 1 of 1 (latest)

sharp wigeonBOT
dry nexus
#

hello! can you share an example charge.succeeded event?

coral torrent
#

hello

#

yea hold on

#

maybe i'm doing this wrong

#

this is an example of a return I get when looking up the latest charge from a user

#

So I'm doing
try {
const customer = await stripe.customers.search({
query: email: "${email}"
});
const listOfCharges = await stripe.charges.list({
customer: customer.data[0].id
});

if (
  listOfCharges.data.length > 0 &&
  listOfCharges.data[0].paid === true &&
  listOfCharges.data[0].refunded === false &&
  listOfCharges.data[0].status === 'succeeded'
) {
  let latestCharge = listOfCharges.data[0];
  console.log(latestCharge)
dry nexus
#

i see you're using Checkout Sessions, do you only support cards as a payment method?

coral torrent
#

yea

#

my sales are completely online

dry nexus
coral torrent
#

how do I get a session from a charge?

dry nexus
#

is there any reason why you need to listen for charge.succeeded specifically? You can listen for checkout.session.completed in your webhook endpoint instead

coral torrent
#

sorry no I guess just to check my work right now I was simply querying for a user by email and grabbing their latest charge - this was the object I was parsing

#

I figured I could grab all the info from there

#

I guess that's not quite the case

dry nexus
#

ah i see, so the charge doesn't contain all of those information as you've noticed

coral torrent
#

yea

dry nexus
coral torrent
#

cool I'll look into that

#

one other question

#

i enabled automatic tax calculation in my admin panel as the no-code option

#

but I don't think it's working

#

is this something I need to also enable in my backend I guess?

dry nexus
#

hrm

coral torrent
#

acct_1Fgk0IJ7tfGRbSV6

dry nexus
#

i assume you created a payment and are not seeing tax on it, can you share the object id for that too?

coral torrent
#

yea let me dig one up

#

here's one: pi_3NQYaFJ7tfGRbSV61VcRCEsX

dry nexus
#

this is probably going to take a while to look into, i'll get back to you

coral torrent
#

ok

dry nexus
coral torrent
#

ok

#

this might take a day or so. Sorry I'm new to coding. Realizing my old devs are using the Stripe API from 2020

#

I think I need to upgrade

dry nexus
#

you're using the stripe-node SDK, i think it's fine

#

you shouldn't need to upgrade specifically to include the automatic_tax parameter

coral torrent
#

it's giving me an error

#

i think it needs to be automatic_tax.enabled: true

#

because it's an object I'm passing into the checkout session

#

right?

dry nexus
#

do you have the request id? or what's the exact error message?

coral torrent
#

const { id } = await this.stripe.checkout.sessions.create({
success_url: ${this.getBaseUrl(req.hostname)}order/${planId}/success,
cancel_url: ${this.getBaseUrl(req.hostname)}order/${planId}/cancel,
payment_method_types: ["card"],
customer_email: user.email,
line_items: plan.description
? [
{
name: plan.name,
description: plan.description,
amount: plan.price * 100,
currency: "usd",
quantity: 1,
},
]
: [
{
name: plan.name,
amount: plan.price * 100,
currency: "usd",
quantity: 1,
},
],
mode: "payment",
billing_address_collection: "required",
automatic_tax.enabled: true,
});

#

"Argument of type '{ success_url: string; cancel_url: string; payment_method_types: "card"[]; customer_email: string; line_items: { name: string; description: string; amount: number; currency: string; quantity: number; }[] | { ...; }[]; ... 4 more ...; true: any; }' is not assignable to parameter of type 'SessionCreateParams'.
Object literal may only specify known properties, and 'automatic_tax' does not exist in type 'SessionCreateParams'."

dry nexus
#

automatic_tax : {
enabled : true
}

coral torrent
#

it's still giving me that error in vscode but let me just try to run the app

#

yea it's still saying "automatic_tax" does not exist in type 'SessionCreateParams'."

#

I think I'll try updating the npm package

#

thanks for your help you've gone above and beyond

#

this has helped

#

I'll reach back out later this week if I still can't figure it out

#

I'm in the middle of onboarding a another dev so hopefully they'll have some insight too