@paybyrd/devagent-test-js 2.0.0 → 2.1.0-alpha.11
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 +11 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,3 +10,14 @@ branches and PRs publish prereleases), and the version in `package.json` stays `
|
|
|
10
10
|
Used by `devagent-test-service` (Azure DevOps): `web/` (npm) and `widget/` (Yarn).
|
|
11
11
|
|
|
12
12
|
Build and test: `npm ci && npm test`.
|
|
13
|
+
|
|
14
|
+
## Demo page
|
|
15
|
+
|
|
16
|
+
`demo/index.html` validates a payment with the built SDK (`dist/`). It is not part of the npm package.
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
npm ci && npm run build
|
|
20
|
+
python3 -m http.server # from the repository root
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Then open http://localhost:8000/demo/.
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -13,7 +13,8 @@ function validatePayment(request) {
|
|
|
13
13
|
else if (request.reference.length > 50) {
|
|
14
14
|
errors.push("reference must be at most 50 characters");
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
// null (JSON payloads, plain JS callers) means "no currency", like undefined
|
|
17
|
+
if (request.currency != null && !SUPPORTED_CURRENCIES.includes(request.currency)) {
|
|
17
18
|
errors.push(`currency must be one of ${SUPPORTED_CURRENCIES.join(", ")}`);
|
|
18
19
|
}
|
|
19
20
|
return { valid: errors.length === 0, errors };
|
package/package.json
CHANGED