@stancer/stancer 1.0.1 → 1.1.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 (371) hide show
  1. package/CHANGELOG.md +23 -2
  2. package/dist/address/api-endpoint.d.ts +20 -0
  3. package/dist/address/api-endpoint.d.ts.map +1 -0
  4. package/dist/address/api-endpoint.js +28 -0
  5. package/dist/address/api-endpoint.js.map +1 -0
  6. package/dist/address/model.d.ts +35 -0
  7. package/dist/address/model.d.ts.map +1 -0
  8. package/dist/address/model.js +63 -0
  9. package/dist/address/model.js.map +1 -0
  10. package/dist/address/repository.d.ts +7 -0
  11. package/dist/address/repository.d.ts.map +1 -0
  12. package/dist/address/repository.js +14 -0
  13. package/dist/address/repository.js.map +1 -0
  14. package/dist/address/validator.d.ts +4 -0
  15. package/dist/address/validator.d.ts.map +1 -0
  16. package/dist/address/validator.js +32 -0
  17. package/dist/address/validator.js.map +1 -0
  18. package/dist/api-endpoint/abstract-api-endpoint.d.ts +46 -0
  19. package/dist/api-endpoint/abstract-api-endpoint.d.ts.map +1 -0
  20. package/dist/api-endpoint/abstract-api-endpoint.js +220 -0
  21. package/dist/api-endpoint/abstract-api-endpoint.js.map +1 -0
  22. package/dist/api-endpoint/configuration.d.ts +34 -0
  23. package/dist/api-endpoint/configuration.d.ts.map +1 -0
  24. package/dist/api-endpoint/configuration.js +99 -0
  25. package/dist/api-endpoint/configuration.js.map +1 -0
  26. package/dist/api-endpoint/http/fetch-http-client.d.ts +3 -0
  27. package/dist/api-endpoint/http/fetch-http-client.d.ts.map +1 -0
  28. package/dist/api-endpoint/http/fetch-http-client.js +34 -0
  29. package/dist/api-endpoint/http/fetch-http-client.js.map +1 -0
  30. package/dist/api-endpoint/http/http.d.ts +18 -0
  31. package/dist/api-endpoint/http/http.d.ts.map +1 -0
  32. package/dist/api-endpoint/http/http.js +47 -0
  33. package/dist/api-endpoint/http/http.js.map +1 -0
  34. package/dist/api-endpoint/http/index.d.ts +3 -0
  35. package/dist/api-endpoint/http/index.d.ts.map +1 -0
  36. package/dist/api-endpoint/http/index.js +3 -0
  37. package/dist/api-endpoint/http/index.js.map +1 -0
  38. package/dist/api-endpoint/version.d.ts +5 -0
  39. package/dist/api-endpoint/version.d.ts.map +1 -0
  40. package/dist/api-endpoint/version.js +6 -0
  41. package/dist/api-endpoint/version.js.map +1 -0
  42. package/dist/card/api-endpoint.d.ts +28 -0
  43. package/dist/card/api-endpoint.d.ts.map +1 -0
  44. package/dist/card/api-endpoint.js +37 -0
  45. package/dist/card/api-endpoint.js.map +1 -0
  46. package/dist/card/enum/funding.d.ts +3 -0
  47. package/dist/card/enum/funding.d.ts.map +1 -0
  48. package/dist/card/enum/funding.js +10 -0
  49. package/dist/card/enum/funding.js.map +1 -0
  50. package/dist/card/enum/nature.d.ts +3 -0
  51. package/dist/card/enum/nature.d.ts.map +1 -0
  52. package/dist/card/enum/nature.js +6 -0
  53. package/dist/card/enum/nature.js.map +1 -0
  54. package/dist/card/enum/network.d.ts +5 -0
  55. package/dist/card/enum/network.d.ts.map +1 -0
  56. package/dist/card/enum/network.js +12 -0
  57. package/dist/card/enum/network.js.map +1 -0
  58. package/dist/card/model.d.ts +55 -0
  59. package/dist/card/model.d.ts.map +1 -0
  60. package/dist/card/model.js +90 -0
  61. package/dist/card/model.js.map +1 -0
  62. package/dist/card/repository.d.ts +7 -0
  63. package/dist/card/repository.d.ts.map +1 -0
  64. package/dist/card/repository.js +10 -0
  65. package/dist/card/repository.js.map +1 -0
  66. package/dist/card/validator.d.ts +8 -0
  67. package/dist/card/validator.d.ts.map +1 -0
  68. package/dist/card/validator.js +71 -0
  69. package/dist/card/validator.js.map +1 -0
  70. package/dist/core/abstract-model.d.ts +51 -0
  71. package/dist/core/abstract-model.d.ts.map +1 -0
  72. package/dist/core/abstract-model.js +93 -0
  73. package/dist/core/abstract-model.js.map +1 -0
  74. package/dist/core/abstract-repository.d.ts +86 -0
  75. package/dist/core/abstract-repository.d.ts.map +1 -0
  76. package/dist/core/abstract-repository.js +97 -0
  77. package/dist/core/abstract-repository.js.map +1 -0
  78. package/dist/core/common/branded-type.d.ts +6 -0
  79. package/dist/core/common/branded-type.d.ts.map +1 -0
  80. package/dist/core/common/branded-type.js +9 -0
  81. package/dist/core/common/branded-type.js.map +1 -0
  82. package/dist/core/common/handler/date-handler.d.ts +5 -0
  83. package/dist/core/common/handler/date-handler.d.ts.map +1 -0
  84. package/dist/core/common/handler/date-handler.js +23 -0
  85. package/dist/core/common/handler/date-handler.js.map +1 -0
  86. package/dist/core/common/handler/enum-handler.d.ts +3 -0
  87. package/dist/core/common/handler/enum-handler.d.ts.map +1 -0
  88. package/dist/core/common/handler/enum-handler.js +14 -0
  89. package/dist/core/common/handler/enum-handler.js.map +1 -0
  90. package/dist/core/common/handler/handler.d.ts +24 -0
  91. package/dist/core/common/handler/handler.d.ts.map +1 -0
  92. package/dist/core/common/handler/handler.js +33 -0
  93. package/dist/core/common/handler/handler.js.map +1 -0
  94. package/dist/core/common/handler/id-handler.d.ts +4 -0
  95. package/dist/core/common/handler/id-handler.d.ts.map +1 -0
  96. package/dist/core/common/handler/id-handler.js +21 -0
  97. package/dist/core/common/handler/id-handler.js.map +1 -0
  98. package/dist/core/common/handler/metadata-handler.d.ts +18 -0
  99. package/dist/core/common/handler/metadata-handler.d.ts.map +1 -0
  100. package/dist/core/common/handler/metadata-handler.js +19 -0
  101. package/dist/core/common/handler/metadata-handler.js.map +1 -0
  102. package/dist/core/common/id-validator.d.ts +10 -0
  103. package/dist/core/common/id-validator.d.ts.map +1 -0
  104. package/dist/core/common/id-validator.js +17 -0
  105. package/dist/core/common/id-validator.js.map +1 -0
  106. package/dist/core/common/mutation-tracked-object.d.ts +8 -0
  107. package/dist/core/common/mutation-tracked-object.d.ts.map +1 -0
  108. package/dist/core/common/mutation-tracked-object.js +38 -0
  109. package/dist/core/common/mutation-tracked-object.js.map +1 -0
  110. package/dist/core/endpoint-interface.d.ts +38 -0
  111. package/dist/core/endpoint-interface.d.ts.map +1 -0
  112. package/dist/core/endpoint-interface.js +2 -0
  113. package/dist/core/endpoint-interface.js.map +1 -0
  114. package/dist/core/error/base-error.d.ts +3 -0
  115. package/dist/core/error/base-error.d.ts.map +1 -0
  116. package/dist/core/error/base-error.js +3 -0
  117. package/dist/core/error/base-error.js.map +1 -0
  118. package/dist/core/error/endpoint/api/api-conflict-error.d.ts +5 -0
  119. package/dist/core/error/endpoint/api/api-conflict-error.d.ts.map +1 -0
  120. package/dist/core/error/endpoint/api/api-conflict-error.js +7 -0
  121. package/dist/core/error/endpoint/api/api-conflict-error.js.map +1 -0
  122. package/dist/core/error/endpoint/api/api-error.d.ts +6 -0
  123. package/dist/core/error/endpoint/api/api-error.d.ts.map +1 -0
  124. package/dist/core/error/endpoint/api/api-error.js +9 -0
  125. package/dist/core/error/endpoint/api/api-error.js.map +1 -0
  126. package/dist/core/error/endpoint/api/api-not-found-error.d.ts +5 -0
  127. package/dist/core/error/endpoint/api/api-not-found-error.d.ts.map +1 -0
  128. package/dist/core/error/endpoint/api/api-not-found-error.js +7 -0
  129. package/dist/core/error/endpoint/api/api-not-found-error.js.map +1 -0
  130. package/dist/core/error/endpoint/api/api-unauthorized-error.d.ts +5 -0
  131. package/dist/core/error/endpoint/api/api-unauthorized-error.d.ts.map +1 -0
  132. package/dist/core/error/endpoint/api/api-unauthorized-error.js +7 -0
  133. package/dist/core/error/endpoint/api/api-unauthorized-error.js.map +1 -0
  134. package/dist/core/error/endpoint/api/api-unknown-error.d.ts +5 -0
  135. package/dist/core/error/endpoint/api/api-unknown-error.d.ts.map +1 -0
  136. package/dist/core/error/endpoint/api/api-unknown-error.js +7 -0
  137. package/dist/core/error/endpoint/api/api-unknown-error.js.map +1 -0
  138. package/dist/core/error/endpoint/api/api-validation-error.d.ts +11 -0
  139. package/dist/core/error/endpoint/api/api-validation-error.d.ts.map +1 -0
  140. package/dist/core/error/endpoint/api/api-validation-error.js +9 -0
  141. package/dist/core/error/endpoint/api/api-validation-error.js.map +1 -0
  142. package/dist/core/error/endpoint/api/index.d.ts +7 -0
  143. package/dist/core/error/endpoint/api/index.d.ts.map +1 -0
  144. package/dist/core/error/endpoint/api/index.js +7 -0
  145. package/dist/core/error/endpoint/api/index.js.map +1 -0
  146. package/dist/core/error/endpoint/route-inaccessible-error.d.ts +5 -0
  147. package/dist/core/error/endpoint/route-inaccessible-error.d.ts.map +1 -0
  148. package/dist/core/error/endpoint/route-inaccessible-error.js +8 -0
  149. package/dist/core/error/endpoint/route-inaccessible-error.js.map +1 -0
  150. package/dist/core/error/unpopulated-error.d.ts +4 -0
  151. package/dist/core/error/unpopulated-error.d.ts.map +1 -0
  152. package/dist/core/error/unpopulated-error.js +4 -0
  153. package/dist/core/error/unpopulated-error.js.map +1 -0
  154. package/dist/core/error/unsendable-error.d.ts +4 -0
  155. package/dist/core/error/unsendable-error.d.ts.map +1 -0
  156. package/dist/core/error/unsendable-error.js +4 -0
  157. package/dist/core/error/unsendable-error.js.map +1 -0
  158. package/dist/core/error/validation-error.d.ts +4 -0
  159. package/dist/core/error/validation-error.d.ts.map +1 -0
  160. package/dist/core/error/validation-error.js +4 -0
  161. package/dist/core/error/validation-error.js.map +1 -0
  162. package/dist/core/validator.d.ts +63 -0
  163. package/dist/core/validator.d.ts.map +1 -0
  164. package/dist/core/validator.js +73 -0
  165. package/dist/core/validator.js.map +1 -0
  166. package/dist/customer/api-endpoint.d.ts +21 -0
  167. package/dist/customer/api-endpoint.d.ts.map +1 -0
  168. package/dist/customer/api-endpoint.js +27 -0
  169. package/dist/customer/api-endpoint.js.map +1 -0
  170. package/dist/customer/model.d.ts +39 -0
  171. package/dist/customer/model.d.ts.map +1 -0
  172. package/dist/customer/model.js +73 -0
  173. package/dist/customer/model.js.map +1 -0
  174. package/dist/customer/repository.d.ts +7 -0
  175. package/dist/customer/repository.d.ts.map +1 -0
  176. package/dist/customer/repository.js +10 -0
  177. package/dist/customer/repository.js.map +1 -0
  178. package/dist/customer/validator.d.ts +4 -0
  179. package/dist/customer/validator.d.ts.map +1 -0
  180. package/dist/customer/validator.js +23 -0
  181. package/dist/customer/validator.js.map +1 -0
  182. package/dist/event/model.d.ts +20 -0
  183. package/dist/event/model.d.ts.map +1 -0
  184. package/dist/event/model.js +30 -0
  185. package/dist/event/model.js.map +1 -0
  186. package/dist/payment/api-endpoint.d.ts +51 -0
  187. package/dist/payment/api-endpoint.d.ts.map +1 -0
  188. package/dist/payment/api-endpoint.js +110 -0
  189. package/dist/payment/api-endpoint.js.map +1 -0
  190. package/dist/payment/enum/currency.d.ts +3 -0
  191. package/dist/payment/enum/currency.d.ts.map +1 -0
  192. package/dist/payment/enum/currency.js +13 -0
  193. package/dist/payment/enum/currency.js.map +1 -0
  194. package/dist/payment/enum/method.d.ts +3 -0
  195. package/dist/payment/enum/method.d.ts.map +1 -0
  196. package/dist/payment/enum/method.js +2 -0
  197. package/dist/payment/enum/method.js.map +1 -0
  198. package/dist/payment/enum/status.d.ts +4 -0
  199. package/dist/payment/enum/status.d.ts.map +1 -0
  200. package/dist/payment/enum/status.js +19 -0
  201. package/dist/payment/enum/status.js.map +1 -0
  202. package/dist/payment/model.d.ts +135 -0
  203. package/dist/payment/model.d.ts.map +1 -0
  204. package/dist/payment/model.js +232 -0
  205. package/dist/payment/model.js.map +1 -0
  206. package/dist/payment/repository.d.ts +17 -0
  207. package/dist/payment/repository.d.ts.map +1 -0
  208. package/dist/payment/repository.js +56 -0
  209. package/dist/payment/repository.js.map +1 -0
  210. package/dist/payment/validator.d.ts +16 -0
  211. package/dist/payment/validator.d.ts.map +1 -0
  212. package/dist/payment/validator.js +81 -0
  213. package/dist/payment/validator.js.map +1 -0
  214. package/dist/payment-intent/api-endpoint.d.ts +63 -0
  215. package/dist/payment-intent/api-endpoint.d.ts.map +1 -0
  216. package/dist/payment-intent/api-endpoint.js +95 -0
  217. package/dist/payment-intent/api-endpoint.js.map +1 -0
  218. package/dist/payment-intent/enum/status.d.ts +5 -0
  219. package/dist/payment-intent/enum/status.d.ts.map +1 -0
  220. package/dist/payment-intent/enum/status.js +20 -0
  221. package/dist/payment-intent/enum/status.js.map +1 -0
  222. package/dist/payment-intent/enum/threeds.d.ts +3 -0
  223. package/dist/payment-intent/enum/threeds.d.ts.map +1 -0
  224. package/dist/payment-intent/enum/threeds.js +2 -0
  225. package/dist/payment-intent/enum/threeds.js.map +1 -0
  226. package/dist/payment-intent/model.d.ts +91 -0
  227. package/dist/payment-intent/model.d.ts.map +1 -0
  228. package/dist/payment-intent/model.js +183 -0
  229. package/dist/payment-intent/model.js.map +1 -0
  230. package/dist/payment-intent/repository.d.ts +13 -0
  231. package/dist/payment-intent/repository.d.ts.map +1 -0
  232. package/dist/payment-intent/repository.js +65 -0
  233. package/dist/payment-intent/repository.js.map +1 -0
  234. package/dist/payment-intent/validator.d.ts +4 -0
  235. package/dist/payment-intent/validator.d.ts.map +1 -0
  236. package/dist/payment-intent/validator.js +38 -0
  237. package/dist/payment-intent/validator.js.map +1 -0
  238. package/dist/payout/model.d.ts +7 -0
  239. package/dist/payout/model.d.ts.map +1 -0
  240. package/dist/payout/model.js +6 -0
  241. package/dist/payout/model.js.map +1 -0
  242. package/dist/refund/api-endpoint.d.ts +22 -0
  243. package/dist/refund/api-endpoint.d.ts.map +1 -0
  244. package/dist/refund/api-endpoint.js +32 -0
  245. package/dist/refund/api-endpoint.js.map +1 -0
  246. package/dist/refund/enum/refund-status.d.ts +3 -0
  247. package/dist/refund/enum/refund-status.d.ts.map +1 -0
  248. package/dist/refund/enum/refund-status.js +10 -0
  249. package/dist/refund/enum/refund-status.js.map +1 -0
  250. package/dist/refund/model.d.ts +38 -0
  251. package/dist/refund/model.d.ts.map +1 -0
  252. package/dist/refund/model.js +51 -0
  253. package/dist/refund/model.js.map +1 -0
  254. package/dist/refund/repository.d.ts +7 -0
  255. package/dist/refund/repository.d.ts.map +1 -0
  256. package/dist/refund/repository.js +10 -0
  257. package/dist/refund/repository.js.map +1 -0
  258. package/dist/refund/validator.d.ts +4 -0
  259. package/dist/refund/validator.d.ts.map +1 -0
  260. package/dist/refund/validator.js +41 -0
  261. package/dist/refund/validator.js.map +1 -0
  262. package/dist/sepa/api-endpoint.d.ts +19 -0
  263. package/dist/sepa/api-endpoint.d.ts.map +1 -0
  264. package/dist/sepa/api-endpoint.js +25 -0
  265. package/dist/sepa/api-endpoint.js.map +1 -0
  266. package/dist/sepa/model.d.ts +32 -0
  267. package/dist/sepa/model.d.ts.map +1 -0
  268. package/dist/sepa/model.js +53 -0
  269. package/dist/sepa/model.js.map +1 -0
  270. package/dist/sepa/repository.d.ts +7 -0
  271. package/dist/sepa/repository.d.ts.map +1 -0
  272. package/dist/sepa/repository.js +10 -0
  273. package/dist/sepa/repository.js.map +1 -0
  274. package/dist/sepa/validator.d.ts +8 -0
  275. package/dist/sepa/validator.d.ts.map +1 -0
  276. package/dist/sepa/validator.js +47 -0
  277. package/dist/sepa/validator.js.map +1 -0
  278. package/dist/webhook/api-endpoint.d.ts +16 -0
  279. package/dist/webhook/api-endpoint.d.ts.map +1 -0
  280. package/dist/webhook/api-endpoint.js +33 -0
  281. package/dist/webhook/api-endpoint.js.map +1 -0
  282. package/dist/webhook/model.d.ts +35 -0
  283. package/dist/webhook/model.d.ts.map +1 -0
  284. package/dist/webhook/model.js +110 -0
  285. package/dist/webhook/model.js.map +1 -0
  286. package/dist/webhook/repository.d.ts +7 -0
  287. package/dist/webhook/repository.d.ts.map +1 -0
  288. package/dist/webhook/repository.js +10 -0
  289. package/dist/webhook/repository.js.map +1 -0
  290. package/dist/webhook/validator.d.ts +4 -0
  291. package/dist/webhook/validator.d.ts.map +1 -0
  292. package/dist/webhook/validator.js +16 -0
  293. package/dist/webhook/validator.js.map +1 -0
  294. package/package.json +4 -2
  295. package/src/api-endpoint/http/fetch-http-client.ts +8 -1
  296. package/src/core/common/handler/metadata-handler.ts +19 -0
  297. package/src/event/model.ts +42 -0
  298. package/src/payment-intent/api-endpoint.ts +2 -1
  299. package/src/payment-intent/model.ts +8 -3
  300. package/src/webhook/api-endpoint.ts +36 -0
  301. package/src/webhook/model.ts +140 -0
  302. package/src/webhook/repository.ts +14 -0
  303. package/src/webhook/validator.ts +18 -0
  304. package/.editorconfig +0 -14
  305. package/.gitlab-ci.yml +0 -159
  306. package/.prettierignore +0 -3
  307. package/eslint.config.js +0 -14
  308. package/pnpm-workspace.yaml +0 -19
  309. package/prettier.config.js +0 -3
  310. package/test/fixtures/endpoint.stub.ts +0 -22
  311. package/test/fixtures/list-endpoint.stub.ts +0 -33
  312. package/test/fixtures/list-model.stub.ts +0 -24
  313. package/test/fixtures/model.stub.ts +0 -12
  314. package/test/functional/address.test.ts +0 -126
  315. package/test/functional/card.test.ts +0 -175
  316. package/test/functional/customer.test.ts +0 -174
  317. package/test/functional/payment-intent.test.ts +0 -215
  318. package/test/functional/payment.test.ts +0 -206
  319. package/test/functional/refund.test.ts +0 -112
  320. package/test/functional/sepa.test.ts +0 -136
  321. package/test/integration/stub-integration.test.ts +0 -88
  322. package/test/stub/stub-endpoint.ts +0 -42
  323. package/test/stub/stub-model.ts +0 -82
  324. package/test/stub/stub-repository.ts +0 -11
  325. package/test/test-helper.ts +0 -133
  326. package/test/unit/address/api-endpoint.test.ts +0 -134
  327. package/test/unit/address/fixtures.ts +0 -60
  328. package/test/unit/address/model.test.ts +0 -75
  329. package/test/unit/address/repository.test.ts +0 -148
  330. package/test/unit/address/validator.test.ts +0 -49
  331. package/test/unit/api-endpoint/http/fetch-http-client.test.ts +0 -44
  332. package/test/unit/api-endpoint/http/http.test.ts +0 -152
  333. package/test/unit/card/api-endpoint.test.ts +0 -170
  334. package/test/unit/card/card-helper.ts +0 -116
  335. package/test/unit/card/fixtures.ts +0 -87
  336. package/test/unit/card/model.test.ts +0 -167
  337. package/test/unit/card/repository.test.ts +0 -146
  338. package/test/unit/card/validator.test.ts +0 -96
  339. package/test/unit/core/common/mutation-tracked-object.test.ts +0 -24
  340. package/test/unit/customer/api-endpoint.test.ts +0 -143
  341. package/test/unit/customer/fixtures.ts +0 -73
  342. package/test/unit/customer/model.test.ts +0 -90
  343. package/test/unit/customer/repository.test.ts +0 -148
  344. package/test/unit/customer/validator.test.ts +0 -62
  345. package/test/unit/payment/api-endpoint.test.ts +0 -188
  346. package/test/unit/payment/fixtures.ts +0 -116
  347. package/test/unit/payment/model.test.ts +0 -240
  348. package/test/unit/payment/repository.test.ts +0 -270
  349. package/test/unit/payment/validator.test.ts +0 -137
  350. package/test/unit/payment-intent/api-endpoint.test.ts +0 -142
  351. package/test/unit/payment-intent/fixtures.ts +0 -94
  352. package/test/unit/payment-intent/model.test.ts +0 -157
  353. package/test/unit/payment-intent/repository.test.ts +0 -263
  354. package/test/unit/payment-intent/validator.test.ts +0 -136
  355. package/test/unit/refund/api-endpoint.test.ts +0 -129
  356. package/test/unit/refund/fixtures.ts +0 -58
  357. package/test/unit/refund/model.test.ts +0 -89
  358. package/test/unit/refund/repository.test.ts +0 -157
  359. package/test/unit/refund/validator.test.ts +0 -89
  360. package/test/unit/sepa/api-endpoint.test.ts +0 -170
  361. package/test/unit/sepa/fixture.ts +0 -62
  362. package/test/unit/sepa/model.test.ts +0 -86
  363. package/test/unit/sepa/repository.test.ts +0 -149
  364. package/test/unit/sepa/sepa-helper.ts +0 -71
  365. package/test/unit/sepa/validator.test.ts +0 -58
  366. package/test/unit/stub/stub-endpoint.test.ts +0 -236
  367. package/test/unit/stub/stub-list-endpoint.test.ts +0 -86
  368. package/test/unit/stub/stub-model.test.ts +0 -111
  369. package/test/unit/stub/stub-repository.test.ts +0 -144
  370. package/tsconfig.json +0 -50
  371. package/vitest.config.ts +0 -20
@@ -1,188 +0,0 @@
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
- });
@@ -1,116 +0,0 @@
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
- ];
@@ -1,240 +0,0 @@
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
- });