@stancer/stancer 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 (139) hide show
  1. package/.editorconfig +14 -0
  2. package/.gitlab-ci.yml +159 -0
  3. package/.prettierignore +3 -0
  4. package/CHANGELOG.md +10 -0
  5. package/LICENSE +19 -0
  6. package/README.md +166 -2
  7. package/eslint.config.js +14 -0
  8. package/package.json +52 -3
  9. package/pnpm-workspace.yaml +19 -0
  10. package/prettier.config.js +3 -0
  11. package/src/address/api-endpoint.ts +30 -0
  12. package/src/address/model.ts +79 -0
  13. package/src/address/repository.ts +18 -0
  14. package/src/address/validator.ts +34 -0
  15. package/src/api-endpoint/abstract-api-endpoint.ts +310 -0
  16. package/src/api-endpoint/configuration.ts +125 -0
  17. package/src/api-endpoint/http/fetch-http-client.ts +29 -0
  18. package/src/api-endpoint/http/http.ts +75 -0
  19. package/src/api-endpoint/http/index.ts +2 -0
  20. package/src/api-endpoint/version.ts +4 -0
  21. package/src/card/api-endpoint.ts +39 -0
  22. package/src/card/enum/funding.ts +11 -0
  23. package/src/card/enum/nature.ts +7 -0
  24. package/src/card/enum/network.ts +16 -0
  25. package/src/card/model.ts +139 -0
  26. package/src/card/repository.ts +11 -0
  27. package/src/card/validator.ts +79 -0
  28. package/src/core/abstract-model.ts +126 -0
  29. package/src/core/abstract-repository.ts +201 -0
  30. package/src/core/common/branded-type.ts +15 -0
  31. package/src/core/common/handler/date-handler.ts +31 -0
  32. package/src/core/common/handler/enum-handler.ts +18 -0
  33. package/src/core/common/handler/handler.ts +64 -0
  34. package/src/core/common/handler/id-handler.ts +27 -0
  35. package/src/core/common/id-validator.ts +23 -0
  36. package/src/core/common/mutation-tracked-object.ts +49 -0
  37. package/src/core/endpoint-interface.ts +43 -0
  38. package/src/core/error/base-error.ts +1 -0
  39. package/src/core/error/endpoint/api/api-conflict-error.ts +7 -0
  40. package/src/core/error/endpoint/api/api-error.ts +10 -0
  41. package/src/core/error/endpoint/api/api-not-found-error.ts +7 -0
  42. package/src/core/error/endpoint/api/api-unauthorized-error.ts +7 -0
  43. package/src/core/error/endpoint/api/api-unknown-error.ts +7 -0
  44. package/src/core/error/endpoint/api/api-validation-error.ts +13 -0
  45. package/src/core/error/endpoint/api/index.ts +6 -0
  46. package/src/core/error/endpoint/route-inaccessible-error.ts +8 -0
  47. package/src/core/error/unpopulated-error.ts +3 -0
  48. package/src/core/error/unsendable-error.ts +3 -0
  49. package/src/core/error/validation-error.ts +3 -0
  50. package/src/core/validator.ts +129 -0
  51. package/src/customer/api-endpoint.ts +29 -0
  52. package/src/customer/model.ts +113 -0
  53. package/src/customer/repository.ts +14 -0
  54. package/src/customer/validator.ts +26 -0
  55. package/src/payment/api-endpoint.ts +118 -0
  56. package/src/payment/enum/currency.ts +14 -0
  57. package/src/payment/enum/method.ts +2 -0
  58. package/src/payment/enum/status.ts +21 -0
  59. package/src/payment/model.ts +378 -0
  60. package/src/payment/repository.ts +73 -0
  61. package/src/payment/validator.ts +96 -0
  62. package/src/payment-intent/api-endpoint.ts +123 -0
  63. package/src/payment-intent/enum/status.ts +21 -0
  64. package/src/payment-intent/enum/threeds.ts +2 -0
  65. package/src/payment-intent/model.ts +266 -0
  66. package/src/payment-intent/repository.ts +85 -0
  67. package/src/payment-intent/validator.ts +45 -0
  68. package/src/payout/model.ts +8 -0
  69. package/src/refund/api-endpoint.ts +33 -0
  70. package/src/refund/enum/refund-status.ts +11 -0
  71. package/src/refund/model.ts +90 -0
  72. package/src/refund/repository.ts +14 -0
  73. package/src/refund/validator.ts +44 -0
  74. package/src/sepa/api-endpoint.ts +26 -0
  75. package/src/sepa/model.ts +80 -0
  76. package/src/sepa/repository.ts +11 -0
  77. package/src/sepa/validator.ts +56 -0
  78. package/test/fixtures/endpoint.stub.ts +22 -0
  79. package/test/fixtures/list-endpoint.stub.ts +33 -0
  80. package/test/fixtures/list-model.stub.ts +24 -0
  81. package/test/fixtures/model.stub.ts +12 -0
  82. package/test/functional/address.test.ts +126 -0
  83. package/test/functional/card.test.ts +175 -0
  84. package/test/functional/customer.test.ts +174 -0
  85. package/test/functional/payment-intent.test.ts +215 -0
  86. package/test/functional/payment.test.ts +206 -0
  87. package/test/functional/refund.test.ts +112 -0
  88. package/test/functional/sepa.test.ts +136 -0
  89. package/test/integration/stub-integration.test.ts +88 -0
  90. package/test/stub/stub-endpoint.ts +42 -0
  91. package/test/stub/stub-model.ts +82 -0
  92. package/test/stub/stub-repository.ts +11 -0
  93. package/test/test-helper.ts +133 -0
  94. package/test/unit/address/api-endpoint.test.ts +134 -0
  95. package/test/unit/address/fixtures.ts +60 -0
  96. package/test/unit/address/model.test.ts +75 -0
  97. package/test/unit/address/repository.test.ts +148 -0
  98. package/test/unit/address/validator.test.ts +49 -0
  99. package/test/unit/api-endpoint/http/fetch-http-client.test.ts +44 -0
  100. package/test/unit/api-endpoint/http/http.test.ts +152 -0
  101. package/test/unit/card/api-endpoint.test.ts +170 -0
  102. package/test/unit/card/card-helper.ts +116 -0
  103. package/test/unit/card/fixtures.ts +87 -0
  104. package/test/unit/card/model.test.ts +167 -0
  105. package/test/unit/card/repository.test.ts +146 -0
  106. package/test/unit/card/validator.test.ts +96 -0
  107. package/test/unit/core/common/mutation-tracked-object.test.ts +24 -0
  108. package/test/unit/customer/api-endpoint.test.ts +143 -0
  109. package/test/unit/customer/fixtures.ts +73 -0
  110. package/test/unit/customer/model.test.ts +90 -0
  111. package/test/unit/customer/repository.test.ts +148 -0
  112. package/test/unit/customer/validator.test.ts +62 -0
  113. package/test/unit/payment/api-endpoint.test.ts +188 -0
  114. package/test/unit/payment/fixtures.ts +116 -0
  115. package/test/unit/payment/model.test.ts +240 -0
  116. package/test/unit/payment/repository.test.ts +270 -0
  117. package/test/unit/payment/validator.test.ts +137 -0
  118. package/test/unit/payment-intent/api-endpoint.test.ts +142 -0
  119. package/test/unit/payment-intent/fixtures.ts +94 -0
  120. package/test/unit/payment-intent/model.test.ts +157 -0
  121. package/test/unit/payment-intent/repository.test.ts +263 -0
  122. package/test/unit/payment-intent/validator.test.ts +136 -0
  123. package/test/unit/refund/api-endpoint.test.ts +129 -0
  124. package/test/unit/refund/fixtures.ts +58 -0
  125. package/test/unit/refund/model.test.ts +89 -0
  126. package/test/unit/refund/repository.test.ts +157 -0
  127. package/test/unit/refund/validator.test.ts +89 -0
  128. package/test/unit/sepa/api-endpoint.test.ts +170 -0
  129. package/test/unit/sepa/fixture.ts +62 -0
  130. package/test/unit/sepa/model.test.ts +86 -0
  131. package/test/unit/sepa/repository.test.ts +149 -0
  132. package/test/unit/sepa/sepa-helper.ts +71 -0
  133. package/test/unit/sepa/validator.test.ts +58 -0
  134. package/test/unit/stub/stub-endpoint.test.ts +236 -0
  135. package/test/unit/stub/stub-list-endpoint.test.ts +86 -0
  136. package/test/unit/stub/stub-model.test.ts +111 -0
  137. package/test/unit/stub/stub-repository.test.ts +144 -0
  138. package/tsconfig.json +50 -0
  139. package/vitest.config.ts +20 -0
@@ -0,0 +1,188 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+
3
+ import { PaymentApiEndpoint } from '#payment/api-endpoint.js';
4
+ import { CurrencyEnum } from '#payment/enum/currency.js';
5
+ import type { IdPayment } from '#payment/model.js';
6
+ import { randomNumber, randomString } from '#test/test-helper.js';
7
+
8
+ import { endpointResource, endpointResourceDeserialized } from './fixtures.js';
9
+
10
+ vi.mock('#api/http/http.js', async (importHTTP) => {
11
+ const original: Record<string, Promise<unknown>> = await importHTTP();
12
+ return {
13
+ ...original,
14
+ transformResponseToData: vi.fn((value) => value.json()),
15
+ };
16
+ });
17
+
18
+ vi.mock('#api/http/fetch-http-client.js', () => {
19
+ return {
20
+ httpClient: {
21
+ makeRequest: vi.fn(() => {
22
+ return Promise.resolve({
23
+ status: 200,
24
+ json: () => {
25
+ return {
26
+ ...endpointResource,
27
+ };
28
+ },
29
+ });
30
+ }),
31
+ },
32
+ };
33
+ });
34
+
35
+ describe('payment api endpoint', () => {
36
+ describe('Serialize/Deserialize resources', () => {
37
+ const endpoint = new PaymentApiEndpoint();
38
+
39
+ it('test deserialize resource', async () => {
40
+ const deserializedResources = await endpoint.deserializeResource(endpointResource);
41
+ expect(deserializedResources).toMatchObject(endpointResourceDeserialized);
42
+ expect(endpointResourceDeserialized).toMatchObject(deserializedResources);
43
+ });
44
+
45
+ it('test post serialize resource', () => {
46
+ const serializedResources = endpoint.postObjectSerializer({
47
+ ...endpointResourceDeserialized,
48
+ wallet: {},
49
+ }) as typeof endpointResource;
50
+
51
+ // property not in postObject are API generated or not postable
52
+ /* eslint-disable @typescript-eslint/no-unused-vars */
53
+ const {
54
+ created,
55
+ date_paym,
56
+ date_bank,
57
+ fee,
58
+ method,
59
+ response,
60
+ response_author,
61
+ status,
62
+ origin,
63
+ payout,
64
+ payment_intent,
65
+ id,
66
+ ...postObject
67
+ } = endpointResource;
68
+ /* eslint-enable @typescript-eslint/no-unused-vars */
69
+
70
+ //Double match to guaranty exact same shape
71
+ //Auth is really special, what we send is not what we receive
72
+ expect(serializedResources).toMatchObject({ ...postObject, auth: true });
73
+ expect({ ...postObject, auth: true }).toMatchObject(serializedResources);
74
+ });
75
+
76
+ it('test patch serialize resource (not available in repository)', () => {
77
+ const serializedResources = endpoint.patchObjectSerializer({
78
+ ...endpointResourceDeserialized,
79
+ wallet: {},
80
+ device: { city: 'city' },
81
+ }) as typeof endpointResource;
82
+
83
+ // property not in patchObject are API generated or not patchable
84
+ /* eslint-disable @typescript-eslint/no-unused-vars */
85
+ const {
86
+ id,
87
+ unique_id,
88
+ created,
89
+ date_bank,
90
+ date_paym,
91
+ fee,
92
+ method,
93
+ origin,
94
+ payment_intent,
95
+ payout,
96
+ response,
97
+ response_author,
98
+ ...patchObject
99
+ } = endpointResource;
100
+ /* eslint-enable */
101
+
102
+ //Double match to guaranty exact same shape
103
+ //Auth is really special, what we send is not what we receive
104
+ expect(serializedResources).toMatchObject({ ...patchObject, auth: true });
105
+ expect({ ...patchObject, auth: true }).toMatchObject(serializedResources);
106
+ });
107
+ });
108
+
109
+ describe('endpoint path', () => {
110
+ it('endpoint url', () => {
111
+ const endpoint = new PaymentApiEndpoint();
112
+ const id = ('paym_' + randomString(24)) as IdPayment;
113
+ expect(endpoint._getResourceUri(id)).toStrictEqual(`https://api.stancer.com/v2/payments/${id}`);
114
+ expect(endpoint._getResourceUri()).toStrictEqual('https://api.stancer.com/v2/payments/');
115
+ });
116
+ });
117
+
118
+ describe('verbs', () => {
119
+ const paymentEndpoint = new PaymentApiEndpoint();
120
+
121
+ it('get', async () => {
122
+ const responseWithId = await paymentEndpoint.get(('paym_' + randomString(24)) as IdPayment);
123
+ expect(await responseWithId).toStrictEqual(endpointResourceDeserialized);
124
+ });
125
+
126
+ it('post no deserialization', async () => {
127
+ const responseWithId = await paymentEndpoint.post({
128
+ amount: randomNumber(0, 1000000),
129
+ currency: CurrencyEnum[randomNumber(0, CurrencyEnum.length - 1)],
130
+ });
131
+ expect(responseWithId).toStrictEqual(endpointResourceDeserialized);
132
+ });
133
+
134
+ it('patch', async () => {
135
+ const patchResponse = await paymentEndpoint.patch(('paym_' + randomString(24)) as IdPayment, endpointResource);
136
+ expect(patchResponse).toStrictEqual(endpointResourceDeserialized);
137
+ });
138
+
139
+ it('delete', async () => {
140
+ expect(await paymentEndpoint.delete(('paym_' + randomString(24)) as IdPayment)).toStrictEqual(
141
+ endpointResourceDeserialized,
142
+ );
143
+ });
144
+ });
145
+
146
+ describe('send', () => {
147
+ const { amount, currency } = endpointResourceDeserialized;
148
+
149
+ it('send with required data', async () => {
150
+ const endpoint = new PaymentApiEndpoint();
151
+
152
+ await expect(endpoint.send(undefined, { amount, currency })).resolves.toStrictEqual(endpointResourceDeserialized);
153
+ });
154
+
155
+ it('does not post with missing amount', async () => {
156
+ const endpoint = new PaymentApiEndpoint();
157
+
158
+ expect(() => endpoint.send(undefined, { currency })).toThrow();
159
+ });
160
+
161
+ it('does not post with missing currency', async () => {
162
+ const endpoint = new PaymentApiEndpoint();
163
+ expect(() => endpoint.send(undefined, { amount })).toThrow();
164
+ });
165
+
166
+ it('Patch if id', async () => {
167
+ const endpoint = new PaymentApiEndpoint();
168
+ const spyonPatch = vi.spyOn(endpoint, 'patch');
169
+ const spyonPost = vi.spyOn(endpoint, 'post');
170
+
171
+ await expect(endpoint.send('paym_' + randomString(24), { currency, amount })).resolves.toStrictEqual(
172
+ endpointResourceDeserialized,
173
+ );
174
+ expect(spyonPatch).toHaveBeenCalledTimes(1);
175
+ expect(spyonPost).toHaveBeenCalledTimes(0);
176
+ });
177
+
178
+ it('post if no id', () => {
179
+ const endpoint = new PaymentApiEndpoint();
180
+ const spyonPatch = vi.spyOn(endpoint, 'patch');
181
+ const spyonPost = vi.spyOn(endpoint, 'post');
182
+
183
+ endpoint.send(undefined, { currency, amount });
184
+ expect(spyonPatch).toHaveBeenCalledTimes(0);
185
+ expect(spyonPost).toHaveBeenCalledTimes(1);
186
+ });
187
+ });
188
+ });
@@ -0,0 +1,116 @@
1
+ import { Temporal } from 'temporal-polyfill';
2
+
3
+ import { CurrencyEnum } from '#payment/enum/currency.js';
4
+ import { MethodEnum } from '#payment/enum/method.js';
5
+ import { StatusEnum } from '#payment/enum/status.js';
6
+ import { Device, paymentAmount } from '#payment/model.js';
7
+ import { randomMonth, randomNumber, randomString } from '#test/test-helper.js';
8
+
9
+ import { IdAddress } from '../../../src/address/model';
10
+ import { IdCard } from '../../../src/card/model';
11
+ import { IdCustomer } from '../../../src/customer/model';
12
+ import { IdPaymentIntent } from '../../../src/payment-intent/model';
13
+ import { IdPayout } from '../../../src/payout/model';
14
+ import { IdSepa } from '../../../src/sepa/model';
15
+
16
+ export const id = `paym_${randomString(24)}`; // required post
17
+ const amount = randomNumber(50, 4294967295);
18
+ const billingAddress = `addr_${randomString(24)}`;
19
+ const card = `card_${randomString(24)}`;
20
+ const capture = true;
21
+ const created = randomNumber(786460000, 1790692636);
22
+ const currency = CurrencyEnum[randomNumber(0, CurrencyEnum.length - 1)];
23
+ const customer = `cust_${randomString(24)}`;
24
+ const date_paym = randomNumber(786460000, 1000000000);
25
+ const date_settlement = `${randomNumber(1971, 2025)}-${randomMonth().toString().padStart(2, '0')}-${randomNumber(1, 28).toString().padStart(2, '0')}`;
26
+ const date_bank = `${randomNumber(1971, 2025)}-${randomMonth().toString().padStart(2, '0')}-${randomNumber(1, 28).toString().padStart(2, '0')}`;
27
+ const description = randomString(3, 64);
28
+ const fee = randomNumber(0, 4294967295);
29
+ const method = MethodEnum[randomNumber(0, MethodEnum.length - 1)];
30
+ const methodsAllowed = [MethodEnum[randomNumber(0, MethodEnum.length - 1)]];
31
+ const orderId = randomString(1, 36);
32
+ const origin = 'api';
33
+ const paymentIntent = `pi_${randomString(24)}`;
34
+ const payout = `pout_${randomString(24)}`;
35
+ const response = randomString(2);
36
+ const responseAuthor = randomString(2, 100);
37
+ const returnUrl = randomString(1, 66);
38
+ const sepa = `sepa_${randomString(24)}`;
39
+ const shippingAddress = `addr_${randomString(24)}`;
40
+ const status = StatusEnum[randomNumber(0, StatusEnum.length - 1)];
41
+ const uniqueId = randomString(1, 36);
42
+ export const wallet = {}; // walletObject
43
+
44
+ export const endpointResource = {
45
+ id,
46
+ amount,
47
+ auth: { returnUrl: 'returnUrl' },
48
+ device: { city: 'city' },
49
+ billing_address: billingAddress,
50
+ capture,
51
+ card,
52
+ created,
53
+ currency,
54
+ customer,
55
+ date_paym,
56
+ date_settlement,
57
+ date_bank,
58
+ description,
59
+ fee,
60
+ method,
61
+ methods_allowed: methodsAllowed,
62
+ order_id: orderId,
63
+ unique_id: uniqueId,
64
+ response,
65
+ response_author: responseAuthor,
66
+ return_url: returnUrl,
67
+ sepa,
68
+ shipping_address: shippingAddress,
69
+ status,
70
+ origin,
71
+ payout,
72
+ payment_intent: paymentIntent,
73
+ wallet,
74
+ };
75
+
76
+ export const creationResource = {
77
+ amount: paymentAmount(amount),
78
+ auth: true,
79
+ capture,
80
+ createdAt: Temporal.Instant.fromEpochMilliseconds(created * 1000),
81
+ currency,
82
+ customer: customer as IdCustomer,
83
+ datePayment: Temporal.Instant.fromEpochMilliseconds(date_paym * 1000),
84
+ dateSettlement: Temporal.PlainDate.from(date_settlement),
85
+ dateBank: Temporal.PlainDate.from(date_bank),
86
+ description,
87
+ device: true as unknown as Device,
88
+ fee,
89
+ method,
90
+ methodsAllowed,
91
+ orderId,
92
+ uniqueId,
93
+ response,
94
+ responseAuthor,
95
+ returnUrl,
96
+ card: card as IdCard,
97
+ sepa: sepa as IdSepa,
98
+ status,
99
+ origin,
100
+ payout: payout as IdPayout,
101
+ billingAddress: billingAddress as IdAddress,
102
+ shippingAddress: shippingAddress as IdAddress,
103
+ paymentIntent: paymentIntent as IdPaymentIntent,
104
+ };
105
+
106
+ export const endpointResourceDeserialized = {
107
+ id,
108
+ ...creationResource,
109
+ device: { city: 'city' },
110
+ };
111
+
112
+ export const listResource = [
113
+ { ...creationResource, uniqueId: 'firstResource' },
114
+ { ...creationResource, uniqueId: 'secondResource' },
115
+ { ...creationResource, uniqueId: 'thirdResource' },
116
+ ];
@@ -0,0 +1,240 @@
1
+ import { Temporal } from 'temporal-polyfill';
2
+ import { describe, expect, it } from 'vitest';
3
+
4
+ import { Currency, CurrencyEnum } from '#payment/enum/currency.ts';
5
+ import { Method, MethodEnum } from '#payment/enum/method.ts';
6
+ import { PaymentStatus, StatusEnum } from '#payment/enum/status.ts';
7
+ import { Device, IdPayment, PaymentModel } from '#payment/model.js';
8
+ import { SetterGetter, SetterGetterId, randomNumber, randomPastDate, randomString } from '#test/test-helper.js';
9
+
10
+ import { IdAddress } from '../../../src/address/model';
11
+ import { IdPaymentIntent } from '../../../src/payment-intent/model';
12
+ import { IdPayout } from '../../../src/payout/model';
13
+
14
+ describe('Setter & Getter', () => {
15
+ const payment = new PaymentModel({});
16
+
17
+ it('id', () => {
18
+ SetterGetterId((value: IdPayment) => new PaymentModel({}, value), 'paym_' + randomString(24));
19
+ });
20
+
21
+ it('amount', () => {
22
+ SetterGetter(
23
+ (value: number) => {
24
+ payment.setAmount(value);
25
+ },
26
+ () => payment.amount,
27
+ randomNumber,
28
+ );
29
+ });
30
+
31
+ it('auth', () => {
32
+ SetterGetter(
33
+ (value: boolean) => payment.setAuth(value),
34
+ () => payment.auth,
35
+ true,
36
+ );
37
+ payment._data.auth = null;
38
+ expect(payment.auth).toBeNullable();
39
+ payment.setAuth(false);
40
+ expect(payment.auth).toBeNullable();
41
+ });
42
+
43
+ it('billing address', () => {
44
+ SetterGetter(
45
+ (value: string) => payment.setBillingAddress(value),
46
+ () => payment.billingAddress,
47
+ 'addr_' + randomString(24),
48
+ );
49
+ });
50
+
51
+ it('card', () => {
52
+ SetterGetter(
53
+ (value: string) => payment.setCard(value),
54
+ () => payment.card,
55
+ 'card_' + randomString(24),
56
+ );
57
+ });
58
+
59
+ it.each(CurrencyEnum.map((n) => [n]) as string[][])('currency %s', (currency: string) => {
60
+ payment._data.currency = null;
61
+ SetterGetter(
62
+ (value: Currency) => payment.setCurrency(value),
63
+ () => payment.currency,
64
+ currency,
65
+ );
66
+ });
67
+
68
+ it('customer', () => {
69
+ SetterGetter(
70
+ (value: string) => payment.setCustomer(value),
71
+ () => payment.customer,
72
+ 'cust_' + randomString(24),
73
+ );
74
+ });
75
+
76
+ it('datePayment', () => {
77
+ SetterGetter(
78
+ (value: Temporal.PlainDate) => (payment._data.datePayment = value),
79
+ () => payment.datePayment,
80
+ randomPastDate(),
81
+ );
82
+ payment._data.datePayment = null;
83
+ SetterGetter(
84
+ (value: Temporal.PlainDate) => (payment._data.datePayment = value),
85
+ () => payment.datePaym,
86
+ randomPastDate(),
87
+ );
88
+ });
89
+
90
+ it('dateSettlement', () => {
91
+ SetterGetter(
92
+ (value: Temporal.PlainDate) => payment.setDateSettlement(value),
93
+ () => payment.dateSettlement,
94
+ randomPastDate(),
95
+ );
96
+ });
97
+
98
+ it('date_bank', () => {
99
+ SetterGetter(
100
+ (value: Temporal.PlainDate) => (payment._data.dateBank = value),
101
+ () => payment.dateBank,
102
+ randomPastDate(),
103
+ );
104
+ });
105
+
106
+ it('description', () => {
107
+ SetterGetter(
108
+ (value: string) => payment.setDescription(value),
109
+ () => payment.description,
110
+ randomString(24),
111
+ );
112
+ });
113
+
114
+ it('device', () => {
115
+ SetterGetter(
116
+ (value: Device) => payment.setDevice(value),
117
+ () => payment.device,
118
+ {},
119
+ );
120
+ });
121
+
122
+ it('fee', () => {
123
+ SetterGetter(
124
+ (value: number) => (payment._data.fee = value),
125
+ () => payment.fee,
126
+ randomNumber(0, 5000),
127
+ );
128
+ });
129
+
130
+ it.each(MethodEnum.map((n) => [n]) as string[][])('method %s', (method) => {
131
+ payment._data.method = null;
132
+
133
+ SetterGetter(
134
+ (value: string) => (payment._data.method = value),
135
+ () => payment.method,
136
+ method,
137
+ );
138
+ });
139
+
140
+ it.each(MethodEnum.map((n) => [[n]]) as string[][][])('method %s', (method) => {
141
+ payment._data.methodsAllowed = null;
142
+ SetterGetter(
143
+ (value: Method[]) => payment.setMethodsAllowed(value),
144
+ () => payment.methodsAllowed,
145
+ method,
146
+ );
147
+ });
148
+
149
+ it('orderId', () => {
150
+ SetterGetter(
151
+ (value: string) => payment.setOrderId(value),
152
+ () => payment.orderId,
153
+ randomString(24),
154
+ );
155
+ });
156
+
157
+ it('origin', () => {
158
+ SetterGetter(
159
+ (value: number) => (payment._data.origin = value),
160
+ () => payment.origin,
161
+ randomNumber(0, 8),
162
+ );
163
+ });
164
+
165
+ it('uniqueId', () => {
166
+ SetterGetter(
167
+ (value: string) => payment.setUniqueId(value),
168
+ () => payment.uniqueId,
169
+ randomString(1, 32),
170
+ );
171
+ });
172
+
173
+ it('response', () => {
174
+ SetterGetter(
175
+ (value: string) => (payment._data.response = value),
176
+ () => payment.response,
177
+ randomString(1, 32),
178
+ );
179
+ });
180
+
181
+ it('responseAuthor', () => {
182
+ SetterGetter(
183
+ (value: string) => (payment._data.responseAuthor = value),
184
+ () => payment.responseAuthor,
185
+ randomString(1, 32),
186
+ );
187
+ });
188
+
189
+ it('returnUrl', () => {
190
+ payment._data.returnUrl = null;
191
+ SetterGetter(
192
+ (value: string) => payment.setReturnUrl(value),
193
+ () => payment.returnUrl,
194
+ randomString(1, 1000),
195
+ );
196
+ });
197
+
198
+ it('Sepa', () => {
199
+ payment._data.currency = 'eur';
200
+ payment._data.sepa = null;
201
+ SetterGetter(
202
+ (value: string) => payment.setSepa(value),
203
+ () => payment.sepa,
204
+ 'sepa_' + randomString(24),
205
+ );
206
+ });
207
+
208
+ it('Shippping address', () => {
209
+ SetterGetter(
210
+ (value: IdAddress) => payment.setShippingAddress(value),
211
+ () => payment.shippingAddress,
212
+ 'addr_' + randomString(24),
213
+ );
214
+ });
215
+
216
+ it.each(StatusEnum.map((n) => [n]))('status %s', (status) => {
217
+ payment._data.status = null;
218
+ SetterGetter(
219
+ (value: PaymentStatus) => payment.setStatus(value),
220
+ () => payment.status,
221
+ status,
222
+ );
223
+ });
224
+
225
+ it('payout', () => {
226
+ SetterGetter(
227
+ (value: IdPayout) => (payment._data.payout = value),
228
+ () => payment.payout,
229
+ 'pout_' + randomString(24),
230
+ );
231
+ });
232
+
233
+ it('payment intent', () => {
234
+ SetterGetter(
235
+ (value: IdPaymentIntent) => (payment._data.paymentIntent = value),
236
+ () => payment.paymentIntent,
237
+ 'pi_' + randomString(24),
238
+ );
239
+ });
240
+ });