@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,174 +0,0 @@
1
- import { getExampleNumber } from 'libphonenumber-js';
2
- import mobileExamples from 'libphonenumber-js/mobile/examples';
3
- import { Temporal } from 'temporal-polyfill';
4
- import 'temporal-polyfill/global';
5
- import { describe, expect, it } from 'vitest';
6
-
7
- import { idAddress } from '#address/model.ts';
8
- import { Configuration } from '#api/configuration.js';
9
- import { IdCustomer } from '#customer/model.js';
10
- import { CustomerRepository } from '#customer/repository.js';
11
- import { randomMonth, randomNumber, randomString } from '#test/test-helper.js';
12
-
13
- const config = Configuration;
14
-
15
- config.setKey({
16
- privateLiveKey: null,
17
- privateTestKey: process.env['API_KEY'] ?? null,
18
- });
19
-
20
- config._host = process.env['API_HOST'] ?? 'api.stancer.com';
21
-
22
- describe('customer functional', () => {
23
- describe('customer creation', () => {
24
- const email = `stancertstest+${randomString(1, 5)}@example.com`;
25
- const mobile = getExampleNumber('FR', mobileExamples)?.formatInternational().replaceAll(' ', '');
26
-
27
- it('create an customer with email ', async () => {
28
- const repository = new CustomerRepository();
29
- const customer = await repository.create({ email });
30
- await repository.send(customer);
31
- expect(customer.id).toBeTruthy();
32
- expect(customer.id).toContain('cust_');
33
- expect(customer.email).toBe(email);
34
- });
35
-
36
- it('create an customer with mobile ', async () => {
37
- const repository = new CustomerRepository();
38
- const customer = await repository.create({ mobile });
39
- await repository.send(customer);
40
- expect(customer.id).toBeTruthy();
41
- expect(customer.id).toContain('cust_');
42
- expect(customer.mobile).toBe(mobile);
43
- });
44
-
45
- it('create an customer with both ', async () => {
46
- const repository = new CustomerRepository();
47
- const customer = await repository.create({ email, mobile });
48
- await repository.send(customer);
49
- expect(customer.id).toBeTruthy();
50
- expect(customer.id).toContain('cust_');
51
- expect(customer.email).toBe(email);
52
- expect(customer.mobile).toBe(mobile);
53
- });
54
-
55
- it('create a complete flat customer', async () => {
56
- const repository = new CustomerRepository();
57
- const mobile = getExampleNumber('FR', mobileExamples)?.formatInternational().replaceAll(' ', '');
58
- const dateBirth = Temporal.PlainDate.from(
59
- `${randomNumber(1000, 2025)}-${String(randomMonth()).padStart(2, '0')}-${String(randomNumber(1, 28)).padStart(2, '0')}`,
60
- );
61
- const externalId = randomString(1, 36);
62
- const legalId = randomString(1, 16);
63
- const name = randomString(3, 64);
64
- const country = randomString(2);
65
-
66
- const customer = await repository.create({ mobile, country, dateBirth, email, externalId, legalId, name });
67
-
68
- await repository.send(customer);
69
-
70
- expect(customer.id).toBeTruthy();
71
-
72
- expect(customer.mobile).toBe(mobile);
73
-
74
- expect(customer._data.mobile).toBe(customer.mobile);
75
- expect(customer._data.dateBirth).toBe(customer.dateBirth);
76
- expect(customer._data.externalId).toBe(customer.externalId);
77
- expect(customer._data.legalId).toBe(customer.legalId);
78
- expect(customer._data.name).toBe(customer.name);
79
- expect(customer._data.country).toBe(customer.country);
80
- });
81
- it('create a complete customer with addresses', async () => {
82
- const repository = new CustomerRepository();
83
- const mobile = getExampleNumber('FR', mobileExamples)?.formatInternational().replaceAll(' ', '');
84
- const dateBirth = Temporal.PlainDate.from(
85
- `${randomNumber(1000, 2025)}-${String(randomMonth()).padStart(2, '0')}-${String(randomNumber(1, 28)).padStart(2, '0')}`,
86
- );
87
- const externalId = randomString(1, 36);
88
- const legalId = randomString(0, 16);
89
- const name = randomString(3, 64);
90
- const country = randomString(2);
91
- const billingAddress = idAddress('addr_YHvhVplBRGET3V7Ns4B6pzD2');
92
- const shippingAddress = idAddress('addr_YHvhVplBRGET3V7Ns4B6pzD2');
93
-
94
- const customer = await repository.create({
95
- mobile,
96
- country,
97
- dateBirth,
98
- email,
99
- externalId,
100
- legalId,
101
- name,
102
- billingAddress,
103
- shippingAddress,
104
- });
105
-
106
- await repository.send(customer);
107
-
108
- expect(customer.id).toBeTruthy();
109
-
110
- expect(customer.mobile).toBe(mobile);
111
-
112
- expect(customer._data.mobile).toBe(customer.mobile);
113
- expect(customer._data.dateBirth).toBe(customer.dateBirth);
114
- expect(customer._data.externalId).toBe(customer.externalId);
115
- expect(customer._data.legalId).toBe(customer.legalId);
116
- expect(customer._data.name).toBe(customer.name);
117
- expect(customer._data.country).toBe(customer.country);
118
- expect(customer._data.billingAddress).toBe(customer.billingAddress);
119
- expect(customer._data.shippingAddress).toBe(customer.shippingAddress);
120
- });
121
-
122
- it('need required values', async () => {
123
- const repository = new CustomerRepository();
124
- const name = randomString(3, 64);
125
-
126
- const customerWithoutRequiredValue = await repository.create({ name });
127
-
128
- await expect(async () => await repository.send(customerWithoutRequiredValue)).rejects.toThrow(
129
- 'one of the partially required data ( email or mobile) is required to send CustomerModel',
130
- );
131
- });
132
- });
133
-
134
- describe('patch', () => {
135
- it('is available on customer', async () => {
136
- const repository = new CustomerRepository();
137
-
138
- const mobile = getExampleNumber('FR', mobileExamples)?.formatInternational().replaceAll(' ', '');
139
-
140
- const country = randomString(2);
141
-
142
- const customer = await repository.create({ mobile, country });
143
-
144
- await repository.send(customer);
145
- const id = customer.id;
146
- const legalId = randomString(1, 16);
147
- customer.setLegalId(legalId);
148
-
149
- await repository.send(customer);
150
- expect(id).toBe(customer.id);
151
- expect(mobile).toBe(customer.mobile);
152
- expect(country).toBe(customer.country);
153
- expect(legalId).toBe(customer.legalId);
154
- });
155
- });
156
-
157
- describe('get', () => {
158
- it('get the correct object', async () => {
159
- const repository = new CustomerRepository();
160
- const id = 'cust_SsySBRtGUq3pG9zbSOhJSKCa' as IdCustomer;
161
- const customer = await repository.create(id);
162
- expect(customer.id).toBe(id);
163
- expect(customer.mobile).toBe('+33612345678');
164
- expect(customer.country).toBe('FR');
165
- expect(customer.dateBirth).toBeInstanceOf(Temporal.PlainDate);
166
- expect(customer.dateBirth.toString()).toBe('2008-01-01');
167
- expect(customer.createdAt).toBeInstanceOf(Temporal.Instant);
168
- expect(customer.createdAt?.toLocaleString()).toContain('8/19/2026, ');
169
- expect(customer.createdAt?.toLocaleString()).toContain(':09:15 PM');
170
- expect(customer.createdAt.epochMilliseconds).toBe(1787141355 * 1000);
171
- expect(customer.deleted).toBe(false);
172
- });
173
- });
174
- });
@@ -1,215 +0,0 @@
1
- import { Temporal } from 'temporal-polyfill';
2
- import 'temporal-polyfill/global';
3
- import { describe, expect, it } from 'vitest';
4
-
5
- import { Configuration } from '#api/configuration.js';
6
- import { PaymentIntentModel, idPaymentIntent } from '#payment-intent/model.js';
7
- import { PaymentIntentRepository } from '#payment-intent/repository.js';
8
- import { CurrencyEnum } from '#payment/enum/currency.js';
9
- import { PaymentAmount, paymentAmount } from '#payment/model.js';
10
- import { RefundModel } from '#refund/model.js';
11
- import { randomNumber, randomString } from '#test/test-helper.js';
12
-
13
- const config = Configuration;
14
- describe('paymentIntent functional', () => {
15
- config.setKey({
16
- privateLiveKey: null,
17
- privateTestKey: process.env['API_KEY'] ?? null,
18
- });
19
- config._host = process.env['API_HOST'] ?? 'api.stancer.com';
20
- const amount = randomNumber(50, 5000) as PaymentAmount;
21
- const currency = CurrencyEnum[randomNumber(0, CurrencyEnum.length - 1)];
22
- describe('paymentIntent creation', () => {
23
- it('create a paymentIntent with minimum information', async () => {
24
- const repository = new PaymentIntentRepository();
25
-
26
- const paymentIntent = await repository.create({ amount, currency });
27
- await repository.send(paymentIntent);
28
- expect(paymentIntent.id).toBeTruthy();
29
- expect(paymentIntent.id).toContain('pi_');
30
- expect(paymentIntent.amount).toBe(amount);
31
- expect(paymentIntent.currency).toBe(currency);
32
- });
33
-
34
- it('create a complete flat paymentIntent', async () => {
35
- const repository = new PaymentIntentRepository();
36
- const amount = paymentAmount(randomNumber(50, 4294967295));
37
- const capture = true; //false doesn't work we need a proper test just for capture
38
- const currency = CurrencyEnum[randomNumber(0, CurrencyEnum.length - 1)];
39
- const description = randomString(3, 64);
40
- const methodsAllowed = ['card']; //because we send all the possible currency
41
- const orderId = randomString(1, 36);
42
- const returnUrl = randomString(1, 66);
43
- const uniqueId = randomString(1, 36);
44
- const paymentIntentData = {
45
- amount,
46
- capture,
47
- currency,
48
- description,
49
- methodsAllowed,
50
- orderId,
51
- uniqueId,
52
- returnUrl: `https://${returnUrl}`,
53
- };
54
-
55
- const paymentIntent = await repository.create(paymentIntentData);
56
-
57
- await repository.send(paymentIntent);
58
-
59
- expect(paymentIntent.id).toBeTruthy();
60
- expect(paymentIntent.uniqueId);
61
-
62
- expect(paymentIntent._data.id).not.toBeUndefined();
63
- expect(paymentIntent._data.id).not.toBeNull();
64
-
65
- expect(paymentIntent._data).toMatchObject(paymentIntentData);
66
- });
67
-
68
- it('need required amount', async () => {
69
- const repository = new PaymentIntentRepository();
70
-
71
- const paymentintentWithoutRequiredValue = await repository.create({ currency });
72
-
73
- await expect(async () => await repository.send(paymentintentWithoutRequiredValue)).rejects.toThrow(
74
- 'amount is required to send PaymentIntentModel',
75
- );
76
- });
77
- it('need required currency', async () => {
78
- const repository = new PaymentIntentRepository();
79
-
80
- const paymentintentWithoutRequiredValue = await repository.create({ amount });
81
-
82
- await expect(async () => await repository.send(paymentintentWithoutRequiredValue)).rejects.toThrow(
83
- 'currency is required to send PaymentIntentModel',
84
- );
85
- });
86
- });
87
-
88
- describe('patch', () => {
89
- it('is available on paymentIntent', async () => {
90
- const repository = new PaymentIntentRepository();
91
- const paymentIntent = await repository.create({ amount, currency });
92
-
93
- await repository.send(paymentIntent);
94
- const id = paymentIntent.id;
95
- expect(id).toBeTruthy();
96
- expect(paymentIntent.amount).toBe(amount);
97
- expect(paymentIntent.currency).toBe(currency);
98
-
99
- const newAmount = randomNumber(51, 5000);
100
- paymentIntent.setAmount(newAmount);
101
- await repository.send(paymentIntent);
102
- expect(id).toBe(paymentIntent.id);
103
- expect(paymentIntent.amount).toBe(newAmount);
104
- expect(paymentIntent.currency).toBe(currency);
105
- });
106
- });
107
- describe('delete', () => {
108
- it('cannot delete payed paymentIntent', async () => {
109
- const repository = new PaymentIntentRepository();
110
- const paymentIntent = await repository.create('pi_iZwj3voYRVsJdfA0IYo1wLJx');
111
- expect(paymentIntent.id).toBeTruthy();
112
- await expect(async () => await repository.delete(paymentIntent)).rejects.toThrow();
113
- });
114
- it('can delete non processed paymentIntent (cancelling it)', async () => {
115
- const repository = new PaymentIntentRepository();
116
- const paymentIntent = await repository.create({ amount, currency });
117
- await repository.send(paymentIntent);
118
- expect(paymentIntent.id).toBeTruthy();
119
- expect(paymentIntent.status).toBe('require_payment_method');
120
- await repository.delete(paymentIntent);
121
- expect(paymentIntent.status).toBe('canceled');
122
- });
123
- });
124
- describe('list', async () => {
125
- it('should return all paymentIntent with same orderId', async () => {
126
- const orderId = `${Date.now()}-${randomString(8)}`;
127
- const expectedAmount = paymentAmount(50);
128
- const expectedCurrency = 'eur';
129
- const expectedCount = 3;
130
- const repository = new PaymentIntentRepository();
131
- const paymentintents = await Promise.all(
132
- Array.from({ length: expectedCount }, () =>
133
- repository
134
- .create()
135
- .then((paymentIntent) =>
136
- repository
137
- .send(paymentIntent.setAmount(expectedAmount).setCurrency(expectedCurrency).setOrderId(orderId))
138
- .then((paymentIntent) => expect(paymentIntent).toHaveProperty('id')),
139
- ),
140
- ),
141
- );
142
- expect(paymentintents).toHaveLength(expectedCount);
143
-
144
- const items = repository.list({ limit: expectedCount, filters: { order_id: orderId } });
145
- let length = 0;
146
- for await (const item of items) {
147
- expect(item).toBeInstanceOf(PaymentIntentModel);
148
- expect(item.amount).toEqual(expectedAmount);
149
- expect(item.currency).toEqual(expectedCurrency);
150
- expect(item.orderId).toEqual(orderId);
151
- length++;
152
- }
153
- expect(length).toBe(expectedCount);
154
- });
155
- it('should return empty list if no paymentIntent match orderId', async () => {
156
- const repository = new PaymentIntentRepository();
157
-
158
- const orderId = `no_matching_order_id`;
159
- const items = await repository.list({ limit: 10, filters: { order_id: orderId } });
160
- const item = await items.next();
161
- expect(item.done).toBeTruthy();
162
- });
163
- });
164
- describe('get', () => {
165
- it('get the correct object', async () => {
166
- const repository = new PaymentIntentRepository();
167
- const id = idPaymentIntent('pi_iZwj3voYRVsJdfA0IYo1wLJx');
168
- const paymentIntent = await repository.create(id);
169
- expect(paymentIntent._data.id).toBe(id);
170
- expect(paymentIntent._data.amount).toBe(50);
171
- expect(paymentIntent._data.billingAddress).toBeUndefined();
172
- expect(paymentIntent._data.capture).toBe(true);
173
- expect(paymentIntent._data.card).toBeUndefined();
174
- expect(paymentIntent._data.createdAt).toStrictEqual(Temporal.Instant.fromEpochMilliseconds(1789138080 * 1000));
175
- expect(paymentIntent._data.currency).toBe('eur');
176
- expect(paymentIntent._data.customer).toBeUndefined();
177
- expect(paymentIntent._data.dateSettlement).toBeUndefined();
178
- expect(paymentIntent._data.description).toBeUndefined();
179
- expect(paymentIntent._data.methodsAllowed).toContain('card');
180
- expect(paymentIntent._data.methodsAllowed).toContain('sepa');
181
- expect(paymentIntent._data.orderId).toBe('1789138080518-QR1vpifg');
182
- expect(paymentIntent._data.origin).toBe('api');
183
- expect(paymentIntent._data.payment).toBeUndefined();
184
- expect(paymentIntent._data.returnUrl).toBeUndefined();
185
- expect(paymentIntent._data.sepa).toBeUndefined();
186
- expect(paymentIntent._data.shippingAddress).toBeUndefined();
187
- expect(paymentIntent._data.status).toBe('canceled');
188
- expect(paymentIntent._data.threeds).toBe('required');
189
- expect(paymentIntent._data.url).toBe('https://payment.dev.iliad78.net/test_pi_iZwj3voYRVsJdfA0IYo1wLJx');
190
- });
191
- it('get a 404 exception if unknown', async () => {
192
- const id = 'pi_' + randomString(24);
193
- const repository = new PaymentIntentRepository();
194
- await expect(() => repository.create(id)).rejects.toThrow();
195
- });
196
- });
197
-
198
- describe('refunds', () => {
199
- it('get refunds', async () => {
200
- const repository = new PaymentIntentRepository();
201
- const id = idPaymentIntent('pi_ulnYUmuUFoqp2yWBy1sgvuA3');
202
- const paymentIntent = await repository.create(id);
203
- expect(paymentIntent.id).toBe(id);
204
- expect(paymentIntent.amount).toBe(612);
205
- await repository.getRefunds(paymentIntent);
206
- expect(paymentIntent.refunds).toHaveLength(2);
207
- expect(paymentIntent.refunds[0]).toBeInstanceOf(RefundModel);
208
-
209
- expect(paymentIntent.refundableAmount).toBe(612);
210
- expect(paymentIntent.refundedAmount).toBe(0);
211
- expect(paymentIntent.amount).toBe(paymentIntent.refundableAmount + paymentIntent.refundedAmount);
212
- expect(paymentIntent.isRefundPopulated()).toBe(true);
213
- });
214
- });
215
- });
@@ -1,206 +0,0 @@
1
- import { Temporal } from 'temporal-polyfill';
2
- import 'temporal-polyfill/global';
3
- import { describe, expect, it } from 'vitest';
4
-
5
- import { Configuration } from '#api/configuration.js';
6
- import { PaymentApiEndpoint } from '#payment/api-endpoint.js';
7
- import { CurrencyEnum } from '#payment/enum/currency.js';
8
- import { IdPayment, PaymentAmount, PaymentModel, idPayment, paymentAmount } from '#payment/model.js';
9
- import { PaymentRepository } from '#payment/repository.js';
10
- import { RefundRepository } from '#refund/repository.ts';
11
- import { randomNumber, randomString } from '#test/test-helper.js';
12
-
13
- describe('payment functional', () => {
14
- Configuration.setKey({
15
- privateLiveKey: null,
16
- privateTestKey: process.env['API_KEY'] ?? null,
17
- });
18
- Configuration._host = process.env['API_HOST'] ?? 'api.stancer.com';
19
- const amount = randomNumber(50, 5000) as PaymentAmount;
20
- const currency = CurrencyEnum[randomNumber(0, CurrencyEnum.length - 1)];
21
- describe('payment creation', () => {
22
- it('create a payment with minimum information', async () => {
23
- const repository = new PaymentRepository();
24
-
25
- const payment = await repository.create({ amount, currency });
26
- await repository.send(payment);
27
- expect(payment.id).toBeTruthy();
28
- expect(payment.id).toContain('paym_');
29
- expect(payment.amount).toBe(amount);
30
- expect(payment.currency).toBe(currency);
31
- });
32
-
33
- it('create a complete flat payment', async () => {
34
- const repository = new PaymentRepository();
35
- const amount = paymentAmount(randomNumber(50, 4294967295));
36
- const capture = true; //false doesn't work we need a proper test just for capture
37
- const currency = CurrencyEnum[randomNumber(0, CurrencyEnum.length - 1)];
38
- const description = randomString(3, 64);
39
- const methodsAllowed = ['card']; //because we send all the possible currency
40
- const orderId = randomString(1, 36);
41
- const returnUrl = randomString(1, 66);
42
- const uniqueId = randomString(1, 36);
43
- const paymentData = {
44
- amount,
45
- capture,
46
- currency,
47
- description,
48
- methodsAllowed,
49
- orderId,
50
- uniqueId,
51
- returnUrl: `https://${returnUrl}`,
52
- };
53
- const payment = await repository.create(paymentData);
54
-
55
- await repository.send(payment);
56
-
57
- expect(payment.id).toBeTruthy();
58
-
59
- //Check that the value send are the value received
60
- expect(payment._data).toMatchObject(paymentData);
61
-
62
- // Check that the API Generated value are populated
63
- expect(payment._data.id).toBe(payment.id);
64
- expect(payment._data.id).toBeDefined();
65
- expect(payment._data.createdAt).toBeDefined();
66
- expect(payment._data.datePayment).toBeDefined();
67
- expect(payment._data.fee).toBeDefined();
68
- expect(payment._data.origin).toBeDefined();
69
- });
70
-
71
- it('need required amount', async () => {
72
- const repository = new PaymentRepository();
73
-
74
- const paymentWithoutRequiredValue = await repository.create({ currency });
75
-
76
- await expect(async () => await repository.send(paymentWithoutRequiredValue)).rejects.toThrow(
77
- 'amount is required to send PaymentModel',
78
- );
79
- });
80
- it('need required currency', async () => {
81
- const repository = new PaymentRepository();
82
-
83
- const paymentWithoutRequiredValue = await repository.create({ amount });
84
-
85
- await expect(async () => await repository.send(paymentWithoutRequiredValue)).rejects.toThrow(
86
- 'currency is required to send PaymentModel',
87
- );
88
- });
89
- });
90
-
91
- describe('patch', () => {
92
- it('is available on payment', async () => {
93
- const repository = new PaymentRepository();
94
- const payment = await repository.create({ amount, currency });
95
-
96
- await repository.send(payment);
97
- const id = payment.id;
98
- expect(id).toBeTruthy();
99
- expect(payment.amount).toBe(amount);
100
- expect(payment.currency).toBe(currency);
101
-
102
- const newAmount = randomNumber(51, 5000);
103
- payment.setAmount(newAmount);
104
- await repository.send(payment);
105
- expect(id).toBe(payment.id);
106
- expect(payment.amount).toBe(newAmount);
107
- expect(payment.currency).toBe(currency);
108
- });
109
- });
110
- describe('delete', () => {
111
- it('cannot delete payment', async () => {
112
- const repository = new PaymentRepository();
113
- const payment = await repository.create({ amount, currency });
114
- await repository.send(payment);
115
- expect(payment.id).toBeTruthy();
116
- await expect(async () => await repository.delete(payment)).rejects.toThrow();
117
- });
118
- });
119
- describe('list', async () => {
120
- it('should return all payment with same orderId', async () => {
121
- const orderId = `${Date.now()}-${randomString(8)}`;
122
- const expectedAmount = paymentAmount(50);
123
- const expectedCurrency = 'eur';
124
- const expectedCount = 3;
125
- const repository = new PaymentRepository();
126
- const payments = await Promise.all(
127
- Array.from({ length: expectedCount }, () =>
128
- repository
129
- .create()
130
- .then((payment) =>
131
- repository
132
- .send(payment.setAmount(expectedAmount).setCurrency(expectedCurrency).setOrderId(orderId))
133
- .then((payment) => expect(payment).toHaveProperty('id')),
134
- ),
135
- ),
136
- );
137
- expect(payments).toHaveLength(expectedCount);
138
-
139
- const items = repository.list({ limit: expectedCount, filters: { order_id: orderId } });
140
- let length = 0;
141
- for await (const item of items) {
142
- expect(item).toBeInstanceOf(PaymentModel);
143
- expect(item.amount).toEqual(expectedAmount);
144
- expect(item.currency).toEqual(expectedCurrency);
145
- expect(item.orderId).toEqual(orderId);
146
- length++;
147
- }
148
- expect(length).toBe(expectedCount);
149
- });
150
-
151
- it('should return empty list if no payment match orderId', async () => {
152
- const repository = new PaymentRepository();
153
-
154
- const orderId = `no_matching_order_id`;
155
- const items = await repository.list({ limit: 10, filters: { order_id: orderId } });
156
- const item = await items.next();
157
- expect(item.done).toBeTruthy();
158
- });
159
- });
160
- describe('get', () => {
161
- it('get the correct object', async () => {
162
- const repository = new PaymentRepository();
163
- const id = 'paym_36bmekUuW4IMdJrMC0MCeyDt' as IdPayment;
164
- const payment = await repository.create(id);
165
- const returnData = {
166
- id,
167
- amount: 500,
168
- card: 'card_uqY2HrovY2sPm0Ac2xhnBkfU',
169
- capture: true,
170
- created: Temporal.Instant.fromEpochMilliseconds(1787844165 * 1000),
171
- currency: 'eur',
172
- datePayment: Temporal.Instant.fromEpochMilliseconds(1787844165 * 1000),
173
- description: 'Automatic test, 5.00 eur',
174
- method: 'card',
175
- fee: 18,
176
- origin: 'api',
177
- response: '00',
178
- status: 'to_capture',
179
- };
180
- const methodsAllowed = ['sepa', 'card'];
181
- expect(payment.methodsAllowed).toStrictEqual(methodsAllowed);
182
- expect(payment).toMatchObject(returnData);
183
- });
184
- it('get a 404 exception if unknown', async () => {
185
- const id = 'paym_' + randomString(24);
186
- const repository = new PaymentRepository();
187
- await expect(() => repository.create(id)).rejects.toThrow();
188
- });
189
- });
190
- describe('refunds', () => {
191
- it('get refunds', async () => {
192
- const refundRepository = new RefundRepository();
193
- const repository = new PaymentRepository(new PaymentApiEndpoint(), refundRepository);
194
- const id = idPayment('paym_NoUQRyZNLEv6q7H2ZBmffR7h');
195
- const payment = await repository.create(id);
196
- expect(payment.id).toBe(id);
197
- expect(payment.amount).toBe(5521);
198
- await repository.populateRefunds(payment);
199
- expect(payment.refunds).toHaveLength(3);
200
- expect(payment.refundableAmount).toBe(0);
201
- expect(payment.refundedAmount).toBe(5521);
202
- expect(payment.amount).toBe(payment.refundedAmount - payment.refundableAmount);
203
- expect(payment.isRefundPopulated()).toBe(true);
204
- });
205
- });
206
- });