#dia-checkout-integration

1 messages · Page 1 of 1 (latest)

fast matrixBOT
slow geyser
#

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

glacial surge
#

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"], });

slow geyser
#

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

glacial surge
#

how to get payment details info after payment in checkout?

slow geyser
#

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?

glacial surge
#

after payment, I want like this, so I would like to get invoice history, and also want to get pdf file from stripe.

slow geyser
#

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

glacial surge
#

can I get this using api?

slow geyser
#

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

glacial surge
#

@slow geyser, i added invoice_creation: {
enabled: true,
}, to create sesson, but in sesson, invoice is still null

slow geyser
#

Did you go through the Session and complete the payment end to end?

glacial surge
#

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.

slow geyser
#

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

glacial surge
#

but I get this id in created session.

fast matrixBOT
slow geyser
#

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

glacial surge
#

``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?

slow geyser
#

please work with @grizzled sleet for help

grizzled sleet
#

It does look like these requests are coming from different accounts

glacial surge
#

same account

grizzled sleet
#

Apologies, had an old tab with another session 🤦‍♂️

#

Looking in to what is happening here

#

Ah I see

#

One request was test mode, the other was live mode

#

You used your live mode key for the GEt request