@jarwizz/create-jarshop 0.1.7 → 0.1.9
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 +6 -1
- package/dist/cli.d.ts +14 -0
- package/dist/cli.js +27 -3
- package/dist/cli.js.map +1 -1
- package/dist/template/README.md +1 -1
- package/dist/template/i18n/dashboard/sk.po +6018 -0
- package/dist/template/package.json +5 -2
- package/dist/template/patches/@vendure__dashboard@3.7.1.patch +6535 -0
- package/dist/template/pnpm-lock.yaml +63 -7
- package/dist/template/pnpm-workspace.yaml +2 -0
- package/dist/template/src/plugins/jarshop-checkout/cod-payment-core.ts +102 -0
- package/dist/template/src/plugins/jarshop-checkout/cod-payment.test.ts +71 -1
- package/dist/template/src/plugins/jarshop-checkout/cod-payment.ts +13 -8
- package/dist/template/src/plugins/jarshop-checkout/dashboard/index.tsx +4 -0
- package/dist/template/src/plugins/jarshop-checkout/dashboard/login-branding.tsx +49 -0
- package/dist/template/src/plugins/jarshop-checkout/shipping-rates.ts +13 -0
- package/dist/template/src/seed.ts +34 -3
- package/dist/template/src/vendure-config.ts +9 -1
- package/dist/template/static/email/templates/partials/footer.hbs +1 -1
- package/dist/template/static/email/templates/partials/header.hbs +3 -1
- package/dist/template/turbo.json +1 -0
- package/dist/template/vite.config.mts +41 -3
- package/dist/template/vitest.config.ts +11 -0
- package/dist/template-manifest.json +1 -1
- package/package.json +1 -1
|
@@ -7,6 +7,9 @@ settings:
|
|
|
7
7
|
overrides:
|
|
8
8
|
eslint-import-resolver-typescript: 3.8.7
|
|
9
9
|
|
|
10
|
+
patchedDependencies:
|
|
11
|
+
'@vendure/dashboard@3.7.1': b2c0c0a597ac4bf69c5f19bc99f36e910661cbea1f5c6cc83b9582e6bd522148
|
|
12
|
+
|
|
10
13
|
importers:
|
|
11
14
|
|
|
12
15
|
.:
|
|
@@ -34,7 +37,7 @@ importers:
|
|
|
34
37
|
version: 3.7.1(pg@8.22.0)(supports-color@7.2.0)(ts-morph@21.0.1)(ts-node@10.9.2(@types/node@24.13.3)(typescript@5.8.2))(typescript@5.8.2)
|
|
35
38
|
'@vendure/dashboard':
|
|
36
39
|
specifier: 3.7.1
|
|
37
|
-
version: 3.7.1(@date-fns/tz@1.5.0)(@floating-ui/dom@1.8.0)(@sinclair/typebox@0.27.12)(@standard-schema/spec@1.1.0)(@tanstack/router-core@1.171.17)(@tiptap/core@3.29.2(@tiptap/pm@3.29.2))(@tiptap/extensions@3.29.2(@tiptap/core@3.29.2(@tiptap/pm@3.29.2))(@tiptap/pm@3.29.2))(@types/node@24.13.3)(ajv-formats@2.1.1(ajv@8.20.0))(ajv@8.20.0)(csstype@3.2.3)(esbuild@0.28.1)(eslint@10.8.0(jiti@2.7.0)(supports-color@7.2.0))(express@5.2.1(supports-color@7.2.0))(jiti@2.7.0)(lightningcss@1.32.0)(next@16.2.12(@babel/core@7.29.7(supports-color@7.2.0))(react-dom@19.2.
|
|
40
|
+
version: 3.7.1(patch_hash=b2c0c0a597ac4bf69c5f19bc99f36e910661cbea1f5c6cc83b9582e6bd522148)(@date-fns/tz@1.5.0)(@floating-ui/dom@1.8.0)(@sinclair/typebox@0.27.12)(@standard-schema/spec@1.1.0)(@tanstack/router-core@1.171.17)(@tiptap/core@3.29.2(@tiptap/pm@3.29.2))(@tiptap/extensions@3.29.2(@tiptap/core@3.29.2(@tiptap/pm@3.29.2))(@tiptap/pm@3.29.2))(@types/node@24.13.3)(ajv-formats@2.1.1(ajv@8.20.0))(ajv@8.20.0)(csstype@3.2.3)(esbuild@0.28.1)(eslint@10.8.0(jiti@2.7.0)(supports-color@7.2.0))(express@5.2.1(supports-color@7.2.0))(jiti@2.7.0)(lightningcss@1.32.0)(next@16.2.12(@babel/core@7.29.7(supports-color@7.2.0))(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(rollup@4.62.4)(supports-color@7.2.0)(tsx@4.20.3)(typescript@5.8.2)
|
|
38
41
|
'@vendure/email-plugin':
|
|
39
42
|
specifier: 3.7.1
|
|
40
43
|
version: 3.7.1(supports-color@7.2.0)(svgo@4.0.2)(typescript@5.8.2)
|
|
@@ -53,6 +56,9 @@ importers:
|
|
|
53
56
|
react:
|
|
54
57
|
specifier: 19.2.4
|
|
55
58
|
version: 19.2.4
|
|
59
|
+
react-dom:
|
|
60
|
+
specifier: 19.2.4
|
|
61
|
+
version: 19.2.4(react@19.2.4)
|
|
56
62
|
typeorm:
|
|
57
63
|
specifier: 0.3.31
|
|
58
64
|
version: 0.3.31(pg@8.22.0)(supports-color@7.2.0)(ts-node@10.9.2(@types/node@24.13.3)(typescript@5.8.2))
|
|
@@ -87,6 +93,9 @@ importers:
|
|
|
87
93
|
vite:
|
|
88
94
|
specifier: 7.3.6
|
|
89
95
|
version: 7.3.6(@types/node@24.13.3)(jiti@2.7.0)(lightningcss@1.32.0)(tsx@4.20.3)
|
|
96
|
+
vitest:
|
|
97
|
+
specifier: 4.1.10
|
|
98
|
+
version: 4.1.10(@types/node@24.13.3)(msw@2.15.0(@types/node@24.13.3)(typescript@5.8.2))(vite@7.3.6(@types/node@24.13.3)(jiti@2.7.0)(lightningcss@1.32.0)(tsx@4.20.3))
|
|
90
99
|
|
|
91
100
|
storefront:
|
|
92
101
|
dependencies:
|
|
@@ -4049,6 +4058,7 @@ packages:
|
|
|
4049
4058
|
eslint@9.39.5:
|
|
4050
4059
|
resolution: {integrity: sha512-DgZS62aPLXKlnxILS/AYCoRvHaZeXceIzlXPkkGGzJWSow1aEk0lbTlxUSlyjC8jcaKxAdOnTDz+o1JFSBsyjw==}
|
|
4051
4060
|
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
|
4061
|
+
deprecated: This version is no longer supported. Please see https://eslint.org/version-support for other options.
|
|
4052
4062
|
hasBin: true
|
|
4053
4063
|
peerDependencies:
|
|
4054
4064
|
jiti: '*'
|
|
@@ -6161,6 +6171,11 @@ packages:
|
|
|
6161
6171
|
peerDependencies:
|
|
6162
6172
|
react: '>=16.8.0'
|
|
6163
6173
|
|
|
6174
|
+
react-dom@19.2.4:
|
|
6175
|
+
resolution: {integrity: sha512-AXJdLo8kgMbimY95O2aKQqsz2iWi9jMgKJhRBAxECE4IFxfcazB2LmzloIoibJI3C12IlY20+KFaLv+71bUJeQ==}
|
|
6176
|
+
peerDependencies:
|
|
6177
|
+
react: ^19.2.4
|
|
6178
|
+
|
|
6164
6179
|
react-dom@19.2.8:
|
|
6165
6180
|
resolution: {integrity: sha512-rVprimfGBG3DR+Tq0IQG2DT5PxKth1WIGDmj5yPmlzr4YBe7uyE+Du4oVqTDXZSHGGGXRtTJEGSSePyQCMBglQ==}
|
|
6166
6181
|
peerDependencies:
|
|
@@ -10018,7 +10033,7 @@ snapshots:
|
|
|
10018
10033
|
- supports-color
|
|
10019
10034
|
- typescript
|
|
10020
10035
|
|
|
10021
|
-
'@vendure-io/ui@1.3.0(@date-fns/tz@1.5.0)(@types/node@24.13.3)(@types/react-dom@19.2.4(@types/react@19.2.18))(@types/react@19.2.18)(next-themes@0.4.6(react-dom@19.2.8(react@19.2.8))(react@19.2.8))(next@16.2.12(@babel/core@7.29.7(supports-color@7.2.0))(react-dom@19.2.
|
|
10036
|
+
'@vendure-io/ui@1.3.0(@date-fns/tz@1.5.0)(@types/node@24.13.3)(@types/react-dom@19.2.4(@types/react@19.2.18))(@types/react@19.2.18)(next-themes@0.4.6(react-dom@19.2.8(react@19.2.8))(react@19.2.8))(next@16.2.12(@babel/core@7.29.7(supports-color@7.2.0))(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(react-dom@19.2.8(react@19.2.8))(react-hook-form@7.84.0(react@19.2.8))(react@19.2.8)(supports-color@7.2.0)(typescript@5.8.2)':
|
|
10022
10037
|
dependencies:
|
|
10023
10038
|
'@base-ui/react': 1.7.0(@date-fns/tz@1.5.0)(@types/react@19.2.18)(date-fns@4.4.0)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)
|
|
10024
10039
|
'@vendure-io/design-tokens': 1.2.0(@types/node@24.13.3)(supports-color@7.2.0)(typescript@5.8.2)
|
|
@@ -10039,7 +10054,7 @@ snapshots:
|
|
|
10039
10054
|
tailwind-merge: 3.6.0
|
|
10040
10055
|
vaul: 1.1.2(@types/react-dom@19.2.4(@types/react@19.2.18))(@types/react@19.2.18)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)
|
|
10041
10056
|
optionalDependencies:
|
|
10042
|
-
next: 16.2.12(@babel/core@7.29.7(supports-color@7.2.0))(react-dom@19.2.
|
|
10057
|
+
next: 16.2.12(@babel/core@7.29.7(supports-color@7.2.0))(react-dom@19.2.4(react@19.2.4))(react@19.2.4)
|
|
10043
10058
|
next-themes: 0.4.6(react-dom@19.2.8(react@19.2.8))(react@19.2.8)
|
|
10044
10059
|
react-hook-form: 7.84.0(react@19.2.8)
|
|
10045
10060
|
transitivePeerDependencies:
|
|
@@ -10173,7 +10188,7 @@ snapshots:
|
|
|
10173
10188
|
- uWebSockets.js
|
|
10174
10189
|
- utf-8-validate
|
|
10175
10190
|
|
|
10176
|
-
'@vendure/dashboard@3.7.1(@date-fns/tz@1.5.0)(@floating-ui/dom@1.8.0)(@sinclair/typebox@0.27.12)(@standard-schema/spec@1.1.0)(@tanstack/router-core@1.171.17)(@tiptap/core@3.29.2(@tiptap/pm@3.29.2))(@tiptap/extensions@3.29.2(@tiptap/core@3.29.2(@tiptap/pm@3.29.2))(@tiptap/pm@3.29.2))(@types/node@24.13.3)(ajv-formats@2.1.1(ajv@8.20.0))(ajv@8.20.0)(csstype@3.2.3)(esbuild@0.28.1)(eslint@10.8.0(jiti@2.7.0)(supports-color@7.2.0))(express@5.2.1(supports-color@7.2.0))(jiti@2.7.0)(lightningcss@1.32.0)(next@16.2.12(@babel/core@7.29.7(supports-color@7.2.0))(react-dom@19.2.
|
|
10191
|
+
'@vendure/dashboard@3.7.1(patch_hash=b2c0c0a597ac4bf69c5f19bc99f36e910661cbea1f5c6cc83b9582e6bd522148)(@date-fns/tz@1.5.0)(@floating-ui/dom@1.8.0)(@sinclair/typebox@0.27.12)(@standard-schema/spec@1.1.0)(@tanstack/router-core@1.171.17)(@tiptap/core@3.29.2(@tiptap/pm@3.29.2))(@tiptap/extensions@3.29.2(@tiptap/core@3.29.2(@tiptap/pm@3.29.2))(@tiptap/pm@3.29.2))(@types/node@24.13.3)(ajv-formats@2.1.1(ajv@8.20.0))(ajv@8.20.0)(csstype@3.2.3)(esbuild@0.28.1)(eslint@10.8.0(jiti@2.7.0)(supports-color@7.2.0))(express@5.2.1(supports-color@7.2.0))(jiti@2.7.0)(lightningcss@1.32.0)(next@16.2.12(@babel/core@7.29.7(supports-color@7.2.0))(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(rollup@4.62.4)(supports-color@7.2.0)(tsx@4.20.3)(typescript@5.8.2)':
|
|
10177
10192
|
dependencies:
|
|
10178
10193
|
'@babel/core': 7.29.7(supports-color@7.2.0)
|
|
10179
10194
|
'@babel/preset-react': 7.29.7(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0)
|
|
@@ -10210,7 +10225,7 @@ snapshots:
|
|
|
10210
10225
|
'@types/react-dom': 19.2.4(@types/react@19.2.18)
|
|
10211
10226
|
'@uidotdev/usehooks': 2.4.1(react-dom@19.2.8(react@19.2.8))(react@19.2.8)
|
|
10212
10227
|
'@vendure-io/design-tokens': 1.2.0(@types/node@24.13.3)(supports-color@7.2.0)(typescript@5.8.2)
|
|
10213
|
-
'@vendure-io/ui': 1.3.0(@date-fns/tz@1.5.0)(@types/node@24.13.3)(@types/react-dom@19.2.4(@types/react@19.2.18))(@types/react@19.2.18)(next-themes@0.4.6(react-dom@19.2.8(react@19.2.8))(react@19.2.8))(next@16.2.12(@babel/core@7.29.7(supports-color@7.2.0))(react-dom@19.2.
|
|
10228
|
+
'@vendure-io/ui': 1.3.0(@date-fns/tz@1.5.0)(@types/node@24.13.3)(@types/react-dom@19.2.4(@types/react@19.2.18))(@types/react@19.2.18)(next-themes@0.4.6(react-dom@19.2.8(react@19.2.8))(react@19.2.8))(next@16.2.12(@babel/core@7.29.7(supports-color@7.2.0))(react-dom@19.2.4(react@19.2.4))(react@19.2.4))(react-dom@19.2.8(react@19.2.8))(react-hook-form@7.84.0(react@19.2.8))(react@19.2.8)(supports-color@7.2.0)(typescript@5.8.2)
|
|
10214
10229
|
'@vitejs/plugin-react': 5.2.0(supports-color@7.2.0)(vite@7.3.6(@types/node@24.13.3)(jiti@2.7.0)(lightningcss@1.32.0)(tsx@4.20.3))
|
|
10215
10230
|
acorn: 8.18.0
|
|
10216
10231
|
acorn-walk: 8.3.5
|
|
@@ -10353,6 +10368,15 @@ snapshots:
|
|
|
10353
10368
|
chai: 6.2.2
|
|
10354
10369
|
tinyrainbow: 3.1.1
|
|
10355
10370
|
|
|
10371
|
+
'@vitest/mocker@4.1.10(msw@2.15.0(@types/node@24.13.3)(typescript@5.8.2))(vite@7.3.6(@types/node@24.13.3)(jiti@2.7.0)(lightningcss@1.32.0)(tsx@4.20.3))':
|
|
10372
|
+
dependencies:
|
|
10373
|
+
'@vitest/spy': 4.1.10
|
|
10374
|
+
estree-walker: 3.0.3
|
|
10375
|
+
magic-string: 0.30.21
|
|
10376
|
+
optionalDependencies:
|
|
10377
|
+
msw: 2.15.0(@types/node@24.13.3)(typescript@5.8.2)
|
|
10378
|
+
vite: 7.3.6(@types/node@24.13.3)(jiti@2.7.0)(lightningcss@1.32.0)(tsx@4.20.3)
|
|
10379
|
+
|
|
10356
10380
|
'@vitest/mocker@4.1.10(msw@2.15.0(@types/node@24.13.3)(typescript@6.0.3))(vite@7.3.6(@types/node@24.13.3)(jiti@2.7.0)(lightningcss@1.32.0)(tsx@4.20.3))':
|
|
10357
10381
|
dependencies:
|
|
10358
10382
|
'@vitest/spy': 4.1.10
|
|
@@ -13512,7 +13536,7 @@ snapshots:
|
|
|
13512
13536
|
react: 19.2.8
|
|
13513
13537
|
react-dom: 19.2.8(react@19.2.8)
|
|
13514
13538
|
|
|
13515
|
-
next@16.2.12(@babel/core@7.29.7(supports-color@7.2.0))(react-dom@19.2.
|
|
13539
|
+
next@16.2.12(@babel/core@7.29.7(supports-color@7.2.0))(react-dom@19.2.4(react@19.2.4))(react@19.2.4):
|
|
13516
13540
|
dependencies:
|
|
13517
13541
|
'@next/env': 16.2.12
|
|
13518
13542
|
'@swc/helpers': 0.5.15
|
|
@@ -13520,7 +13544,7 @@ snapshots:
|
|
|
13520
13544
|
caniuse-lite: 1.0.30001806
|
|
13521
13545
|
postcss: 8.4.31
|
|
13522
13546
|
react: 19.2.4
|
|
13523
|
-
react-dom: 19.2.
|
|
13547
|
+
react-dom: 19.2.4(react@19.2.4)
|
|
13524
13548
|
styled-jsx: 5.1.6(@babel/core@7.29.7(supports-color@7.2.0))(react@19.2.4)
|
|
13525
13549
|
optionalDependencies:
|
|
13526
13550
|
'@next/swc-darwin-arm64': 16.2.12
|
|
@@ -14250,6 +14274,11 @@ snapshots:
|
|
|
14250
14274
|
date-fns-jalali: 4.1.0-0
|
|
14251
14275
|
react: 19.2.8
|
|
14252
14276
|
|
|
14277
|
+
react-dom@19.2.4(react@19.2.4):
|
|
14278
|
+
dependencies:
|
|
14279
|
+
react: 19.2.4
|
|
14280
|
+
scheduler: 0.27.0
|
|
14281
|
+
|
|
14253
14282
|
react-dom@19.2.8(react@19.2.8):
|
|
14254
14283
|
dependencies:
|
|
14255
14284
|
react: 19.2.8
|
|
@@ -15299,6 +15328,33 @@ snapshots:
|
|
|
15299
15328
|
lightningcss: 1.32.0
|
|
15300
15329
|
tsx: 4.20.3
|
|
15301
15330
|
|
|
15331
|
+
vitest@4.1.10(@types/node@24.13.3)(msw@2.15.0(@types/node@24.13.3)(typescript@5.8.2))(vite@7.3.6(@types/node@24.13.3)(jiti@2.7.0)(lightningcss@1.32.0)(tsx@4.20.3)):
|
|
15332
|
+
dependencies:
|
|
15333
|
+
'@vitest/expect': 4.1.10
|
|
15334
|
+
'@vitest/mocker': 4.1.10(msw@2.15.0(@types/node@24.13.3)(typescript@5.8.2))(vite@7.3.6(@types/node@24.13.3)(jiti@2.7.0)(lightningcss@1.32.0)(tsx@4.20.3))
|
|
15335
|
+
'@vitest/pretty-format': 4.1.10
|
|
15336
|
+
'@vitest/runner': 4.1.10
|
|
15337
|
+
'@vitest/snapshot': 4.1.10
|
|
15338
|
+
'@vitest/spy': 4.1.10
|
|
15339
|
+
'@vitest/utils': 4.1.10
|
|
15340
|
+
es-module-lexer: 2.3.2
|
|
15341
|
+
expect-type: 1.4.0
|
|
15342
|
+
magic-string: 0.30.21
|
|
15343
|
+
obug: 2.1.4
|
|
15344
|
+
pathe: 2.0.3
|
|
15345
|
+
picomatch: 4.0.5
|
|
15346
|
+
std-env: 4.2.0
|
|
15347
|
+
tinybench: 2.9.0
|
|
15348
|
+
tinyexec: 1.3.0
|
|
15349
|
+
tinyglobby: 0.2.17
|
|
15350
|
+
tinyrainbow: 3.1.1
|
|
15351
|
+
vite: 7.3.6(@types/node@24.13.3)(jiti@2.7.0)(lightningcss@1.32.0)(tsx@4.20.3)
|
|
15352
|
+
why-is-node-running: 2.3.0
|
|
15353
|
+
optionalDependencies:
|
|
15354
|
+
'@types/node': 24.13.3
|
|
15355
|
+
transitivePeerDependencies:
|
|
15356
|
+
- msw
|
|
15357
|
+
|
|
15302
15358
|
vitest@4.1.10(@types/node@24.13.3)(msw@2.15.0(@types/node@24.13.3)(typescript@6.0.3))(vite@7.3.6(@types/node@24.13.3)(jiti@2.7.0)(lightningcss@1.32.0)(tsx@4.20.3)):
|
|
15303
15359
|
dependencies:
|
|
15304
15360
|
'@vitest/expect': 4.1.10
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The decisions behind cash on delivery, with nothing from Vendure in them.
|
|
3
|
+
*
|
|
4
|
+
* This file is the counterpart of `cod-payment.ts` in the way `order-lifecycle-core.ts`
|
|
5
|
+
* is the counterpart of `order-lifecycle-process.ts`: the rules live here, and the
|
|
6
|
+
* Vendure handler only gives them Vendure's shape. Keeping the rules free of imports
|
|
7
|
+
* lets the platform's contract matrix prove them from the root workspace, where this
|
|
8
|
+
* project's dependencies are never installed.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export type CashOnDeliveryAuthorization<Metadata> =
|
|
12
|
+
| {
|
|
13
|
+
amount: number;
|
|
14
|
+
state: "Authorized";
|
|
15
|
+
transactionId: string;
|
|
16
|
+
metadata: Metadata;
|
|
17
|
+
}
|
|
18
|
+
| {
|
|
19
|
+
amount: number;
|
|
20
|
+
state: "Declined";
|
|
21
|
+
errorMessage: string;
|
|
22
|
+
metadata: Metadata;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type CashOnDeliverySettlement = { success: true };
|
|
26
|
+
|
|
27
|
+
/** One order, one cash collection: the id is the order's, so it cannot drift from it. */
|
|
28
|
+
export function cashOnDeliveryTransactionId(orderCode: string): string {
|
|
29
|
+
return `cod:${orderCode}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Cash on delivery, with the memory of what has already been collected.
|
|
34
|
+
*
|
|
35
|
+
* The memory matters because a collected payment is finished. Authorizing it again is
|
|
36
|
+
* how one order is charged twice, and it is refused here rather than only in Vendure's
|
|
37
|
+
* payment state machine, so a shop reading these rules through the adapter contract sees
|
|
38
|
+
* the same answer the shop itself gives.
|
|
39
|
+
*
|
|
40
|
+
* A ledger is created rather than kept in this module, so a caller that needs an
|
|
41
|
+
* untouched one — the contract matrix runs every rule from a clean start — can have it
|
|
42
|
+
* without reaching into private state.
|
|
43
|
+
*/
|
|
44
|
+
export interface CashOnDeliveryLedger {
|
|
45
|
+
/**
|
|
46
|
+
* Checkout only records that cash will be collected. The payment stays Authorized
|
|
47
|
+
* until an operator confirms the money arrived, so nothing here pretends it was
|
|
48
|
+
* received.
|
|
49
|
+
*/
|
|
50
|
+
authorize<Metadata>(input: {
|
|
51
|
+
orderCode: string;
|
|
52
|
+
amount: number;
|
|
53
|
+
metadata: Metadata;
|
|
54
|
+
}): CashOnDeliveryAuthorization<Metadata>;
|
|
55
|
+
|
|
56
|
+
/** An operator's statement that the cash arrived; there is no gateway to ask. */
|
|
57
|
+
settle(transactionId: string): CashOnDeliverySettlement;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* An operator undoing a collection: either the cash never arrived, or it was
|
|
61
|
+
* marked collected by mistake. Vendure lets a settled payment be cancelled, so
|
|
62
|
+
* the ledger has to forget it too — otherwise the order could never be paid
|
|
63
|
+
* again, which is stricter than the platform and not what anyone asked for.
|
|
64
|
+
*/
|
|
65
|
+
cancel(transactionId: string): CashOnDeliverySettlement;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function createCashOnDeliveryLedger(): CashOnDeliveryLedger {
|
|
69
|
+
const collected = new Set<string>();
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
authorize(input) {
|
|
73
|
+
const transactionId = cashOnDeliveryTransactionId(input.orderCode);
|
|
74
|
+
|
|
75
|
+
if (collected.has(transactionId)) {
|
|
76
|
+
return {
|
|
77
|
+
amount: input.amount,
|
|
78
|
+
state: "Declined",
|
|
79
|
+
errorMessage: "The cash for this order has already been collected",
|
|
80
|
+
metadata: input.metadata,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
amount: input.amount,
|
|
86
|
+
state: "Authorized",
|
|
87
|
+
transactionId,
|
|
88
|
+
metadata: input.metadata,
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
settle(transactionId) {
|
|
93
|
+
collected.add(transactionId);
|
|
94
|
+
return { success: true };
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
cancel(transactionId) {
|
|
98
|
+
collected.delete(transactionId);
|
|
99
|
+
return { success: true };
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
@@ -34,11 +34,81 @@ describe("jarShopCodPaymentHandler", () => {
|
|
|
34
34
|
const result = await jarShopCodPaymentHandler.settlePayment(
|
|
35
35
|
context,
|
|
36
36
|
order,
|
|
37
|
-
{} as Payment,
|
|
37
|
+
{ transactionId: "cod:ORDER-123" } as Payment,
|
|
38
38
|
[],
|
|
39
39
|
method,
|
|
40
40
|
);
|
|
41
41
|
|
|
42
42
|
expect(result).toEqual({ success: true });
|
|
43
43
|
});
|
|
44
|
+
|
|
45
|
+
it("refuses to authorize collection a second time once the cash arrived", async () => {
|
|
46
|
+
const collected = { code: "ORDER-456" } as Order;
|
|
47
|
+
|
|
48
|
+
await jarShopCodPaymentHandler.createPayment(
|
|
49
|
+
context,
|
|
50
|
+
collected,
|
|
51
|
+
500,
|
|
52
|
+
[],
|
|
53
|
+
{},
|
|
54
|
+
method,
|
|
55
|
+
);
|
|
56
|
+
await jarShopCodPaymentHandler.settlePayment(
|
|
57
|
+
context,
|
|
58
|
+
collected,
|
|
59
|
+
{ transactionId: "cod:ORDER-456" } as Payment,
|
|
60
|
+
[],
|
|
61
|
+
method,
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const again = await jarShopCodPaymentHandler.createPayment(
|
|
65
|
+
context,
|
|
66
|
+
collected,
|
|
67
|
+
500,
|
|
68
|
+
[],
|
|
69
|
+
{},
|
|
70
|
+
method,
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
expect(again).toMatchObject({ state: "Declined" });
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("lets the shop start again once a collection is cancelled", async () => {
|
|
77
|
+
const mistaken = { code: "ORDER-789" } as Order;
|
|
78
|
+
const payment = { transactionId: "cod:ORDER-789" } as Payment;
|
|
79
|
+
|
|
80
|
+
await jarShopCodPaymentHandler.createPayment(
|
|
81
|
+
context,
|
|
82
|
+
mistaken,
|
|
83
|
+
500,
|
|
84
|
+
[],
|
|
85
|
+
{},
|
|
86
|
+
method,
|
|
87
|
+
);
|
|
88
|
+
await jarShopCodPaymentHandler.settlePayment(
|
|
89
|
+
context,
|
|
90
|
+
mistaken,
|
|
91
|
+
payment,
|
|
92
|
+
[],
|
|
93
|
+
method,
|
|
94
|
+
);
|
|
95
|
+
await jarShopCodPaymentHandler.cancelPayment!(
|
|
96
|
+
context,
|
|
97
|
+
mistaken,
|
|
98
|
+
payment,
|
|
99
|
+
[],
|
|
100
|
+
method,
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const again = await jarShopCodPaymentHandler.createPayment(
|
|
104
|
+
context,
|
|
105
|
+
mistaken,
|
|
106
|
+
500,
|
|
107
|
+
[],
|
|
108
|
+
{},
|
|
109
|
+
method,
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
expect(again).toMatchObject({ state: "Authorized" });
|
|
113
|
+
});
|
|
44
114
|
});
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { LanguageCode, PaymentMethodHandler } from "@vendure/core";
|
|
2
|
+
import { createCashOnDeliveryLedger } from "./cod-payment-core.js";
|
|
3
|
+
|
|
4
|
+
/** One ledger for the shop, so what it has already collected stays remembered. */
|
|
5
|
+
const ledger = createCashOnDeliveryLedger();
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* Cash on delivery is a two-step payment: checkout authorizes collection, and
|
|
5
9
|
* an authenticated operator settles it only after money is actually received.
|
|
10
|
+
*
|
|
11
|
+
* The decisions are made in `cod-payment-core.ts`; this handler is the Vendure
|
|
12
|
+
* face of them and adds nothing of its own.
|
|
6
13
|
*/
|
|
7
14
|
export const jarShopCodPaymentHandler = new PaymentMethodHandler({
|
|
8
15
|
code: "jarshop-cod-handler",
|
|
@@ -17,12 +24,10 @@ export const jarShopCodPaymentHandler = new PaymentMethodHandler({
|
|
|
17
24
|
},
|
|
18
25
|
],
|
|
19
26
|
args: {},
|
|
20
|
-
createPayment: async (_ctx, order, amount, _args, metadata) =>
|
|
21
|
-
amount,
|
|
22
|
-
|
|
23
|
-
transactionId
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
settlePayment: async () => ({ success: true }),
|
|
27
|
-
cancelPayment: async () => ({ success: true }),
|
|
27
|
+
createPayment: async (_ctx, order, amount, _args, metadata) =>
|
|
28
|
+
ledger.authorize({ orderCode: order.code, amount, metadata }),
|
|
29
|
+
settlePayment: async (_ctx, _order, payment) =>
|
|
30
|
+
ledger.settle(payment.transactionId),
|
|
31
|
+
cancelPayment: async (_ctx, _order, payment) =>
|
|
32
|
+
ledger.cancel(payment.transactionId),
|
|
28
33
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { api, defineDashboardExtension, useQuery } from "@vendure/dashboard";
|
|
2
|
+
import { JarShopLoginLogo } from "./login-branding.js";
|
|
2
3
|
import { graphql } from "@/gql";
|
|
3
4
|
import { useState, type FormEvent } from "react";
|
|
4
5
|
import {
|
|
@@ -261,6 +262,9 @@ function EmailBrandConfigurationBlock() {
|
|
|
261
262
|
}
|
|
262
263
|
|
|
263
264
|
defineDashboardExtension({
|
|
265
|
+
login: {
|
|
266
|
+
logo: { component: JarShopLoginLogo },
|
|
267
|
+
},
|
|
264
268
|
pageBlocks: [
|
|
265
269
|
{
|
|
266
270
|
id: "jarshop-order-email-delivery-status",
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Replaces the default Vendure wordmark on the Dashboard login page via the
|
|
2
|
+
// login.logo extension point (see defineDashboardExtension in ./index.tsx).
|
|
3
|
+
//
|
|
4
|
+
// The brand ships two tile variants that differ only in their three fill
|
|
5
|
+
// colours: a blue tile for light surfaces and a light tile for the dark
|
|
6
|
+
// Dashboard. Rather than render both and hide one, the single mark below swaps
|
|
7
|
+
// those fills on the `dark` class that the Dashboard's theme provider puts on
|
|
8
|
+
// the root element, so the login logo stays legible in light, dark and system
|
|
9
|
+
// themes without any script. The favicon is the blue tile in every theme,
|
|
10
|
+
// because a browser tab has no way to ask the page which theme is active.
|
|
11
|
+
export function JarShopLoginLogo() {
|
|
12
|
+
return (
|
|
13
|
+
<svg
|
|
14
|
+
viewBox="0 0 1200 1200"
|
|
15
|
+
className="h-16 w-auto"
|
|
16
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
17
|
+
role="img"
|
|
18
|
+
aria-label="JarShop"
|
|
19
|
+
>
|
|
20
|
+
<title>JarShop</title>
|
|
21
|
+
<rect
|
|
22
|
+
x="440"
|
|
23
|
+
y="60"
|
|
24
|
+
width="320"
|
|
25
|
+
height="84"
|
|
26
|
+
rx="42"
|
|
27
|
+
className="fill-[#243A52] dark:fill-[#E9F0F7]"
|
|
28
|
+
/>
|
|
29
|
+
<rect
|
|
30
|
+
x="100"
|
|
31
|
+
y="200"
|
|
32
|
+
width="1000"
|
|
33
|
+
height="900"
|
|
34
|
+
rx="220"
|
|
35
|
+
className="fill-[#243A52] dark:fill-[#E9F0F7]"
|
|
36
|
+
/>
|
|
37
|
+
<g transform="translate(225,368) scale(0.5)">
|
|
38
|
+
<path
|
|
39
|
+
className="fill-[#A8C0DA] dark:fill-[#4C6C91]"
|
|
40
|
+
d="M 431.1 225.3 L 431.1 259.6 590.5 419 L 750 578.4 750 543.5 L 750 508.5 591.2 349.8 C 503.9 262.4, 432.2 191, 431.8 191 C 431.4 191, 431.1 206.4, 431.1 225.3 M 78 578.5 L 78 613.5 237 772.5 L 396 931.5 396 896.5 L 396 861.5 237 702.5 L 78 543.5 78 578.5 M 799.1 599.3 L 799.1 633.6 951 785.5 L 1103 937.5 1103 902.5 L 1103 867.5 951.7 716.2 C 868.6 633.1, 800.2 565, 799.8 565 C 799.4 565, 799.1 580.4, 799.1 599.3"
|
|
41
|
+
/>
|
|
42
|
+
<path
|
|
43
|
+
className="fill-[#4C6C91] dark:fill-[#243A52]"
|
|
44
|
+
d="M 555.2 702.3 L 396 861.5 396.2 896.3 L 396.5 931 573 754.5 L 749.5 578 732 560.5 L 714.5 543 555.2 702.3 M 1261.7 708.8 L 1103 867.5 1103 902.3 C 1103 921.4, 1103.3 937, 1103.8 937 C 1104.2 937, 1176 865.5, 1263.3 778.2 L 1422 619.4 1422 584.7 C 1421.9 565.6, 1421.6 550, 1421.2 550 C 1420.8 550, 1349.1 621.4, 1261.7 708.8"
|
|
45
|
+
/>
|
|
46
|
+
</g>
|
|
47
|
+
</svg>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shipping rates the seed configures on the starter's own methods, in minor
|
|
3
|
+
* units of the Channel currency, tax included.
|
|
4
|
+
*
|
|
5
|
+
* The seed reads them to configure `default-shipping-calculator`, and the platform's
|
|
6
|
+
* contract matrix reads them to know what the native methods must quote. One module
|
|
7
|
+
* for both is what keeps the matrix from proving a price the shop no longer charges.
|
|
8
|
+
* It imports nothing, so the root matrix can load it without pulling Vendure in.
|
|
9
|
+
*/
|
|
10
|
+
export const seededShippingRates = Object.freeze({
|
|
11
|
+
pickup: 0,
|
|
12
|
+
courier: 490,
|
|
13
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CurrencyCode,
|
|
3
|
+
GlobalSettingsService,
|
|
3
4
|
LanguageCode,
|
|
4
5
|
ProductService,
|
|
5
6
|
ProductVariantService,
|
|
@@ -20,6 +21,7 @@ import {
|
|
|
20
21
|
import { GlobalFlag } from "@vendure/common/lib/generated-types";
|
|
21
22
|
import { config } from "./vendure-config";
|
|
22
23
|
import { JarShopLegalConfiguration } from "./plugins/jarshop-checkout/legal.entity.js";
|
|
24
|
+
import { seededShippingRates } from "./plugins/jarshop-checkout/shipping-rates.js";
|
|
23
25
|
|
|
24
26
|
const productSlug = "jarshop-demo-product";
|
|
25
27
|
|
|
@@ -42,6 +44,7 @@ async function seed(): Promise<void> {
|
|
|
42
44
|
const taxCategoryService = app.get(TaxCategoryService);
|
|
43
45
|
const taxRateService = app.get(TaxRateService);
|
|
44
46
|
const channelService = app.get(ChannelService);
|
|
47
|
+
const globalSettingsService = app.get(GlobalSettingsService);
|
|
45
48
|
const paymentMethodService = app.get(PaymentMethodService);
|
|
46
49
|
const shippingMethodService = app.get(ShippingMethodService);
|
|
47
50
|
const connection = app.get(TransactionalConnection);
|
|
@@ -70,15 +73,43 @@ async function seed(): Promise<void> {
|
|
|
70
73
|
memberIds: [slovakia.id],
|
|
71
74
|
});
|
|
72
75
|
}
|
|
76
|
+
// The Dashboard offers a translation tab per language listed in the global
|
|
77
|
+
// settings, and the Shop API falls back to the channel default language.
|
|
78
|
+
// Both are database state, so an installation created before JarShop chose
|
|
79
|
+
// Slovak still has to be corrected here rather than in the config alone.
|
|
80
|
+
const storeLanguages = [LanguageCode.sk, LanguageCode.en];
|
|
81
|
+
const globalSettings = await globalSettingsService.getSettings(ctx);
|
|
82
|
+
const missingGlobalLanguages = storeLanguages.filter(
|
|
83
|
+
(languageCode) =>
|
|
84
|
+
!globalSettings.availableLanguages.includes(languageCode),
|
|
85
|
+
);
|
|
86
|
+
if (missingGlobalLanguages.length > 0) {
|
|
87
|
+
await globalSettingsService.updateSettings(ctx, {
|
|
88
|
+
availableLanguages: [
|
|
89
|
+
...globalSettings.availableLanguages,
|
|
90
|
+
...missingGlobalLanguages,
|
|
91
|
+
],
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const channelLanguagesMissing =
|
|
96
|
+
channel.defaultLanguageCode !== LanguageCode.sk ||
|
|
97
|
+
storeLanguages.some(
|
|
98
|
+
(languageCode) =>
|
|
99
|
+
!(channel.availableLanguageCodes ?? []).includes(languageCode),
|
|
100
|
+
);
|
|
73
101
|
if (
|
|
74
102
|
!channel.defaultTaxZone ||
|
|
75
|
-
channel.defaultCurrencyCode !== CurrencyCode.EUR
|
|
103
|
+
channel.defaultCurrencyCode !== CurrencyCode.EUR ||
|
|
104
|
+
channelLanguagesMissing
|
|
76
105
|
) {
|
|
77
106
|
await channelService.update(ctx, {
|
|
78
107
|
id: channel.id,
|
|
79
108
|
defaultTaxZoneId: taxZone.id,
|
|
80
109
|
defaultCurrencyCode: CurrencyCode.EUR,
|
|
81
110
|
availableCurrencyCodes: [CurrencyCode.EUR],
|
|
111
|
+
defaultLanguageCode: LanguageCode.sk,
|
|
112
|
+
availableLanguageCodes: storeLanguages,
|
|
82
113
|
});
|
|
83
114
|
channel = await channelService.getDefaultChannel(ctx);
|
|
84
115
|
ctx = await requestContextService.create({
|
|
@@ -101,7 +132,7 @@ async function seed(): Promise<void> {
|
|
|
101
132
|
calculator: {
|
|
102
133
|
code: "default-shipping-calculator",
|
|
103
134
|
arguments: [
|
|
104
|
-
{ name: "rate", value:
|
|
135
|
+
{ name: "rate", value: String(seededShippingRates.pickup) },
|
|
105
136
|
{ name: "taxRate", value: "0" },
|
|
106
137
|
{ name: "includesTax", value: "auto" },
|
|
107
138
|
],
|
|
@@ -134,7 +165,7 @@ async function seed(): Promise<void> {
|
|
|
134
165
|
calculator: {
|
|
135
166
|
code: "default-shipping-calculator",
|
|
136
167
|
arguments: [
|
|
137
|
-
{ name: "rate", value:
|
|
168
|
+
{ name: "rate", value: String(seededShippingRates.courier) },
|
|
138
169
|
{ name: "taxRate", value: "0" },
|
|
139
170
|
{ name: "includesTax", value: "auto" },
|
|
140
171
|
],
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
DefaultJobQueuePlugin,
|
|
3
3
|
DefaultSchedulerPlugin,
|
|
4
4
|
DefaultSearchPlugin,
|
|
5
|
+
LanguageCode,
|
|
5
6
|
VendureConfig,
|
|
6
7
|
} from "@vendure/core";
|
|
7
8
|
import { AssetServerPlugin } from "@vendure/asset-server-plugin";
|
|
@@ -39,6 +40,10 @@ function storefrontAccountUrl(locale: string, path: string): string {
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
export const config: VendureConfig = {
|
|
43
|
+
// JarShop sells in Slovakia first. This is read when a new installation
|
|
44
|
+
// populates its default channel and global settings, so it decides which
|
|
45
|
+
// translation the Dashboard and Shop API fall back to.
|
|
46
|
+
defaultLanguageCode: LanguageCode.sk,
|
|
42
47
|
apiOptions: {
|
|
43
48
|
port: Number(process.env.PORT ?? 3000),
|
|
44
49
|
adminApiPath: "admin-api",
|
|
@@ -81,7 +86,10 @@ export const config: VendureConfig = {
|
|
|
81
86
|
paymentOptions: { paymentMethodHandlers: [jarShopCodPaymentHandler] },
|
|
82
87
|
plugins: [
|
|
83
88
|
JarShopCheckoutPlugin,
|
|
84
|
-
|
|
89
|
+
// A GraphQL IDE is a development convenience, not something a live
|
|
90
|
+
// storefront's admin needs exposed - and its own page is titled
|
|
91
|
+
// "Vendure GraphiQL", which JarShop has no override for.
|
|
92
|
+
...(isDev ? [GraphiqlPlugin.init()] : []),
|
|
85
93
|
AssetServerPlugin.init({
|
|
86
94
|
route: "assets",
|
|
87
95
|
assetUploadDir: path.join(__dirname, "../static/assets"),
|