@tillhub/schemas 6.458.0 → 6.459.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.
@@ -1010,7 +1010,7 @@ module.exports = {
1010
1010
  required: ['shop_name']
1011
1011
  },
1012
1012
  payment_links: {
1013
- description: 'Payment link creation defaults.',
1013
+ description: 'Payment link creation defaults and merchant notifications.',
1014
1014
  type: 'object',
1015
1015
  additionalProperties: false,
1016
1016
  properties: {
@@ -1023,7 +1023,24 @@ module.exports = {
1023
1023
  description: 'Default usage mode for LinkPay payment links.',
1024
1024
  type: 'string',
1025
1025
  enum: ['single_use', 'multi_use']
1026
- }
1026
+ },
1027
+ merchant_notification: oneOf({
1028
+ description: 'Merchant email notifications for successful payment link authorizations and captures.',
1029
+ type: 'object',
1030
+ additionalProperties: false,
1031
+ required: ['enabled', 'email'],
1032
+ properties: {
1033
+ enabled: {
1034
+ description: 'Enable merchant payment notification emails.',
1035
+ type: 'boolean'
1036
+ },
1037
+ email: {
1038
+ description: 'Recipient email address for merchant payment notifications.',
1039
+ type: 'string',
1040
+ format: 'email'
1041
+ }
1042
+ }
1043
+ })
1027
1044
  }
1028
1045
  },
1029
1046
  hide_empty_fields: oneOf({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tillhub/schemas",
3
- "version": "6.458.0",
3
+ "version": "6.459.0",
4
4
  "private": false,
5
5
  "description": "All Tillhub API OpenAPI 3 compatible JSON Schemas.",
6
6
  "main": "./lib/index.js",
@@ -34,6 +34,70 @@ test('Configurations: patch schema validation', function (t) {
34
34
  t.end()
35
35
  })
36
36
 
37
+ ;['create', 'update', 'patch'].forEach(function (operation) {
38
+ const request = require('../../lib/v1/configurations')[operation].request
39
+ const validatePayload = ajv.compile(request)
40
+ const payload = function (paymentLinks) {
41
+ return {
42
+ ...(operation === 'create' ? { name: 'Payment link configuration', owner: 'self' } : {}),
43
+ settings: { payment_links: paymentLinks }
44
+ }
45
+ }
46
+
47
+ test(`Configurations: ${operation} accepts merchant notification settings`, function (t) {
48
+ const cases = [
49
+ ['configured notifications with existing defaults', {
50
+ default_expiry_days: 7,
51
+ default_usage_mode: 'single_use',
52
+ merchant_notification: { enabled: true, email: 'merchant@example.com' }
53
+ }],
54
+ ['omitted notifications with existing defaults', {
55
+ default_expiry_days: 14,
56
+ default_usage_mode: 'multi_use'
57
+ }],
58
+ ['omitted notifications and defaults', {}],
59
+ ['null notifications', { merchant_notification: null }],
60
+ ['disabled notifications with an email', {
61
+ merchant_notification: { enabled: false, email: 'merchant@example.com' }
62
+ }]
63
+ ]
64
+ t.plan(cases.length)
65
+ cases.forEach(function ([description, paymentLinks]) {
66
+ const valid = validatePayload(payload(paymentLinks))
67
+ t.ok(valid, `${description}: ${ajv.errorsText(validatePayload.errors)}`)
68
+ })
69
+ t.end()
70
+ })
71
+
72
+ test(`Configurations: ${operation} rejects invalid merchant notification settings`, function (t) {
73
+ const cases = [
74
+ ['enabled-only notifications', { enabled: true }],
75
+ ['disabled notifications without an email', { enabled: false }],
76
+ ['email-only notifications', { email: 'merchant@example.com' }],
77
+ ['empty notifications', {}],
78
+ ['a string enabled flag', { enabled: 'true', email: 'merchant@example.com' }],
79
+ ['a null enabled flag', { enabled: null, email: 'merchant@example.com' }],
80
+ ['a null email', { enabled: true, email: null }],
81
+ ['a malformed email', { enabled: true, email: 'not-an-email' }],
82
+ ['a numeric email', { enabled: true, email: 123 }],
83
+ ['a boolean email', { enabled: true, email: false }],
84
+ ['an object email', { enabled: true, email: {} }],
85
+ ['an array email', { enabled: true, email: ['merchant@example.com'] }],
86
+ ['an unknown notification property', {
87
+ enabled: true,
88
+ email: 'merchant@example.com',
89
+ recipient: 'merchant@example.com'
90
+ }],
91
+ ['a non-object notification block', 'enabled']
92
+ ]
93
+ t.plan(cases.length)
94
+ cases.forEach(function ([description, merchantNotification]) {
95
+ t.notOk(validatePayload(payload({ merchant_notification: merchantNotification })), description)
96
+ })
97
+ t.end()
98
+ })
99
+ })
100
+
37
101
  test('Configurations: opening_hours_exceptions accepts Open all-day, Open hours, and Closed full-day', function (t) {
38
102
  t.plan(1)
39
103
  const valid = validateUpdatePayload({