@unchainedshop/plugins 1.1.3 → 1.1.7

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 (332) hide show
  1. package/lib/delivery/pick-mup.d.ts +1 -0
  2. package/lib/delivery/pick-mup.js +98 -0
  3. package/lib/delivery/pick-mup.js.map +1 -0
  4. package/lib/delivery/post.d.ts +1 -0
  5. package/lib/delivery/post.js +23 -0
  6. package/lib/delivery/post.js.map +1 -0
  7. package/lib/delivery/send-message.d.ts +1 -0
  8. package/lib/delivery/send-message.js +41 -0
  9. package/lib/delivery/send-message.js.map +1 -0
  10. package/lib/delivery/stores.d.ts +1 -0
  11. package/lib/delivery/stores.js +39 -0
  12. package/lib/delivery/stores.js.map +1 -0
  13. package/lib/enrollments/licensed.d.ts +1 -0
  14. package/lib/enrollments/licensed.js +40 -0
  15. package/lib/enrollments/licensed.js.map +1 -0
  16. package/lib/files/gridfs/gridfs-adapter.js +1 -1
  17. package/lib/files/gridfs/gridfs-adapter.js.map +1 -1
  18. package/lib/files/gridfs/gridfs-webhook.js +2 -2
  19. package/lib/files/gridfs/gridfs-webhook.js.map +1 -1
  20. package/lib/files/minio/minio-webhook.js +1 -1
  21. package/lib/files/minio/minio-webhook.js.map +1 -1
  22. package/lib/filters/local-search.d.ts +3 -0
  23. package/lib/filters/local-search.js +84 -0
  24. package/lib/filters/local-search.js.map +1 -0
  25. package/lib/filters/strict-equal.d.ts +1 -0
  26. package/lib/filters/strict-equal.js +25 -0
  27. package/lib/filters/strict-equal.js.map +1 -0
  28. package/lib/payment/apple-iap/adapter.d.ts +1 -0
  29. package/lib/payment/apple-iap/adapter.js +284 -0
  30. package/lib/payment/apple-iap/adapter.js.map +1 -0
  31. package/lib/payment/apple-iap/db/AppleTransactionsCollection.d.ts +7 -0
  32. package/lib/payment/apple-iap/db/AppleTransactionsCollection.js +5 -0
  33. package/lib/payment/apple-iap/db/AppleTransactionsCollection.js.map +1 -0
  34. package/lib/payment/apple-iap/index.d.ts +2 -0
  35. package/lib/payment/apple-iap/index.js +3 -0
  36. package/lib/payment/apple-iap/index.js.map +1 -0
  37. package/lib/payment/apple-iap/module/configureAppleTransactionsModule.d.ts +9 -0
  38. package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js +18 -0
  39. package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js.map +1 -0
  40. package/lib/payment/bity/adapter.d.ts +1 -0
  41. package/lib/payment/bity/adapter.js +316 -0
  42. package/lib/payment/bity/adapter.js.map +1 -0
  43. package/lib/payment/bity/db/BityCredentialsCollection.d.ts +11 -0
  44. package/lib/payment/bity/db/BityCredentialsCollection.js +5 -0
  45. package/lib/payment/bity/db/BityCredentialsCollection.js.map +1 -0
  46. package/lib/payment/bity/index.d.ts +2 -0
  47. package/lib/payment/bity/index.js +3 -0
  48. package/lib/payment/bity/index.js.map +1 -0
  49. package/lib/payment/bity/module/configureBityModule.d.ts +11 -0
  50. package/lib/payment/bity/module/configureBityModule.js +33 -0
  51. package/lib/payment/bity/module/configureBityModule.js.map +1 -0
  52. package/lib/payment/braintree.d.ts +1 -0
  53. package/lib/payment/braintree.js +129 -0
  54. package/lib/payment/braintree.js.map +1 -0
  55. package/lib/payment/cryptopay.d.ts +1 -0
  56. package/lib/payment/cryptopay.js +159 -0
  57. package/lib/payment/cryptopay.js.map +1 -0
  58. package/lib/payment/datatrans-v2/api/authorize.d.ts +2 -0
  59. package/lib/payment/datatrans-v2/api/authorize.js +12 -0
  60. package/lib/payment/datatrans-v2/api/authorize.js.map +1 -0
  61. package/lib/payment/datatrans-v2/api/authorizeAuthenticated.d.ts +2 -0
  62. package/lib/payment/datatrans-v2/api/authorizeAuthenticated.js +11 -0
  63. package/lib/payment/datatrans-v2/api/authorizeAuthenticated.js.map +1 -0
  64. package/lib/payment/datatrans-v2/api/cancel.d.ts +2 -0
  65. package/lib/payment/datatrans-v2/api/cancel.js +10 -0
  66. package/lib/payment/datatrans-v2/api/cancel.js.map +1 -0
  67. package/lib/payment/datatrans-v2/api/index.d.ts +19 -0
  68. package/lib/payment/datatrans-v2/api/index.js +24 -0
  69. package/lib/payment/datatrans-v2/api/index.js.map +1 -0
  70. package/lib/payment/datatrans-v2/api/init.d.ts +2 -0
  71. package/lib/payment/datatrans-v2/api/init.js +31 -0
  72. package/lib/payment/datatrans-v2/api/init.js.map +1 -0
  73. package/lib/payment/datatrans-v2/api/makeFetcher.d.ts +2 -0
  74. package/lib/payment/datatrans-v2/api/makeFetcher.js +41 -0
  75. package/lib/payment/datatrans-v2/api/makeFetcher.js.map +1 -0
  76. package/lib/payment/datatrans-v2/api/secureFields.d.ts +2 -0
  77. package/lib/payment/datatrans-v2/api/secureFields.js +14 -0
  78. package/lib/payment/datatrans-v2/api/secureFields.js.map +1 -0
  79. package/lib/payment/datatrans-v2/api/settle.d.ts +2 -0
  80. package/lib/payment/datatrans-v2/api/settle.js +10 -0
  81. package/lib/payment/datatrans-v2/api/settle.js.map +1 -0
  82. package/lib/payment/datatrans-v2/api/status.d.ts +2 -0
  83. package/lib/payment/datatrans-v2/api/status.js +7 -0
  84. package/lib/payment/datatrans-v2/api/status.js.map +1 -0
  85. package/lib/payment/datatrans-v2/api/validate.d.ts +2 -0
  86. package/lib/payment/datatrans-v2/api/validate.js +10 -0
  87. package/lib/payment/datatrans-v2/api/validate.js.map +1 -0
  88. package/lib/payment/datatrans-v2/generateSignature.d.ts +10 -0
  89. package/lib/payment/datatrans-v2/generateSignature.js +19 -0
  90. package/lib/payment/datatrans-v2/generateSignature.js.map +1 -0
  91. package/lib/payment/datatrans-v2/getPaths.d.ts +9 -0
  92. package/lib/payment/datatrans-v2/getPaths.js +9 -0
  93. package/lib/payment/datatrans-v2/getPaths.js.map +1 -0
  94. package/lib/payment/datatrans-v2/index.d.ts +1 -0
  95. package/lib/payment/datatrans-v2/index.js +384 -0
  96. package/lib/payment/datatrans-v2/index.js.map +1 -0
  97. package/lib/payment/datatrans-v2/middleware.d.ts +1 -0
  98. package/lib/payment/datatrans-v2/middleware.js +111 -0
  99. package/lib/payment/datatrans-v2/middleware.js.map +1 -0
  100. package/lib/payment/datatrans-v2/parseRegistrationData.d.ts +11 -0
  101. package/lib/payment/datatrans-v2/parseRegistrationData.js +26 -0
  102. package/lib/payment/datatrans-v2/parseRegistrationData.js.map +1 -0
  103. package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts +7 -0
  104. package/lib/payment/datatrans-v2/roundedAmountFromOrder.js +10 -0
  105. package/lib/payment/datatrans-v2/roundedAmountFromOrder.js.map +1 -0
  106. package/lib/payment/datatrans-v2/splitProperties.d.ts +8 -0
  107. package/lib/payment/datatrans-v2/splitProperties.js +58 -0
  108. package/lib/payment/datatrans-v2/splitProperties.js.map +1 -0
  109. package/lib/payment/invoice-prepaid.d.ts +1 -0
  110. package/lib/payment/invoice-prepaid.js +30 -0
  111. package/lib/payment/invoice-prepaid.js.map +1 -0
  112. package/lib/payment/invoice.d.ts +1 -0
  113. package/lib/payment/invoice.js +27 -0
  114. package/lib/payment/invoice.js.map +1 -0
  115. package/lib/payment/paypal-checkout.d.ts +1 -0
  116. package/lib/payment/paypal-checkout.js +82 -0
  117. package/lib/payment/paypal-checkout.js.map +1 -0
  118. package/lib/payment/postfinance-checkout/api.d.ts +11 -0
  119. package/lib/payment/postfinance-checkout/api.js +109 -0
  120. package/lib/payment/postfinance-checkout/api.js.map +1 -0
  121. package/lib/payment/postfinance-checkout/index.d.ts +1 -0
  122. package/lib/payment/postfinance-checkout/index.js +186 -0
  123. package/lib/payment/postfinance-checkout/index.js.map +1 -0
  124. package/lib/payment/postfinance-checkout/middleware.d.ts +1 -0
  125. package/lib/payment/postfinance-checkout/middleware.js +42 -0
  126. package/lib/payment/postfinance-checkout/middleware.js.map +1 -0
  127. package/lib/payment/postfinance-checkout/types.d.ts +23 -0
  128. package/lib/payment/postfinance-checkout/types.js +12 -0
  129. package/lib/payment/postfinance-checkout/types.js.map +1 -0
  130. package/lib/payment/postfinance-checkout/utils.d.ts +4 -0
  131. package/lib/payment/postfinance-checkout/utils.js +20 -0
  132. package/lib/payment/postfinance-checkout/utils.js.map +1 -0
  133. package/lib/payment/stripe.d.ts +1 -0
  134. package/lib/payment/stripe.js +214 -0
  135. package/lib/payment/stripe.js.map +1 -0
  136. package/lib/payment/worldline-saferpay/index.d.ts +1 -0
  137. package/lib/payment/worldline-saferpay/index.js +112 -0
  138. package/lib/payment/worldline-saferpay/index.js.map +1 -0
  139. package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.d.ts +14 -0
  140. package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.js +29 -0
  141. package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.js.map +1 -0
  142. package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayConnection.d.ts +9 -0
  143. package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayConnection.js +28 -0
  144. package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayConnection.js.map +1 -0
  145. package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.d.ts +4 -0
  146. package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.js +2 -0
  147. package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.js.map +1 -0
  148. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentMethods.d.ts +1 -0
  149. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentMethods.js +2 -0
  150. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentMethods.js.map +1 -0
  151. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.d.ts +73 -0
  152. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.js +2 -0
  153. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.js.map +1 -0
  154. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.d.ts +53 -0
  155. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.js +2 -0
  156. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.js.map +1 -0
  157. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Request.d.ts +13 -0
  158. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Request.js +2 -0
  159. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Request.js.map +1 -0
  160. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Response.d.ts +9 -0
  161. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Response.js +2 -0
  162. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Response.js.map +1 -0
  163. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Transaction.d.ts +5 -0
  164. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Transaction.js +2 -0
  165. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Transaction.js.map +1 -0
  166. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.d.ts +13 -0
  167. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.js +2 -0
  168. package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.js.map +1 -0
  169. package/lib/pricing/delivery-swiss-tax.d.ts +15 -0
  170. package/lib/pricing/delivery-swiss-tax.js +98 -0
  171. package/lib/pricing/delivery-swiss-tax.js.map +1 -0
  172. package/lib/pricing/discount-100-off.d.ts +1 -0
  173. package/lib/pricing/discount-100-off.js +34 -0
  174. package/lib/pricing/discount-100-off.js.map +1 -0
  175. package/lib/pricing/discount-half-price-manual.d.ts +1 -0
  176. package/lib/pricing/discount-half-price-manual.js +34 -0
  177. package/lib/pricing/discount-half-price-manual.js.map +1 -0
  178. package/lib/pricing/discount-half-price.d.ts +1 -0
  179. package/lib/pricing/discount-half-price.js +37 -0
  180. package/lib/pricing/discount-half-price.js.map +1 -0
  181. package/lib/pricing/free-delivery.d.ts +2 -0
  182. package/lib/pricing/free-delivery.js +26 -0
  183. package/lib/pricing/free-delivery.js.map +1 -0
  184. package/lib/pricing/free-payment.d.ts +2 -0
  185. package/lib/pricing/free-payment.js +26 -0
  186. package/lib/pricing/free-payment.js.map +1 -0
  187. package/lib/pricing/order-delivery.d.ts +1 -0
  188. package/lib/pricing/order-delivery.js +33 -0
  189. package/lib/pricing/order-delivery.js.map +1 -0
  190. package/lib/pricing/order-discount.d.ts +1 -0
  191. package/lib/pricing/order-discount.js +110 -0
  192. package/lib/pricing/order-discount.js.map +1 -0
  193. package/lib/pricing/order-items-discount.d.ts +1 -0
  194. package/lib/pricing/order-items-discount.js +88 -0
  195. package/lib/pricing/order-items-discount.js.map +1 -0
  196. package/lib/pricing/order-items.d.ts +1 -0
  197. package/lib/pricing/order-items.js +44 -0
  198. package/lib/pricing/order-items.js.map +1 -0
  199. package/lib/pricing/order-payment.d.ts +1 -0
  200. package/lib/pricing/order-payment.js +33 -0
  201. package/lib/pricing/order-payment.js.map +1 -0
  202. package/lib/pricing/product-catalog-price.d.ts +1 -0
  203. package/lib/pricing/product-catalog-price.js +37 -0
  204. package/lib/pricing/product-catalog-price.js.map +1 -0
  205. package/lib/pricing/product-discount.d.ts +1 -0
  206. package/lib/pricing/product-discount.js +55 -0
  207. package/lib/pricing/product-discount.js.map +1 -0
  208. package/lib/pricing/product-price-ECB-interbank-exchange.d.ts +1 -0
  209. package/lib/pricing/product-price-ECB-interbank-exchange.js +90 -0
  210. package/lib/pricing/product-price-ECB-interbank-exchange.js.map +1 -0
  211. package/lib/pricing/product-price-coinbase-exchange.d.ts +1 -0
  212. package/lib/pricing/product-price-coinbase-exchange.js +60 -0
  213. package/lib/pricing/product-price-coinbase-exchange.js.map +1 -0
  214. package/lib/pricing/product-price-cryptopay.d.ts +1 -0
  215. package/lib/pricing/product-price-cryptopay.js +21 -0
  216. package/lib/pricing/product-price-cryptopay.js.map +1 -0
  217. package/lib/pricing/product-price-rateconversion.d.ts +1 -0
  218. package/lib/pricing/product-price-rateconversion.js +51 -0
  219. package/lib/pricing/product-price-rateconversion.js.map +1 -0
  220. package/lib/pricing/product-price-round.d.ts +11 -0
  221. package/lib/pricing/product-price-round.js +54 -0
  222. package/lib/pricing/product-price-round.js.map +1 -0
  223. package/lib/pricing/product-swiss-tax.d.ts +13 -0
  224. package/lib/pricing/product-swiss-tax.js +102 -0
  225. package/lib/pricing/product-swiss-tax.js.map +1 -0
  226. package/lib/pricing/utils/cache.d.ts +8 -0
  227. package/lib/pricing/utils/cache.js +28 -0
  228. package/lib/pricing/utils/cache.js.map +1 -0
  229. package/lib/quotations/manual.d.ts +1 -0
  230. package/lib/quotations/manual.js +21 -0
  231. package/lib/quotations/manual.js.map +1 -0
  232. package/lib/warehousing/google-sheets.d.ts +1 -0
  233. package/lib/warehousing/google-sheets.js +153 -0
  234. package/lib/warehousing/google-sheets.js.map +1 -0
  235. package/lib/warehousing/store.d.ts +1 -0
  236. package/lib/warehousing/store.js +33 -0
  237. package/lib/warehousing/store.js.map +1 -0
  238. package/lib/worker/BulkImportWorker.js +3 -3
  239. package/lib/worker/BulkImportWorker.js.map +1 -1
  240. package/lib/worker/GenerateOrderWorker.js +1 -1
  241. package/lib/worker/GenerateOrderWorker.js.map +1 -1
  242. package/lib/worker/ZombieKillerWorker.js.map +1 -1
  243. package/lib/worker/email.js +55 -4
  244. package/lib/worker/email.js.map +1 -1
  245. package/license +274 -0
  246. package/package.json +29 -12
  247. package/src/delivery/pick-mup.ts +119 -0
  248. package/src/delivery/post.ts +30 -0
  249. package/src/delivery/send-message.ts +54 -0
  250. package/src/delivery/stores.ts +49 -0
  251. package/src/enrollments/licensed.ts +49 -0
  252. package/src/files/gridfs/gridfs-adapter.ts +1 -1
  253. package/src/files/gridfs/gridfs-webhook.js +2 -2
  254. package/src/files/minio/minio-webhook.js +1 -1
  255. package/src/filters/local-search.ts +105 -0
  256. package/src/filters/strict-equal.ts +31 -0
  257. package/src/payment/apple-iap/adapter.ts +390 -0
  258. package/src/payment/apple-iap/db/AppleTransactionsCollection.ts +13 -0
  259. package/src/payment/apple-iap/index.ts +3 -0
  260. package/src/payment/apple-iap/module/configureAppleTransactionsModule.ts +31 -0
  261. package/src/payment/bity/adapter.ts +417 -0
  262. package/src/payment/bity/db/BityCredentialsCollection.ts +17 -0
  263. package/src/payment/bity/index.ts +3 -0
  264. package/src/payment/bity/module/configureBityModule.ts +46 -0
  265. package/src/payment/braintree.ts +147 -0
  266. package/src/payment/cryptopay.ts +195 -0
  267. package/src/payment/datatrans-v2/api/authorize.ts +17 -0
  268. package/src/payment/datatrans-v2/api/authorizeAuthenticated.ts +20 -0
  269. package/src/payment/datatrans-v2/api/cancel.ts +13 -0
  270. package/src/payment/datatrans-v2/api/index.ts +24 -0
  271. package/src/payment/datatrans-v2/api/init.ts +40 -0
  272. package/src/payment/datatrans-v2/api/makeFetcher.ts +49 -0
  273. package/src/payment/datatrans-v2/api/secureFields.ts +19 -0
  274. package/src/payment/datatrans-v2/api/settle.ts +13 -0
  275. package/src/payment/datatrans-v2/api/status.ts +8 -0
  276. package/src/payment/datatrans-v2/api/types.d.ts +378 -0
  277. package/src/payment/datatrans-v2/api/validate.ts +13 -0
  278. package/src/payment/datatrans-v2/generateSignature.ts +24 -0
  279. package/src/payment/datatrans-v2/getPaths.ts +24 -0
  280. package/src/payment/datatrans-v2/index.ts +476 -0
  281. package/src/payment/datatrans-v2/middleware.ts +147 -0
  282. package/src/payment/datatrans-v2/parseRegistrationData.ts +32 -0
  283. package/src/payment/datatrans-v2/roundedAmountFromOrder.ts +16 -0
  284. package/src/payment/datatrans-v2/splitProperties.ts +63 -0
  285. package/src/payment/invoice-prepaid.ts +40 -0
  286. package/src/payment/invoice.ts +36 -0
  287. package/src/payment/paypal-checkout.ts +107 -0
  288. package/src/payment/postfinance-checkout/api.ts +142 -0
  289. package/src/payment/postfinance-checkout/index.ts +241 -0
  290. package/src/payment/postfinance-checkout/middleware.ts +54 -0
  291. package/src/payment/postfinance-checkout/types.ts +27 -0
  292. package/src/payment/postfinance-checkout/utils.ts +35 -0
  293. package/src/payment/stripe.ts +278 -0
  294. package/src/payment/worldline-saferpay/index.ts +140 -0
  295. package/src/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.ts +54 -0
  296. package/src/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayConnection.ts +36 -0
  297. package/src/payment/worldline-saferpay/worldline-saferpay-client/index.ts +8 -0
  298. package/src/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentMethods.ts +26 -0
  299. package/src/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.ts +75 -0
  300. package/src/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.ts +55 -0
  301. package/src/payment/worldline-saferpay/worldline-saferpay-client/models/Request.ts +14 -0
  302. package/src/payment/worldline-saferpay/worldline-saferpay-client/models/Response.ts +9 -0
  303. package/src/payment/worldline-saferpay/worldline-saferpay-client/models/Transaction.ts +6 -0
  304. package/src/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.ts +15 -0
  305. package/src/pricing/delivery-swiss-tax.ts +115 -0
  306. package/src/pricing/discount-100-off.ts +44 -0
  307. package/src/pricing/discount-half-price-manual.ts +43 -0
  308. package/src/pricing/discount-half-price.ts +46 -0
  309. package/src/pricing/free-delivery.ts +31 -0
  310. package/src/pricing/free-payment.ts +32 -0
  311. package/src/pricing/order-delivery.ts +45 -0
  312. package/src/pricing/order-discount.ts +158 -0
  313. package/src/pricing/order-items-discount.ts +116 -0
  314. package/src/pricing/order-items.ts +61 -0
  315. package/src/pricing/order-payment.ts +46 -0
  316. package/src/pricing/product-catalog-price.ts +56 -0
  317. package/src/pricing/product-discount.ts +69 -0
  318. package/src/pricing/product-price-ECB-interbank-exchange.ts +108 -0
  319. package/src/pricing/product-price-coinbase-exchange.ts +82 -0
  320. package/src/pricing/product-price-cryptopay.ts +25 -0
  321. package/src/pricing/product-price-rateconversion.ts +73 -0
  322. package/src/pricing/product-price-round.ts +78 -0
  323. package/src/pricing/product-swiss-tax.ts +117 -0
  324. package/src/pricing/utils/cache.js +32 -0
  325. package/src/quotations/manual.ts +27 -0
  326. package/src/warehousing/google-sheets.ts +165 -0
  327. package/src/warehousing/store.ts +47 -0
  328. package/src/worker/BulkImportWorker.ts +3 -3
  329. package/src/worker/GenerateOrderWorker.ts +1 -1
  330. package/src/worker/ZombieKillerWorker.ts +5 -5
  331. package/src/worker/email.ts +56 -4
  332. package/lib/worker/MessageWorker.d.ts +0 -10
@@ -0,0 +1,417 @@
1
+ import { PaymentDirector, PaymentAdapter, PaymentError } from '@unchainedshop/core-payment';
2
+
3
+ import { IPaymentAdapter } from '@unchainedshop/types/payments';
4
+ import { createLogger } from '@unchainedshop/logger';
5
+
6
+ import { OrderPricingSheet } from '@unchainedshop/core-orders';
7
+ import bodyParser from 'body-parser';
8
+ import { acl, roles, useMiddlewareWithCurrentContext } from '@unchainedshop/api';
9
+ import crypto from 'crypto';
10
+ import fetch from 'isomorphic-unfetch';
11
+ import ClientOAuth2 from '@unchainedshop/client-oauth2';
12
+ import { Context } from '@unchainedshop/types/api';
13
+ import { BityModule } from './module/configureBityModule';
14
+
15
+ const logger = createLogger('unchained:core-payment:bity');
16
+
17
+ const { checkAction } = acl;
18
+ const { actions } = roles;
19
+
20
+ let currentToken;
21
+
22
+ const {
23
+ BITY_CLIENT_ID,
24
+ BITY_CLIENT_SECRET,
25
+ BITY_BANK_ACCOUNT_IBAN,
26
+ BITY_BANK_ACCOUNT_ADDRESS,
27
+ BITY_BANK_ACCOUNT_CITY,
28
+ BITY_BANK_ACCOUNT_COUNTRY,
29
+ BITY_BANK_ACCOUNT_NAME,
30
+ BITY_BANK_ACCOUNT_ZIP,
31
+ BITY_API_ENDPOINT = 'https://exchange.api.bity.com',
32
+ BITY_OAUTH_INIT_PATH = '/graphql/bity-auth',
33
+ BITY_OAUTH_REDIRECT_URI = 'http://localhost:4010/graphql/bity',
34
+ BITY_OAUTH_STATE = 'unchained',
35
+ BITY_OAUTH_PATH = '/graphql/bity',
36
+ } = process.env;
37
+
38
+ const createBityAuth = () => {
39
+ if (!BITY_CLIENT_ID) throw new Error('Bity plugin is not setup');
40
+
41
+ return new ClientOAuth2({
42
+ clientId: BITY_CLIENT_ID,
43
+ clientSecret: BITY_CLIENT_SECRET,
44
+ accessTokenUri: 'https://connect.bity.com/oauth2/token',
45
+ authorizationUri: 'https://connect.bity.com/oauth2/auth',
46
+ redirectUri: BITY_OAUTH_REDIRECT_URI,
47
+ state: BITY_OAUTH_STATE,
48
+ scopes: [
49
+ 'https://auth.bity.com/scopes/exchange.place',
50
+ 'https://auth.bity.com/scopes/exchange.history',
51
+ 'offline_access',
52
+ ],
53
+ sendClientCredentialsInBody: true,
54
+ });
55
+ };
56
+
57
+ const upsertBityCredentials = async (user, context: Context) => {
58
+ currentToken = user;
59
+
60
+ const iv = crypto.randomBytes(16);
61
+ const key = crypto
62
+ .createHash('sha256')
63
+ .update(String(BITY_CLIENT_SECRET))
64
+ .digest('base64')
65
+ .substring(0, 32);
66
+
67
+ const cipher = crypto.createCipheriv('aes-256-cbc', key, iv);
68
+ let encrypted = cipher.update(JSON.stringify(user.data));
69
+ encrypted = Buffer.concat([encrypted, cipher.final()]);
70
+
71
+ const externalId = `${BITY_CLIENT_ID}-${BITY_OAUTH_REDIRECT_URI}-${BITY_OAUTH_STATE}`;
72
+ const doc = {
73
+ externalId,
74
+ data: {
75
+ iv: iv.toString('hex'),
76
+ encryptedData: encrypted.toString('hex'),
77
+ },
78
+ expires: user.expires,
79
+ };
80
+
81
+ const bityModule = (context.modules as any).bity as BityModule;
82
+ await bityModule.upsertCredentials(doc, context.userId);
83
+ };
84
+
85
+ const getTokenFromDb = async (bityAuth, context: Context) => {
86
+ const bityModule = (context.modules as any).bity as BityModule;
87
+ const credentials = await bityModule.findBityCredentials({
88
+ externalId: `${BITY_CLIENT_ID}-${BITY_OAUTH_REDIRECT_URI}-${BITY_OAUTH_STATE}`,
89
+ });
90
+ if (!credentials?.data) return null;
91
+
92
+ const iv = Buffer.from(credentials.data.iv, 'hex');
93
+ const encryptedText = Buffer.from(credentials.data.encryptedData, 'hex');
94
+ const key = crypto
95
+ .createHash('sha256')
96
+ .update(String(BITY_CLIENT_SECRET))
97
+ .digest('base64')
98
+ .substr(0, 32);
99
+
100
+ const decipher = crypto.createDecipheriv('aes-256-cbc', key, iv);
101
+ let decrypted = decipher.update(encryptedText);
102
+ decrypted = Buffer.concat([decrypted, decipher.final()]);
103
+ const data = JSON.parse(decrypted.toString());
104
+
105
+ const token = bityAuth.createToken(data.access_token, data.refresh_token, data.token_type, { data });
106
+ return token;
107
+ };
108
+
109
+ const refreshBityUser = async (context: Context) => {
110
+ if (currentToken) {
111
+ const newToken = await currentToken.refresh();
112
+ if (newToken) {
113
+ await upsertBityCredentials(newToken, context);
114
+ }
115
+ }
116
+ };
117
+
118
+ const signPayload = (...args) => {
119
+ const resultString = args.filter(Boolean).join('');
120
+ const signKeyInBytes = Buffer.from(BITY_CLIENT_ID, 'hex');
121
+
122
+ const signedString = crypto.createHmac('sha256', signKeyInBytes).update(resultString).digest('hex');
123
+ return signedString;
124
+ };
125
+
126
+ const bityExchangeFetch = async (params: { path: string; data?: any }, context: Context) => {
127
+ const body = params.data && JSON.stringify(params.data);
128
+ const doFetch = async () => {
129
+ const response = await fetch(`${BITY_API_ENDPOINT}${params.path}`, {
130
+ method: body ? 'POST' : 'GET',
131
+ body: body || undefined,
132
+ headers: {
133
+ Authorization: `Bearer ${currentToken.accessToken}`,
134
+ 'Content-Type': 'application/json',
135
+ },
136
+ });
137
+ return response;
138
+ };
139
+ const response = await doFetch();
140
+ if (response.status === 401) {
141
+ await refreshBityUser(context);
142
+ return doFetch();
143
+ }
144
+ return response;
145
+ };
146
+
147
+ const createBityOrder = async (data: any, context: Context) => {
148
+ const response = await bityExchangeFetch(
149
+ {
150
+ path: '/v2/orders',
151
+ data,
152
+ },
153
+ context,
154
+ );
155
+
156
+ if (response?.status !== 201) {
157
+ logger.error('Bity Plugin: Response invalid', {
158
+ data,
159
+ route: '/orders',
160
+ response,
161
+ });
162
+ throw new Error('Could not create Bity Order');
163
+ }
164
+ return response.headers.get('Location');
165
+ };
166
+
167
+ // eslint-disable-next-line
168
+ const estimateBityOrder = async (data: any, context: Context) => {
169
+ const response = await bityExchangeFetch(
170
+ {
171
+ path: '/v2/orders/estimate',
172
+ data,
173
+ },
174
+ context,
175
+ );
176
+
177
+ if (response?.status !== 200) {
178
+ logger.error('Bity Plugin: Response invalid', {
179
+ data,
180
+ route: '/orders/estimate',
181
+ response,
182
+ });
183
+ throw new Error('Could not estimate Bity Currency Conversion');
184
+ }
185
+ return response.json();
186
+ };
187
+
188
+ useMiddlewareWithCurrentContext(BITY_OAUTH_INIT_PATH, async (req, res) => {
189
+ if (req.method === 'GET') {
190
+ try {
191
+ const resolvedContext = req.unchainedContext;
192
+ await checkAction(resolvedContext, actions.managePaymentProviders);
193
+
194
+ const bityAuthClient = createBityAuth();
195
+ const uri = bityAuthClient.code.getUri();
196
+ logger.info(`Bity Webhook: Login ${uri}`);
197
+ res.writeHead(302, {
198
+ Location: uri,
199
+ });
200
+ res.end();
201
+ return;
202
+ } catch (e) {
203
+ logger.warn(`Bity Webhook: Failed with ${e.message}`);
204
+ res.writeHead(503);
205
+ res.end(JSON.stringify(e));
206
+ return;
207
+ }
208
+ }
209
+ res.writeHead(404);
210
+ res.end();
211
+ });
212
+
213
+ useMiddlewareWithCurrentContext(BITY_OAUTH_PATH, async (req, res, next) => {
214
+ bodyParser.urlencoded({ extended: false })(req, res, next);
215
+ });
216
+
217
+ useMiddlewareWithCurrentContext(BITY_OAUTH_PATH, async (req, res) => {
218
+ if (req.method === 'GET') {
219
+ try {
220
+ const resolvedContext = req.unchainedContext as Context;
221
+ await checkAction(resolvedContext, actions.managePaymentProviders);
222
+ const bityAuthClient = createBityAuth();
223
+ const user = await bityAuthClient.code.getToken(req.originalUrl);
224
+ await upsertBityCredentials(user, resolvedContext);
225
+ res.writeHead(200);
226
+ res.end('Bity Credentials Setup Complete');
227
+ return;
228
+ } catch (e) {
229
+ logger.warn(`Bity Webhook: Failed with ${e.message}`);
230
+ res.writeHead(503);
231
+ res.end(JSON.stringify(e));
232
+ return;
233
+ }
234
+ }
235
+ res.writeHead(404);
236
+ res.end();
237
+ });
238
+
239
+ let bityAuthClient;
240
+ const loadToken = async (context: Context) => {
241
+ if (currentToken) return currentToken;
242
+
243
+ if (!bityAuthClient) {
244
+ bityAuthClient = createBityAuth();
245
+ }
246
+
247
+ if (bityAuthClient) {
248
+ currentToken = await getTokenFromDb(bityAuthClient, context);
249
+ }
250
+
251
+ return currentToken;
252
+ };
253
+
254
+ let token;
255
+
256
+ const Bity: IPaymentAdapter = {
257
+ ...PaymentAdapter,
258
+
259
+ key: 'shop.unchained.payment.bity',
260
+ label: 'Bity',
261
+ version: '1.0',
262
+
263
+ initialConfiguration: [],
264
+
265
+ typeSupported: (type) => {
266
+ return type === 'GENERIC';
267
+ },
268
+
269
+ actions: (params) => {
270
+ loadToken(params.context).then((t) => {
271
+ token = t;
272
+ });
273
+ const adapter = {
274
+ ...PaymentAdapter.actions(params),
275
+
276
+ configurationError: () => {
277
+ if (!token) {
278
+ return PaymentError.INCOMPLETE_CONFIGURATION;
279
+ }
280
+ return null;
281
+ },
282
+
283
+ isActive: () => {
284
+ if (adapter.configurationError() === null) return true;
285
+ return false;
286
+ },
287
+
288
+ isPayLaterAllowed() {
289
+ return false;
290
+ },
291
+
292
+ sign: async (transactionContext = {}) => {
293
+ // Signing the order will estimate a new order in bity and sign it with private data
294
+ logger.info(`Bity Plugin: Sign ${JSON.stringify(transactionContext)}`);
295
+
296
+ const { orderPayment } = params.paymentContext;
297
+
298
+ const order = await params.context.modules.orders.findOrder({
299
+ orderId: orderPayment.orderId,
300
+ });
301
+ const pricing = OrderPricingSheet({
302
+ calculation: order.calculation,
303
+ currency: order.currency,
304
+ });
305
+
306
+ if (!pricing) {
307
+ throw new Error('Price calculation of order invalid');
308
+ }
309
+
310
+ const totalAmount = Math.round(pricing.total({ useNetPrice: false }).amount / 10 || 0) * 10;
311
+
312
+ const payload = await estimateBityOrder(
313
+ {
314
+ output: {
315
+ currency: 'EUR',
316
+ amount: `${totalAmount / 100}`,
317
+ },
318
+ input: {
319
+ currency: 'BTC',
320
+ },
321
+ },
322
+ params.context,
323
+ );
324
+
325
+ const signature = signPayload(
326
+ JSON.stringify(payload),
327
+ order._id,
328
+ totalAmount,
329
+ BITY_CLIENT_SECRET,
330
+ );
331
+
332
+ return JSON.stringify({
333
+ payload,
334
+ signature,
335
+ });
336
+ },
337
+
338
+ charge: async () => {
339
+ const { order } = params.paymentContext;
340
+ const { bityPayload, bitySignature } = order?.context || {};
341
+
342
+ const pricing = OrderPricingSheet({
343
+ calculation: order.calculation,
344
+ currency: order.currency,
345
+ });
346
+
347
+ if (!pricing) {
348
+ throw new Error('Price calculation of order invalid');
349
+ }
350
+
351
+ const totalAmount =
352
+ Math.round(
353
+ pricing.total({
354
+ useNetPrice: false,
355
+ }).amount / 10 || 0,
356
+ ) * 10;
357
+
358
+ const signature = signPayload(
359
+ JSON.stringify(bityPayload),
360
+ order._id,
361
+ totalAmount,
362
+ BITY_CLIENT_SECRET,
363
+ );
364
+ if (bitySignature !== signature) {
365
+ logger.warn(`Bity Plugin: Signature Mismatch ${JSON.stringify(bityPayload)} ${bitySignature}`);
366
+ throw new Error('Signature Mismatch');
367
+ }
368
+
369
+ const path = await createBityOrder(
370
+ {
371
+ input: {
372
+ amount: bityPayload.input.amount,
373
+ currency: bityPayload.input.currency,
374
+ },
375
+ output: {
376
+ currency: bityPayload.output.currency,
377
+ type: 'bank_account',
378
+ iban: BITY_BANK_ACCOUNT_IBAN,
379
+ reference: order._id,
380
+ owner: {
381
+ address: BITY_BANK_ACCOUNT_ADDRESS,
382
+ city: BITY_BANK_ACCOUNT_CITY,
383
+ country: BITY_BANK_ACCOUNT_COUNTRY,
384
+ name: BITY_BANK_ACCOUNT_NAME,
385
+ zip: BITY_BANK_ACCOUNT_ZIP,
386
+ },
387
+ },
388
+ },
389
+ params.context,
390
+ );
391
+
392
+ logger.info(`Bity Plugin: Prepared Bity Order`, path);
393
+ const response = await bityExchangeFetch({ path }, params.context);
394
+
395
+ const bityOrder = await response?.json();
396
+ if (!bityOrder) {
397
+ logger.warn(`Bity Plugin: Bity Order not found ${JSON.stringify(path)} ${bitySignature}`);
398
+ throw new Error('Bity Order not Found');
399
+ }
400
+
401
+ await params.context.modules.orders.updateContext(
402
+ order._id,
403
+ {
404
+ bityOrder,
405
+ },
406
+ params.context,
407
+ );
408
+
409
+ return false;
410
+ },
411
+ };
412
+
413
+ return adapter;
414
+ },
415
+ };
416
+
417
+ PaymentDirector.registerAdapter(Bity);
@@ -0,0 +1,17 @@
1
+ import { Db, TimestampFields, _ID } from '@unchainedshop/types/common';
2
+
3
+ export type BityCredentialsType = {
4
+ _id?: _ID;
5
+ externalId: string;
6
+ data: {
7
+ iv: string;
8
+ encryptedData: string;
9
+ };
10
+ expires: Date;
11
+ } & TimestampFields;
12
+
13
+ export const BityCredentialsCollection = (db: Db) => {
14
+ const BityCredentials = db.collection<BityCredentialsType>('bity_credentials');
15
+
16
+ return BityCredentials;
17
+ };
@@ -0,0 +1,3 @@
1
+ import './adapter';
2
+
3
+ export { configureBityModule } from './module/configureBityModule';
@@ -0,0 +1,46 @@
1
+ import { Db } from '@unchainedshop/types/common';
2
+ import { generateDbObjectId } from '@unchainedshop/utils';
3
+ import { BityCredentialsCollection, BityCredentialsType } from '../db/BityCredentialsCollection';
4
+
5
+ export interface BityModule {
6
+ findBityCredentials: (query: { externalId: string }) => Promise<BityCredentialsType>;
7
+
8
+ upsertCredentials: (doc: BityCredentialsType, userId: string) => Promise<string | null>;
9
+ }
10
+
11
+ export const configureBityModule = ({ db }: { db: Db }): BityModule => {
12
+ const BityCredentials = BityCredentialsCollection(db);
13
+
14
+ return {
15
+ findBityCredentials: async ({ externalId }) => {
16
+ return BityCredentials.findOne({ externalId });
17
+ },
18
+
19
+ upsertCredentials: async (doc, userId) => {
20
+ await BityCredentials.updateOne(
21
+ {
22
+ externalId: doc.externalId,
23
+ },
24
+ {
25
+ $set: {
26
+ data: {
27
+ iv: doc.data.iv,
28
+ encryptedData: doc.data.encryptedData,
29
+ },
30
+ expires: doc.expires,
31
+ updated: new Date(),
32
+ updatedBy: userId,
33
+ },
34
+ $setOnInsert: {
35
+ _id: generateDbObjectId(),
36
+ externalId: doc.externalId,
37
+ created: new Date(),
38
+ createdBy: userId,
39
+ },
40
+ },
41
+ );
42
+
43
+ return doc.externalId;
44
+ },
45
+ };
46
+ };
@@ -0,0 +1,147 @@
1
+ import { IPaymentAdapter } from '@unchainedshop/types/payments';
2
+ import { PaymentDirector, PaymentAdapter, PaymentError } from '@unchainedshop/core-payment';
3
+ import { createLogger } from '@unchainedshop/logger';
4
+
5
+ const logger = createLogger('unchained:core-payment:braintree');
6
+
7
+ const { BRAINTREE_SANDBOX_TOKEN, BRAINTREE_PRIVATE_KEY } = process.env;
8
+
9
+ const BraintreeDirect: IPaymentAdapter = {
10
+ ...PaymentAdapter,
11
+
12
+ key: 'shop.unchained.braintree-direct',
13
+ label: 'Braintree Direct',
14
+ version: '1.0',
15
+
16
+ initialConfiguration: [
17
+ {
18
+ key: 'publicKey',
19
+ value: null,
20
+ },
21
+ {
22
+ key: 'merchantId',
23
+ value: null,
24
+ },
25
+ ],
26
+
27
+ typeSupported: (type) => {
28
+ return type === 'GENERIC';
29
+ },
30
+
31
+ actions: (params) => {
32
+ const getPublicKey = () => {
33
+ return params.config.reduce((current, item) => {
34
+ if (item.key === 'publicKey') return item.value;
35
+ return current;
36
+ }, null);
37
+ };
38
+
39
+ const getMerchantId = () => {
40
+ return params.config.reduce((current, item) => {
41
+ if (item.key === 'merchantId') return item.value;
42
+ return current;
43
+ }, null);
44
+ };
45
+
46
+ const getAccessToken = () => {
47
+ return BRAINTREE_SANDBOX_TOKEN;
48
+ };
49
+
50
+ // eslint-disable-next-line
51
+ const getPrivateKey = () => {
52
+ return BRAINTREE_PRIVATE_KEY;
53
+ };
54
+
55
+ const getGateway = (braintree) => {
56
+ const accessToken = getAccessToken();
57
+ if (accessToken) {
58
+ // sandbox mode!
59
+ return braintree.connect({
60
+ accessToken,
61
+ });
62
+ }
63
+ return braintree.connect({
64
+ environment: braintree.Environment.Production,
65
+ merchantId: getMerchantId(),
66
+ publicKey: getPublicKey(),
67
+ privateKey: getPrivateKey(),
68
+ });
69
+ };
70
+
71
+ const adapter = {
72
+ ...PaymentAdapter.actions(params),
73
+
74
+ configurationError: () => {
75
+ const publicCredentialsValid =
76
+ getAccessToken() || (getMerchantId() && getPublicKey() && getPrivateKey());
77
+
78
+ if (!publicCredentialsValid) {
79
+ return PaymentError.WRONG_CREDENTIALS;
80
+ }
81
+ return null;
82
+ },
83
+
84
+ isActive: () => {
85
+ if (adapter.configurationError() === null) return true;
86
+ return false;
87
+ },
88
+
89
+ isPayLaterAllowed: () => {
90
+ return false;
91
+ },
92
+
93
+ sign: async () => {
94
+ const braintree = require('braintree'); // eslint-disable-line
95
+ const gateway = getGateway(braintree);
96
+ const result = await gateway.clientToken.generate({});
97
+ if (result.success) {
98
+ return result.clientToken;
99
+ }
100
+ throw new Error('Could not retrieve the client token');
101
+ },
102
+
103
+ charge: async ({ paypalPaymentMethodNonce }) => {
104
+ const { modules } = params.context;
105
+ const { order } = params.paymentContext;
106
+ if (!paypalPaymentMethodNonce)
107
+ throw new Error('You have to provide paypalPaymentMethodNonce in paymentContext');
108
+ const braintree = require('braintree'); // eslint-disable-line
109
+ const gateway = getGateway(braintree);
110
+ const address = order.billingAddress || {};
111
+ const pricing = modules.orders.pricingSheet(order);
112
+ const rounded = Math.round(pricing.total({ useNetPrice: false }).amount / 10 || 0) * 10;
113
+ const saleRequest = {
114
+ amount: rounded / 100,
115
+ merchantAccountId: order.currency,
116
+ paymentMethodNonce: paypalPaymentMethodNonce,
117
+ orderId: order.orderNumber || order._id,
118
+ shipping: {
119
+ firstName: address.firstName,
120
+ lastName: address.lastName,
121
+ company: address.company,
122
+ streetAddress: address.addressLine,
123
+ extendedAddress: address.addressLine2,
124
+ locality: address.city,
125
+ region: address.regionCode,
126
+ postalCode: address.postalCode,
127
+ countryCodeAlpha2: address.countryCode,
128
+ },
129
+ options: {
130
+ submitForSettlement: true,
131
+ },
132
+ };
133
+ const result = await gateway.transaction.sale(saleRequest);
134
+ if (result.success) {
135
+ logger.info(`Braintree Plugin: ${result.message}`, saleRequest);
136
+ return result;
137
+ }
138
+ logger.warn(`Braintree Plugin: ${result.message}`, saleRequest);
139
+ throw new Error(result.message);
140
+ },
141
+ };
142
+
143
+ return adapter;
144
+ },
145
+ };
146
+
147
+ PaymentDirector.registerAdapter(BraintreeDirect);