#blackoutapp
1 messages · Page 1 of 1 (latest)
hello! can you share an example charge.succeeded event?
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)
i see you're using Checkout Sessions, do you only support cards as a payment method?
if you're only supporting cards, then what I would recommend is to consider using checkout.session.completed instead : https://dashboard.stripe.com/events/evt_1NJC2HJ7tfGRbSV6R8FFnDL2 - maybe take a look and see if it contains all the details you need?
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
how do I get a session from a charge?
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
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
ah i see, so the charge doesn't contain all of those information as you've noticed
yea
you can setup a webhook to listen for checkout.session.completed events instead : https://stripe.com/docs/webhooks/quickstart and process the events when you receive them
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?
hrm
Can you share your account id so that I can take a closer look at how your setup? You can find your account id by logging in to https://dashboard.stripe.com/settings/account. It'll be in the upper right hand corner and looks like acct_123
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
acct_1Fgk0IJ7tfGRbSV6
i assume you created a payment and are not seeing tax on it, can you share the object id for that too?
this is probably going to take a while to look into, i'll get back to you
ok
include automatic_tax.enabled=true : https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-automatic_tax when you create the Checkout Session. Try making payment with a customer who has a billing address in NY and see if tax now shows
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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
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
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?
do you have the request id? or what's the exact error message?
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'."
automatic_tax : {
enabled : true
}
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