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]: Unable to retrieve the payment provider with id: #10609

Closed
ChinmayX opened this issue Dec 14, 2024 · 4 comments
Closed

[Bug]: Unable to retrieve the payment provider with id: #10609

ChinmayX opened this issue Dec 14, 2024 · 4 comments

Comments

@ChinmayX
Copy link

Package.json file

{
	"name": "store",
	"private": true,
	"scripts": {
		"build": "medusa build",
		"seed": "medusa exec ./src/scripts/seed.ts",
		"start": "medusa start",
		"dev": "medusa develop"
	},
	"dependencies": {
		"@medusajs/admin-sdk": "latest",
		"@medusajs/cli": "latest",
		"@medusajs/framework": "latest",
		"@medusajs/medusa": "latest",
		"@mikro-orm/core": "5.9.7",
		"@mikro-orm/knex": "5.9.7",
		"@mikro-orm/migrations": "5.9.7",
		"@mikro-orm/postgresql": "5.9.7",
		"@opentelemetry/exporter-zipkin": "^1.28.0",
		"@opentelemetry/instrumentation-pg": "^0.48.0",
		"@opentelemetry/resources": "^1.28.0",
		"@opentelemetry/sdk-node": "^0.55.0",
		"@opentelemetry/sdk-trace-node": "^1.28.0",
		"awilix": "^8.0.1",
		"cashfree-pg": "^4.3.1",
		"pg": "^8.13.0"
	},
	"devDependencies": {
		"@mikro-orm/cli": "5.9.7",
		"@swc/core": "1.5.7",
		"@types/node": "^20.0.0",
		"@types/react": "^18.3.2",
		"@types/react-dom": "^18.2.25",
		"prop-types": "^15.8.1",
		"react": "^18.2.0",
		"react-dom": "^18.2.0",
		"ts-node": "^10.9.2",
		"typescript": "^5.6.2",
		"vite": "^5.2.11"
	},
	"engines": {
		"node": ">=20"
	}
}

Node.js version

v20.17.0

Database and its version

postgreSQL

Operating system name and version

Windowns 10

Browser name

No response

What happended?

error:   
      Unable to retrieve the payment provider with id: pp_cashfree
      Please make sure that the provider is registered in the container and it is configured correctly in your project configuration file.

This is while trying to use the custom payment provider I made.
have attached the files for reference
src/modules/cashfree/service.ts

import {
	AbstractPaymentProvider,
	MedusaError,
	PaymentActions,
	PaymentSessionStatus,
} from "@medusajs/framework/utils";
import {
	CreatePaymentProviderSession,
	ProviderWebhookPayload,
	UpdatePaymentProviderSession,
} from "@medusajs/types";

import { Cashfree } from "cashfree-pg";
import * as Types from "./types";

class CashfreePaymentService extends AbstractPaymentProvider<Types.Options> {
	static identifier = "cashfree";
	... METHODS ...
}

export default CashfreePaymentService;

src/modules/cashfree/index.ts

import { ModuleProvider, Modules } from "@medusajs/framework/utils";
import CashfreePaymentService from "./service";

export default ModuleProvider(Modules.PAYMENT, { services: [CashfreePaymentService] });

Im trying to implement a payment flow in a custom react native storefront
Cart -> Select Shipping method -> Create payment collection -> Create Payment session
getting this error while creating the payment session for provider_id : pp_cashfree

Expected behavior

Create a payment session
image

Actual behavior

gives error
image

Link to reproduction repo

https://github.com/Elite-Digital-Crew/HustleX

@jaykanjia
Copy link

I think your payment provider id will be pp_cashfree_cashfree (pp_<service_identifier>_<module_id>)

@kasperkristensen
Copy link
Contributor

Hi @ChinmayX, your reproduction URL leads to a 404 page, so I can't see how you have registered your payment provider, but the ID you are using is wrong. You are providing only pp_cashfree which translates to pp_{identifier}, but the ID that is generated and stored in the DB is created like this pp_{identifier}_{id}, as described here: https://docs.medusajs.com/resources/references/payment/provider#identifier.

So to give an example if you have registered your payment provider like this in your medusa-config.ts:

module.exports = defineConfig({
  // ...
  modules: [
    {
      resolve: "@medusajs/medusa/payment",
      options: {
        providers: [
          {
            resolve: "./src/modules/cashfree-payment",
            id: "cashfree",
            options: {
              // provider options...
              apiKey: "..."
            }
          }
        ]
      }
    }
  ]

Then the id will be pp_cashfree_cashfree.

Closing the issue as this seems to be the cause of your issue, based on the information that is available. If you are still facing issues, then feel free to re-open it.

@Pacocc97
Copy link

Hey guys, actually I´m having the same issue here. I already assigned my payment provider to the current region. The ID of the provider is "openpay". Its saved as pp_openpay_openpay in my DB. The issue is that it returns that the provider with that ID, doesnt exist. Already tryed pp_openpay as well...

@ChinmayX
Copy link
Author

just upgrade to medusa v2.1.1

or as a temporary solution
change packages/modules/payment/src/services/payment-provider.ts inside your node_modules

this.#logger.error(errMessage) -> this.#logger.error(e)

this will show you the exact error

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

4 participants