#dia-checkout-integration
1 messages · Page 1 of 1 (latest)
Hey @glacial surge we're happy to help but we focus on developers asking clear and concrete questions about our products and their code. Please take the time to carefully summarize what you are doing, what your code looks like, the exact error(s) you are hitting, etc. all in one clear message so that I can help you
ts const session = await stripe.checkout.sessions.create({ line_items: [ { price_data: { currency: "eur", product_data: { name: "Structure Report", description: "This is structure report of cyprus company", }, unit_amount: 8000, }, quantity: 1, }, ], mode: "payment", success_url: "https://example.com/success", cancel_url: "https://example.com/success", payment_intent_data: { description: "Payment for Structure Report", // You can provide additional data for the payment intent here }, payment_method_types: ["card"], });
Please pause
Write a clear summary in one clear message. Don't press the return key for every message. Just take the time to cleanly summarize it all
dia-checkout-integration
how to get payment details info after payment in checkout?
Not sure what "payment details info after payment" mean though, sorry but can you try and provide more details and context? Do you mean the exact payment method used such as a card's brand and last 4 digits? Or something else?
after payment, I want like this, so I would like to get invoice history, and also want to get pdf file from stripe.
Okay, so by default Checkout does not create any Invoice at all for one-time payments.
You can enable this if you want (with a fee) and it's documented here: https://stripe.com/docs/receipts?payment-ui=checkout#paid-invoices
After that the Checkout Session will have an Invoice id and you can use https://stripe.com/docs/api/invoices/list to list them those though you will likely need to build a customer management logic with a login/password and such
This is definitely drastically more work if you want to support this
can I get this using api?
what is "this". I'm sorry but you need to spend more time on your question and write clear details of what you are after, right now you are being really vague and I can't help you properly
@slow geyser, i added invoice_creation: {
enabled: true,
}, to create sesson, but in sesson, invoice is still null
Did you go through the Session and complete the payment end to end?
no yet, but after payment, how can I get sesson again?
const session = await stripe.checkout.sessions.retrieve(sessionId); i tried this, but I get error.
i tried this, but I get error.
I'm sorry but saying the exact error would help me help you. Please try to take a minute or two before sending the question to make it clear
Those are pictures though. We're both devs, please share all the relevant information as text, especially exact error messages and exact object ids
I assume you mostly created that Checkout Session on account A and then are using that UI tool to retrieve it with the API key of account B
``ts
export const createCheckout = async (req: Request, res: Response) => {
try {
const stripe = new Stripe(process.env.STRIPE_TEST_API_KEY ?? "");
const session = await stripe.checkout.sessions.create({
line_items: [
{
price_data: {
currency: "eur",
product_data: {
name: "Structure Report",
description: "This is structure report of cyprus company",
},
unit_amount: 8000,
},
quantity: 1,
},
],
invoice_creation: {
enabled: true,
},
mode: "payment",
success_url: "https://example.com/success",
cancel_url: "https://example.com/success",
});
return res.status(StatusCodes.OK).json({ result: session });
} catch (error) {
return res.status(StatusCodes.INTERNAL_SERVER_ERROR).json({ error: error?.message ?? error });
}
};
``
this is create sesson.
export const handleTest = async (req: Request, res: Response) => {
try {
const { sessionId } = req.body;
console.log("sessionId: ", sessionId);
const stripe = new Stripe(process.env.STRIPE_API_KEY ?? "");
try {
// Retrieve the session
const session = await stripe.checkout.sessions.retrieve(sessionId);
console.log("session: ", session);
// Retrieve payment details from 'session'
const paymentIntentId = session.payment_intent as string;
const paymentIntent = await stripe.paymentIntents.retrieve(paymentIntentId);
// Now you can access payment details, e.g., paymentIntent.amount, paymentIntent.currency, etc.
// Your additional logic here
res.status(200).json({ success: true, paymentDetails: "Okay" });
} catch (error) {
console.error("Error retrieving payment details:", error);
res.status(500).json({ success: false, error: "Internal server error" });
}
} catch (error) {
return res.status(StatusCodes.INTERNAL_SERVER_ERROR).json({ error: error?.message ?? error });
}
};
this is get session
I used session_id from first, and then used to second, but get error
type: 'StripeInvalidRequestError',
raw: {
code: 'resource_missing',
doc_url: 'https://stripe.com/docs/error-codes/resource-missing',
message: 'No such checkout.session: cs_test_a1iGNbhtPJcVxBXTFehbH5MP2ynx3H7ufJ0M8u61Wo4y5aBR99miXN9bQY',
request_log_url: 'https://dashboard.stripe.com/logs/req_3D0zl9uUEdW6hU?t=1705952525',
type: 'invalid_request_error',
headers: {
server: 'nginx',
date: 'Mon, 22 Jan 2024 19:42:05 GMT',
'content-type': 'application/json',
'content-length': '363',
connection: 'keep-alive',
'access-control-allow-credentials': 'true',
'access-control-allow-methods': 'GET,HEAD,PUT,PATCH,POST,DELETE',
'access-control-allow-origin': '*',
'access-control-expose-headers': 'Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required',
'access-control-max-age': '300',
'cache-control': 'no-cache, no-store',
'content-security-policy': "report-uri https://q.stripe.com/csp-report?p=v1%2Fcheckout%2Fsessions%2F%3Asession; block-all-mixed-content; default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'; img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'",
'request-id': 'req_3D0zl9uUEdW6hU',
'stripe-version': '2023-10-16',
vary: 'Origin',
'x-stripe-routing-context-priority-tier': 'livemode',
'strict-transport-security': 'max-age=63072000; includeSubDomains; preload'
},
statusCode: 404,
requestId: 'req_3D0zl9uUEdW6hU'
},
@slow geyser, can you tell me how can I get sesson from session_id? or how can I get payment_indent after checkout page?
please work with @grizzled sleet for help
It does look like these requests are coming from different accounts
same account