@tly-pay/vendure-plugin 0.0.0-stage → 1.0.0

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 (86) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/LICENSE +21 -0
  3. package/README.md +192 -2
  4. package/assets/coins/arb.svg +10 -0
  5. package/assets/coins/base.svg +4 -0
  6. package/assets/coins/bln.svg +4 -0
  7. package/assets/coins/bnb.svg +13 -0
  8. package/assets/coins/btc.svg +1 -0
  9. package/assets/coins/busd.svg +7 -0
  10. package/assets/coins/coin.svg +1 -0
  11. package/assets/coins/dai.svg +1 -0
  12. package/assets/coins/doge.svg +109 -0
  13. package/assets/coins/eth.svg +10 -0
  14. package/assets/coins/jst.svg +11 -0
  15. package/assets/coins/link.svg +4 -0
  16. package/assets/coins/ltc.svg +4 -0
  17. package/assets/coins/op.svg +12 -0
  18. package/assets/coins/pol.svg +11 -0
  19. package/assets/coins/shib.svg +18 -0
  20. package/assets/coins/sol.svg +15 -0
  21. package/assets/coins/sun.svg +71 -0
  22. package/assets/coins/trx.svg +4 -0
  23. package/assets/coins/uni.svg +10 -0
  24. package/assets/coins/usdc.svg +6 -0
  25. package/assets/coins/usdd.svg +18 -0
  26. package/assets/coins/usdt.svg +1 -0
  27. package/assets/coins/wbtc.svg +16 -0
  28. package/assets/coins/weth.svg +17 -0
  29. package/assets/tly-pay-mark.svg +31 -0
  30. package/dashboard/api.ts +167 -0
  31. package/dashboard/appearance.tsx +253 -0
  32. package/dashboard/banner.tsx +72 -0
  33. package/dashboard/i18n/en.po +584 -0
  34. package/dashboard/index.tsx +33 -0
  35. package/dashboard/logic.ts +219 -0
  36. package/dashboard/messages.tsx +90 -0
  37. package/dashboard/notice.tsx +15 -0
  38. package/dashboard/order-block.tsx +21 -0
  39. package/dashboard/orders.tsx +246 -0
  40. package/dashboard/page.tsx +174 -0
  41. package/dashboard/settings.tsx +186 -0
  42. package/dashboard/use-connect.ts +46 -0
  43. package/dist/api.d.ts +169 -0
  44. package/dist/api.js +541 -0
  45. package/dist/client-ref.d.ts +75 -0
  46. package/dist/client-ref.js +165 -0
  47. package/dist/connect-flow.d.ts +65 -0
  48. package/dist/connect-flow.js +177 -0
  49. package/dist/connection-check.d.ts +28 -0
  50. package/dist/connection-check.js +49 -0
  51. package/dist/connection.d.ts +140 -0
  52. package/dist/connection.js +361 -0
  53. package/dist/contracts.d.ts +66 -0
  54. package/dist/contracts.js +151 -0
  55. package/dist/creation-service.d.ts +136 -0
  56. package/dist/creation-service.js +242 -0
  57. package/dist/handler.d.ts +13 -0
  58. package/dist/handler.js +45 -0
  59. package/dist/hosted-checkout.d.ts +3 -0
  60. package/dist/hosted-checkout.js +25 -0
  61. package/dist/index.d.ts +11 -0
  62. package/dist/index.js +32 -0
  63. package/dist/ownership.d.ts +38 -0
  64. package/dist/ownership.js +38 -0
  65. package/dist/payment-sync.d.ts +45 -0
  66. package/dist/payment-sync.js +111 -0
  67. package/dist/persistence.d.ts +104 -0
  68. package/dist/persistence.js +405 -0
  69. package/dist/plugin.d.ts +26 -0
  70. package/dist/plugin.js +112 -0
  71. package/dist/public-api.d.ts +56 -0
  72. package/dist/public-api.js +221 -0
  73. package/dist/records.d.ts +53 -0
  74. package/dist/records.js +109 -0
  75. package/dist/release-config.d.ts +55 -0
  76. package/dist/release-config.js +107 -0
  77. package/dist/release-config.json +15 -0
  78. package/dist/secret-box.d.ts +19 -0
  79. package/dist/secret-box.js +65 -0
  80. package/dist/service.d.ts +267 -0
  81. package/dist/service.js +788 -0
  82. package/dist/signed-webhook.d.ts +67 -0
  83. package/dist/signed-webhook.js +119 -0
  84. package/dist/storefront/checkout.d.mts +86 -0
  85. package/dist/storefront/checkout.mjs +149 -0
  86. package/package.json +97 -4
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="60px" height="60px" viewBox="0 0 60 60" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <title>USDD</title>
4
+ <g id="USDD" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
5
+ <circle fill="#FFFFFF" cx="30" cy="30" r="30"></circle>
6
+ <g>
7
+ <circle stroke="#216C58" stroke-width="2" fill-opacity="0.2" fill="#216C58" cx="30" cy="30" r="29"></circle>
8
+ <circle stroke="#216C58" stroke-width="2" fill="#216C58" cx="30" cy="30" r="20"></circle>
9
+ <g transform="translate(12.000000, 12.000000)">
10
+ <path d="M36,16.4774128 C35.3511153,7.27078029 27.5405633,0 18.0007887,0 C8.45321383,0 0.63769057,7.28267504 0,16.5 M0,19.5 C0.674438666,28.7236199 8.47688334,36 18.0028463,36 C27.5027601,36 35.2885688,28.7633607 36,19.5756235" stroke="#FFFFFF"></path>
11
+ <g transform="translate(10.500000, 4.500000)" fill="#FFFFFF">
12
+ <path d="M6.87370164,24.7957795 L6.875,27.7857143 L5,27.7857143 L4.9984662,24.5473739 C5.57320514,24.6759864 6.19856141,24.7587883 6.87370164,24.7957795 Z M10.0015482,24.628319 L10,27.7857143 L8.125,27.7857143 L8.12630762,24.8127919 C8.79689409,24.7949647 9.42219869,24.7330091 10.0015482,24.628319 Z M10.0010884,17.0510292 L9.99992286,20.1679872 C9.4624153,20.3379925 8.83459611,20.4392245 8.12539702,20.4670592 L8.12482178,16.3868907 C8.99705299,16.674386 9.62109517,16.8971944 10.0010884,17.0510292 Z M6.80203046,15.9617128 L6.875,15.984 L6.87558182,20.4415021 C6.12564064,20.3786313 5.50169948,20.2282059 4.99928926,19.9994808 L4.99808231,15.3489362 C5.52152672,15.5337673 6.12308041,15.7380261 6.80203046,15.9617128 Z M10.0017532,8.55827726 L10.000311,12.5672966 C9.45008781,12.3691206 8.82536466,12.1561617 8.12551652,11.9297141 L8.12664091,8.01124622 C8.88938337,8.08417415 9.5190383,8.26173666 10.0017532,8.55827726 Z M6.87196113,7.97892451 L6.87454929,11.511972 C5.9875372,11.2058158 5.36008935,10.9659558 4.99875909,10.7991776 L4.99914595,8.3047756 C5.49261617,8.11052283 6.11394302,8.00495507 6.87196113,7.97892451 Z M10,2.28571429 L10.0009202,3.95359293 C9.42747022,3.81805235 8.80180528,3.73364679 8.12487056,3.69939759 L8.125,2.28571429 L10,2.28571429 Z M6.875,2.28571429 L6.87486498,3.69344249 C6.2058152,3.72297808 5.58107109,3.80889994 4.99950391,3.95237683 L5,2.28571429 L6.875,2.28571429 Z M15,0 L15,1.89473684 L0,1.89473684 L0,0 L15,0 Z"></path>
13
+ <path d="M7.41116751,4.5 C5.45685279,4.5 3.85786802,4.9467655 2.58883249,5.86657682 C1.21827411,6.81266846 0.558375635,8.12668464 0.558375635,9.78234501 C0.558375635,11.4380054 1.24365482,12.6994609 2.63959391,13.5667116 C3.17258883,13.8820755 4.56852792,14.4076819 6.80203046,15.143531 C8.8071066,15.7742588 9.97461929,16.1947439 10.3299492,16.3787062 C11.4467005,16.9568733 12.0304569,17.745283 12.0304569,18.7439353 C12.0304569,19.532345 11.6243655,20.1367925 10.8629442,20.6098383 C10.1015228,21.0566038 9.03553299,21.2931267 7.71573604,21.2931267 C6.21827411,21.2931267 5.12690355,21.0040431 4.41624365,20.4784367 C3.62944162,19.8739892 3.14720812,18.8490566 2.94416244,17.4299191 L0,17.4299191 C0.126903553,19.8214286 0.964467005,21.5559299 2.48730964,22.6597035 C3.73096447,23.5532345 5.4822335,24 7.71573604,24 C10.0253807,24 11.8274112,23.5006739 13.0964467,22.5545822 C14.3654822,21.5822102 15,20.2419137 15,18.559973 C15,16.8254717 14.213198,15.4851752 12.6395939,14.5128032 C11.928934,14.0923181 10.3553299,13.4615903 7.89340102,12.6731806 C6.21827411,12.1212938 5.17766497,11.7270889 4.79695431,11.5168464 C3.93401015,11.0438005 3.52791878,10.3867925 3.52791878,9.59838275 C3.52791878,8.70485175 3.88324873,8.04784367 4.64467005,7.65363881 C5.25380711,7.31199461 6.11675127,7.15431267 7.25888325,7.15431267 C8.5786802,7.15431267 9.59390863,7.39083558 10.2538071,7.91644205 C10.9137056,8.41576819 11.3959391,9.25673854 11.6497462,10.4130728 L14.5939086,10.4130728 C14.4162437,8.36320755 13.680203,6.83894879 12.4111675,5.86657682 C11.2182741,4.9467655 9.54314721,4.5 7.41116751,4.5 Z" stroke="#FFFFFF" stroke-width="0.5" fill-rule="nonzero"></path>
14
+ </g>
15
+ </g>
16
+ </g>
17
+ </g>
18
+ </svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="98" height="98"><title>Tether USD</title><g fill="none" fill-rule="evenodd"><circle cx="16" cy="16" r="16" fill="#26A17B"/><path fill="#FFF" d="M17.922 17.383v-.002c-.11.008-.677.042-1.942.042-1.01 0-1.721-.03-1.971-.042v.003c-3.888-.171-6.79-.848-6.79-1.658 0-.809 2.902-1.486 6.79-1.66v2.644c.254.018.982.061 1.988.061 1.207 0 1.812-.05 1.925-.06v-2.643c3.88.173 6.775.85 6.775 1.658 0 .81-2.895 1.485-6.775 1.657m0-3.59v-2.366h5.414V7.819H8.595v3.608h5.414v2.365c-4.4.202-7.709 1.074-7.709 2.118 0 1.044 3.309 1.915 7.709 2.118v7.582h3.913v-7.584c4.393-.202 7.694-1.073 7.694-2.116 0-1.043-3.301-1.914-7.694-2.117"/></g></svg>
@@ -0,0 +1,16 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="98" height="98" viewBox="0 0 500 500" fill="none"><title>Wrapped Bitcoin</title>
2
+ <g clip-path="url(#clip0_1_11065)">
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M250 0C388 0 500 111.9 500 250C500 388 388 500 250 500C111.9 500 0 388 0 250C0 111.9 111.9 0 250 0Z" fill="white"/>
4
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M407.7 104.9L394 118.7C461.9 193 461.9 306.7 394 381L407.7 394.7C483.3 312.7 483.3 186.6 407.7 104.6V104.9Z" fill="#5A5564"/>
5
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M118.9 106.1C193.1 38.2002 307 38.2002 381.2 106.1L395 92.4002C313.1 16.8002 186.8 16.8002 104.9 92.4002L118.9 106.1Z" fill="#5A5564"/>
6
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M106.1 381.1C38.3002 306.9 38.3002 193.2 106.1 118.9L92.4002 105.2C16.8002 187.1 16.8002 313.4 92.4002 395.3L106.1 381.1Z" fill="#5A5564"/>
7
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M381.1 393.8C306.9 461.7 193 461.7 118.8 393.8L105 407.5C186.9 483.1 313.2 483.1 395.1 407.5L381.1 393.8Z" fill="#5A5564"/>
8
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M291.6 215C291.6 242.5 248.7 239.1 235 239.1V190.7C248.7 190.8 291.6 186.5 291.6 215ZM302.8 290.1C302.8 320.1 251.4 316.7 235 316.7V263.5C251.4 263.5 302.8 258.8 302.8 290.1ZM336.7 204.2C334 175.6 309.3 166 278 163V123.5H253.9V162.2C247.5 162.2 241 162.2 234.6 162.4V123.5H210.6V163.2H195.2H161.6V189.1C161.6 189.1 179.4 188.8 179.2 189.1C185.9 188.4 192 193.1 192.9 199.7V308.5C192.8 310.8 191.7 312.9 190 314.4C188.3 315.9 186 316.6 183.8 316.5C184.1 316.7 166.2 316.5 166.2 316.5L161.4 345.4H192.9H210.2V385.8H234.4V346H253.7V385.6H277.9V345.7C318.7 343.2 347.2 333.1 350.7 294.9C353.6 264.1 339.1 250.4 316 244.9C330 237.7 338.8 225.1 336.7 204.2Z" fill="#F09242"/>
9
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M249.9 19.5C122.7 19.6 19.7 122.7 19.7 249.9C19.7 377.1 122.8 480.2 250.1 480.2C377.3 480.2 480.4 377.1 480.5 249.9C480.3 122.7 377.2 19.7 249.9 19.6V19.5ZM249.9 500C111.9 500 0 388 0 250C0 111.9 111.9 0 250 0C388 0 500 111.9 500 249.9C499.8 388 388 499.8 249.9 500Z" fill="#282138"/>
10
+ </g>
11
+ <defs>
12
+ <clipPath id="clip0_1_11065">
13
+ <rect width="500" height="500" fill="white"/>
14
+ </clipPath>
15
+ </defs>
16
+ </svg>
@@ -0,0 +1,17 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="98" height="98" viewBox="0 0 500 500" fill="none"><title>Wrapped Ether</title>
2
+ <g clip-path="url(#clip0_1_11114)">
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M250 500C388.1 500 500 388.1 500 250C500 111.9 388.1 0 250 0C111.9 0 0 111.9 0 250C0 388.1 111.9 500 250 500Z" fill="#25292E"/>
4
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M386.1 86.8C349.3 56 301.8 37.5 250 37.5C198.2 37.5 150.7 56 113.9 86.8C111.1 89.1 111 93.3 113.6 95.8L118.1 100.3C120.4 102.6 124.2 102.7 126.7 100.6C160.2 72.9 203.2 56.2 250.1 56.2C297 56.2 340 72.9 373.5 100.6C376 102.7 379.8 102.6 382.1 100.3L386.6 95.8C389 93.3 388.9 89.1 386.1 86.8ZM100.3 118C102.6 120.3 102.7 124.1 100.6 126.6C72.9 160.1 56.2 203.1 56.2 250C56.2 296.9 72.9 339.9 100.6 373.4C102.7 375.9 102.6 379.7 100.3 382L95.8 386.5C93.3 389 89.1 388.9 86.8 386.2C56 349.3 37.5 301.8 37.5 250C37.5 198.2 56 150.7 86.8 113.9C89.1 111.1 93.3 111 95.8 113.6L100.3 118ZM399.4 373.4C397.3 375.9 397.4 379.7 399.7 382L404.2 386.5C406.7 389 410.9 388.9 413.2 386.2C444 349.3 462.5 301.9 462.5 250.1C462.5 198.3 444 150.8 413.2 114C410.9 111.2 406.7 111.1 404.2 113.7L399.7 118.2C397.4 120.5 397.3 124.3 399.4 126.8C427.1 160.3 443.8 203.3 443.8 250.2C443.8 297.1 427.1 339.9 399.4 373.4ZM113.9 413.2C150.8 444 198.2 462.5 250 462.5C301.8 462.5 349.3 444 386.1 413.2C388.9 410.9 389 406.7 386.4 404.2L381.9 399.7C379.6 397.4 375.8 397.3 373.3 399.4C339.8 427.1 296.8 443.8 249.9 443.8C203 443.8 160 427.1 126.5 399.4C124 397.3 120.2 397.4 117.9 399.7L113.4 404.2C111 406.7 111.1 410.9 113.9 413.2Z" fill="white"/>
5
+ <path d="M165.6 261.5L250 311.4L334.4 261.5L250 380.4L165.6 261.5Z" fill="url(#paint0_linear_1_11114)"/>
6
+ <path d="M250 292.8L165.6 242.9L250 110L334.4 242.9L250 292.8Z" fill="white"/>
7
+ </g>
8
+ <defs>
9
+ <linearGradient id="paint0_linear_1_11114" x1="249.992" y1="261.48" x2="249.992" y2="380.395" gradientUnits="userSpaceOnUse">
10
+ <stop stop-color="white"/>
11
+ <stop offset="1" stop-color="white" stop-opacity="0.9"/>
12
+ </linearGradient>
13
+ <clipPath id="clip0_1_11114">
14
+ <rect width="500" height="500" fill="white"/>
15
+ </clipPath>
16
+ </defs>
17
+ </svg>
@@ -0,0 +1,31 @@
1
+ <svg width="764" height="370" viewBox="84 84 764 370" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <title>TLY Pay mark</title>
3
+ <path d="M315.5 84C211.737 84 130.629 84.3021 99.6433 84.4368C94.418 84.4595 91.7613 90.6511 95.3594 94.4404C108.352 108.123 131.898 132.484 146.5 145C157.889 154.762 173.085 158 179.5 158H301C381.5 158 401 240.324 424.5 250C439.071 256 440 233.217 461 224C484 213.905 499.357 224.5 503 216C506.643 207.5 461 145 430.5 113C403 91.5 362.548 84 315.5 84Z" fill="url(#paint0_linear_2022_2908)"/>
4
+ <path d="M809.999 85.4995L834.5 85.4997C848 85.4998 778.5 148.273 763.5 154C736 164.5 715.5 157.75 694 190C658.27 243.594 628.232 323.107 594.5 378.5C576.838 407.502 549.983 425.513 520 435.772C520 435.772 456 452.5 415 419.5C374 386.5 361.5 338.5 361.5 338.5C400.966 381.5 494.13 382 518.5 335C553.5 267.5 576.5 221 611.5 166.5C636 123 665.62 85.4996 721 85.4996C798.423 85.4996 804.211 85.4995 809.999 85.4995Z" fill="url(#paint1_linear_2022_2908)"/>
5
+ <path d="M306 243C321 243 338.505 313.445 361.5 338.499C361.5 338.499 374 386.5 415 419.5C456 452.5 520 435.771 520 435.771C469.345 453.103 409.761 448.307 370.5 437C317 421.591 295.176 387 281.5 341C270.5 303.999 278.5 243 306 243Z" fill="url(#paint2_linear_2022_2908)"/>
6
+ <circle cx="482.5" cy="269.5" r="37" fill="url(#paint3_radial_2022_2908)"/>
7
+ <defs>
8
+ <linearGradient id="paint0_linear_2022_2908" x1="474.5" y1="150" x2="115" y2="100" gradientUnits="userSpaceOnUse">
9
+ <stop stop-color="#5989FE"/>
10
+ <stop offset="0.288206" stop-color="#2D2EE3"/>
11
+ <stop offset="0.408827" stop-color="#2319CA"/>
12
+ <stop offset="0.561091" stop-color="#241CD0"/>
13
+ <stop offset="1" stop-color="#4D73FF"/>
14
+ </linearGradient>
15
+ <linearGradient id="paint1_linear_2022_2908" x1="818.5" y1="67.5" x2="417" y2="440.5" gradientUnits="userSpaceOnUse">
16
+ <stop stop-color="#5881FF"/>
17
+ <stop offset="0.312608" stop-color="#4668FF"/>
18
+ <stop offset="0.618632" stop-color="#364EFD"/>
19
+ <stop offset="0.985166" stop-color="#2118C4"/>
20
+ </linearGradient>
21
+ <linearGradient id="paint2_linear_2022_2908" x1="239" y1="330" x2="528" y2="366" gradientUnits="userSpaceOnUse">
22
+ <stop offset="0.0937048" stop-color="#281ACE"/>
23
+ <stop offset="0.497877" stop-color="#4F7AFF"/>
24
+ <stop offset="1" stop-color="#6289FF"/>
25
+ </linearGradient>
26
+ <radialGradient id="paint3_radial_2022_2908" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(482.5 269.5) rotate(90) scale(37)">
27
+ <stop stop-color="white"/>
28
+ <stop offset="0.774038" stop-color="#BDEA13"/>
29
+ </radialGradient>
30
+ </defs>
31
+ </svg>
@@ -0,0 +1,167 @@
1
+ import { api } from "@vendure/dashboard"
2
+ import type { IconOption } from "./logic"
3
+
4
+ /** Admin API documents of the plugin; results are typed by hand to keep the extension self-contained. */
5
+
6
+ export type Asset = { symbol: string; name: string; networks: string[] }
7
+
8
+ export type Status = {
9
+ connected: boolean
10
+ state: "off" | "ok" | "pending" | "warn"
11
+ displayName: string
12
+ storeId: string
13
+ currency: string
14
+ merchantDomain: string
15
+ paymentsReady: boolean
16
+ paymentAssets: Asset[]
17
+ lastErr: string
18
+ unverified: boolean
19
+ validatedAt: number
20
+ webhookUrl: string
21
+ releaseComplete: boolean
22
+ consoleOrigin: string
23
+ apiHost: string
24
+ checkoutMode: string
25
+ /** The selected marks, which may be none; every mark the Store accepts while never saved. */
26
+ checkoutIcons: string[]
27
+ /** Options in the order checkout shows the icons. */
28
+ checkoutIconOptions: IconOption[]
29
+ checkoutCoinNames: boolean
30
+ /** Name of the Channel's TLY Pay payment method, or the default title without one. */
31
+ checkoutTitle: string
32
+ paymentMethodId: string | null
33
+ siteMode: "standard" | "test"
34
+ channelCurrency: string
35
+ paymentMethod: "missing" | "disabled" | "no_checker" | "ready"
36
+ }
37
+
38
+ export type Result = { result: string; retry: boolean }
39
+
40
+ export type OrderRow = {
41
+ id: string
42
+ orderCode: string
43
+ orderId: string | null
44
+ orderState: string | null
45
+ state: string
46
+ status: string | null
47
+ statusVersion: number
48
+ amountRaw: string
49
+ currency: string
50
+ checkoutMode: string
51
+ paymentId: string | null
52
+ err: string | null
53
+ settleErr: string | null
54
+ settledAt: string | null
55
+ createdAt: string
56
+ updatedAt: string
57
+ }
58
+
59
+ export type OrderCounts = Record<"all" | "open" | "paid" | "attention" | "closed" | "creating", number>
60
+
61
+ export type OrderDetail = {
62
+ row: OrderRow
63
+ checkoutOrigin: string | null
64
+ returnUrl: string | null
65
+ clientRef: string | null
66
+ live: { status: string; statusVersion: number; activatedAt: string | null; paymentExpiresAt: string; updatedAt: string } | null
67
+ liveErr: string | null
68
+ events: { eventId: string; status: string; statusVersion: number; occurredAt: string; receivedAt: string;
69
+ outcome: string | null; processedAt: string | null }[]
70
+ }
71
+
72
+ const STATUS_FIELDS = `connected state displayName storeId currency merchantDomain paymentsReady
73
+ paymentAssets { symbol name networks } lastErr unverified validatedAt webhookUrl releaseComplete consoleOrigin
74
+ apiHost checkoutMode checkoutIcons checkoutIconOptions { mark label iconUrl accepted } checkoutCoinNames checkoutTitle
75
+ paymentMethodId siteMode channelCurrency paymentMethod`
76
+ const ROW_FIELDS = `id orderCode orderId orderState state status statusVersion amountRaw currency checkoutMode paymentId
77
+ err settleErr settledAt createdAt updatedAt`
78
+
79
+ export async function readStatus(): Promise<Status> {
80
+ return (await api.query<{ tlyPayStatus: Status }>(`query TlyPayStatus { tlyPayStatus { ${STATUS_FIELDS} } }`)).tlyPayStatus
81
+ }
82
+
83
+ /** Rechecks the connection against TLY Pay first, as the Settings tab does when it opens. */
84
+ export async function checkStatus(): Promise<Status> {
85
+ return (await api.mutate<{ tlyPayCheckConnection: Status }, Record<string, never>>(
86
+ `mutation TlyPayCheck { tlyPayCheckConnection { ${STATUS_FIELDS} } }`, {})).tlyPayCheckConnection
87
+ }
88
+
89
+ export async function startConnect(adminUrl: string, popup: boolean): Promise<{ url: string | null; result: string }> {
90
+ return (await api.mutate<{ tlyPayStartConnect: { url: string | null; result: string } }, { adminUrl: string; popup: boolean }>(
91
+ `mutation TlyPayStart($adminUrl: String!, $popup: Boolean!) { tlyPayStartConnect(adminUrl: $adminUrl, popup: $popup) { url result } }`,
92
+ { adminUrl, popup })).tlyPayStartConnect
93
+ }
94
+
95
+ export async function completeConnect(state: string, code: string): Promise<Result> {
96
+ return (await api.mutate<{ tlyPayCompleteConnect: Result }, { state: string; code: string }>(
97
+ `mutation TlyPayComplete($state: String!, $code: String!) { tlyPayCompleteConnect(state: $state, code: $code) { result retry } }`,
98
+ { state, code })).tlyPayCompleteConnect
99
+ }
100
+
101
+ export async function retryConnect(state: string): Promise<Result> {
102
+ return (await api.mutate<{ tlyPayRetryConnect: Result }, { state: string }>(
103
+ `mutation TlyPayRetry($state: String!) { tlyPayRetryConnect(state: $state) { result retry } }`, { state })).tlyPayRetryConnect
104
+ }
105
+
106
+ export async function disconnect(): Promise<Result> {
107
+ return (await api.mutate<{ tlyPayDisconnect: Result }, { confirm: boolean }>(
108
+ `mutation TlyPayDisconnect($confirm: Boolean!) { tlyPayDisconnect(confirm: $confirm) { result retry } }`,
109
+ { confirm: true })).tlyPayDisconnect
110
+ }
111
+
112
+ export async function saveCheckoutMode(mode: string): Promise<Result> {
113
+ return (await api.mutate<{ tlyPaySetCheckoutMode: Result }, { mode: string }>(
114
+ `mutation TlyPayMode($mode: String!) { tlyPaySetCheckoutMode(mode: $mode) { result retry } }`, { mode })).tlyPaySetCheckoutMode
115
+ }
116
+
117
+ /** Saves the Checkout appearance panel: the marks replace the selection exactly. */
118
+ export async function saveCheckoutAppearance(marks: string[], coinNames: boolean): Promise<Result> {
119
+ return (await api.mutate<{ tlyPaySetCheckoutAppearance: Result }, { marks: string[]; coinNames: boolean }>(
120
+ `mutation TlyPayAppearance($marks: [String!]!, $coinNames: Boolean!) {
121
+ tlyPaySetCheckoutAppearance(marks: $marks, coinNames: $coinNames) { result retry } }`,
122
+ { marks, coinNames })).tlyPaySetCheckoutAppearance
123
+ }
124
+
125
+ /** Rechecks the connection, then selects exactly the coins the TLY Pay Store accepts now. */
126
+ export async function syncCheckoutIcons(): Promise<Result> {
127
+ return (await api.mutate<{ tlyPaySyncCheckoutIcons: Result }, Record<string, never>>(
128
+ `mutation TlyPayIconsSync { tlyPaySyncCheckoutIcons { result retry } }`, {})).tlyPaySyncCheckoutIcons
129
+ }
130
+
131
+ /** Saves the TLY Pay site of Settings > Advanced; the store connects again afterwards. */
132
+ export async function saveSiteMode(mode: string): Promise<Result> {
133
+ return (await api.mutate<{ tlyPaySetSiteMode: Result }, { mode: string }>(
134
+ `mutation TlyPaySite($mode: String!) { tlyPaySetSiteMode(mode: $mode) { result retry } }`, { mode })).tlyPaySetSiteMode
135
+ }
136
+
137
+ export async function createPaymentMethod(name: string): Promise<Result> {
138
+ return (await api.mutate<{ tlyPayCreatePaymentMethod: Result }, { name: string }>(
139
+ `mutation TlyPayMethod($name: String!) { tlyPayCreatePaymentMethod(name: $name) { result retry } }`,
140
+ { name })).tlyPayCreatePaymentMethod
141
+ }
142
+
143
+ export async function listOrders(filter: string, skip: number, take: number): Promise<{ items: OrderRow[]; totalItems: number;
144
+ counts: OrderCounts }> {
145
+ return (await api.query<{ tlyPayOrders: { items: OrderRow[]; totalItems: number; counts: OrderCounts } },
146
+ { filter: string; skip: number; take: number }>(
147
+ `query TlyPayOrders($filter: String, $skip: Int, $take: Int) { tlyPayOrders(filter: $filter, skip: $skip, take: $take) {
148
+ items { ${ROW_FIELDS} } totalItems counts { all open paid attention closed creating } } }`,
149
+ { filter, skip, take })).tlyPayOrders
150
+ }
151
+
152
+ export async function readOrder(id: string): Promise<OrderDetail | null> {
153
+ return (await api.query<{ tlyPayOrder: OrderDetail | null }, { id: string }>(
154
+ `query TlyPayOrder($id: String!) { tlyPayOrder(id: $id) { row { ${ROW_FIELDS} } checkoutOrigin returnUrl clientRef
155
+ live { status statusVersion activatedAt paymentExpiresAt updatedAt } liveErr
156
+ events { eventId status statusVersion occurredAt receivedAt outcome processedAt } } }`, { id })).tlyPayOrder
157
+ }
158
+
159
+ export async function orderIntent(orderCode: string): Promise<string | null> {
160
+ return (await api.query<{ tlyPayOrderIntent: string | null }, { orderCode: string }>(
161
+ `query TlyPayOrderIntent($orderCode: String!) { tlyPayOrderIntent(orderCode: $orderCode) }`, { orderCode })).tlyPayOrderIntent
162
+ }
163
+
164
+ export async function reconcile(id: string): Promise<Result> {
165
+ return (await api.mutate<{ tlyPayReconcile: Result }, { id: string }>(
166
+ `mutation TlyPayReconcile($id: String!) { tlyPayReconcile(id: $id) { result retry } }`, { id })).tlyPayReconcile
167
+ }
@@ -0,0 +1,253 @@
1
+ import { Trans, useLingui } from "@lingui/react/macro"
2
+ import { Button, Card, CardContent, CardDescription, CardHeader, CardTitle, Label, Link, Switch } from "@vendure/dashboard"
3
+ import { useEffect, useState } from "react"
4
+ import { saveCheckoutAppearance, Status, syncCheckoutIcons } from "./api"
5
+ import { coinNameLabels, IconOption, listText, sameMarks, selectionNote, shownIcons, toggleMark } from "./logic"
6
+
7
+ type Props = {
8
+ status: Status
9
+ working: boolean
10
+ run: (action: () => Promise<{ result: string }>) => Promise<void>
11
+ }
12
+
13
+ /** One coin of the picker: the whole tile is the label of a real checkbox. */
14
+ function CoinTile({ option, checked, hint, onChange }: { option: IconOption; checked: boolean; hint: string | undefined;
15
+ onChange: (checked: boolean) => void }) {
16
+ return (
17
+ <label title={hint}
18
+ className="group/coin relative flex h-[68px] w-[72px] cursor-pointer select-none flex-col items-center justify-center gap-1.5 rounded-lg border bg-background transition hover:border-foreground/40 hover:shadow-sm active:scale-[.97] has-[:checked]:border-primary has-[:checked]:bg-primary/5 has-[:checked]:ring-1 has-[:checked]:ring-inset has-[:checked]:ring-primary has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-primary">
19
+ <input type="checkbox" className="sr-only" value={option.mark} checked={checked}
20
+ onChange={(event) => onChange(event.target.checked)} />
21
+ <span aria-hidden="true"
22
+ className="absolute -right-1.5 -top-1.5 grid size-[18px] scale-0 place-items-center rounded-full bg-primary text-primary-foreground ring-2 ring-background transition-transform group-has-[:checked]/coin:scale-100">
23
+ <svg viewBox="0 0 12 12" fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"
24
+ className="size-2.5"><path d="M2.6 6.3 5 8.6l4.5-5" /></svg>
25
+ </span>
26
+ <img src={option.iconUrl} alt="" width={26} height={26} className="size-[26px]" />
27
+ <span className="text-xs font-semibold leading-none tracking-wide text-muted-foreground group-has-[:checked]/coin:text-foreground">
28
+ {option.label}
29
+ </span>
30
+ </label>
31
+ )
32
+ }
33
+
34
+ /**
35
+ * The payment method row as a storefront shows it from `tlyPayCheckout`: title, icons and, when shown,
36
+ * the coin names. Vendure is headless and the plugin has no storefront of its own, so the row is drawn
37
+ * here with a neutral default look instead of the storefront's theme. It is plain markup, so it needs
38
+ * no fallback.
39
+ */
40
+ function PreviewStage({ title, icons, coinNames }: { title: string; icons: IconOption[]; coinNames: string | null }) {
41
+ return (
42
+ <div className="relative flex flex-col justify-center rounded-lg bg-muted/50 px-5 pb-5 pt-9"
43
+ style={{ backgroundImage: "radial-gradient(rgba(127, 127, 127, .22) 1px, transparent 1px)", backgroundSize: "14px 14px" }}>
44
+ <span className="absolute left-3.5 top-2.5 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground">
45
+ <Trans>Preview</Trans>
46
+ </span>
47
+ <span className="absolute right-3.5 top-2.5 text-[11px] text-muted-foreground"><Trans>Default storefront look</Trans></span>
48
+ <div className="mx-auto w-full max-w-[640px]">
49
+ <div className="rounded border-[1.5px] border-neutral-900 bg-white px-4 py-3.5 text-[15px] text-neutral-900 shadow-sm">
50
+ <div className="flex flex-wrap items-center gap-x-2.5 gap-y-1.5">
51
+ <span aria-hidden="true" className="grid size-[18px] flex-none place-items-center rounded-full border-[1.5px] border-neutral-900">
52
+ <span className="size-[9px] rounded-full bg-neutral-900" />
53
+ </span>
54
+ <span>{title}</span>
55
+ <span className="ml-1 inline-flex min-h-[22px] flex-wrap gap-1">
56
+ {icons.map((icon) => (
57
+ <img key={icon.mark} src={icon.iconUrl} alt={icon.label} width={22} height={22} className="size-[22px]" />
58
+ ))}
59
+ </span>
60
+ </div>
61
+ {coinNames !== null && <div className="ml-7 mt-2.5 text-sm text-neutral-700">{coinNames}</div>}
62
+ </div>
63
+ </div>
64
+ </div>
65
+ )
66
+ }
67
+
68
+ /**
69
+ * Checkout appearance panel of the Settings tab, from top to bottom: the preview of the payment method
70
+ * row, one tile per coin in two groups (accepted by the TLY Pay Store or not), one note for the
71
+ * selection, the collapsed text settings and the save and sync actions; or the empty state while the
72
+ * Store accepts no coin. The controls update the preview at once and nothing is saved before Save
73
+ * changes. The title is the native name of the Vendure payment method, so the panel shows it and links
74
+ * to where it is edited instead of offering a second field.
75
+ */
76
+ export function CheckoutAppearance({ status, working, run }: Props) {
77
+ const { t } = useLingui()
78
+ const options = status.checkoutIconOptions
79
+ const [icons, setIcons] = useState<string[]>(status.checkoutIcons)
80
+ const [names, setNames] = useState(status.checkoutCoinNames)
81
+ const [syncing, setSyncing] = useState(false)
82
+
83
+ // A sync or a new connection check may change the saved selection; the tiles then follow it.
84
+ const savedIcons = status.checkoutIcons.join(",")
85
+ useEffect(() => {
86
+ setIcons(status.checkoutIcons)
87
+ // eslint-disable-next-line react-hooks/exhaustive-deps
88
+ }, [savedIcons])
89
+ useEffect(() => setNames(status.checkoutCoinNames), [status.checkoutCoinNames])
90
+
91
+ // The list is formatted in the language of the sentence around it, which may still be the English source.
92
+ const listLocale = t({
93
+ message: "en",
94
+ context: "list format locale",
95
+ comment: "BCP 47 tag of the language of this catalog; it formats the coin list of the sentence \"Pay with {list}.\"",
96
+ })
97
+ const title = status.paymentMethodId === null ? t`Crypto payment` : status.checkoutTitle
98
+ const note = selectionNote(options, icons)
99
+ const unaccepted = note !== null && note.kind === "unaccepted" ? listText(note.labels, listLocale) : ""
100
+ const labels = coinNameLabels(options, icons)
101
+ const list = listText(labels, listLocale)
102
+ const sentence = labels.length === 0 ? t`Pay with supported crypto assets through TLY Pay Checkout.` : t`Pay with ${list}.`
103
+ const dirty = !sameMarks(icons, status.checkoutIcons) || names !== status.checkoutCoinNames
104
+ const groups = [
105
+ { id: "accepted", title: t`Accepted by your TLY Pay store`, options: options.filter((option) => option.accepted) },
106
+ { id: "other", title: t`Not enabled in your store yet`, options: options.filter((option) => !option.accepted) },
107
+ ]
108
+
109
+ const sync = async () => {
110
+ setSyncing(true)
111
+ try {
112
+ await run(async () => {
113
+ const done = await syncCheckoutIcons()
114
+ // The synced selection replaces unsaved tile changes, also when it equals the one saved before.
115
+ if (done.result === "checkout_icons_synced") setIcons(status.checkoutIcons)
116
+ return done
117
+ })
118
+ } finally {
119
+ setSyncing(false)
120
+ }
121
+ }
122
+
123
+ return (
124
+ <Card id="tly-pay-checkout-appearance">
125
+ <CardHeader>
126
+ <CardTitle><Trans>Checkout appearance</Trans></CardTitle>
127
+ <CardDescription><Trans>Choose the coin icons customers see next to TLY Pay at checkout.</Trans></CardDescription>
128
+ </CardHeader>
129
+ <CardContent className="flex flex-col gap-4">
130
+ {!options.some((option) => option.accepted) ? (
131
+ <div className="flex items-center gap-3.5 rounded-lg bg-muted/50 p-4 text-sm text-muted-foreground">
132
+ <span aria-hidden="true" className="inline-flex flex-none">
133
+ {options.slice(0, 5).map((option, index) => (
134
+ <img key={option.mark} src={option.iconUrl} alt="" width={24} height={24}
135
+ className={`size-6 rounded-full opacity-60 grayscale ring-2 ring-muted ${index === 0 ? "" : "-ml-1.5"}`} />
136
+ ))}
137
+ </span>
138
+ <span><Trans>Connect TLY Pay to choose checkout icons.</Trans></span>
139
+ </div>
140
+ ) : (
141
+ <>
142
+ <PreviewStage title={title} icons={shownIcons(options, icons)} coinNames={names ? sentence : null} />
143
+
144
+ <fieldset className="flex flex-wrap gap-x-9 gap-y-4">
145
+ <legend className="sr-only"><Trans>Checkout icons</Trans></legend>
146
+ {groups.filter((group) => group.options.length > 0).map((group) => (
147
+ <div key={group.id} role="group" aria-labelledby={`tly-pay-appearance-group-${group.id}`}>
148
+ <p id={`tly-pay-appearance-group-${group.id}`} className="mb-2 flex items-center gap-1.5 text-xs font-semibold">
149
+ <span aria-hidden="true" className={group.id === "accepted"
150
+ ? "size-[7px] flex-none rounded-full bg-green-600"
151
+ : "size-[7px] flex-none rounded-full ring-[1.5px] ring-inset ring-muted-foreground/50"} />
152
+ {group.title}
153
+ </p>
154
+ <div className="flex flex-wrap gap-2">
155
+ {group.options.map((option) => (
156
+ <CoinTile key={option.mark} option={option} checked={icons.includes(option.mark)}
157
+ hint={option.mark === "usdt" ? t`USDT (also USDT0)` : undefined}
158
+ onChange={(checked) => setIcons((current) => toggleMark(current, option.mark, checked))} />
159
+ ))}
160
+ </div>
161
+ </div>
162
+ ))}
163
+ </fieldset>
164
+
165
+ <div aria-live="polite">
166
+ {note !== null && note.kind === "unaccepted" && (
167
+ <p className="flex items-start gap-2 rounded-md bg-amber-500/10 px-3 py-2 text-sm text-amber-800 dark:text-amber-200">
168
+ <svg viewBox="0 0 16 16" fill="currentColor" aria-hidden="true" className="mt-0.5 size-[15px] flex-none">
169
+ <path d="M8 1.2 15 14H1L8 1.2Zm-.8 4.6v4h1.6v-4H7.2Zm0 5.4v1.6h1.6v-1.6H7.2Z" />
170
+ </svg>
171
+ <span>
172
+ {note.labels.length === 1
173
+ ? <Trans><b>{unaccepted}</b> isn't enabled in your TLY Pay store yet. Customers will see the icon but can't pay with it.</Trans>
174
+ : <Trans><b>{unaccepted}</b> aren't enabled in your TLY Pay store yet. Customers will see the icons but can't pay with them.</Trans>}
175
+ {status.consoleOrigin !== "" && (
176
+ <>{" "}<a className="whitespace-nowrap font-semibold underline" href={status.consoleOrigin} target="_blank"
177
+ rel="noopener noreferrer"><Trans>Enable in TLY Pay</Trans></a></>
178
+ )}
179
+ </span>
180
+ </p>
181
+ )}
182
+ {note !== null && note.kind === "none" && (
183
+ <p className="flex items-start gap-2 rounded-md bg-muted/50 px-3 py-2 text-sm text-muted-foreground">
184
+ <svg viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5" aria-hidden="true"
185
+ className="mt-0.5 size-[15px] flex-none"><circle cx="8" cy="8" r="6.2" /><path d="M8 7.2v4M8 4.8v.6" /></svg>
186
+ <span><Trans>No icons selected. Checkout shows the title without coin icons.</Trans></span>
187
+ </p>
188
+ )}
189
+ </div>
190
+
191
+ <details className="group/text rounded-lg border">
192
+ <summary className="flex cursor-pointer list-none items-center gap-2 rounded-lg px-3 py-2.5 text-sm font-semibold hover:bg-muted/50 [&::-webkit-details-marker]:hidden">
193
+ <svg viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"
194
+ aria-hidden="true" className="size-3.5 flex-none text-muted-foreground transition-transform group-open/text:rotate-90">
195
+ <path d="m6 3.5 4.5 4.5L6 12.5" />
196
+ </svg>
197
+ <span className="flex-none"><Trans>Customize text</Trans></span>
198
+ <span className="ml-auto flex min-w-0 items-center gap-2 font-normal text-muted-foreground group-open/text:hidden">
199
+ <span className="truncate">{title}</span>
200
+ <span aria-hidden="true" className="size-1 flex-none rounded-full bg-muted-foreground/60" />
201
+ <span className="flex-none">{names ? t`coin names shown` : t`coin names hidden`}</span>
202
+ </span>
203
+ </summary>
204
+ <div className="grid gap-4 pb-4 pl-[34px] pr-3.5 pt-1.5 text-sm">
205
+ <div className="flex flex-col gap-1">
206
+ <span className="text-xs font-semibold"><Trans>Title</Trans></span>
207
+ <div className="flex flex-wrap items-center gap-x-3 gap-y-1">
208
+ <span className="font-medium">{title}</span>
209
+ {status.paymentMethodId !== null && (
210
+ <Link className="text-xs underline" to={`/payment-methods/${status.paymentMethodId}`}>
211
+ <Trans>Edit in Payment methods</Trans>
212
+ </Link>
213
+ )}
214
+ </div>
215
+ <span className="text-xs text-muted-foreground">
216
+ {status.paymentMethodId !== null
217
+ ? <Trans>The title is the name of this Channel's TLY Pay payment method. Vendure shows that name wherever it lists the payment method.</Trans>
218
+ : <Trans>The title is the name of the TLY Pay payment method. Add the payment method above, then change its name under Settings &gt; Payment methods.</Trans>}
219
+ </span>
220
+ </div>
221
+ <Label className="flex cursor-pointer items-start gap-2.5 font-normal">
222
+ <Switch checked={names} aria-describedby="tly-pay-appearance-names-example"
223
+ onCheckedChange={(value: boolean) => setNames(value === true)} />
224
+ <span className="flex flex-col gap-0.5">
225
+ <span><Trans>Show coin names under the title</Trans></span>
226
+ <span id="tly-pay-appearance-names-example" className="text-xs text-muted-foreground"><Trans>Adds "{sentence}"</Trans></span>
227
+ </span>
228
+ </Label>
229
+ </div>
230
+ </details>
231
+
232
+ <div className="flex flex-wrap items-center gap-x-3.5 gap-y-2.5">
233
+ <Button disabled={working || !dirty} onClick={() => void run(() => saveCheckoutAppearance(icons, names))}>
234
+ <Trans>Save changes</Trans>
235
+ </Button>
236
+ <span role="status" className="inline-flex items-center gap-1.5 text-sm text-muted-foreground">
237
+ {dirty && <><span aria-hidden="true" className="size-1.5 rounded-full bg-amber-500" /><Trans>Unsaved changes</Trans></>}
238
+ </span>
239
+ <Button variant="ghost" className="sm:ml-auto" disabled={working}
240
+ title={t`Select exactly the coins your TLY Pay store accepts now`} onClick={() => void sync()}>
241
+ <svg viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round"
242
+ aria-hidden="true" className={syncing ? "size-3.5 animate-spin" : "size-3.5"}>
243
+ <path d="M13.5 8a5.5 5.5 0 1 1-1.6-3.9" /><path d="M13.5 2.5v3h-3" />
244
+ </svg>
245
+ {syncing ? <Trans>Syncing...</Trans> : <Trans>Sync with TLY Pay store</Trans>}
246
+ </Button>
247
+ </div>
248
+ </>
249
+ )}
250
+ </CardContent>
251
+ </Card>
252
+ )
253
+ }
@@ -0,0 +1,72 @@
1
+ import { Trans } from "@lingui/react/macro"
2
+ import { Alert, AlertDescription, Button, useNavigate } from "@vendure/dashboard"
3
+ import { useEffect, useState } from "react"
4
+ import markUrl from "../assets/tly-pay-mark.svg"
5
+ import { readStatus, Status } from "./api"
6
+ import { RelayedResult } from "./logic"
7
+ import { useCopy } from "./messages"
8
+ import { PAGE_PATH, useConnect } from "./use-connect"
9
+
10
+ /**
11
+ * Dashboard home banner: the branded onboarding with Connect TLY Pay until the shop is connected,
12
+ * then a notice only while the wallet setup is missing, the latest check failed transiently or the
13
+ * connection needs attention.
14
+ */
15
+ export function TlyPayBanner() {
16
+ const copy = useCopy()
17
+ const navigate = useNavigate()
18
+ const [status, setStatus] = useState<Status | null>(null)
19
+ const openSettings = (result = "") => void navigate({ to: PAGE_PATH, search: result === ""
20
+ ? { tab: "settings" } : { tab: "settings", tly_result: result } } as never)
21
+ const connect = useConnect((message: RelayedResult) => openSettings(message.result))
22
+
23
+ useEffect(() => {
24
+ readStatus().then(setStatus, () => setStatus(null))
25
+ }, [])
26
+
27
+ if (status === null || status.state === "ok" && !status.unverified) return null
28
+ if (status.state === "pending" || status.unverified) {
29
+ return (
30
+ <Alert>
31
+ <AlertDescription>
32
+ {status.state === "pending" ? copy.walletSetup : copy.unverified}{" "}
33
+ {status.state === "pending" && status.consoleOrigin !== "" && (
34
+ <a className="underline" href={status.consoleOrigin} target="_blank" rel="noopener noreferrer"><Trans>Open TLY Pay</Trans></a>
35
+ )}
36
+ </AlertDescription>
37
+ </Alert>
38
+ )
39
+ }
40
+ if (status.state === "warn") {
41
+ return (
42
+ <Alert variant="destructive">
43
+ <AlertDescription className="flex flex-wrap items-center gap-3">
44
+ <Trans>TLY Pay is currently unavailable at checkout. Open TLY Pay settings to see why.</Trans>
45
+ <Button size="sm" variant="outline" onClick={() => openSettings()}><Trans>Open TLY Pay settings</Trans></Button>
46
+ </AlertDescription>
47
+ </Alert>
48
+ )
49
+ }
50
+ return (
51
+ <section className="flex flex-wrap items-center gap-4 rounded-lg border bg-card p-5">
52
+ <span className="flex size-14 items-center justify-center rounded-md bg-muted">
53
+ <img src={markUrl} alt="" width={52} height={25} />
54
+ </span>
55
+ <div className="flex min-w-64 flex-1 flex-col gap-1">
56
+ <h2 className="text-base font-semibold"><Trans>Start accepting crypto payments with TLY Pay.</Trans></h2>
57
+ <p className="text-sm text-muted-foreground">
58
+ <Trans>Connect your TLY Pay account to finish setting up this store. Your payment credentials and Webhook are configured automatically after you authorize the connection.</Trans>
59
+ </p>
60
+ <div role="status" aria-live="polite" className="text-sm">
61
+ {connect.phase === "waiting" && <Trans>Finish the connection in the TLY Pay window.</Trans>}
62
+ </div>
63
+ </div>
64
+ <div className="flex items-center gap-3">
65
+ <Button disabled={!status.releaseComplete} onClick={() => void connect.start()}>
66
+ <Trans>Connect TLY Pay</Trans>
67
+ </Button>
68
+ <Button variant="ghost" onClick={() => openSettings()}><Trans>Setup guide</Trans></Button>
69
+ </div>
70
+ </section>
71
+ )
72
+ }