@easypayment/medusa-paypal-ui 1.2.2 → 1.2.7
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/CHANGELOG.md +23 -1
- package/README.md +85 -52
- package/dist/index.cjs +197 -88
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +197 -88
- package/dist/index.mjs.map +1 -1
- package/dist/order.cjs.map +1 -1
- package/dist/order.mjs.map +1 -1
- package/package.json +1 -1
- package/src/adapters/MedusaNextPayPalAdapter.tsx +196 -195
- package/src/client/http.ts +214 -204
- package/src/client/paypal.ts +91 -88
- package/src/client/types.ts +40 -40
- package/src/components/PayPalAdvancedCard.tsx +646 -611
- package/src/components/PayPalCurrencyNotice.tsx +24 -19
- package/src/components/PayPalPaymentSection.tsx +5 -1
- package/src/components/PayPalProvider.tsx +44 -38
- package/src/components/PayPalSmartButtons.tsx +489 -445
- package/src/hooks/usePayPalConfig.ts +99 -96
- package/src/hooks/usePayPalPaymentMethods.ts +145 -145
- package/src/index.ts +19 -16
- package/src/order.ts +140 -134
- package/src/utils/next-errors.ts +21 -21
- package/src/utils/processing-overlay.ts +96 -96
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import React from "react"
|
|
4
|
-
import type { PayPalConfig } from "../client/types"
|
|
5
|
-
|
|
6
|
-
export function PayPalCurrencyNotice({ config }: { config: PayPalConfig }) {
|
|
7
|
-
if (config.currency_supported) return null
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<div
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
</
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import React from "react"
|
|
4
|
+
import type { PayPalConfig } from "../client/types"
|
|
5
|
+
|
|
6
|
+
export function PayPalCurrencyNotice({ config }: { config: PayPalConfig }) {
|
|
7
|
+
if (config.currency_supported) return null
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<div
|
|
11
|
+
role="alert"
|
|
12
|
+
style={{ padding: 12, border: "1px solid #ddd", borderRadius: 10 }}
|
|
13
|
+
>
|
|
14
|
+
<div style={{ fontWeight: 600, marginBottom: 6 }}>
|
|
15
|
+
PayPal currency issue
|
|
16
|
+
</div>
|
|
17
|
+
<ul style={{ margin: 0, paddingLeft: 18 }}>
|
|
18
|
+
{(config.currency_errors || []).map((e) => (
|
|
19
|
+
<li key={e}>{e}</li>
|
|
20
|
+
))}
|
|
21
|
+
</ul>
|
|
22
|
+
</div>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
@@ -10,7 +10,11 @@ import {
|
|
|
10
10
|
|
|
11
11
|
// Re-exported for backward compatibility — these have always been part of this
|
|
12
12
|
// module's public API. The canonical definitions live in ../constants.
|
|
13
|
-
export {
|
|
13
|
+
export {
|
|
14
|
+
PAYPAL_WALLET_PROVIDER_ID,
|
|
15
|
+
PAYPAL_CARD_PROVIDER_ID,
|
|
16
|
+
isPayPalProviderId,
|
|
17
|
+
}
|
|
14
18
|
|
|
15
19
|
const SPIN_STYLE = `@keyframes _pp_section_spin { to { transform: rotate(360deg) } }`
|
|
16
20
|
|
|
@@ -1,38 +1,44 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import React, { useMemo } from "react"
|
|
4
|
-
import { PayPalScriptProvider } from "@paypal/react-paypal-js"
|
|
5
|
-
import type { ReactPayPalScriptOptions } from "@paypal/react-paypal-js"
|
|
6
|
-
import type { PayPalConfig } from "../client/types"
|
|
7
|
-
|
|
8
|
-
const BN_CODE = "MBJTechnolabs_SI_SPB"
|
|
9
|
-
|
|
10
|
-
export function PayPalProvider(props: {
|
|
11
|
-
config: PayPalConfig
|
|
12
|
-
intent?: "capture" | "authorize"
|
|
13
|
-
disableFunding?: string
|
|
14
|
-
children: React.ReactNode
|
|
15
|
-
}) {
|
|
16
|
-
const { config, intent = "capture", disableFunding, children } = props
|
|
17
|
-
|
|
18
|
-
const options = useMemo((): ReactPayPalScriptOptions => {
|
|
19
|
-
return {
|
|
20
|
-
clientId: config.client_id,
|
|
21
|
-
currency: config.currency,
|
|
22
|
-
intent,
|
|
23
|
-
components: config.client_token ? "buttons,card-fields" : "buttons",
|
|
24
|
-
"data-client-token": config.client_token || undefined,
|
|
25
|
-
"disable-funding": disableFunding,
|
|
26
|
-
"data-partner-attribution-id": BN_CODE,
|
|
27
|
-
}
|
|
28
|
-
}, [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import React, { useMemo } from "react"
|
|
4
|
+
import { PayPalScriptProvider } from "@paypal/react-paypal-js"
|
|
5
|
+
import type { ReactPayPalScriptOptions } from "@paypal/react-paypal-js"
|
|
6
|
+
import type { PayPalConfig } from "../client/types"
|
|
7
|
+
|
|
8
|
+
const BN_CODE = "MBJTechnolabs_SI_SPB"
|
|
9
|
+
|
|
10
|
+
export function PayPalProvider(props: {
|
|
11
|
+
config: PayPalConfig
|
|
12
|
+
intent?: "capture" | "authorize"
|
|
13
|
+
disableFunding?: string
|
|
14
|
+
children: React.ReactNode
|
|
15
|
+
}) {
|
|
16
|
+
const { config, intent = "capture", disableFunding, children } = props
|
|
17
|
+
|
|
18
|
+
const options = useMemo((): ReactPayPalScriptOptions => {
|
|
19
|
+
return {
|
|
20
|
+
clientId: config.client_id,
|
|
21
|
+
currency: config.currency,
|
|
22
|
+
intent,
|
|
23
|
+
components: config.client_token ? "buttons,card-fields" : "buttons",
|
|
24
|
+
"data-client-token": config.client_token || undefined,
|
|
25
|
+
"disable-funding": disableFunding,
|
|
26
|
+
"data-partner-attribution-id": BN_CODE,
|
|
27
|
+
}
|
|
28
|
+
}, [
|
|
29
|
+
config.client_id,
|
|
30
|
+
config.currency,
|
|
31
|
+
config.client_token,
|
|
32
|
+
intent,
|
|
33
|
+
disableFunding,
|
|
34
|
+
])
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<PayPalScriptProvider
|
|
38
|
+
key={`${options.clientId}-${options["data-client-token"] ?? "no-token"}`}
|
|
39
|
+
options={options}
|
|
40
|
+
>
|
|
41
|
+
{children}
|
|
42
|
+
</PayPalScriptProvider>
|
|
43
|
+
)
|
|
44
|
+
}
|