Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: payment.webhook_received unable to match payment_provider pp_stripe #9494

Open
420coupe opened this issue Oct 7, 2024 · 3 comments
Open
Assignees

Comments

@420coupe
Copy link
Contributor

420coupe commented Oct 7, 2024

Bug report

Describe the bug

The endpoint payment.webhook_received is failing to match payment provider with id pp_stripe. Order is still placed and considered successful, payment is captured in stripe however the webhook fails because it doesn't match pp_stripe to any provider.

System information

Medusa version (including plugins):@medusajs/[email protected]
Node.js version: v21.7.1
Database: Supabase (postgres)
Operating system: Ubuntu 22.04.4
Browser (if relevant):

Steps to reproduce the behavior

  1. Stand up new medusa backend with latest dev code (RC)
  2. create an order
  3. order goes through successfully, however stripe has 2 attempts to capture the same payment_intent and payment.webhook_received fails which is file packges/modules/payment/src/services/payment-provider
  4. See error

Expected behavior

Submit an order and correctly match to payment provider which i believe should be pp_stripe_stripe instead of pp_stripe

Screenshots

image
image
image

Code snippets

medusa-config.js

const { loadEnv, defineConfig, Modules } = require("@medusajs/framework/utils");

loadEnv(process.env.NODE_ENV, process.cwd());

module.exports = defineConfig({
  projectConfig: {
    databaseUrl: process.env.DATABASE_URL,
    http: {
      storeCors: process.env.STORE_CORS,
      adminCors: process.env.ADMIN_CORS,
      authCors: process.env.AUTH_CORS,
      jwtSecret: process.env.JWT_SECRET || "supersecret",
      cookieSecret: process.env.COOKIE_SECRET || "supersecret",
    },
  },
admin: {
	backendUrl: process.env.MEDUSA_BACKEND_URL,
	path: process.env.MEDUSA_ADMIN_PATH,
	},
  modules: {
    digitalProductModuleService: {
      resolve: "./modules/digital-product",
    },
    [Modules.FULFILLMENT]: {
      resolve: "@medusajs/medusa/fulfillment",
      options: {
        providers: [
          {
            resolve: "@medusajs/medusa/fulfillment-manual",
            id: "manual",
          },
          {
            resolve: "./modules/digital-product-fulfillment",
            id: "digital",
          },
        ],
      },
    },
    [Modules.NOTIFICATION]: {
      resolve: "@medusajs/medusa/notification",
      options: {
        providers: [
          {
            resolve: "@medusajs/medusa/notification-sendgrid",
            id: "sendgrid",
            options: {
              channels: ["email"],
              api_key: process.env.SENDGRID_API_KEY,
              from: process.env.SENDGRID_FROM,
            },
          },
        ],
      },
    },
    [Modules.PAYMENT]: {
      resolve: "@medusajs/medusa/payment",
      options: {
        providers: [
          {
            resolve: "@medusajs/medusa/payment-stripe",
            id: "stripe",
            options: {
              apiKey: process.env.STRIPE_API_KEY,
              automatic_payment_methods: true,
              capture: true,
            },
          },
        ],
      },
    },
    [Modules.FILE]: {
      resolve: "@medusajs/medusa/file",
      options: {
        providers: [
          {
            resolve: "@medusajs/medusa/file-s3",
            id: "s3",
            options: {
              file_url: process.env.SUPABASE_S3_FILE_URL,
              access_key_id: process.env.SUPABASE_S3_ACCESS_KEY,
              secret_access_key: process.env.SUPABASE_S3_SECRET_KEY,
              region: process.env.SUPABASE_S3_REGION,
              bucket: process.env.SUPABASE_S3_BUCKET,
              endpoint: process.env.SUPABASE_S3_ENDPOINT,
              prefix: process.env.SUPABASE_S3_PREFIX,
              additional_client_config: {
                forcePathStyle: true,
              },
            },
          },
        ],
      },
    },
  },
});
@olivermrbl
Copy link
Contributor

@420coupe can you let me know what the provider ID of the payment is? As you say, this should be pp_stripe_stripe since you are using the standard credit card method.

CleanShot 2024-10-08 at 09 33 52

@420coupe
Copy link
Contributor Author

420coupe commented Oct 8, 2024

@420coupe can you let me know what the provider ID of the payment is? As you say, this should be pp_stripe_stripe since you are using the standard credit card method.

CleanShot 2024-10-08 at 09 33 52

provider id in the db is pp_stripe_stripe
image

I have also tried paymentElement vs CardElement and still getting the same results, two capture attempts and error matching coming back to the payment.webhook_received

@420coupe
Copy link
Contributor Author

420coupe commented Oct 8, 2024

also something else i just noticed while digging in the db, status is never updated from authorized to capture in payment_collections nor payment_sessions

to add on this payment_session.data.status is never updated either, not sure if this is handled by the stripe_webhook return since i've never got it working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants