Offsite Payment App Template: Error encountered on createPaymentSession
cjayalmontecm opened this issue ยท 2 comments
Issue summary
I encountered "PrismaClientKnownRequestError: Invalid db_server_default.paymentSession.create()
invocation in."
I checked and found that sometimes the same Payment Session is passed in the Payment Session URL.
I also noticed that it occasionally triggers the createPaymentSession function multiple times, leading Prisma to attempt creating a new Payment Session with an already existing Payment ID
Actual Error
creyendo-vite-shopify | [2024-09-12 11:56:03 GMT+9] [INFO] createpaymentSession: {"id":"rEYA9912OIv4YXJlsLko3INde","gid":"gid://shopify/PaymentSession/rEYA9912OIv4YXJlsLko3INde",.......}
creyendo-vite-shopify |
creyendo-vite-express | [2024-09-12 11:56:06] [INFO] [xxxxxxx-xxxx-xxxx-xxxx-xxxxxxx] Request passed from cors (https://creyendo-ext.ec.campt.jp).
creyendo-vite-shopify | POST /payment_session 200 - - 3634.828 ms
creyendo-vite-shopify | [2024-09-12 11:56:08 GMT+9] [INFO] createpaymentSession: {"id":"rEYA9912OIv4YXJlsLko3INde","gid":"gid://shopify/PaymentSession/rEYA9912OIv4YXJlsLko3INde",.......}
creyendo-vite-shopify |
creyendo-vite-shopify | PrismaClientKnownRequestError:
creyendo-vite-shopify | Invalid `db_server_default.paymentSession.create()` invocation in
creyendo-vite-shopify | /src/app/Shopify/build/index.js:326:131
creyendo-vite-shopify |
creyendo-vite-shopify | 323 // app/routes/payments.repository.ts
creyendo-vite-shopify | 324 var createPaymentSession = async (paymentSession) => {
creyendo-vite-shopify | 325 let { amount, paymentMethod, customer } = paymentSession, file = loggerFile("debug");
creyendo-vite-shopify | โ 326 return new Logger(file).info(`createpaymentSession: ${JSON.stringify(paymentSession)}`), await db_server_default.paymentSession.create(
creyendo-vite-shopify | Unique constraint failed on the fields: (`id`)
creyendo-vite-shopify | at Rn.handleRequestError (/src/app/Shopify/node_modules/.prisma/client/runtime/library.js:174:7325)
creyendo-vite-shopify | at Rn.handleAndLogRequestError (/src/app/Shopify/node_modules/.prisma/client/runtime/library.js:174:6754)
creyendo-vite-shopify | at Rn.request (/src/app/Shopify/node_modules/.prisma/client/runtime/library.js:174:6344)
creyendo-vite-shopify | at createPaymentSession (/src/app/Shopify/build/index.js:326:92)
creyendo-vite-shopify | at action4 (/src/app/Shopify/build/index.js:1207:73)
creyendo-vite-shopify | at Object.callRouteActionRR (/src/app/Shopify/node_modules/@remix-run/server-runtime/dist/data.js:35:16)
creyendo-vite-shopify | at callLoaderOrAction (/src/app/Shopify/node_modules/@remix-run/server-runtime/node_modules/@remix-run/router/router.ts:4043:16)
creyendo-vite-shopify | at submit (/src/app/Shopify/node_modules/@remix-run/server-runtime/node_modules/@remix-run/router/router.ts:3156:16)
creyendo-vite-shopify | at queryImpl (/src/app/Shopify/node_modules/@remix-run/server-runtime/node_modules/@remix-run/router/router.ts:3091:22)
creyendo-vite-shopify | at Object.queryRoute (/src/app/Shopify/node_modules/@remix-run/server-runtime/node_modules/@remix-run/router/router.ts:3041:18) {
creyendo-vite-shopify | code: 'P2002',
creyendo-vite-shopify | clientVersion: '4.16.2',
creyendo-vite-shopify | meta: { target: [ 'id' ] }
creyendo-vite-shopify | }
creyendo-vite-shopify | POST /payment_session 500 - - 128.225 ms
I'm not sure if the issue was coming from Shopify itself triggering payment_session multiple times or in our current codes.
Does anyone encounter same issue as mine? What did you do to fix the issue?
Hi there ๐
This repo is for the general Shopify App Remix template. I would recommend creating a discussion in the Shopify community forums.
Hello @lizkenyon, Thank you for the reply.
I'm currently using the Payment App Template of the Remix: https://github.com/Shopify/example-app--payments-app-template--remix/tree/main-js which was forked from this repo.
So I'm hoping if someone has an idea about the issue and that can help me here. Since I can't post directly to the Payment App repo.