I'm trying to implement marketplace, each vendor has it's own PayPal account for this purpose I saved PayPal config (clientId, secret etc) in database and want to get on PayPalProviderService for this purpose I need to know which user is currently logged in. Here is article which show how to create a middleware to access loggedInUserExample - Access loggedInUser
product.ts (works fine successfully able to get the loggedInUser id)
import { Lifetime } from "awilix";
import { ProductService as MedusaProductService } from "@medusajs/medusa";
// extend core product service
class ProductService extends MedusaProductService {
// The default life time for a core service is SINGLETON
static LIFE_TIME = Lifetime.SCOPED;
constructor(container, options) {
// @ts-ignore
super(...arguments);
try {
console.log("=====>Product Logged in user id:", container.loggedInUser);
} catch (e) {
console.log(e);
}
}
}
export default ProductService;
I also want to get the loggedInUser on PayPalProviderService
paypal-provider.ts (Unable to get loggedInUser it fail to resolve)
class PayPalProviderService extends AbstractPaymentProcessor {
static LIFE_TIME = Lifetime.SCOPED;
constructor(container, options) {
// @ts-ignore
super(...arguments);
try {
console.log(
"=====>Paypal Provider Logged in user id:",
container.loggedInUser
);
} catch (e) {
console.log(e);
}
}
// Other methods...
}
export default PayPalProviderService;
Every time I get this error.
AwilixResolutionError: Could not resolve 'loggedInUser'.
Resolution path: pp_paypal -> paypalProviderService -> loggedInUser
Steps to reproduce this error
Install new medusa backend
Create loggedInUser middleware
Create plugin for payment
Try to access loggedInUser inside payment provider service (in this case PaypalProviderService)
Bug report
Describe the bug
I'm trying to implement marketplace, each vendor has it's own
PayPal
account for this purpose I savedPayPal config (clientId, secret etc)
in database and want to get onPayPalProviderService
for this purpose I need to know which user is currently logged in. Here is article which show how to create a middleware to accessloggedInUser
Example - Access loggedInUsermiddleware.ts
product.ts (works fine successfully able to get the loggedInUser id)
I also want to get the
loggedInUser
onPayPalProviderService
paypal-provider.ts (Unable to get
loggedInUser
it fail to resolve)Every time I get this error.
Steps to reproduce this error