@easypayment/medusa-paypal-ui 1.0.50 โ 1.0.52
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/README.md +0 -60
- package/dist/index.cjs +457 -146
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -17
- package/dist/index.d.ts +11 -17
- package/dist/index.mjs +466 -155
- package/dist/index.mjs.map +1 -1
- package/dist/order.cjs +20 -7
- package/dist/order.cjs.map +1 -1
- package/dist/order.mjs +20 -7
- package/dist/order.mjs.map +1 -1
- package/package.json +6 -1
- package/src/adapters/MedusaNextPayPalAdapter.tsx +6 -14
- package/src/client/http.ts +15 -44
- package/src/client/paypal.ts +7 -37
- package/src/components/PayPalAdvancedCard.tsx +163 -42
- package/src/components/PayPalCurrencyNotice.tsx +1 -1
- package/src/components/PayPalPaymentSection.tsx +8 -14
- package/src/components/PayPalProvider.tsx +1 -1
- package/src/components/PayPalSmartButtons.tsx +192 -54
- package/src/hooks/usePayPalConfig.ts +13 -4
- package/src/hooks/usePayPalPaymentMethods.ts +14 -4
- package/src/index.ts +1 -0
- package/src/order.ts +20 -7
- package/src/utils/next-errors.ts +17 -0
- package/src/utils/processing-overlay.ts +55 -0
package/README.md
CHANGED
|
@@ -739,66 +739,6 @@ export default Payment
|
|
|
739
739
|
|
|
740
740
|
---
|
|
741
741
|
|
|
742
|
-
## ๐งพ Order confirmation page
|
|
743
|
-
|
|
744
|
-
The Medusa starter's order page renders the payment method with a hard lookup:
|
|
745
|
-
|
|
746
|
-
```tsx
|
|
747
|
-
// src/modules/order/components/payment-details/index.tsx
|
|
748
|
-
{paymentInfoMap[payment.provider_id].title}
|
|
749
|
-
```
|
|
750
|
-
|
|
751
|
-
`paymentInfoMap` has no entry for the PayPal providers (`pp_paypal_paypal`,
|
|
752
|
-
`pp_paypal_card_paypal_card`), so this throws:
|
|
753
|
-
|
|
754
|
-
```
|
|
755
|
-
Cannot read properties of undefined (reading 'title')
|
|
756
|
-
```
|
|
757
|
-
|
|
758
|
-
Use the **server-safe** helpers from the `/order` subpath (no React, safe to
|
|
759
|
-
import in the server-rendered order page). `fetchPayPalConfig` reads the titles
|
|
760
|
-
configured in **Medusa Admin โ Settings โ PayPal** (`paypal_title` /
|
|
761
|
-
`card_title`), so the order page shows the **same labels as checkout**:
|
|
762
|
-
|
|
763
|
-
```tsx
|
|
764
|
-
import { getPaymentLabel, fetchPayPalConfig } from "@easypayment/medusa-paypal-ui/order"
|
|
765
|
-
|
|
766
|
-
// Make the component async (it's a server component) and fetch the admin titles:
|
|
767
|
-
const PaymentDetails = async ({ order }: { order: any }) => {
|
|
768
|
-
const payment = order.payment_collections?.[0]?.payments?.[0]
|
|
769
|
-
|
|
770
|
-
const titles = await fetchPayPalConfig({
|
|
771
|
-
baseUrl: process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL!,
|
|
772
|
-
publishableApiKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
|
|
773
|
-
})
|
|
774
|
-
|
|
775
|
-
return (
|
|
776
|
-
// ...
|
|
777
|
-
<Text className="txt-medium text-ui-fg-subtle" data-testid="payment-method">
|
|
778
|
-
{getPaymentLabel(
|
|
779
|
-
payment?.provider_id,
|
|
780
|
-
paymentInfoMap[payment?.provider_id]?.title,
|
|
781
|
-
titles
|
|
782
|
-
)}
|
|
783
|
-
</Text>
|
|
784
|
-
// ...
|
|
785
|
-
)
|
|
786
|
-
}
|
|
787
|
-
```
|
|
788
|
-
|
|
789
|
-
If that component also renders an icon, guard it too:
|
|
790
|
-
|
|
791
|
-
```tsx
|
|
792
|
-
{paymentInfoMap[payment.provider_id]?.icon ?? <CreditCard />}
|
|
793
|
-
```
|
|
794
|
-
|
|
795
|
-
`getPaymentLabel(providerId, fallback?, titles?)` resolves, in order: the
|
|
796
|
-
**admin-configured PayPal/card title** (`titles`) โ built-in default โ your
|
|
797
|
-
`fallback` โ the raw id. It never throws on an unknown provider. If you'd rather
|
|
798
|
-
not fetch, omit `titles` and it falls back to the default labels.
|
|
799
|
-
|
|
800
|
-
---
|
|
801
|
-
|
|
802
742
|
## ๐งช Testing
|
|
803
743
|
|
|
804
744
|
Toggle between sandbox and live in **Medusa Admin โ Settings โ PayPal โ PayPal Connection โ Environment**.
|