@vicacha-devs/medusa-payment-bold 0.0.0-stage → 0.0.1

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.
Files changed (155) hide show
  1. package/.medusa/server/src/admin/index.cjs +1732 -0
  2. package/.medusa/server/src/admin/index.js +1732 -0
  3. package/.medusa/server/src/api/admin/bold/banks/route.js +15 -0
  4. package/.medusa/server/src/api/admin/bold/payment-button/route.js +44 -0
  5. package/.medusa/server/src/api/admin/bold/payment-link/route.js +61 -0
  6. package/.medusa/server/src/api/admin/bold/payment-link-methods/route.js +16 -0
  7. package/.medusa/server/src/api/admin/bold/payment-methods/route.js +17 -0
  8. package/.medusa/server/src/api/admin/bold/payment-qr/route.js +53 -0
  9. package/.medusa/server/src/api/admin/bold/payment-status/route.js +37 -0
  10. package/.medusa/server/src/api/admin/bold/payment-stream/route.js +103 -0
  11. package/.medusa/server/src/api/admin/bold/pos-push/route.js +46 -0
  12. package/.medusa/server/src/api/admin/bold/refund/route.js +37 -0
  13. package/.medusa/server/src/api/admin/bold/terminals/route.js +16 -0
  14. package/.medusa/server/src/api/admin/plugin/route.js +10 -0
  15. package/.medusa/server/src/api/hooks/payment/bold/route.js +104 -0
  16. package/.medusa/server/src/api/store/plugin/route.js +4 -0
  17. package/.medusa/server/src/hooks/index.js +10 -0
  18. package/.medusa/server/src/hooks/use-bold-checkout-handler.js +135 -0
  19. package/.medusa/server/src/hooks/use-bold-payment-methods.js +20 -0
  20. package/.medusa/server/src/hooks/use-bold-payment-status-stream.js +19 -0
  21. package/.medusa/server/src/hooks/use-bold-refund.js +19 -0
  22. package/.medusa/server/src/hooks/use-bold-terminals.js +13 -0
  23. package/.medusa/server/src/hooks/use-create-bold-button.js +19 -0
  24. package/.medusa/server/src/hooks/use-create-bold-link.js +19 -0
  25. package/.medusa/server/src/hooks/use-create-bold-qr.js +19 -0
  26. package/.medusa/server/src/hooks/use-create-bold-terminal.js +19 -0
  27. package/.medusa/server/src/index.js +21 -0
  28. package/.medusa/server/src/lib/error-utils.js +25 -0
  29. package/.medusa/server/src/lib/get-active-providers.js +34 -0
  30. package/.medusa/server/src/lib/get-provider-options.js +20 -0
  31. package/.medusa/server/src/lib/index.js +4 -0
  32. package/.medusa/server/src/lib/session-helpers.js +11 -0
  33. package/.medusa/server/src/providers/bold-button/index.js +157 -0
  34. package/.medusa/server/src/providers/bold-link/index.js +249 -0
  35. package/.medusa/server/src/providers/bold-online/index.js +169 -0
  36. package/.medusa/server/src/providers/bold-terminal/index.js +170 -0
  37. package/.medusa/server/src/rbac.js +58 -0
  38. package/.medusa/server/src/sdk/client.js +112 -0
  39. package/.medusa/server/src/sdk/query-keys.js +13 -0
  40. package/.medusa/server/src/services/bold-client.js +304 -0
  41. package/.medusa/server/src/services/integrity.js +54 -0
  42. package/.medusa/server/src/types/constants.js +55 -0
  43. package/.medusa/server/src/types/enums.js +15 -0
  44. package/.medusa/server/src/types/errors.js +80 -0
  45. package/.medusa/server/src/types/index.js +3 -0
  46. package/.medusa/server/src/workflows/create-bold-payment-link.js +7 -0
  47. package/.medusa/server/src/workflows/create-bold-refund.js +7 -0
  48. package/.medusa/server/src/workflows/get-bold-payment-methods.js +7 -0
  49. package/.medusa/server/src/workflows/get-integration-api-payment-methods.js +7 -0
  50. package/.medusa/server/src/workflows/get-payment-link-methods.js +7 -0
  51. package/.medusa/server/src/workflows/get-terminals.js +7 -0
  52. package/.medusa/server/src/workflows/index.js +7 -0
  53. package/.medusa/server/src/workflows/steps/create-bold-link.js +43 -0
  54. package/.medusa/server/src/workflows/steps/get-bold-payment-methods.js +12 -0
  55. package/.medusa/server/src/workflows/steps/get-payment-link-methods.js +12 -0
  56. package/.medusa/server/src/workflows/steps/get-terminals.js +13 -0
  57. package/.medusa/server/src/workflows/steps/refund-bold-payment.js +15 -0
  58. package/README.md +106 -2
  59. package/package.json +115 -3
  60. package/src/__tests__/bold-contract.spec.ts +40 -0
  61. package/src/__tests__/bold-qa-emulator.ts +582 -0
  62. package/src/__tests__/bold-use-cases.spec.ts +773 -0
  63. package/src/__tests__/medusa-payment-shim.mjs +334 -0
  64. package/src/__tests__/register-ts-resolver.mjs +101 -0
  65. package/src/admin/README.md +71 -0
  66. package/src/admin/components/bold-terminal-status.tsx +166 -0
  67. package/src/admin/components/icons/bold-fav.tsx +45 -0
  68. package/src/admin/components/icons/copy.tsx +23 -0
  69. package/src/admin/components/icons/index.ts +3 -0
  70. package/src/admin/components/icons/qr-code.tsx +33 -0
  71. package/src/admin/components/icons/smart-phone.tsx +23 -0
  72. package/src/admin/components/index.ts +4 -0
  73. package/src/admin/components/logos/bold.tsx +45 -0
  74. package/src/admin/components/method-item.tsx +19 -0
  75. package/src/admin/components/provider-card.tsx +21 -0
  76. package/src/admin/components/section.tsx +23 -0
  77. package/src/admin/i18n/README.md +58 -0
  78. package/src/admin/i18n/index.ts +11 -0
  79. package/src/admin/i18n/json/ar.json +99 -0
  80. package/src/admin/i18n/json/en.json +99 -0
  81. package/src/admin/i18n/json/es.json +99 -0
  82. package/src/admin/i18n/json/tr.json +99 -0
  83. package/src/admin/routes/settings/bold/components/bold-methods-sidebar.tsx +96 -0
  84. package/src/admin/routes/settings/bold/components/bold-providers-section.tsx +67 -0
  85. package/src/admin/routes/settings/bold/components/index.ts +2 -0
  86. package/src/admin/routes/settings/bold/page.tsx +109 -0
  87. package/src/admin/tsconfig.json +24 -0
  88. package/src/admin/vite-env.d.ts +1 -0
  89. package/src/admin/widgets/bold-audit-timeline.tsx +155 -0
  90. package/src/admin/widgets/bold-payment-actions/bold-payment-actions.tsx +114 -0
  91. package/src/admin/widgets/bold-payment-actions/components/bold-payment-tabs.tsx +127 -0
  92. package/src/admin/widgets/bold-payment-actions/components/bold-remote-payment-panel.tsx +104 -0
  93. package/src/admin/widgets/bold-payment-actions/components/bold-terminal-section.tsx +71 -0
  94. package/src/admin/widgets/bold-payment-actions/hooks/bold-order-balance.ts +126 -0
  95. package/src/admin/widgets/bold-payment-actions/hooks/use-bold-widget-state.tsx +181 -0
  96. package/src/admin/widgets/bold-refund-actions.tsx +151 -0
  97. package/src/admin/widgets/index.ts +12 -0
  98. package/src/api/README.md +37 -0
  99. package/src/api/admin/bold/banks/route.ts +23 -0
  100. package/src/api/admin/bold/payment-button/route.ts +57 -0
  101. package/src/api/admin/bold/payment-link/route.ts +68 -0
  102. package/src/api/admin/bold/payment-link-methods/route.ts +24 -0
  103. package/src/api/admin/bold/payment-methods/route.ts +27 -0
  104. package/src/api/admin/bold/payment-qr/route.ts +68 -0
  105. package/src/api/admin/bold/payment-status/route.ts +48 -0
  106. package/src/api/admin/bold/payment-stream/route.ts +157 -0
  107. package/src/api/admin/bold/pos-push/route.ts +59 -0
  108. package/src/api/admin/bold/refund/route.ts +51 -0
  109. package/src/api/admin/bold/terminals/route.ts +26 -0
  110. package/src/api/admin/plugin/route.ts +14 -0
  111. package/src/api/hooks/payment/bold/route.ts +156 -0
  112. package/src/api/store/plugin/route.ts +5 -0
  113. package/src/hooks/index.ts +9 -0
  114. package/src/hooks/use-bold-checkout-handler.ts +172 -0
  115. package/src/hooks/use-bold-payment-methods.ts +36 -0
  116. package/src/hooks/use-bold-payment-status-stream.ts +55 -0
  117. package/src/hooks/use-bold-refund.ts +33 -0
  118. package/src/hooks/use-bold-terminals.ts +22 -0
  119. package/src/hooks/use-create-bold-button.ts +34 -0
  120. package/src/hooks/use-create-bold-link.ts +33 -0
  121. package/src/hooks/use-create-bold-qr.ts +33 -0
  122. package/src/hooks/use-create-bold-terminal.ts +37 -0
  123. package/src/index.ts +31 -0
  124. package/src/lib/error-utils.ts +29 -0
  125. package/src/lib/get-active-providers.ts +52 -0
  126. package/src/lib/get-provider-options.ts +54 -0
  127. package/src/lib/index.ts +3 -0
  128. package/src/lib/session-helpers.ts +16 -0
  129. package/src/providers/README.md +30 -0
  130. package/src/providers/bold-button/index.ts +244 -0
  131. package/src/providers/bold-link/index.ts +350 -0
  132. package/src/providers/bold-online/index.ts +254 -0
  133. package/src/providers/bold-terminal/index.ts +258 -0
  134. package/src/rbac.ts +72 -0
  135. package/src/sdk/client.ts +157 -0
  136. package/src/sdk/query-keys.ts +13 -0
  137. package/src/services/bold-client.ts +470 -0
  138. package/src/services/integrity.ts +74 -0
  139. package/src/types/constants.ts +63 -0
  140. package/src/types/enums.ts +13 -0
  141. package/src/types/errors.ts +88 -0
  142. package/src/types/index.ts +517 -0
  143. package/src/workflows/create-bold-payment-link.ts +16 -0
  144. package/src/workflows/create-bold-refund.ts +16 -0
  145. package/src/workflows/get-bold-payment-methods.ts +13 -0
  146. package/src/workflows/get-integration-api-payment-methods.ts +13 -0
  147. package/src/workflows/get-payment-link-methods.ts +13 -0
  148. package/src/workflows/get-terminals.ts +10 -0
  149. package/src/workflows/index.ts +6 -0
  150. package/src/workflows/steps/create-bold-link.ts +74 -0
  151. package/src/workflows/steps/get-bold-payment-methods.ts +21 -0
  152. package/src/workflows/steps/get-payment-link-methods.ts +19 -0
  153. package/src/workflows/steps/get-terminals.ts +20 -0
  154. package/src/workflows/steps/refund-bold-payment.ts +28 -0
  155. package/tsconfig.json +41 -0
@@ -0,0 +1,99 @@
1
+ {
2
+ "bold": {
3
+ "admin": {
4
+ "settings": {
5
+ "title": "Bold Kolombiya Ayarları",
6
+ "subtitle": "Ödeme sağlayıcılarını ve yöntemlerini yönetin.",
7
+ "refresh": "Yenile",
8
+ "enabled_providers": "Etkin Sağlayıcılar",
9
+ "enabled_providers_description": "Aktif ödeme sağlayıcı türleri",
10
+ "integration_methods": "Entegrasyon API Yöntemleri",
11
+ "integration_methods_description": "Datáfono ve POS terminal ödeme yöntemleri",
12
+ "payment_link_methods": "Ödeme Bağlantısı Yöntemleri",
13
+ "payment_link_methods_description": "Çevrimiçi ödeme yöntemleri (QR, Kartlar, PSE, Nequi)",
14
+ "no_providers_configured": "Yapılandırılmış sağlayıcı yok",
15
+ "no_methods_available": "Mevcut yöntem yok",
16
+ "method_status_available": "Mevcut",
17
+ "provider_link": "Ödeme Bağlantısı",
18
+ "provider_online": "Çevrimiçi Ödemeler",
19
+ "provider_terminal": "POS Datáfono",
20
+ "provider_button": "Ödeme Düğmesi",
21
+ "loading": "Yükleniyor...",
22
+ "unauthorized_short": "API Erişimi Bekliyor (403)",
23
+ "unauthorized_methods_desc": "Lütfen Bold Üye İşyeri Portalınızda Çevrimiçi Ödemeler (API de Pagos en Línea) özelliğinin etkinleştirildiğinden emin olun.",
24
+ "enable_payments_link": "Çevrimiçi Ödeme API'sini Etkinleştir →",
25
+ "unauthorized_terminals_title": "POS Terminal Entegrasyon Yetkisi Gerekli (403)",
26
+ "unauthorized_terminals_desc": "Datáfono POS işlemleri Bold portalınız üzerinden API entegrasyonları için açıkça yetkilendirilmelidir.",
27
+ "enable_terminals_link": "Terminalleri Yetkilendir →"
28
+ },
29
+ "widget": {
30
+ "title": "Bold Ödeme İşlemleri",
31
+ "description": "Müşteriye uzaktan ödeme bağlantısı veya POS ödemesi gönderin",
32
+ "link_btn": "Ödeme Bağlantısı",
33
+ "qr_btn": "QR Kod",
34
+ "terminal_btn": "Terminale Gönder",
35
+ "terminal_placeholder": "POS Seri No (ör. POS_SMART_01)",
36
+ "send_to_terminal": "POS Terminaline Gönder",
37
+ "approved": "Ödeme Onaylandı",
38
+ "partially_paid": "Kısmen Ödendi",
39
+ "remaining_balance": "Kalan Bakiye",
40
+ "processing": "Ödeme İşleniyor",
41
+ "copy_link": "Bağlantıyı Kopyala",
42
+ "copied": "Kopyalandı",
43
+ "copied_desc": "Ödeme bağlantısı panoya kopyalandı!",
44
+ "already_captured": "Bu sipariş Bold aracılığıyla başarıyla yetkilendirildi ve tahsil edildi.",
45
+ "paid_and_captured": "Ödendi ve Tahsil Edildi"
46
+ },
47
+ "terminal_status": {
48
+ "title": "Bold POS Terminal Filosu Durumu",
49
+ "refresh": "Filoyu Yenile",
50
+ "serial": "Seri Numarası",
51
+ "model": "Donanım Modeli",
52
+ "status": "Durum",
53
+ "battery": "Pil",
54
+ "connectivity": "Bağlantı",
55
+ "unknown": "BİLİNMİYOR",
56
+ "na": "N/A"
57
+ },
58
+ "audit": {
59
+ "title": "Bold Ödeme Denetim Kaydı",
60
+ "events_count": "{{count}} Olay Kaydedildi",
61
+ "session_init": "Oturum Başlatıldı",
62
+ "payment_auth": "Ödeme Yetkilendirildi",
63
+ "payment_captured": "Ödeme Tahsil Edildi ve Kapatıldı",
64
+ "mode_link": "Ödeme Bağlantısı",
65
+ "mode_terminal": "Terminale Gönder",
66
+ "ref": "Ref: {{ref}}",
67
+ "amount": "Tutar: ${{amount}} {{currency}}",
68
+ "headers": {
69
+ "event": "Olay",
70
+ "provider_mode": "Sağlayıcı / Mod",
71
+ "reference": "Referans",
72
+ "amount": "Tutar",
73
+ "status": "Durum",
74
+ "timestamp": "Zaman Damgası"
75
+ },
76
+ "statuses": {
77
+ "success": "BAŞARILI",
78
+ "pending": "BEKLİYOR",
79
+ "info": "BİLGİ"
80
+ }
81
+ },
82
+ "refund": {
83
+ "title": "Bold Ödeme İadesi",
84
+ "captured": "Tahsil Edildi",
85
+ "fully_refunded": "Tamamen İade Edildi",
86
+ "fully_refunded_desc": "Bu ödeme tamamen iade edilmiştir (${{amount}} COP).",
87
+ "captured_total": "Toplam Tahsil Edilen",
88
+ "remaining": "Kalan İade Edilebilir",
89
+ "placeholder": "İade Tutarı (COP)",
90
+ "action": "İade Yap",
91
+ "invalid_amount_title": "Geçersiz Tutar",
92
+ "invalid_amount_desc": "Lütfen 1 ile ${{max}} COP arasında bir tutar girin.",
93
+ "success_title": "İade İşlendi",
94
+ "success_desc": "${{amount}} COP tutarındaki iade başarılı oldu.",
95
+ "error_title": "İade Hatası"
96
+ }
97
+ }
98
+ }
99
+ }
@@ -0,0 +1,96 @@
1
+ import { Text } from "@medusajs/ui"
2
+ import { useTranslation } from "react-i18next"
3
+
4
+ import { MethodItem, Section } from "../../../../components"
5
+
6
+ interface BoldMethodsSidebarProps {
7
+ linkMethods: Record<string, any> | undefined
8
+ isLoadingLink: boolean
9
+ integrationMethods: Array<{ name: string; enabled?: boolean }>
10
+ isLoadingIntegration: boolean
11
+ }
12
+
13
+ export const BoldMethodsSidebar = ({
14
+ linkMethods,
15
+ isLoadingLink,
16
+ integrationMethods,
17
+ isLoadingIntegration,
18
+ }: BoldMethodsSidebarProps) => {
19
+ const { t } = useTranslation()
20
+
21
+ return (
22
+ <>
23
+ <Section
24
+ title={t("bold.admin.settings.payment_link_methods", {
25
+ defaultValue: "Payment Link Methods",
26
+ })}
27
+ description={t("bold.admin.settings.payment_link_methods_description", {
28
+ defaultValue: "Online payment methods (QR, Cards, PSE, Nequi)",
29
+ })}
30
+ >
31
+ {isLoadingLink ? (
32
+ <div className="p-4">
33
+ <Text className="text-xs text-ui-fg-subtle">
34
+ {t("bold.admin.settings.loading", { defaultValue: "Loading..." })}
35
+ </Text>
36
+ </div>
37
+ ) : linkMethods && Object.keys(linkMethods).length > 0 ? (
38
+ <div>
39
+ {Object.entries(linkMethods).map(([method], i) => (
40
+ <MethodItem
41
+ key={i}
42
+ name={method}
43
+ status={t("bold.admin.settings.method_status_available", {
44
+ defaultValue: "Available",
45
+ })}
46
+ />
47
+ ))}
48
+ </div>
49
+ ) : (
50
+ <div className="p-4">
51
+ <Text className="text-xs text-ui-fg-subtle">
52
+ {t("bold.admin.settings.no_methods_available", {
53
+ defaultValue: "No methods available",
54
+ })}
55
+ </Text>
56
+ </div>
57
+ )}
58
+ </Section>
59
+
60
+ <Section
61
+ title={t("bold.admin.settings.integration_methods", {
62
+ defaultValue: "Integration API Methods",
63
+ })}
64
+ description={t("bold.admin.settings.integration_methods_description", {
65
+ defaultValue: "POS and terminal payment methods",
66
+ })}
67
+ >
68
+ {isLoadingIntegration ? (
69
+ <div className="p-4">
70
+ <Text className="text-xs text-ui-fg-subtle">
71
+ {t("bold.admin.settings.loading", { defaultValue: "Loading..." })}
72
+ </Text>
73
+ </div>
74
+ ) : integrationMethods.length === 0 ? (
75
+ <div className="p-4">
76
+ <Text className="text-xs text-ui-fg-subtle">
77
+ {t("bold.admin.settings.no_methods_available", {
78
+ defaultValue: "No methods available",
79
+ })}
80
+ </Text>
81
+ </div>
82
+ ) : (
83
+ <div>
84
+ {integrationMethods.map((m, i) => (
85
+ <MethodItem
86
+ key={i}
87
+ name={m.name}
88
+ status={m.enabled ? "Enabled" : "Disabled"}
89
+ />
90
+ ))}
91
+ </div>
92
+ )}
93
+ </Section>
94
+ </>
95
+ )
96
+ }
@@ -0,0 +1,67 @@
1
+ import { Text } from "@medusajs/ui"
2
+ import { useTranslation } from "react-i18next"
3
+
4
+ import { EBoldPaymentProvider } from "../../../../../types"
5
+ import { ProviderCard, Section } from "../../../../components"
6
+
7
+ interface BoldProvidersSectionProps {
8
+ activeBoldProviders: EBoldPaymentProvider[]
9
+ isLoading: boolean
10
+ }
11
+
12
+ const PROVIDERS = [
13
+ EBoldPaymentProvider.LINK,
14
+ EBoldPaymentProvider.ONLINE,
15
+ EBoldPaymentProvider.TERMINAL,
16
+ EBoldPaymentProvider.BUTTON,
17
+ ]
18
+
19
+ export const BoldProvidersSection = ({
20
+ activeBoldProviders,
21
+ isLoading,
22
+ }: BoldProvidersSectionProps) => {
23
+ const { t } = useTranslation()
24
+
25
+ return (
26
+ <Section
27
+ title={t("bold.admin.settings.enabled_providers", {
28
+ defaultValue: "Enabled Providers",
29
+ })}
30
+ description={t("bold.admin.settings.enabled_providers_description", {
31
+ defaultValue: "Active payment provider types",
32
+ })}
33
+ >
34
+ {isLoading ? (
35
+ <div className="p-4">
36
+ <Text className="text-xs text-ui-fg-subtle">
37
+ {t("bold.admin.settings.loading", { defaultValue: "Loading..." })}
38
+ </Text>
39
+ </div>
40
+ ) : activeBoldProviders.length === 0 ? (
41
+ <div className="p-4">
42
+ <Text className="text-xs text-ui-fg-subtle">
43
+ {t("bold.admin.settings.no_providers_configured", {
44
+ defaultValue: "No providers configured",
45
+ })}
46
+ </Text>
47
+ </div>
48
+ ) : (
49
+ <div className="p-4 grid grid-cols-2 sm:grid-cols-4 gap-3">
50
+ {PROVIDERS.map((provider) => {
51
+ const providerKey = provider.replace("bold-", "")
52
+ return (
53
+ <ProviderCard
54
+ key={provider}
55
+ title={t(`bold.admin.settings.provider_${providerKey}`, {
56
+ defaultValue: providerKey,
57
+ })}
58
+ providerId={provider}
59
+ isEnabled={activeBoldProviders.includes(provider)}
60
+ />
61
+ )
62
+ })}
63
+ </div>
64
+ )}
65
+ </Section>
66
+ )
67
+ }
@@ -0,0 +1,2 @@
1
+ export { BoldProvidersSection } from "./bold-providers-section"
2
+ export { BoldMethodsSidebar } from "./bold-methods-sidebar"
@@ -0,0 +1,109 @@
1
+ import { defineRouteConfig } from "@medusajs/admin-sdk"
2
+ import { CORE_LAYOUT_IDS } from "@medusajs/admin-shared"
3
+ import { LayoutComposer } from "@medusajs/dashboard/components"
4
+ import { Heading, Text, Button } from "@medusajs/ui"
5
+ import { usePaymentProviders } from "@vicacha-devs/medusa-shared-admin/admin"
6
+ import { useTranslation } from "react-i18next"
7
+
8
+ import {
9
+ useBoldIntegrationApiPaymentMethods,
10
+ useBoldPaymentLinkPaymentMethods,
11
+ useBoldTerminals,
12
+ } from "../../../../hooks"
13
+ import { getActiveBoldProviders } from "../../../../lib"
14
+ import { BoldTerminalStatusWidget } from "../../../components"
15
+ import { BoldFavIcon } from "../../../components/icons/bold-fav"
16
+ import { BoldMethodsSidebar, BoldProvidersSection } from "./components"
17
+ import { RbacGuard } from "@vicacha-devs/medusa-shared-admin/admin"
18
+
19
+ export const BoldSettingsPage = () => {
20
+ const { t } = useTranslation()
21
+
22
+ // 1. Payment Providers
23
+ const { providers = [], isLoading: isLoadingProviders } =
24
+ usePaymentProviders()
25
+ const activeBoldProviders = getActiveBoldProviders(providers)
26
+
27
+ // 2. Integration API Payment Methods
28
+ const {
29
+ data: integrationMethodsData,
30
+ isLoading: isLoadingIntegration,
31
+ refetch: refetchIntegration,
32
+ } = useBoldIntegrationApiPaymentMethods()
33
+ const integrationMethods = Array.isArray(integrationMethodsData)
34
+ ? integrationMethodsData
35
+ : integrationMethodsData || []
36
+
37
+ // 3. Payment Link Methods
38
+ const {
39
+ data: linkMethods,
40
+ isLoading: isLoadingLink,
41
+ refetch: refetchLink,
42
+ } = useBoldPaymentLinkPaymentMethods()
43
+
44
+ // 4. Terminals
45
+ const { refetch: refetchTerminals } = useBoldTerminals()
46
+
47
+ const handleRefresh = () => {
48
+ refetchTerminals()
49
+ refetchIntegration()
50
+ refetchLink()
51
+ }
52
+
53
+ return (
54
+ <div className="flex flex-col gap-y-4 h-full">
55
+ {/* Header */}
56
+ <div className="flex items-center justify-between px-6 py-4 border-b border-ui-border-base">
57
+ <div className="flex-1">
58
+ <Heading level="h1" className="text-lg font-semibold">
59
+ {t("bold.admin.settings.title", {
60
+ defaultValue: "Bold Colombia Settings",
61
+ })}
62
+ </Heading>
63
+ <Text className="text-xs text-ui-fg-subtle mt-1">
64
+ {t("bold.admin.settings.subtitle", {
65
+ defaultValue: "Manage payment providers and methods.",
66
+ })}
67
+ </Text>
68
+ </div>
69
+ <Button size="small" variant="secondary" onClick={handleRefresh}>
70
+ {t("bold.admin.settings.refresh", { defaultValue: "Refresh" })}
71
+ </Button>
72
+ </div>
73
+
74
+ {/* Content */}
75
+ <LayoutComposer
76
+ widgetsZonePrefix="bold.settings.details"
77
+ preferredLayoutId={CORE_LAYOUT_IDS.TWO_COLUMN}
78
+ sections={{
79
+ main: (
80
+ <>
81
+ <BoldProvidersSection
82
+ activeBoldProviders={activeBoldProviders}
83
+ isLoading={isLoadingProviders}
84
+ />
85
+ <BoldTerminalStatusWidget />
86
+ </>
87
+ ),
88
+ side: (
89
+ <BoldMethodsSidebar
90
+ linkMethods={linkMethods}
91
+ isLoadingLink={isLoadingLink}
92
+ integrationMethods={integrationMethods}
93
+ isLoadingIntegration={isLoadingIntegration}
94
+ />
95
+ ),
96
+ }}
97
+ />
98
+ </div>
99
+ )
100
+ }
101
+
102
+ export const config = defineRouteConfig({ label: "Bold", icon: BoldFavIcon })
103
+ const GuardedBoldSettingsPage = () => (
104
+ <RbacGuard permission="bold.read">
105
+ <BoldSettingsPage />
106
+ </RbacGuard>
107
+ )
108
+
109
+ export default GuardedBoldSettingsPage
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2023",
4
+ "useDefineForClassFields": true,
5
+ "lib": ["ES2023", "DOM", "DOM.Iterable"],
6
+ "module": "ESNext",
7
+ "skipLibCheck": true,
8
+
9
+ /* Bundler mode */
10
+ "moduleResolution": "bundler",
11
+ "allowImportingTsExtensions": true,
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "noEmit": true,
15
+ "jsx": "react-jsx",
16
+
17
+ /* Linting */
18
+ "strict": true,
19
+ "noUnusedLocals": true,
20
+ "noUnusedParameters": true,
21
+ "noFallthroughCasesInSwitch": true
22
+ },
23
+ "include": ["."]
24
+ }
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
@@ -0,0 +1,155 @@
1
+ import { defineWidgetConfig } from "@medusajs/admin-sdk"
2
+ import { Container, Heading, Badge, Table } from "@medusajs/ui"
3
+ import { useTranslation } from "react-i18next"
4
+
5
+ interface AuditRow {
6
+ id: string
7
+ event: string
8
+ provider: string
9
+ mode: string
10
+ status: "success" | "pending" | "info"
11
+ reference: string
12
+ amount: string
13
+ timestamp: string
14
+ }
15
+
16
+ const BoldAuditTimelineWidget = ({ data: order }: { data: any }) => {
17
+ const { t } = useTranslation()
18
+
19
+ const boldCollections =
20
+ order?.payment_collections?.filter((pc: any) =>
21
+ pc.payment_sessions?.some((s: any) =>
22
+ s.provider_id?.startsWith("pp_bold")
23
+ )
24
+ ) || []
25
+
26
+ if (boldCollections.length === 0) {
27
+ return null
28
+ }
29
+
30
+ const rows: AuditRow[] = []
31
+
32
+ boldCollections.forEach((pc: any) => {
33
+ pc.payment_sessions?.forEach((s: any) => {
34
+ if (s.provider_id?.startsWith("pp_bold")) {
35
+ const ref = s.data?.reference || s.data?.payment_link_id || s.id
36
+
37
+ // 1. Session Init
38
+ rows.push({
39
+ id: `${s.id}-init`,
40
+ event: t("bold.admin.audit.session_init"),
41
+ provider: s.provider_id,
42
+ mode: s.data?.email
43
+ ? t("bold.admin.audit.mode_link")
44
+ : t("bold.admin.audit.mode_terminal"),
45
+ status: "info",
46
+ reference: ref,
47
+ amount: `$${(s.amount || 0).toLocaleString()} ${(s.currency_code || "COP").toUpperCase()}`,
48
+ timestamp: new Date(s.created_at).toLocaleString(),
49
+ })
50
+
51
+ // 2. Authorization
52
+ if (s.authorized_at) {
53
+ rows.push({
54
+ id: `${s.id}-auth`,
55
+ event: t("bold.admin.audit.payment_auth"),
56
+ provider: s.provider_id,
57
+ mode: s.data?.email
58
+ ? t("bold.admin.audit.mode_link")
59
+ : t("bold.admin.audit.mode_terminal"),
60
+ status: "success",
61
+ reference: ref,
62
+ amount: `$${(s.amount || 0).toLocaleString()} ${(s.currency_code || "COP").toUpperCase()}`,
63
+ timestamp: new Date(s.authorized_at).toLocaleString(),
64
+ })
65
+ }
66
+
67
+ // 3. Capture
68
+ if (s.payment?.captured_at) {
69
+ rows.push({
70
+ id: `${s.id}-capture`,
71
+ event: t("bold.admin.audit.payment_captured"),
72
+ provider: s.provider_id,
73
+ mode: s.data?.email
74
+ ? t("bold.admin.audit.mode_link")
75
+ : t("bold.admin.audit.mode_terminal"),
76
+ status: "success",
77
+ reference: s.payment.id,
78
+ amount: `$${(s.payment.amount || s.amount || 0).toLocaleString()} ${(s.currency_code || "COP").toUpperCase()}`,
79
+ timestamp: new Date(s.payment.captured_at).toLocaleString(),
80
+ })
81
+ }
82
+ }
83
+ })
84
+ })
85
+
86
+ return (
87
+ <Container className="p-4 rounded-lg border bg-card space-y-3">
88
+ <div className="flex items-center justify-between border-b pb-3">
89
+ <Heading level="h2" className="text-base font-semibold">
90
+ {t("bold.admin.audit.title")}
91
+ </Heading>
92
+ <Badge color="blue">
93
+ {t("bold.admin.audit.events_count", { count: rows.length })}
94
+ </Badge>
95
+ </div>
96
+
97
+ <Table>
98
+ <Table.Header>
99
+ <Table.Row>
100
+ <Table.HeaderCell>
101
+ {t("bold.admin.audit.headers.event")}
102
+ </Table.HeaderCell>
103
+ <Table.HeaderCell>
104
+ {t("bold.admin.audit.headers.provider_mode")}
105
+ </Table.HeaderCell>
106
+ <Table.HeaderCell>
107
+ {t("bold.admin.audit.headers.reference")}
108
+ </Table.HeaderCell>
109
+ <Table.HeaderCell>
110
+ {t("bold.admin.audit.headers.amount")}
111
+ </Table.HeaderCell>
112
+ <Table.HeaderCell>
113
+ {t("bold.admin.audit.headers.status")}
114
+ </Table.HeaderCell>
115
+ <Table.HeaderCell>
116
+ {t("bold.admin.audit.headers.timestamp")}
117
+ </Table.HeaderCell>
118
+ </Table.Row>
119
+ </Table.Header>
120
+ <Table.Body>
121
+ {rows.map((row) => (
122
+ <Table.Row key={row.id}>
123
+ <Table.Cell className="font-semibold text-xs text-ui-fg-base">
124
+ {row.event}
125
+ </Table.Cell>
126
+ <Table.Cell className="text-xs text-ui-fg-subtle">
127
+ <span className="font-mono">{row.provider}</span> ({row.mode})
128
+ </Table.Cell>
129
+ <Table.Cell className="font-mono text-xs text-ui-fg-muted">
130
+ {row.reference}
131
+ </Table.Cell>
132
+ <Table.Cell className="font-medium text-xs text-ui-fg-base">
133
+ {row.amount}
134
+ </Table.Cell>
135
+ <Table.Cell>
136
+ <Badge color={row.status === "success" ? "green" : "blue"}>
137
+ {t(`bold.admin.audit.statuses.${row.status}`)}
138
+ </Badge>
139
+ </Table.Cell>
140
+ <Table.Cell className="text-[11px] font-mono text-ui-fg-subtle">
141
+ {row.timestamp}
142
+ </Table.Cell>
143
+ </Table.Row>
144
+ ))}
145
+ </Table.Body>
146
+ </Table>
147
+ </Container>
148
+ )
149
+ }
150
+
151
+ export const config = defineWidgetConfig({
152
+ zone: "order.details.after",
153
+ })
154
+
155
+ export default BoldAuditTimelineWidget
@@ -0,0 +1,114 @@
1
+ import { defineWidgetConfig } from "@medusajs/admin-sdk"
2
+ import { DetailWidgetProps, AdminOrder } from "@medusajs/framework/types"
3
+ import { Container, Heading, toast, Text, Badge } from "@medusajs/ui"
4
+ import { useState, useEffect } from "react"
5
+ import { useTranslation } from "react-i18next"
6
+
7
+ import { useBoldWidgetState } from "./hooks/use-bold-widget-state"
8
+ import { BoldTerminalSection } from "./components/bold-terminal-section"
9
+ import { BoldPaymentTabs } from "./components/bold-payment-tabs"
10
+
11
+ export const BoldPaymentActionsWidget = ({
12
+ data: order,
13
+ }: DetailWidgetProps<AdminOrder>) => {
14
+ const { t } = useTranslation()
15
+ const { state, actions } = useBoldWidgetState(order)
16
+ const [activeRemoteTab, setActiveRemoteTab] = useState<"link" | "qr">("link")
17
+
18
+ useEffect(() => {
19
+ if (!state.isLinkEnabled && state.isQrEnabled) {
20
+ setActiveRemoteTab("qr")
21
+ } else if (state.isLinkEnabled) {
22
+ setActiveRemoteTab("link")
23
+ }
24
+ }, [state.isLinkEnabled, state.isQrEnabled])
25
+
26
+ if (state.isLoadingProviders || !state.hasBoldProviders) {
27
+ return null
28
+ }
29
+
30
+ const handleCopy = (text: string) => {
31
+ navigator.clipboard.writeText(text)
32
+ toast.success(t("bold.admin.widget.toast.copied"))
33
+ }
34
+
35
+ return (
36
+ <Container className="p-4 space-y-4">
37
+ {/* Widget Header */}
38
+ <div className="flex items-start justify-between gap-x-2 pb-3 border-b border-ui-border-base">
39
+ <div className="space-y-0.5 min-w-0 flex-1">
40
+ <Heading
41
+ level="h2"
42
+ className="text-sm font-semibold text-ui-fg-base truncate"
43
+ >
44
+ {t("bold.admin.widget.title")}
45
+ </Heading>
46
+ <Text className="text-xs text-ui-fg-subtle line-clamp-2">
47
+ {t("bold.admin.widget.description")}
48
+ </Text>
49
+ </div>
50
+
51
+ <Badge
52
+ color={state.isApproved ? "green" : "orange"}
53
+ size="small"
54
+ className="whitespace-nowrap shrink-0"
55
+ >
56
+ {state.isApproved
57
+ ? t("bold.admin.widget.approved")
58
+ : state.isPartiallyPaid
59
+ ? t("bold.admin.widget.partially_paid", {
60
+ defaultValue: "Partially Paid",
61
+ })
62
+ : t("bold.admin.widget.processing")}
63
+ </Badge>
64
+ </div>
65
+
66
+ {state.isPartiallyPaid && !state.isApproved && (
67
+ <div className="flex items-center justify-between px-3 py-2 rounded-md bg-ui-bg-subtle border border-ui-border-base text-xs">
68
+ <span className="text-ui-fg-subtle">
69
+ {t("bold.admin.widget.remaining_balance", {
70
+ defaultValue: "Remaining Balance",
71
+ })}
72
+ :
73
+ </span>
74
+ <strong className="text-ui-fg-base font-mono">
75
+ ${state.payableAmount.toLocaleString()}{" "}
76
+ {(order.currency_code || "COP").toUpperCase()}
77
+ </strong>
78
+ </div>
79
+ )}
80
+
81
+ <div className="space-y-4">
82
+ {/* 1. REMOTE PAYMENTS (Tabs for Link vs QR) */}
83
+ {(state.isLinkEnabled || state.isQrEnabled) && (
84
+ <BoldPaymentTabs
85
+ activeTab={activeRemoteTab}
86
+ onTabChange={setActiveRemoteTab}
87
+ state={state}
88
+ actions={actions}
89
+ onCopy={handleCopy}
90
+ />
91
+ )}
92
+
93
+ {/* 2. PHYSICAL POS TERMINAL (Permanently visible outside tabs) */}
94
+ {state.isTerminalEnabled && (
95
+ <BoldTerminalSection
96
+ terminalSerial={state.terminalSerial}
97
+ terminalModel={state.terminalModel}
98
+ isApproved={state.isApproved}
99
+ isPushingToPos={state.isPushingToPos}
100
+ onSerialChange={actions.setTerminalSerial}
101
+ onModelChange={actions.setTerminalModel}
102
+ onSubmit={actions.handlePushToPos}
103
+ />
104
+ )}
105
+ </div>
106
+ </Container>
107
+ )
108
+ }
109
+
110
+ export const config = defineWidgetConfig({
111
+ zone: "order.details.side",
112
+ })
113
+
114
+ export default BoldPaymentActionsWidget