manishkatyan / strapi-stripe

Stripe Plugin for Strapi CMS
65 stars 32 forks source link

Error when i went to section payments #94

Closed uridark closed 1 year ago

uridark commented 1 year ago

error: select "t0"., "t0"."id", "t0"."created_by_id", "t0"."updated_by_id" from "public"."strapi-stripe_ss-product" as "t0" where ("t0"."id" = $1) limit $2 - invalid input syntax for type integer: "undefined" error: select "t0"., "t0"."id", "t0"."created_by_id", "t0"."updated_by_id" from "public"."strapi-stripe_ss-product" as "t0" where ("t0"."id" = $1) limit $2 - invalid input syntax for type integer: "undefined" at Parser.parseErrorMessage (D:\Projects BeardBoy\reseed-api\node_modules\pg-protocol\dist\parser.js:287:98) at Parser.handlePacket (D:\Projects BeardBoy\reseed-api\node_modules\pg-protocol\dist\parser.js:126:29) at Parser.parse (D:\Projects BeardBoy\reseed-api\node_modules\pg-protocol\dist\parser.js:39:38) at Socket. (D:\Projects BeardBoy\reseed-api\node_modules\pg-protocol\dist\index.js:11:42) at Socket.emit (node:events:513:28) at Socket.emit (node:domain:489:12) at addChunk (node:internal/streams/readable:324:12) at readableAddChunk (node:internal/streams/readable:297:9) at Readable.push (node:internal/streams/readable:234:10) at TCP.onStreamRead (node:internal/stream_base_commons:190:23)

image

only occurs when using yarn develop --watch-admin in console

uridark commented 1 year ago

another error, in POST createProduct:

[2023-06-21 20:16:12.489] http: POST /strapi-stripe/createProduct (1018 ms) 200 image after push button create: image

console log of the error: StripeInvalidRequestError: Plans may only be created with products of type service, but the supplied product (prod_O7spOpGW9TPliG) had type good. at StripeError.generate (D:\Projects BeardBoy\reseed-api\node_modules\stripe\lib\Error.js:40:16) at res.toJSON.then.StripeAPIError.message (D:\Projects BeardBoy\reseed-api\node_modules\stripe\lib\StripeResource.js:220:35) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { type: 'StripeInvalidRequestError', raw: { message: 'Plans may only be created with products of type service, but the supplied product (prod_O7spOpGW9TPliG) had type good.', param: 'product', request_log_url: 'https://dashboard.stripe.com/test/logs/req_6Y9UoTil5jirVj?t=1687400172', type: 'invalid_request_error', headers: { server: 'nginx', date: 'Thu, 22 Jun 2023 02:16:12 GMT', 'content-type': 'application/json', 'content-length': '321', connection: 'keep-alive', 'access-control-allow-credentials': 'true', 'access-control-allow-methods': 'GET, POST, HEAD, OPTIONS, DELETE', 'access-control-allow-origin': '', 'access-control-expose-headers': 'Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required', 'access-control-max-age': '300', 'cache-control': 'no-cache, no-store', 'idempotency-key': 'f3a558a1-3249-4429-91ee-661c2a50649e', 'original-request': 'req_6Y9UoTil5jirVj', 'request-id': 'req_6Y9UoTil5jirVj', 'stripe-should-retry': 'false', 'stripe-version': '2016-07-06', 'x-stripe-routing-context-priority-tier': 'api-testmode', 'strict-transport-security': 'max-age=63072000; includeSubDomains; preload' }, statusCode: 400, requestId: 'req_6Y9UoTil5jirVj' }, rawType: 'invalid_request_error', code: undefined, doc_url: undefined, param: 'product', detail: undefined, headers: { server: 'nginx', date: 'Thu, 22 Jun 2023 02:16:12 GMT', 'content-type': 'application/json', 'content-length': '321', connection: 'keep-alive', 'access-control-allow-credentials': 'true', 'access-control-allow-methods': 'GET, POST, HEAD, OPTIONS, DELETE', 'access-control-allow-origin': '', 'access-control-expose-headers': 'Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required', 'access-control-max-age': '300', 'cache-control': 'no-cache, no-store', 'idempotency-key': 'f3a558a1-3249-4429-91ee-661c2a50649e', 'original-request': 'req_6Y9UoTil5jirVj', 'request-id': 'req_6Y9UoTil5jirVj', 'stripe-should-retry': 'false', 'stripe-version': '2016-07-06', 'x-stripe-routing-context-priority-tier': 'api-testmode', 'strict-transport-security': 'max-age=63072000; includeSubDomains; preload' }, requestId: 'req_6Y9UoTil5jirVj', statusCode: 400, charge: undefined, decline_code: undefined, payment_intent: undefined, payment_method: undefined, payment_method_type: undefined, setup_intent: undefined, source: undefined }

nishekh-e-r commented 1 year ago

@uridark I am not able to produce the above error, can you please provide more information on how to reproduce it?

uridark commented 1 year ago

version: "strapi-stripe": "^3.4.1", 1.- I init strapi with yarn develop 2.- go to payment section: image when i enter in payment section throw the next error: error: select "t0"., "t0"."id", "t0"."created_by_id", "t0"."updated_by_id" from "public"."strapi-stripe_ss-product" as "t0" where ("t0"."id" = $1) limit $2 - invalid input syntax for type integer: "undefined" error: select "t0"., "t0"."id", "t0"."created_by_id", "t0"."updated_by_id" from "public"."strapi-stripe_ss-product" as "t0" where ("t0"."id" = $1) limit $2 - invalid input syntax for type integer: "undefined" at Parser.parseErrorMessage (D:\Projects BeardBoy\reseed-api\node_modules\pg-protocol\dist\parser.js:287:98) at Parser.handlePacket (D:\Projects BeardBoy\reseed-api\node_modules\pg-protocol\dist\parser.js:126:29) at Parser.parse (D:\Projects BeardBoy\reseed-api\node_modules\pg-protocol\dist\parser.js:39:38) at Socket. (D:\Projects BeardBoy\reseed-api\node_modules\pg-protocol\dist\index.js:11:42) at Socket.emit (node:events:513:28) at Socket.emit (node:domain:489:12) at addChunk (node:internal/streams/readable:324:12) at readableAddChunk (node:internal/streams/readable:297:9) at Readable.push (node:internal/streams/readable:234:10) at TCP.onStreamRead (node:internal/stream_base_commons:190:23) If i want to create a product:

image then => image when this happen, the server throw: StripeInvalidRequestError: Plans may only be created with products of type service, but the supplied product (prod_O9k0KfZyssFXMs) had type good. at StripeError.generate (D:\Projects BeardBoy\reseed-api\node_modules\stripe\lib\Error.js:40:16) at res.toJSON.then.StripeAPIError.message (D:\Projects BeardBoy\reseed-api\node_modules\stripe\lib\StripeResource.js:220:35) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { type: 'StripeInvalidRequestError', raw: { message: 'Plans may only be created with products of type service, but the supplied product (prod_O9k0KfZyssFXMs) had type good.', param: 'product', request_log_url: 'https://dashboard.stripe.com/test/logs/req_oneLzTiaxjCPYm?t=1687828619', type: 'invalid_request_error', headers: { server: 'nginx', date: 'Tue, 27 Jun 2023 01:16:59 GMT', 'content-type': 'application/json', 'content-length': '321', connection: 'keep-alive', 'access-control-allow-credentials': 'true', 'access-control-allow-methods': 'GET, POST, HEAD, OPTIONS, DELETE', 'access-control-allow-origin': '', 'access-control-expose-headers': 'Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required', 'access-control-max-age': '300', 'cache-control': 'no-cache, no-store', 'idempotency-key': '4c3d714b-d460-4ae7-9e70-0015e1d58406', 'original-request': 'req_oneLzTiaxjCPYm', 'request-id': 'req_oneLzTiaxjCPYm', 'stripe-should-retry': 'false', 'stripe-version': '2016-07-06', 'x-stripe-routing-context-priority-tier': 'api-testmode', 'strict-transport-security': 'max-age=63072000; includeSubDomains; preload' }, statusCode: 400, requestId: 'req_oneLzTiaxjCPYm' }, rawType: 'invalid_request_error', code: undefined, doc_url: undefined, param: 'product', detail: undefined, headers: { server: 'nginx', date: 'Tue, 27 Jun 2023 01:16:59 GMT', 'content-type': 'application/json', 'content-length': '321', connection: 'keep-alive', 'access-control-allow-credentials': 'true', 'access-control-allow-methods': 'GET, POST, HEAD, OPTIONS, DELETE', 'access-control-allow-origin': '', 'access-control-expose-headers': 'Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required', 'access-control-max-age': '300', 'cache-control': 'no-cache, no-store', 'idempotency-key': '4c3d714b-d460-4ae7-9e70-0015e1d58406', 'original-request': 'req_oneLzTiaxjCPYm', 'request-id': 'req_oneLzTiaxjCPYm', 'stripe-should-retry': 'false', 'stripe-version': '2016-07-06', 'x-stripe-routing-context-priority-tier': 'api-testmode', 'strict-transport-security': 'max-age=63072000; includeSubDomains; preload' }, requestId: 'req_oneLzTiaxjCPYm', statusCode: 400, charge: undefined, decline_code: undefined, payment_intent: undefined, payment_method: undefined, payment_method_type: undefined, setup_intent: undefined, source: undefined } I follow all steps to integrate stripe with strapi, this is my config: image

uridark commented 1 year ago

i already clean up the cache of the project, build it again and reinstall strapi-stripe but the error remains

uridark commented 1 year ago

code of stripe in src/extensions/strapi-stripe/public/stripe.js `// @ts-nocheck / eslint-disable no-undef / 'use strict';

window.onload = () => { // for product Checkout const ssProduct = document.querySelectorAll('.SS_ProductCheckout');

if (ssProduct) { ssProduct.forEach(product => { product.addEventListener('click', function handleClick(event) { SS_ProductCheckout( event.target.dataset.id, event.target.dataset.url, event.target.dataset.email ); }); }); } // for storing product payment order in strapi const params = new URLSearchParams(document.location.search); const checkoutSessionId = params.get('sessionId'); if (checkoutSessionId) { SS_GetProductPaymentDetails(checkoutSessionId); } };

// product Checkout logic

function SS_ProductCheckout(productId, baseUrl, userEmail) { localStorage.setItem('strapiStripeUrl', baseUrl); const getRedirectUrl = baseUrl + '/strapi-stripe/getRedirectUrl/' + productId + '/' + userEmail;

fetch(getRedirectUrl, { method: 'get', mode: 'cors', headers: new Headers({ 'Content-Type': 'application/json', }), }) .then(response => response.json()) .then(response => { if (response.url) { window.location.replace(response.url); } }); }

// storing product payment order in strapi logic

function SS_GetProductPaymentDetails(checkoutSessionId) { const baseUrl = localStorage.getItem('strapiStripeUrl'); const retrieveCheckoutSessionUrl = baseUrl + '/strapi-stripe/retrieveCheckoutSession/' + checkoutSessionId; if ( window.performance .getEntriesByType('navigation') .map(nav => nav.type) .includes('reload') ) { console.info('website reloded'); } else { fetch(retrieveCheckoutSessionUrl, { method: 'get', mode: 'cors', headers: new Headers({ 'Content-Type': 'application/json', }), }); } } `

nishekh-e-r commented 1 year ago

@uridark I think you haven't added .env variables. you can check the installation section which will explain how to add a .env variable https://www.npmjs.com/package/strapi-stripe

uridark commented 1 year ago

i dont think is that the problem, im already have it, of course, i change the xxx for the keys and token STRAPI_ADMIN_API_TOKEN= xxxx STRAPI_ADMIN_LIVE_STRIPE_SECRET_KEY= xxxx STRAPI_ADMIN_TEST_STRIPE_SECRET_KEY= xxxx

uridark commented 1 year ago

i think is something in the middlewares of security in strapi, i modified for integrate aws s3 in strapi, so, in someway, i think interferes with stripe. module.exports = [ 'strapi::errors', { name: 'strapi::security', config: { contentSecurityPolicy: { useDefaults: true, directives: { 'connect-src': ["'self'", 'https:',], 'img-src': [ "'self'", 'data:', 'blob:', 'market-assets.strapi.io', 'here is the bucket s3', ], 'media-src': [ "'self'", 'data:', 'blob:', 'market-assets.strapi.io', 'here is the bucket s3', ], upgradeInsecureRequests: null, }, }, }, }, / End of snippet / 'strapi::cors', 'strapi::poweredBy', 'strapi::logger', 'strapi::query', 'strapi::body', 'strapi::session', 'strapi::favicon', 'strapi::public', ]; otherwise, i cant find the error, i follow all the steps in installing stripe, step by step.

nishekh-e-r commented 1 year ago

@uridark I think you need to update the stripe api. also please check this issue link who has faced similar one https://github.com/manishkatyan/strapi-stripe/issues/64