@easypayment/medusa-payment-paypal 0.9.18 → 0.9.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.medusa/server/src/admin/index.js +287 -118
- package/.medusa/server/src/admin/index.mjs +287 -118
- package/.medusa/server/src/admin/routes/settings/paypal/connection/page.d.ts.map +1 -1
- package/.medusa/server/src/admin/routes/settings/paypal/connection/page.js +386 -127
- package/.medusa/server/src/admin/routes/settings/paypal/connection/page.js.map +1 -1
- package/.medusa/server/src/api/admin/paypal/onboarding-link/route.d.ts.map +1 -1
- package/.medusa/server/src/api/admin/paypal/onboarding-link/route.js +4 -0
- package/.medusa/server/src/api/admin/paypal/onboarding-link/route.js.map +1 -1
- package/.medusa/server/src/modules/paypal/service.d.ts +1 -0
- package/.medusa/server/src/modules/paypal/service.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/service.js +5 -1
- package/.medusa/server/src/modules/paypal/service.js.map +1 -1
- package/package.json +1 -1
- package/src/admin/routes/settings/paypal/connection/page.tsx +419 -131
- package/src/api/admin/paypal/onboarding-link/route.ts +6 -0
- package/src/modules/paypal/service.ts +7 -2
|
@@ -8,6 +8,7 @@ import type PayPalModuleService from "../../../../modules/paypal/service"
|
|
|
8
8
|
type Body = {
|
|
9
9
|
email?: string
|
|
10
10
|
products?: string[]
|
|
11
|
+
environment?: "sandbox" | "live"
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export async function POST(req: AuthenticatedMedusaRequest, res: MedusaResponse) {
|
|
@@ -19,10 +20,15 @@ export async function POST(req: AuthenticatedMedusaRequest, res: MedusaResponse)
|
|
|
19
20
|
? String(req.auth_context.user_metadata.email)
|
|
20
21
|
: undefined
|
|
21
22
|
const email = authEmail ?? body.email ?? "admin@paypal.com"
|
|
23
|
+
const env =
|
|
24
|
+
body.environment === "sandbox" || body.environment === "live"
|
|
25
|
+
? body.environment
|
|
26
|
+
: undefined
|
|
22
27
|
|
|
23
28
|
const link = await paypal.createOnboardingLink({
|
|
24
29
|
email,
|
|
25
30
|
products: body.products,
|
|
31
|
+
env,
|
|
26
32
|
})
|
|
27
33
|
|
|
28
34
|
return res.json({
|
|
@@ -493,10 +493,15 @@ class PayPalModuleService extends MedusaService({
|
|
|
493
493
|
return await this.getCurrentRow()
|
|
494
494
|
}
|
|
495
495
|
|
|
496
|
-
async createOnboardingLink(input?: { email?: string; products?: string[] }) {
|
|
496
|
+
async createOnboardingLink(input?: { email?: string; products?: string[]; env?: Environment }) {
|
|
497
497
|
const { onboarding } = await this.ensureSettingsDefaults()
|
|
498
498
|
const return_url = `${String(onboarding.backend_url || "").replace(/\/$/, "")}/admin/paypal/onboard-complete`
|
|
499
|
-
|
|
499
|
+
// Honor an explicit environment from the caller so the generated link can't
|
|
500
|
+
// depend on a racing "set environment" request having landed first.
|
|
501
|
+
const env =
|
|
502
|
+
input?.env === "sandbox" || input?.env === "live"
|
|
503
|
+
? input.env
|
|
504
|
+
: await this.getCurrentEnvironment()
|
|
500
505
|
const partner_merchant_id = await this.getPartnerMerchantId(env)
|
|
501
506
|
|
|
502
507
|
const email = (input?.email || "").trim()
|