@unchainedshop/plugins 3.1.14 → 4.0.0-rc.10

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 (331) hide show
  1. package/lib/delivery/pick-mup.js +0 -2
  2. package/lib/delivery/pick-mup.js.map +1 -1
  3. package/lib/files/gridfs/adapter.d.ts.map +1 -1
  4. package/lib/files/gridfs/adapter.js +3 -2
  5. package/lib/files/gridfs/adapter.js.map +1 -1
  6. package/lib/files/gridfs/handler-express.d.ts.map +1 -1
  7. package/lib/files/gridfs/handler-express.js +6 -2
  8. package/lib/files/gridfs/handler-express.js.map +1 -1
  9. package/lib/files/gridfs/handler-fastify.d.ts.map +1 -1
  10. package/lib/files/gridfs/handler-fastify.js +5 -2
  11. package/lib/files/gridfs/handler-fastify.js.map +1 -1
  12. package/lib/files/gridfs/module.d.ts +2 -2
  13. package/lib/files/gridfs/module.d.ts.map +1 -1
  14. package/lib/filters/local-search.d.ts.map +1 -1
  15. package/lib/filters/local-search.js +9 -2
  16. package/lib/filters/local-search.js.map +1 -1
  17. package/lib/filters/strict-equal.js +18 -0
  18. package/lib/filters/strict-equal.js.map +1 -1
  19. package/lib/payment/apple-iap/adapter.js +6 -13
  20. package/lib/payment/apple-iap/adapter.js.map +1 -1
  21. package/lib/payment/apple-iap/fix-periods.d.ts.map +1 -1
  22. package/lib/payment/apple-iap/fix-periods.js +3 -5
  23. package/lib/payment/apple-iap/fix-periods.js.map +1 -1
  24. package/lib/payment/apple-iap/handler-express.js +4 -4
  25. package/lib/payment/apple-iap/handler-express.js.map +1 -1
  26. package/lib/payment/apple-iap/handler-fastify.js +4 -4
  27. package/lib/payment/apple-iap/handler-fastify.js.map +1 -1
  28. package/lib/payment/apple-iap/module.d.ts +2 -2
  29. package/lib/payment/apple-iap/module.d.ts.map +1 -1
  30. package/lib/payment/braintree.js +3 -4
  31. package/lib/payment/braintree.js.map +1 -1
  32. package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts +1 -2
  33. package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts.map +1 -1
  34. package/lib/payment/cryptopay/db/CryptopayTransactions.js.map +1 -1
  35. package/lib/payment/cryptopay/handle-webhook.js +1 -1
  36. package/lib/payment/cryptopay/handle-webhook.js.map +1 -1
  37. package/lib/payment/cryptopay/handler-express.d.ts.map +1 -1
  38. package/lib/payment/cryptopay/handler-express.js +4 -57
  39. package/lib/payment/cryptopay/handler-express.js.map +1 -1
  40. package/lib/payment/cryptopay/handler-fastify.d.ts.map +1 -1
  41. package/lib/payment/cryptopay/handler-fastify.js +4 -56
  42. package/lib/payment/cryptopay/handler-fastify.js.map +1 -1
  43. package/lib/payment/cryptopay/module.d.ts +26 -26
  44. package/lib/payment/cryptopay/module.d.ts.map +1 -1
  45. package/lib/payment/cryptopay/module.js +26 -24
  46. package/lib/payment/cryptopay/module.js.map +1 -1
  47. package/lib/payment/cryptopay/plugin.d.ts.map +1 -1
  48. package/lib/payment/cryptopay/plugin.js +33 -79
  49. package/lib/payment/cryptopay/plugin.js.map +1 -1
  50. package/lib/payment/datatrans-v2/api/types.d.ts +41 -41
  51. package/lib/payment/datatrans-v2/api/types.d.ts.map +1 -1
  52. package/lib/payment/datatrans-v2/getPaths.d.ts +2 -2
  53. package/lib/payment/datatrans-v2/getPaths.d.ts.map +1 -1
  54. package/lib/payment/datatrans-v2/index.js +16 -14
  55. package/lib/payment/datatrans-v2/index.js.map +1 -1
  56. package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts +1 -1
  57. package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts.map +1 -1
  58. package/lib/payment/datatrans-v2/roundedAmountFromOrder.js +3 -3
  59. package/lib/payment/datatrans-v2/roundedAmountFromOrder.js.map +1 -1
  60. package/lib/payment/paypal-checkout.js +6 -8
  61. package/lib/payment/paypal-checkout.js.map +1 -1
  62. package/lib/payment/payrexx/api/index.d.ts +2 -2
  63. package/lib/payment/payrexx/api/index.d.ts.map +1 -1
  64. package/lib/payment/payrexx/api/makeFetcher.d.ts.map +1 -1
  65. package/lib/payment/payrexx/api/makeFetcher.js.map +1 -1
  66. package/lib/payment/payrexx/index.js +4 -4
  67. package/lib/payment/payrexx/index.js.map +1 -1
  68. package/lib/payment/payrexx/payrexx.js +2 -2
  69. package/lib/payment/payrexx/payrexx.js.map +1 -1
  70. package/lib/payment/postfinance-checkout/api-client.d.ts +16 -0
  71. package/lib/payment/postfinance-checkout/api-client.d.ts.map +1 -0
  72. package/lib/payment/postfinance-checkout/api-client.js +75 -0
  73. package/lib/payment/postfinance-checkout/api-client.js.map +1 -0
  74. package/lib/payment/postfinance-checkout/api-types.d.ts +98 -0
  75. package/lib/payment/postfinance-checkout/api-types.d.ts.map +1 -0
  76. package/lib/payment/postfinance-checkout/api-types.js +51 -0
  77. package/lib/payment/postfinance-checkout/api-types.js.map +1 -0
  78. package/lib/payment/postfinance-checkout/api.d.ts +5 -5
  79. package/lib/payment/postfinance-checkout/api.d.ts.map +1 -1
  80. package/lib/payment/postfinance-checkout/api.js +38 -62
  81. package/lib/payment/postfinance-checkout/api.js.map +1 -1
  82. package/lib/payment/postfinance-checkout/handler-express.d.ts.map +1 -1
  83. package/lib/payment/postfinance-checkout/handler-express.js +5 -5
  84. package/lib/payment/postfinance-checkout/handler-express.js.map +1 -1
  85. package/lib/payment/postfinance-checkout/handler-fastify.d.ts.map +1 -1
  86. package/lib/payment/postfinance-checkout/handler-fastify.js +6 -6
  87. package/lib/payment/postfinance-checkout/handler-fastify.js.map +1 -1
  88. package/lib/payment/postfinance-checkout/index.d.ts +2 -1
  89. package/lib/payment/postfinance-checkout/index.d.ts.map +1 -1
  90. package/lib/payment/postfinance-checkout/index.js +27 -30
  91. package/lib/payment/postfinance-checkout/index.js.map +1 -1
  92. package/lib/payment/postfinance-checkout/types.d.ts +4 -4
  93. package/lib/payment/postfinance-checkout/types.d.ts.map +1 -1
  94. package/lib/payment/postfinance-checkout/utils.d.ts +3 -3
  95. package/lib/payment/postfinance-checkout/utils.d.ts.map +1 -1
  96. package/lib/payment/postfinance-checkout/utils.js +5 -6
  97. package/lib/payment/postfinance-checkout/utils.js.map +1 -1
  98. package/lib/payment/saferpay/adapter.d.ts.map +1 -1
  99. package/lib/payment/saferpay/adapter.js +4 -6
  100. package/lib/payment/saferpay/adapter.js.map +1 -1
  101. package/lib/payment/saferpay/api/models/Transaction.d.ts +2 -2
  102. package/lib/payment/saferpay/api/models/Transaction.d.ts.map +1 -1
  103. package/lib/payment/saferpay/module.d.ts +2 -2
  104. package/lib/payment/saferpay/module.d.ts.map +1 -1
  105. package/lib/payment/stripe/index.js +5 -5
  106. package/lib/payment/stripe/index.js.map +1 -1
  107. package/lib/payment/stripe/stripe.js +3 -3
  108. package/lib/payment/stripe/stripe.js.map +1 -1
  109. package/lib/presets/all.d.ts +15 -13
  110. package/lib/presets/all.d.ts.map +1 -1
  111. package/lib/presets/all.js +3 -1
  112. package/lib/presets/all.js.map +1 -1
  113. package/lib/pricing/delivery-swiss-tax.d.ts.map +1 -1
  114. package/lib/pricing/delivery-swiss-tax.js +2 -2
  115. package/lib/pricing/delivery-swiss-tax.js.map +1 -1
  116. package/lib/pricing/order-delivery.js +1 -1
  117. package/lib/pricing/order-delivery.js.map +1 -1
  118. package/lib/pricing/order-discount.js +3 -3
  119. package/lib/pricing/order-discount.js.map +1 -1
  120. package/lib/pricing/order-items-discount.js +1 -1
  121. package/lib/pricing/order-items-discount.js.map +1 -1
  122. package/lib/pricing/order-items.js +1 -1
  123. package/lib/pricing/order-items.js.map +1 -1
  124. package/lib/pricing/order-payment.js +1 -1
  125. package/lib/pricing/order-payment.js.map +1 -1
  126. package/lib/pricing/order-round.d.ts +1 -1
  127. package/lib/pricing/order-round.d.ts.map +1 -1
  128. package/lib/pricing/order-round.js +8 -8
  129. package/lib/pricing/order-round.js.map +1 -1
  130. package/lib/pricing/product-catalog-price.d.ts +0 -1
  131. package/lib/pricing/product-catalog-price.d.ts.map +1 -1
  132. package/lib/pricing/product-catalog-price.js +6 -18
  133. package/lib/pricing/product-catalog-price.js.map +1 -1
  134. package/lib/pricing/product-price-rateconversion.js +2 -2
  135. package/lib/pricing/product-price-rateconversion.js.map +1 -1
  136. package/lib/pricing/product-round.d.ts +1 -1
  137. package/lib/pricing/product-round.d.ts.map +1 -1
  138. package/lib/pricing/product-round.js +2 -2
  139. package/lib/pricing/product-round.js.map +1 -1
  140. package/lib/pricing/product-swiss-tax.d.ts +1 -1
  141. package/lib/pricing/product-swiss-tax.d.ts.map +1 -1
  142. package/lib/pricing/product-swiss-tax.js +2 -2
  143. package/lib/pricing/product-swiss-tax.js.map +1 -1
  144. package/lib/warehousing/eth-minter.js +2 -2
  145. package/lib/warehousing/eth-minter.js.map +1 -1
  146. package/lib/worker/budgetsms.d.ts +10 -0
  147. package/lib/worker/budgetsms.d.ts.map +1 -0
  148. package/lib/worker/budgetsms.js +217 -0
  149. package/lib/worker/budgetsms.js.map +1 -0
  150. package/lib/worker/bulk-import.js +1 -1
  151. package/lib/worker/bulk-import.js.map +1 -1
  152. package/lib/worker/bulkgate.d.ts +2 -0
  153. package/lib/worker/bulkgate.d.ts.map +1 -0
  154. package/lib/worker/bulkgate.js +104 -0
  155. package/lib/worker/bulkgate.js.map +1 -0
  156. package/lib/worker/enrollment-order-generator.js +1 -1
  157. package/lib/worker/enrollment-order-generator.js.map +1 -1
  158. package/lib/worker/error-notifications.d.ts +4 -4
  159. package/lib/worker/error-notifications.d.ts.map +1 -1
  160. package/lib/worker/heartbeat.js +2 -8
  161. package/lib/worker/heartbeat.js.map +1 -1
  162. package/lib/worker/message.d.ts +1 -1
  163. package/lib/worker/message.d.ts.map +1 -1
  164. package/lib/worker/sms.js +16 -16
  165. package/lib/worker/sms.js.map +1 -1
  166. package/lib/worker/twilio.d.ts +2 -0
  167. package/lib/worker/twilio.d.ts.map +1 -0
  168. package/lib/worker/twilio.js +56 -0
  169. package/lib/worker/twilio.js.map +1 -0
  170. package/lib/worker/update-coinbase-rates.js +1 -1
  171. package/lib/worker/update-coinbase-rates.js.map +1 -1
  172. package/lib/worker/update-ecb-rates.js.map +1 -1
  173. package/package.json +32 -53
  174. package/src/delivery/pick-mup.ts +0 -2
  175. package/src/files/gridfs/adapter.ts +7 -2
  176. package/src/files/gridfs/handler-express.ts +9 -2
  177. package/src/files/gridfs/handler-fastify.ts +8 -2
  178. package/src/files/gridfs/module.ts +2 -2
  179. package/src/filters/local-search.ts +11 -2
  180. package/src/filters/strict-equal.ts +21 -0
  181. package/src/payment/apple-iap/adapter.ts +7 -14
  182. package/src/payment/apple-iap/fix-periods.ts +4 -7
  183. package/src/payment/apple-iap/handler-express.ts +4 -4
  184. package/src/payment/apple-iap/handler-fastify.ts +4 -4
  185. package/src/payment/apple-iap/module.ts +2 -2
  186. package/src/payment/braintree.ts +3 -4
  187. package/src/payment/cryptopay/db/CryptopayTransactions.ts +1 -2
  188. package/src/payment/cryptopay/denote-amount.test.ts +28 -0
  189. package/src/payment/cryptopay/denote-amount.ts +29 -0
  190. package/src/payment/cryptopay/derive-btc-address.test.ts +22 -0
  191. package/src/payment/cryptopay/derive-btc-address.ts +48 -0
  192. package/src/payment/cryptopay/derive-eth-address.test.ts +22 -0
  193. package/src/payment/cryptopay/derive-eth-address.ts +38 -0
  194. package/src/payment/cryptopay/handle-webhook.ts +103 -0
  195. package/src/payment/cryptopay/handler-express.ts +4 -70
  196. package/src/payment/cryptopay/handler-fastify.ts +6 -71
  197. package/src/payment/cryptopay/module.ts +44 -40
  198. package/src/payment/cryptopay/plugin.ts +50 -87
  199. package/src/payment/cryptopay/readme.md +23 -1
  200. package/src/payment/datatrans-v2/api/types.ts +41 -41
  201. package/src/payment/datatrans-v2/getPaths.ts +2 -2
  202. package/src/payment/datatrans-v2/index.ts +17 -15
  203. package/src/payment/datatrans-v2/roundedAmountFromOrder.ts +4 -4
  204. package/src/payment/paypal-checkout.ts +6 -11
  205. package/src/payment/payrexx/api/index.ts +2 -2
  206. package/src/payment/payrexx/api/makeFetcher.ts +1 -1
  207. package/src/payment/payrexx/index.ts +4 -4
  208. package/src/payment/payrexx/payrexx.ts +2 -2
  209. package/src/payment/postfinance-checkout/api-client.ts +106 -0
  210. package/src/payment/postfinance-checkout/api-types.ts +111 -0
  211. package/src/payment/postfinance-checkout/api.ts +58 -85
  212. package/src/payment/postfinance-checkout/handler-express.ts +5 -7
  213. package/src/payment/postfinance-checkout/handler-fastify.ts +6 -8
  214. package/src/payment/postfinance-checkout/index.ts +43 -35
  215. package/src/payment/postfinance-checkout/types.ts +6 -6
  216. package/src/payment/postfinance-checkout/utils.ts +7 -12
  217. package/src/payment/saferpay/adapter.ts +4 -6
  218. package/src/payment/saferpay/api/models/Transaction.ts +2 -2
  219. package/src/payment/saferpay/module.ts +2 -2
  220. package/src/payment/stripe/index.ts +5 -5
  221. package/src/payment/stripe/stripe.ts +3 -3
  222. package/src/presets/all.ts +3 -1
  223. package/src/pricing/delivery-swiss-tax.ts +6 -2
  224. package/src/pricing/order-delivery.ts +1 -1
  225. package/src/pricing/order-discount.ts +3 -3
  226. package/src/pricing/order-items-discount.ts +1 -1
  227. package/src/pricing/order-items.ts +1 -1
  228. package/src/pricing/order-payment.ts +1 -1
  229. package/src/pricing/order-round.ts +9 -9
  230. package/src/pricing/product-catalog-price.ts +6 -25
  231. package/src/pricing/product-price-rateconversion.ts +2 -2
  232. package/src/pricing/product-round.ts +3 -3
  233. package/src/pricing/product-swiss-tax.test.ts +6 -6
  234. package/src/pricing/product-swiss-tax.ts +2 -2
  235. package/src/warehousing/eth-minter.ts +2 -2
  236. package/src/worker/budgetsms.ts +268 -0
  237. package/src/worker/bulk-import.ts +1 -1
  238. package/src/worker/bulkgate.ts +138 -0
  239. package/src/worker/enrollment-order-generator.ts +3 -3
  240. package/src/worker/error-notifications.ts +4 -4
  241. package/src/worker/heartbeat.ts +4 -11
  242. package/src/worker/message.ts +1 -1
  243. package/src/worker/push-notification.ts +2 -2
  244. package/src/worker/twilio.ts +71 -0
  245. package/src/worker/update-coinbase-rates.ts +3 -6
  246. package/src/worker/update-ecb-rates.ts +3 -3
  247. package/lib/accounts/google-oauth.d.ts +0 -4
  248. package/lib/accounts/google-oauth.d.ts.map +0 -1
  249. package/lib/accounts/google-oauth.js +0 -145
  250. package/lib/accounts/google-oauth.js.map +0 -1
  251. package/lib/accounts/linkedin-oauth.d.ts +0 -4
  252. package/lib/accounts/linkedin-oauth.d.ts.map +0 -1
  253. package/lib/accounts/linkedin-oauth.js +0 -82
  254. package/lib/accounts/linkedin-oauth.js.map +0 -1
  255. package/lib/files/gridfs/gridfs-adapter.d.ts +0 -3
  256. package/lib/files/gridfs/gridfs-adapter.d.ts.map +0 -1
  257. package/lib/files/gridfs/gridfs-adapter.js +0 -97
  258. package/lib/files/gridfs/gridfs-adapter.js.map +0 -1
  259. package/lib/files/gridfs/gridfs-webhook.d.ts +0 -11
  260. package/lib/files/gridfs/gridfs-webhook.d.ts.map +0 -1
  261. package/lib/files/gridfs/gridfs-webhook.js +0 -84
  262. package/lib/files/gridfs/gridfs-webhook.js.map +0 -1
  263. package/lib/files/minio/minio-adapter.d.ts +0 -6
  264. package/lib/files/minio/minio-adapter.d.ts.map +0 -1
  265. package/lib/files/minio/minio-adapter.js +0 -181
  266. package/lib/files/minio/minio-adapter.js.map +0 -1
  267. package/lib/files/minio/minio-webhook.d.ts +0 -2
  268. package/lib/files/minio/minio-webhook.d.ts.map +0 -1
  269. package/lib/files/minio/minio-webhook.js +0 -33
  270. package/lib/files/minio/minio-webhook.js.map +0 -1
  271. package/lib/payment/apple-iap/module/configureAppleTransactionsModule.d.ts +0 -9
  272. package/lib/payment/apple-iap/module/configureAppleTransactionsModule.d.ts.map +0 -1
  273. package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js +0 -17
  274. package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js.map +0 -1
  275. package/lib/payment/cryptopay/middleware.d.ts +0 -2
  276. package/lib/payment/cryptopay/middleware.d.ts.map +0 -1
  277. package/lib/payment/cryptopay/middleware.js +0 -75
  278. package/lib/payment/cryptopay/middleware.js.map +0 -1
  279. package/lib/payment/cryptopay/module/configureCryptopayModule.d.ts +0 -25
  280. package/lib/payment/cryptopay/module/configureCryptopayModule.d.ts.map +0 -1
  281. package/lib/payment/cryptopay/module/configureCryptopayModule.js +0 -75
  282. package/lib/payment/cryptopay/module/configureCryptopayModule.js.map +0 -1
  283. package/lib/payment/datatrans-v2/middleware.d.ts +0 -2
  284. package/lib/payment/datatrans-v2/middleware.d.ts.map +0 -1
  285. package/lib/payment/datatrans-v2/middleware.js +0 -68
  286. package/lib/payment/datatrans-v2/middleware.js.map +0 -1
  287. package/lib/payment/payrexx/middleware.d.ts +0 -2
  288. package/lib/payment/payrexx/middleware.d.ts.map +0 -1
  289. package/lib/payment/payrexx/middleware.js +0 -86
  290. package/lib/payment/payrexx/middleware.js.map +0 -1
  291. package/lib/payment/postfinance-checkout/middleware.d.ts +0 -2
  292. package/lib/payment/postfinance-checkout/middleware.d.ts.map +0 -1
  293. package/lib/payment/postfinance-checkout/middleware.js +0 -38
  294. package/lib/payment/postfinance-checkout/middleware.js.map +0 -1
  295. package/lib/payment/saferpay/middleware.d.ts +0 -2
  296. package/lib/payment/saferpay/middleware.d.ts.map +0 -1
  297. package/lib/payment/saferpay/middleware.js +0 -57
  298. package/lib/payment/saferpay/middleware.js.map +0 -1
  299. package/lib/payment/saferpay/module/configureSaferpayTransactionsModule.d.ts +0 -10
  300. package/lib/payment/saferpay/module/configureSaferpayTransactionsModule.d.ts.map +0 -1
  301. package/lib/payment/saferpay/module/configureSaferpayTransactionsModule.js +0 -24
  302. package/lib/payment/saferpay/module/configureSaferpayTransactionsModule.js.map +0 -1
  303. package/lib/payment/stripe/middleware.d.ts +0 -6
  304. package/lib/payment/stripe/middleware.d.ts.map +0 -1
  305. package/lib/payment/stripe/middleware.js +0 -114
  306. package/lib/payment/stripe/middleware.js.map +0 -1
  307. package/lib/plugins-index.d.ts +0 -48
  308. package/lib/plugins-index.d.ts.map +0 -1
  309. package/lib/plugins-index.js +0 -107
  310. package/lib/plugins-index.js.map +0 -1
  311. package/lib/worker/BaseWorker.d.ts +0 -30
  312. package/lib/worker/BaseWorker.d.ts.map +0 -1
  313. package/lib/worker/BaseWorker.js +0 -79
  314. package/lib/worker/BaseWorker.js.map +0 -1
  315. package/lib/worker/EventListenerWorker.d.ts +0 -6
  316. package/lib/worker/EventListenerWorker.d.ts.map +0 -1
  317. package/lib/worker/EventListenerWorker.js +0 -46
  318. package/lib/worker/EventListenerWorker.js.map +0 -1
  319. package/lib/worker/FailedRescheduler.d.ts +0 -15
  320. package/lib/worker/FailedRescheduler.d.ts.map +0 -1
  321. package/lib/worker/FailedRescheduler.js +0 -45
  322. package/lib/worker/FailedRescheduler.js.map +0 -1
  323. package/lib/worker/IntervalWorker.d.ts +0 -10
  324. package/lib/worker/IntervalWorker.d.ts.map +0 -1
  325. package/lib/worker/IntervalWorker.js +0 -37
  326. package/lib/worker/IntervalWorker.js.map +0 -1
  327. package/src/worker/BaseWorker.ts +0 -116
  328. package/src/worker/EventListenerWorker.ts +0 -61
  329. package/src/worker/FailedRescheduler.ts +0 -80
  330. package/src/worker/IntervalWorker.ts +0 -54
  331. package/src/worker/sms.ts +0 -87
@@ -3,7 +3,7 @@ import { createLogger } from '@unchainedshop/logger';
3
3
  import { WebhookData } from './types.js';
4
4
  import { getTransaction, getTransactionCompletion } from './api.js';
5
5
 
6
- const logger = createLogger('unchained:core-payment:postfinance-checkout');
6
+ const logger = createLogger('unchained:core-payment:postfinance-checkout:handler');
7
7
 
8
8
  export const postfinanceCheckoutHandler = async (req, res) => {
9
9
  const context = req.unchainedContext as Context;
@@ -13,7 +13,7 @@ export const postfinanceCheckoutHandler = async (req, res) => {
13
13
  try {
14
14
  const transactionCompletion = await getTransactionCompletion(data.entityId as unknown as string);
15
15
  const transaction = await getTransaction(
16
- transactionCompletion.linkedTransaction as unknown as string,
16
+ transactionCompletion ? (transactionCompletion as any).linkedTransaction : data.entityId,
17
17
  );
18
18
  const { orderPaymentId } = transaction.metaData as { orderPaymentId: string };
19
19
  const orderPayment = await modules.orders.payments.findOrderPayment({
@@ -27,19 +27,17 @@ export const postfinanceCheckoutHandler = async (req, res) => {
27
27
  },
28
28
  });
29
29
  logger.info(
30
- `PostFinance Checkout Webhook: Transaction ${transactionCompletion.linkedTransaction} marked order payment ID ${transaction.metaData.orderPaymentId} as paid`,
30
+ `Transaction ${transactionCompletion.linkedTransaction} marked order payment ID ${transaction.metaData.orderPaymentId} as paid`,
31
31
  );
32
32
  res.writeHead(200);
33
33
  res.end(`Order marked as paid: ${order.orderNumber}`);
34
34
  } catch (e) {
35
- logger.error(`PostFinance Checkout Webhook: Unchained rejected to checkout with message`, e);
35
+ logger.error(e);
36
36
  res.writeHead(500);
37
37
  res.end(JSON.stringify({ name: e.name, code: e.code, message: e.message }));
38
38
  }
39
39
  } else {
40
- logger.error(
41
- `PostFinance Checkout Webhook: Received unknown listenerEntityTechnicalName ${data.listenerEntityTechnicalName}`,
42
- );
40
+ logger.error(`Received unknown listenerEntityTechnicalName ${data.listenerEntityTechnicalName}`);
43
41
  res.writeHead(404);
44
42
  res.end();
45
43
  }
@@ -4,7 +4,7 @@ import { WebhookData } from './types.js';
4
4
  import { getTransaction, getTransactionCompletion } from './api.js';
5
5
  import { FastifyRequest, RouteHandlerMethod } from 'fastify';
6
6
 
7
- const logger = createLogger('unchained:core-payment:postfinance-checkout');
7
+ const logger = createLogger('unchained:core-payment:postfinance-checkout:handler');
8
8
 
9
9
  export const postfinanceCheckoutHandler: RouteHandlerMethod = async (
10
10
  req: FastifyRequest & {
@@ -19,7 +19,7 @@ export const postfinanceCheckoutHandler: RouteHandlerMethod = async (
19
19
  try {
20
20
  const transactionCompletion = await getTransactionCompletion(data.entityId as unknown as string);
21
21
  const transaction = await getTransaction(
22
- transactionCompletion.linkedTransaction as unknown as string,
22
+ transactionCompletion ? (transactionCompletion as any).linkedTransaction : data.entityId,
23
23
  );
24
24
  const { orderPaymentId } = transaction.metaData as { orderPaymentId: string };
25
25
  const orderPayment = await modules.orders.payments.findOrderPayment({
@@ -29,23 +29,21 @@ export const postfinanceCheckoutHandler: RouteHandlerMethod = async (
29
29
 
30
30
  const order = await services.orders.checkoutOrder(orderPayment.orderId, {
31
31
  paymentContext: {
32
- transactionId: transactionCompletion.linkedTransaction,
32
+ transactionId: transaction.id,
33
33
  },
34
34
  });
35
35
  logger.info(
36
- `PostFinance Checkout Webhook: Transaction ${transactionCompletion.linkedTransaction} marked order payment ID ${transaction.metaData.orderPaymentId} as paid`,
36
+ `Transaction ${transaction.id} marked order payment ID ${transaction.metaData.orderPaymentId} as paid`,
37
37
  );
38
38
  reply.status(200);
39
39
  return reply.send(`Order marked as paid: ${order.orderNumber}`);
40
40
  } catch (e) {
41
- logger.error(`PostFinance Checkout Webhook: Unchained rejected to checkout with message`, e);
41
+ logger.error(e);
42
42
  reply.status(500);
43
43
  return reply.send({ name: e.name, code: e.code, message: e.message });
44
44
  }
45
45
  } else {
46
- logger.error(
47
- `PostFinance Checkout Webhook: Received unknown listenerEntityTechnicalName ${data.listenerEntityTechnicalName}`,
48
- );
46
+ logger.error(`Received unknown listenerEntityTechnicalName ${data.listenerEntityTechnicalName}`);
49
47
  reply.status(404);
50
48
  return reply.send();
51
49
  }
@@ -8,7 +8,6 @@ import {
8
8
  PaymentDirector,
9
9
  PaymentError,
10
10
  } from '@unchainedshop/core';
11
- import * as pf from 'postfinancecheckout';
12
11
 
13
12
  import {
14
13
  confirmDeferredTransaction,
@@ -23,8 +22,15 @@ import {
23
22
  } from './api.js';
24
23
  import { orderIsPaid } from './utils.js';
25
24
  import { CompletionModes, IntegrationModes, SignResponse } from './types.js';
26
-
27
- const { PostFinanceCheckout } = pf;
25
+ import {
26
+ TransactionCreate,
27
+ LineItem,
28
+ LineItemType,
29
+ TokenizationMode,
30
+ TransactionCompletionBehavior,
31
+ TransactionState,
32
+ CreationEntityState,
33
+ } from './api-types.js';
28
34
 
29
35
  const {
30
36
  PFCHECKOUT_SPACE_ID,
@@ -34,7 +40,7 @@ const {
34
40
  PFCHECKOUT_FAILED_URL,
35
41
  } = process.env;
36
42
 
37
- const logger = createLogger('unchained:core-payment:postfinance');
43
+ const logger = createLogger('unchained:core-payment:postfinance-checkout');
38
44
 
39
45
  const newError = ({ code, message }: { code: string; message: string }) => {
40
46
  const error = new Error(message);
@@ -66,9 +72,7 @@ const PostfinanceCheckout: IPaymentAdapter = {
66
72
  );
67
73
  },
68
74
 
69
- // eslint-disable-next-line
70
75
  configurationError() {
71
- // eslint-disable-line
72
76
  if (
73
77
  !PFCHECKOUT_SPACE_ID ||
74
78
  !PFCHECKOUT_USER_ID ||
@@ -94,7 +98,7 @@ const PostfinanceCheckout: IPaymentAdapter = {
94
98
  if (!credentials.meta) return false;
95
99
  const { linkedSpaceId } = credentials.meta;
96
100
  const tokenData = await getToken(linkedSpaceId, credentials.token);
97
- return tokenData.state === PostFinanceCheckout.model.CreationEntityState.ACTIVE;
101
+ return tokenData.state === CreationEntityState.ACTIVE;
98
102
  },
99
103
 
100
104
  sign: async (transactionContext: any = {}) => {
@@ -105,41 +109,42 @@ const PostfinanceCheckout: IPaymentAdapter = {
105
109
  const completionMode = adapter.getCompletionMode();
106
110
  const pricing = OrderPricingSheet({
107
111
  calculation: order.calculation,
108
- currency: order.currency,
112
+ currencyCode: order.currencyCode,
109
113
  });
110
114
 
111
115
  const totalAmount = pricing?.total({ useNetPrice: false }).amount;
112
- const transaction = new PostFinanceCheckout.model.TransactionCreate();
113
- const userId = order?.userId || context?.userId;
114
- transaction.currency = order.currency;
115
- transaction.metaData = {
116
- orderPaymentId: orderPayment._id,
116
+ const transaction: TransactionCreate = {
117
+ currency: order.currencyCode,
118
+ metaData: {
119
+ orderPaymentId: orderPayment._id,
120
+ },
121
+ successUrl: `${transactionContext?.successUrl || PFCHECKOUT_SUCCESS_URL}?order_id=${
122
+ orderPayment.orderId
123
+ }`,
124
+ failedUrl: `${transactionContext?.failedUrl || PFCHECKOUT_FAILED_URL}?order_id=${
125
+ orderPayment.orderId
126
+ }`,
127
+ customerId: order?.userId || context?.userId,
128
+ tokenizationMode: TokenizationMode.ALLOW_ONE_CLICK_PAYMENT,
117
129
  };
118
- transaction.successUrl = `${transactionContext?.successUrl || PFCHECKOUT_SUCCESS_URL}?order_id=${
119
- orderPayment.orderId
120
- }`;
121
- transaction.failedUrl = `${transactionContext?.failedUrl || PFCHECKOUT_FAILED_URL}?order_id=${
122
- orderPayment.orderId
123
- }`;
124
- transaction.customerId = userId;
125
- transaction.tokenizationMode =
126
- PostFinanceCheckout.model.TokenizationMode.ALLOW_ONE_CLICK_PAYMENT;
130
+
127
131
  if (completionMode === CompletionModes.Immediate) {
128
- transaction.completionBehavior =
129
- PostFinanceCheckout.model.TransactionCompletionBehavior.COMPLETE_IMMEDIATELY;
132
+ transaction.completionBehavior = TransactionCompletionBehavior.COMPLETE_IMMEDIATELY;
130
133
  } else if (completionMode === CompletionModes.Deferred) {
131
- transaction.completionBehavior =
132
- PostFinanceCheckout.model.TransactionCompletionBehavior.COMPLETE_DEFERRED;
134
+ transaction.completionBehavior = TransactionCompletionBehavior.COMPLETE_DEFERRED;
133
135
  }
136
+
134
137
  if (totalAmount) {
135
- const lineItemSum = new PostFinanceCheckout.model.LineItemCreate();
136
- lineItemSum.name = `Bestellung ${orderPayment.orderId}`;
137
- lineItemSum.type = PostFinanceCheckout.model.LineItemType.FEE;
138
- lineItemSum.quantity = 1;
139
- lineItemSum.uniqueId = orderPayment.orderId;
140
- lineItemSum.amountIncludingTax = totalAmount / 100;
138
+ const lineItemSum: LineItem = {
139
+ name: `Bestellung ${orderPayment.orderId}`,
140
+ type: LineItemType.FEE,
141
+ quantity: 1,
142
+ uniqueId: orderPayment.orderId,
143
+ amountIncludingTax: totalAmount / 100,
144
+ };
141
145
  transaction.lineItems = [lineItemSum];
142
146
  }
147
+
143
148
  const transactionId = await createTransaction(transaction);
144
149
  let location = null;
145
150
  if (integrationMode === IntegrationModes.PaymentPage) {
@@ -216,10 +221,10 @@ const PostfinanceCheckout: IPaymentAdapter = {
216
221
  return false;
217
222
  }
218
223
  const transaction = await getTransaction(transactionId);
219
- const refund = transaction.state === PostFinanceCheckout.model.TransactionState.FULFILL;
224
+ const refund = transaction.state === TransactionState.FULFILL;
220
225
  const pricing = OrderPricingSheet({
221
226
  calculation: order.calculation,
222
- currency: order.currency,
227
+ currencyCode: order.currencyCode,
223
228
  });
224
229
 
225
230
  const totalAmount = pricing?.total({ useNetPrice: false }).amount;
@@ -237,7 +242,7 @@ const PostfinanceCheckout: IPaymentAdapter = {
237
242
  return false;
238
243
  }
239
244
  const transaction = await getTransaction(transactionId);
240
- if (transaction.state === PostFinanceCheckout.model.TransactionState.AUTHORIZED) {
245
+ if (transaction.state === TransactionState.AUTHORIZED) {
241
246
  return confirmDeferredTransaction(transactionId);
242
247
  }
243
248
  return false;
@@ -249,3 +254,6 @@ const PostfinanceCheckout: IPaymentAdapter = {
249
254
  };
250
255
 
251
256
  PaymentDirector.registerAdapter(PostfinanceCheckout);
257
+
258
+ export * from './types.js';
259
+ export * from './api-types.js';
@@ -1,22 +1,22 @@
1
- export enum IntegrationModes { // eslint-disable-line
1
+ export enum IntegrationModes {
2
2
  PaymentPage = 'PaymentPage',
3
3
  Lightbox = 'Lightbox',
4
4
  iFrame = 'iFrame',
5
5
  }
6
6
 
7
- export enum CompletionModes { // eslint-disable-line
7
+ export enum CompletionModes {
8
8
  Immediate = 'Immediate',
9
9
  Deferred = 'Deferred',
10
10
  }
11
11
 
12
- export type SignResponse = {
12
+ export interface SignResponse {
13
13
  transactionId: number;
14
14
  location: string | null;
15
- };
15
+ }
16
16
 
17
17
  export type listenerEntityTechnicalNames = 'TransactionCompletion';
18
18
 
19
- export type WebhookData = {
19
+ export interface WebhookData {
20
20
  eventId: number;
21
21
  entityId: number;
22
22
  listenerEntityId: number;
@@ -24,4 +24,4 @@ export type WebhookData = {
24
24
  spaceId: number;
25
25
  webhookListenerId: number;
26
26
  timestamp: string; // "YYYY-MM-DDTHH:MM:ss+0000", e.g. "2022-02-18T12:40:42+0000"
27
- };
27
+ }
@@ -1,22 +1,20 @@
1
1
  import { OrderPricingSheet } from '@unchainedshop/core';
2
2
  import { Order } from '@unchainedshop/core-orders';
3
- import * as pf from 'postfinancecheckout';
4
-
5
- const { PostFinanceCheckout } = pf;
3
+ import { Transaction, TransactionState } from './api-types.js';
6
4
 
7
5
  export const transactionIsPaid = async (
8
- transaction: pf.PostFinanceCheckout.model.Transaction,
6
+ transaction: Transaction,
9
7
  expectedCurrency: string,
10
8
  expectedAmount: number,
11
9
  ): Promise<boolean> => {
12
- if (transaction.state === PostFinanceCheckout.model.TransactionState.FULFILL) {
10
+ if (transaction.state === TransactionState.FULFILL) {
13
11
  return (
14
12
  transaction.completedAmount !== undefined &&
15
13
  transaction.completedAmount.toFixed(2) === expectedAmount.toFixed(2) &&
16
14
  transaction.currency === expectedCurrency
17
15
  );
18
16
  }
19
- if (transaction.state === PostFinanceCheckout.model.TransactionState.AUTHORIZED) {
17
+ if (transaction.state === TransactionState.AUTHORIZED) {
20
18
  return (
21
19
  transaction.authorizationAmount !== undefined &&
22
20
  transaction.authorizationAmount.toFixed(2) === expectedAmount.toFixed(2) &&
@@ -26,14 +24,11 @@ export const transactionIsPaid = async (
26
24
  return false;
27
25
  };
28
26
 
29
- export const orderIsPaid = async (
30
- order: Order,
31
- transaction: pf.PostFinanceCheckout.model.Transaction,
32
- ): Promise<boolean> => {
27
+ export const orderIsPaid = async (order: Order, transaction: Transaction): Promise<boolean> => {
33
28
  const pricing = OrderPricingSheet({
34
29
  calculation: order.calculation,
35
- currency: order.currency,
30
+ currencyCode: order.currencyCode,
36
31
  });
37
32
  const totalAmount = pricing.total({ useNetPrice: false }).amount / 100;
38
- return transactionIsPaid(transaction, order.currency, totalAmount);
33
+ return transactionIsPaid(transaction, order.currencyCode, totalAmount);
39
34
  };
@@ -68,9 +68,7 @@ export const WordlineSaferpay: IPaymentAdapter = {
68
68
  return config.find((item) => item.key === 'terminalId')?.value;
69
69
  },
70
70
 
71
- // eslint-disable-next-line
72
71
  configurationError() {
73
- // eslint-disable-line
74
72
  if (
75
73
  !SAFERPAY_BASE_URL ||
76
74
  !SAFERPAY_CUSTOMER_ID ||
@@ -100,7 +98,7 @@ export const WordlineSaferpay: IPaymentAdapter = {
100
98
  }
101
99
  const pricing = OrderPricingSheet({
102
100
  calculation: order.calculation,
103
- currency: order.currency,
101
+ currencyCode: order.currencyCode,
104
102
  });
105
103
  const totalAmount = pricing?.total({ useNetPrice: false }).amount;
106
104
 
@@ -115,7 +113,7 @@ export const WordlineSaferpay: IPaymentAdapter = {
115
113
  Payment: {
116
114
  Amount: {
117
115
  Value: totalAmount.toString(),
118
- CurrencyCode: order.currency,
116
+ CurrencyCode: order.currencyCode,
119
117
  },
120
118
  OrderId: order._id,
121
119
  Description: transactionContext.description || 'Bestellung',
@@ -160,7 +158,7 @@ export const WordlineSaferpay: IPaymentAdapter = {
160
158
  }
161
159
  const pricing = OrderPricingSheet({
162
160
  calculation: order.calculation,
163
- currency: order.currency,
161
+ currencyCode: order.currencyCode,
164
162
  });
165
163
  const totalAmount = pricing.total({ useNetPrice: false }).amount;
166
164
 
@@ -176,7 +174,7 @@ export const WordlineSaferpay: IPaymentAdapter = {
176
174
  const success =
177
175
  !paymentPageAssert.ErrorMessage &&
178
176
  paymentPageAssert.Transaction.Amount.Value === totalAmount.toString() &&
179
- paymentPageAssert.Transaction.Amount.CurrencyCode === order.currency &&
177
+ paymentPageAssert.Transaction.Amount.CurrencyCode === order.currencyCode &&
180
178
  (paymentPageAssert.Transaction.Status === 'AUTHORIZED' ||
181
179
  paymentPageAssert.Transaction.Status === 'CAPTURED');
182
180
  if (success) {
@@ -1,6 +1,6 @@
1
1
  export type TransactionStatus = 'AUTHORIZED' | 'CANCELED' | 'CAPTURED' | 'PENDING';
2
2
 
3
- export type TransactionAmount = {
3
+ export interface TransactionAmount {
4
4
  Value: string;
5
5
  CurrencyCode: string;
6
- };
6
+ }
@@ -36,6 +36,6 @@ export default {
36
36
  },
37
37
  };
38
38
 
39
- export type SaferpayTransactionsModule = {
39
+ export interface SaferpayTransactionsModule {
40
40
  saferpayTransactions: Awaited<ReturnType<typeof configureSaferpayTransactionsModule>>;
41
- };
41
+ }
@@ -90,7 +90,7 @@ const Stripe: IPaymentAdapter = {
90
90
  if (orderPayment) {
91
91
  const pricing = OrderPricingSheet({
92
92
  calculation: order.calculation,
93
- currency: order.currency,
93
+ currencyCode: order.currencyCode,
94
94
  });
95
95
  const { userId, name, email } = await getUserData(order?.userId);
96
96
  const paymentIntent = await createOrderPaymentIntent(
@@ -121,7 +121,7 @@ const Stripe: IPaymentAdapter = {
121
121
  const { userId, name, email } = await getUserData(order?.userId);
122
122
  const pricing = OrderPricingSheet({
123
123
  calculation: order.calculation,
124
- currency: order.currency,
124
+ currencyCode: order.currencyCode,
125
125
  });
126
126
 
127
127
  const paymentIntentObject = paymentIntentId
@@ -132,15 +132,15 @@ const Stripe: IPaymentAdapter = {
132
132
  customer: paymentCredentials.meta?.customer,
133
133
  confirm: true,
134
134
  payment_method: paymentCredentials.token,
135
- payment_method_types: paymentCredentials.meta?.payment_method_types, // eslint-disable-line
135
+ payment_method_types: paymentCredentials.meta?.payment_method_types,
136
136
  // payment_method_options: paymentCredentials.meta?.payment_method_options, // eslint-disable-line
137
137
  },
138
138
  );
139
139
 
140
- const { currency, amount } = pricing.total({ useNetPrice: false });
140
+ const { currencyCode, amount } = pricing.total({ useNetPrice: false });
141
141
 
142
142
  if (
143
- paymentIntentObject.currency !== currency.toLowerCase() ||
143
+ paymentIntentObject.currency !== currencyCode.toLowerCase() ||
144
144
  paymentIntentObject.amount !== Math.round(amount)
145
145
  ) {
146
146
  throw new Error('The price has changed since the intent has been created');
@@ -18,7 +18,7 @@ export const initStripeClient = async (): Promise<StripeType> => {
18
18
  // @ts-ignore
19
19
  const { default: Stripe } = await import('stripe');
20
20
  stripe = new Stripe(STRIPE_SECRET, {
21
- apiVersion: '2025-05-28.basil',
21
+ apiVersion: '2025-06-30.basil',
22
22
  });
23
23
  return stripe;
24
24
  };
@@ -122,11 +122,11 @@ export const createOrderPaymentIntent = async (
122
122
  const description = `${descriptorPrefix || EMAIL_WEBSITE_NAME || 'Unchained'}`.trim();
123
123
  const customer = options?.customer || (await upsertCustomer({ userId, name, email }));
124
124
 
125
- const { currency, amount } = pricing.total({ useNetPrice: false });
125
+ const { currencyCode, amount } = pricing.total({ useNetPrice: false });
126
126
 
127
127
  const paymentIntent = await stripe.paymentIntents.create({
128
128
  amount: Math.round(amount),
129
- currency: currency.toLowerCase(),
129
+ currency: currencyCode.toLowerCase(),
130
130
  description,
131
131
  statement_descriptor_suffix: `${order._id.substring(0, 4)}..${order._id.substring(order._id.length - 4)}`,
132
132
  setup_future_usage: 'off_session', // Verify your integration in this guide by including this parameter
@@ -21,7 +21,9 @@ import '../filters/strict-equal.js';
21
21
  import '../filters/local-search.js';
22
22
 
23
23
  // Workers
24
- import '../worker/sms.js';
24
+ import '../worker/twilio.js';
25
+ import '../worker/bulkgate.js';
26
+ import '../worker/budgetsms.js';
25
27
  import '../worker/push-notification.js';
26
28
  import '../worker/enrollment-order-generator.js';
27
29
 
@@ -19,8 +19,12 @@ const getTaxRate = ({ order, provider }: { order?: Order; provider?: DeliveryPro
19
19
  return taxCategory.rate(order?.ordered);
20
20
  };
21
21
 
22
- const isDeliveryAddressInSwitzerland = ({ orderDelivery, order, country = null }) => {
23
- let countryCode = country?.toUpperCase().trim() || order.countryCode;
22
+ const isDeliveryAddressInSwitzerland = ({
23
+ orderDelivery,
24
+ order,
25
+ countryCode: forceCountryCode = null,
26
+ }) => {
27
+ let countryCode = forceCountryCode?.toUpperCase().trim() || order.countryCode;
24
28
 
25
29
  const address = orderDelivery?.context?.address || order?.billingAddress;
26
30
 
@@ -29,7 +29,7 @@ export const OrderDelivery: IOrderPricingAdapter = {
29
29
  if (!orderDelivery) return null;
30
30
  const pricing = DeliveryPricingSheet({
31
31
  calculation: orderDelivery.calculation,
32
- currency: order.currency,
32
+ currencyCode: order.currencyCode,
33
33
  });
34
34
  const tax = pricing.taxSum();
35
35
  const shipping = pricing.gross();
@@ -48,7 +48,7 @@ export const OrderDiscount: IOrderPricingAdapter<OrderDiscountConfiguration> = {
48
48
  resolveRatioAndTaxDivisorForPricingSheet(
49
49
  ProductPricingSheet({
50
50
  calculation: orderPosition.calculation,
51
- currency: order.currency,
51
+ currencyCode: order.currencyCode,
52
52
  quantity: orderPosition.quantity,
53
53
  }),
54
54
  totalAmountOfItems,
@@ -58,7 +58,7 @@ export const OrderDiscount: IOrderPricingAdapter<OrderDiscountConfiguration> = {
58
58
  const deliveryShare = resolveRatioAndTaxDivisorForPricingSheet(
59
59
  DeliveryPricingSheet({
60
60
  calculation: orderDelivery.calculation || [],
61
- currency: order.currency,
61
+ currencyCode: order.currencyCode,
62
62
  }),
63
63
  totalAmountOfPaymentAndDelivery,
64
64
  );
@@ -66,7 +66,7 @@ export const OrderDiscount: IOrderPricingAdapter<OrderDiscountConfiguration> = {
66
66
  const paymentShare = resolveRatioAndTaxDivisorForPricingSheet(
67
67
  PaymentPricingSheet({
68
68
  calculation: orderPayment.calculation || [],
69
- currency: order.currency,
69
+ currencyCode: order.currencyCode,
70
70
  }),
71
71
  totalAmountOfPaymentAndDelivery,
72
72
  );
@@ -42,7 +42,7 @@ const OrderItemsDiscount: IOrderPricingAdapter<OrderDiscountConfiguration> = {
42
42
  resolveRatioAndTaxDivisorForPricingSheet(
43
43
  ProductPricingSheet({
44
44
  calculation: orderPosition.calculation,
45
- currency: order.currency,
45
+ currencyCode: order.currencyCode,
46
46
  quantity: orderPosition.quantity,
47
47
  }),
48
48
  totalAmountOfItems,
@@ -30,7 +30,7 @@ const OrderItems: IOrderPricingAdapter = {
30
30
  (current, orderPosition) => {
31
31
  const pricing = ProductPricingSheet({
32
32
  calculation: orderPosition.calculation,
33
- currency: order.currency,
33
+ currencyCode: order.currencyCode,
34
34
  quantity: orderPosition.quantity,
35
35
  });
36
36
  const tax = pricing.taxSum();
@@ -30,7 +30,7 @@ const OrderPayment: IOrderPricingAdapter = {
30
30
 
31
31
  const pricing = PaymentPricingSheet({
32
32
  calculation: orderPayment.calculation,
33
- currency: order.currency,
33
+ currencyCode: order.currencyCode,
34
34
  });
35
35
  const tax = pricing.taxSum();
36
36
  const paymentFees = pricing.gross();
@@ -7,7 +7,7 @@ import {
7
7
 
8
8
  interface PriceRoundSettings {
9
9
  defaultPrecision: number;
10
- roundTo: (value: number, precision: number, currency: string) => number;
10
+ roundTo: (value: number, precision: number, currencyCode: string) => number;
11
11
  }
12
12
 
13
13
  export const OrderPriceRound: IOrderPricingAdapter & {
@@ -39,11 +39,11 @@ export const OrderPriceRound: IOrderPricingAdapter & {
39
39
  actions: (params) => {
40
40
  const pricingAdapter = OrderPricingAdapter.actions(params);
41
41
 
42
- const calculateDifference = (amount: number, currency: string) => {
42
+ const calculateDifference = (amount: number, currencyCode: string) => {
43
43
  const roundedAmount = OrderPriceRound.settings.roundTo(
44
44
  amount,
45
45
  OrderPriceRound.settings.defaultPrecision,
46
- currency,
46
+ currencyCode,
47
47
  );
48
48
  return roundedAmount - amount;
49
49
  };
@@ -52,7 +52,7 @@ export const OrderPriceRound: IOrderPricingAdapter & {
52
52
  ...pricingAdapter,
53
53
 
54
54
  calculate: async () => {
55
- const { currency } = params.context;
55
+ const { currencyCode } = params.context;
56
56
 
57
57
  const { amount: deliveryAmount } = params.calculationSheet.total({
58
58
  category: OrderPricingRowCategory.Delivery,
@@ -60,7 +60,7 @@ export const OrderPriceRound: IOrderPricingAdapter & {
60
60
  });
61
61
  if (deliveryAmount) {
62
62
  pricingAdapter.resultSheet().addDelivery({
63
- amount: calculateDifference(deliveryAmount, currency),
63
+ amount: calculateDifference(deliveryAmount, currencyCode),
64
64
  taxAmount: 0,
65
65
  meta: {
66
66
  adapter: OrderPriceRound.key,
@@ -74,7 +74,7 @@ export const OrderPriceRound: IOrderPricingAdapter & {
74
74
  });
75
75
  if (discountAmount) {
76
76
  pricingAdapter.resultSheet().addDiscount({
77
- amount: calculateDifference(discountAmount, currency),
77
+ amount: calculateDifference(discountAmount, currencyCode),
78
78
  taxAmount: 0,
79
79
  meta: {
80
80
  adapter: OrderPriceRound.key,
@@ -89,7 +89,7 @@ export const OrderPriceRound: IOrderPricingAdapter & {
89
89
  });
90
90
  if (itemsAmount) {
91
91
  pricingAdapter.resultSheet().addItems({
92
- amount: calculateDifference(itemsAmount, currency),
92
+ amount: calculateDifference(itemsAmount, currencyCode),
93
93
  taxAmount: 0,
94
94
  meta: {
95
95
  adapter: OrderPriceRound.key,
@@ -103,7 +103,7 @@ export const OrderPriceRound: IOrderPricingAdapter & {
103
103
  });
104
104
  if (paymentAmount) {
105
105
  pricingAdapter.resultSheet().addPayment({
106
- amount: calculateDifference(paymentAmount, currency),
106
+ amount: calculateDifference(paymentAmount, currencyCode),
107
107
  taxAmount: 0,
108
108
  meta: {
109
109
  adapter: OrderPriceRound.key,
@@ -115,7 +115,7 @@ export const OrderPriceRound: IOrderPricingAdapter & {
115
115
  category: OrderPricingRowCategory.Taxes,
116
116
  });
117
117
  if (taxesAmount) {
118
- const taxDifference = calculateDifference(taxesAmount, currency);
118
+ const taxDifference = calculateDifference(taxesAmount, currencyCode);
119
119
  pricingAdapter.resultSheet().calculation.push({
120
120
  category: OrderPricingRowCategory.Taxes,
121
121
  amount: taxDifference,
@@ -3,28 +3,6 @@ import {
3
3
  ProductPricingAdapter,
4
4
  IProductPricingAdapter,
5
5
  } from '@unchainedshop/core';
6
- import { resolveBestCurrency } from '@unchainedshop/utils';
7
- import pMemoize from 'p-memoize';
8
- import ExpiryMap from 'expiry-map';
9
-
10
- const { NODE_ENV } = process.env;
11
-
12
- const memoizeCache = new ExpiryMap(NODE_ENV === 'production' ? 1000 * 60 : 100); // Cached values expire after 10 seconds
13
-
14
- export const resolveCurrency = pMemoize(
15
- async (context) => {
16
- const { country, currency: forcedCurrency, modules } = context;
17
- const countryObject = await modules.countries.findCountry({ isoCode: country });
18
- const currencies = await modules.currencies.findCurrencies({ includeInactive: false });
19
- const currency =
20
- forcedCurrency || resolveBestCurrency(countryObject.defaultCurrencyCode, currencies);
21
- return currency;
22
- },
23
- {
24
- cache: memoizeCache,
25
- cacheKey: ([{ currency, country }]) => `${currency}-${country}`,
26
- },
27
- );
28
6
 
29
7
  export const ProductPrice: IProductPricingAdapter = {
30
8
  ...ProductPricingAdapter,
@@ -45,9 +23,12 @@ export const ProductPrice: IProductPricingAdapter = {
45
23
  ...pricingAdapter,
46
24
 
47
25
  calculate: async () => {
48
- const { product, country, quantity, modules } = params.context;
49
- const currency = await resolveCurrency(params.context);
50
- const price = await modules.products.prices.price(product, { country, currency, quantity });
26
+ const { product, countryCode, currencyCode, quantity, modules } = params.context;
27
+ const price = await modules.products.prices.price(product, {
28
+ countryCode,
29
+ currencyCode,
30
+ quantity,
31
+ });
51
32
  if (price) {
52
33
  const itemTotal = price.amount * quantity;
53
34
  pricingAdapter.resultSheet().addItem({