@unchainedshop/plugins 3.0.0-alpha2 → 3.0.0-alpha4

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 (217) hide show
  1. package/lib/delivery/pick-mup.js +1 -1
  2. package/lib/delivery/pick-mup.js.map +1 -1
  3. package/lib/files/gridfs/gridfs-webhook.d.ts +1 -1
  4. package/lib/files/gridfs/gridfs-webhook.d.ts.map +1 -1
  5. package/lib/filters/local-search.d.ts +1 -1
  6. package/lib/filters/local-search.d.ts.map +1 -1
  7. package/lib/filters/local-search.js.map +1 -1
  8. package/lib/payment/apple-iap/db/AppleTransactionsCollection.d.ts +1 -1
  9. package/lib/payment/apple-iap/db/AppleTransactionsCollection.d.ts.map +1 -1
  10. package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts +1 -1
  11. package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts.map +1 -1
  12. package/lib/payment/cryptopay/plugin.d.ts +1 -1
  13. package/lib/payment/cryptopay/plugin.d.ts.map +1 -1
  14. package/lib/payment/datatrans-v2/index.js +2 -2
  15. package/lib/payment/datatrans-v2/index.js.map +1 -1
  16. package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts +2 -2
  17. package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts.map +1 -1
  18. package/lib/payment/paypal-checkout.js +7 -1
  19. package/lib/payment/paypal-checkout.js.map +1 -1
  20. package/lib/payment/postfinance-checkout/api.js +3 -3
  21. package/lib/payment/postfinance-checkout/api.js.map +1 -1
  22. package/lib/payment/postfinance-checkout/utils.d.ts +1 -1
  23. package/lib/payment/postfinance-checkout/utils.d.ts.map +1 -1
  24. package/lib/payment/saferpay/adapter.d.ts +1 -1
  25. package/lib/payment/saferpay/adapter.d.ts.map +1 -1
  26. package/lib/payment/saferpay/api/api/SaferpayClient.d.ts +1 -1
  27. package/lib/payment/saferpay/api/api/SaferpayClient.d.ts.map +1 -1
  28. package/lib/payment/saferpay/db/SaferpayTransactionsCollection.d.ts +1 -1
  29. package/lib/payment/saferpay/db/SaferpayTransactionsCollection.d.ts.map +1 -1
  30. package/lib/payment/stripe/middleware.d.ts.map +1 -1
  31. package/lib/payment/stripe/middleware.js +0 -3
  32. package/lib/payment/stripe/middleware.js.map +1 -1
  33. package/lib/payment/stripe/stripe.d.ts +3 -3
  34. package/lib/payment/stripe/stripe.d.ts.map +1 -1
  35. package/lib/payment/stripe/stripe.js +4 -4
  36. package/lib/payment/stripe/stripe.js.map +1 -1
  37. package/lib/plugins-index.d.ts +3 -31
  38. package/lib/plugins-index.d.ts.map +1 -1
  39. package/lib/plugins-index.js +10 -61
  40. package/lib/plugins-index.js.map +1 -1
  41. package/lib/presets/base-express.d.ts +3 -0
  42. package/lib/presets/base-express.d.ts.map +1 -0
  43. package/lib/presets/base-express.js +6 -0
  44. package/lib/presets/base-express.js.map +1 -0
  45. package/lib/presets/base-modules.d.ts +29 -0
  46. package/lib/presets/base-modules.d.ts.map +1 -0
  47. package/lib/presets/base-modules.js +40 -0
  48. package/lib/presets/base-modules.js.map +1 -0
  49. package/lib/presets/countries/ch.d.ts +4 -0
  50. package/lib/presets/countries/ch.d.ts.map +1 -0
  51. package/lib/presets/countries/ch.js +4 -0
  52. package/lib/presets/countries/ch.js.map +1 -0
  53. package/lib/presets/crypto-express.d.ts +4 -0
  54. package/lib/presets/crypto-express.d.ts.map +1 -0
  55. package/lib/presets/crypto-express.js +9 -0
  56. package/lib/presets/crypto-express.js.map +1 -0
  57. package/lib/presets/crypto-modules.d.ts +11 -0
  58. package/lib/presets/crypto-modules.d.ts.map +1 -0
  59. package/lib/presets/crypto-modules.js +14 -0
  60. package/lib/presets/crypto-modules.js.map +1 -0
  61. package/lib/pricing/delivery-swiss-tax.d.ts +1 -1
  62. package/lib/pricing/delivery-swiss-tax.d.ts.map +1 -1
  63. package/lib/pricing/delivery-swiss-tax.js +1 -1
  64. package/lib/pricing/delivery-swiss-tax.js.map +1 -1
  65. package/lib/pricing/discount-100-off.d.ts +1 -1
  66. package/lib/pricing/discount-100-off.d.ts.map +1 -1
  67. package/lib/pricing/discount-half-price-manual.d.ts +1 -1
  68. package/lib/pricing/discount-half-price-manual.d.ts.map +1 -1
  69. package/lib/pricing/discount-half-price.d.ts +1 -1
  70. package/lib/pricing/discount-half-price.d.ts.map +1 -1
  71. package/lib/pricing/free-delivery.d.ts +1 -1
  72. package/lib/pricing/free-delivery.d.ts.map +1 -1
  73. package/lib/pricing/free-delivery.js +1 -1
  74. package/lib/pricing/free-delivery.js.map +1 -1
  75. package/lib/pricing/free-payment.d.ts +1 -1
  76. package/lib/pricing/free-payment.d.ts.map +1 -1
  77. package/lib/pricing/free-payment.js +1 -1
  78. package/lib/pricing/free-payment.js.map +1 -1
  79. package/lib/pricing/order-delivery.d.ts +1 -1
  80. package/lib/pricing/order-delivery.d.ts.map +1 -1
  81. package/lib/pricing/order-discount.d.ts +1 -1
  82. package/lib/pricing/order-discount.d.ts.map +1 -1
  83. package/lib/pricing/order-discount.js +1 -1
  84. package/lib/pricing/order-discount.js.map +1 -1
  85. package/lib/pricing/order-items-discount.js +1 -1
  86. package/lib/pricing/order-items-discount.js.map +1 -1
  87. package/lib/pricing/order-round.d.ts +1 -1
  88. package/lib/pricing/order-round.d.ts.map +1 -1
  89. package/lib/pricing/order-round.js +1 -1
  90. package/lib/pricing/order-round.js.map +1 -1
  91. package/lib/pricing/product-catalog-price.d.ts +1 -1
  92. package/lib/pricing/product-catalog-price.d.ts.map +1 -1
  93. package/lib/pricing/product-discount.js +1 -1
  94. package/lib/pricing/product-discount.js.map +1 -1
  95. package/lib/pricing/product-price-rateconversion.d.ts +1 -1
  96. package/lib/pricing/product-price-rateconversion.d.ts.map +1 -1
  97. package/lib/pricing/product-round.d.ts +1 -1
  98. package/lib/pricing/product-round.d.ts.map +1 -1
  99. package/lib/pricing/product-swiss-tax.d.ts +4 -12
  100. package/lib/pricing/product-swiss-tax.d.ts.map +1 -1
  101. package/lib/pricing/product-swiss-tax.js +3 -3
  102. package/lib/pricing/product-swiss-tax.js.map +1 -1
  103. package/lib/warehousing/eth-minter.js +4 -3
  104. package/lib/warehousing/eth-minter.js.map +1 -1
  105. package/lib/worker/bulk-import.d.ts +1 -1
  106. package/lib/worker/bulk-import.d.ts.map +1 -1
  107. package/lib/worker/bulk-import.js.map +1 -1
  108. package/lib/worker/error-notifications.d.ts +1 -1
  109. package/lib/worker/error-notifications.d.ts.map +1 -1
  110. package/lib/worker/error-notifications.js +1 -1
  111. package/lib/worker/error-notifications.js.map +1 -1
  112. package/lib/worker/export-token.d.ts +2 -2
  113. package/lib/worker/export-token.d.ts.map +1 -1
  114. package/lib/worker/export-token.js +1 -1
  115. package/lib/worker/export-token.js.map +1 -1
  116. package/lib/worker/external.d.ts +1 -1
  117. package/lib/worker/external.d.ts.map +1 -1
  118. package/lib/worker/http-request.d.ts +1 -1
  119. package/lib/worker/http-request.d.ts.map +1 -1
  120. package/lib/worker/message.d.ts +1 -1
  121. package/lib/worker/message.d.ts.map +1 -1
  122. package/lib/worker/message.js.map +1 -1
  123. package/lib/worker/update-coinbase-rates.js +1 -1
  124. package/lib/worker/update-coinbase-rates.js.map +1 -1
  125. package/lib/worker/update-ecb-rates.js +1 -1
  126. package/lib/worker/update-ecb-rates.js.map +1 -1
  127. package/lib/worker/update-token-ownership.d.ts +1 -1
  128. package/lib/worker/update-token-ownership.d.ts.map +1 -1
  129. package/lib/worker/zombie-killer.d.ts +1 -1
  130. package/lib/worker/zombie-killer.d.ts.map +1 -1
  131. package/package.json +28 -26
  132. package/src/delivery/pick-mup.ts +1 -1
  133. package/src/delivery/post.ts +1 -1
  134. package/src/delivery/send-message.ts +1 -1
  135. package/src/delivery/stores.ts +1 -1
  136. package/src/enrollments/licensed.ts +1 -1
  137. package/src/files/gridfs/gridfs-adapter.ts +1 -1
  138. package/src/files/gridfs/gridfs-webhook.ts +1 -1
  139. package/src/files/minio/minio-adapter.ts +1 -1
  140. package/src/filters/local-search.ts +4 -4
  141. package/src/filters/strict-equal.ts +1 -1
  142. package/src/payment/apple-iap/adapter.ts +3 -3
  143. package/src/payment/apple-iap/db/AppleTransactionsCollection.ts +1 -1
  144. package/src/payment/braintree.ts +1 -1
  145. package/src/payment/cryptopay/db/CryptopayTransactions.ts +1 -1
  146. package/src/payment/cryptopay/middleware.ts +3 -3
  147. package/src/payment/cryptopay/plugin.ts +2 -2
  148. package/src/payment/datatrans-v2/index.ts +3 -3
  149. package/src/payment/datatrans-v2/middleware.ts +1 -1
  150. package/src/payment/datatrans-v2/roundedAmountFromOrder.ts +2 -2
  151. package/src/payment/invoice-prepaid.ts +1 -1
  152. package/src/payment/invoice.ts +1 -1
  153. package/src/payment/paypal-checkout.ts +8 -2
  154. package/src/payment/payrexx/index.ts +1 -1
  155. package/src/payment/payrexx/middleware.ts +1 -1
  156. package/src/payment/postfinance-checkout/api.ts +3 -3
  157. package/src/payment/postfinance-checkout/index.ts +1 -1
  158. package/src/payment/postfinance-checkout/middleware.ts +1 -1
  159. package/src/payment/postfinance-checkout/utils.ts +1 -1
  160. package/src/payment/saferpay/adapter.ts +2 -2
  161. package/src/payment/saferpay/api/api/SaferpayClient.ts +1 -1
  162. package/src/payment/saferpay/db/SaferpayTransactionsCollection.ts +1 -1
  163. package/src/payment/saferpay/middleware.ts +1 -1
  164. package/src/payment/stripe/index.ts +1 -1
  165. package/src/payment/stripe/middleware.ts +1 -4
  166. package/src/payment/stripe/stripe.ts +7 -7
  167. package/src/plugins-index.ts +14 -70
  168. package/src/presets/base-express.ts +7 -0
  169. package/src/presets/base-modules.ts +56 -0
  170. package/src/presets/countries/ch.ts +3 -0
  171. package/src/presets/crypto-express.ts +12 -0
  172. package/src/presets/crypto-modules.ts +23 -0
  173. package/src/pricing/delivery-swiss-tax.ts +3 -6
  174. package/src/pricing/discount-100-off.test.ts +13 -7
  175. package/src/pricing/discount-100-off.ts +1 -1
  176. package/src/pricing/discount-half-price-manual.test.ts +13 -7
  177. package/src/pricing/discount-half-price-manual.ts +1 -1
  178. package/src/pricing/discount-half-price.test.ts +15 -7
  179. package/src/pricing/discount-half-price.ts +1 -1
  180. package/src/pricing/free-delivery.test.ts +3 -8
  181. package/src/pricing/free-delivery.ts +5 -2
  182. package/src/pricing/free-payment.ts +5 -2
  183. package/src/pricing/licenced-enrollment.test.ts +33 -34
  184. package/src/pricing/order-delivery.test.ts +3 -5
  185. package/src/pricing/order-delivery.ts +1 -1
  186. package/src/pricing/order-discount.test.ts +3 -3
  187. package/src/pricing/order-discount.ts +1 -1
  188. package/src/pricing/order-items-discount.ts +1 -1
  189. package/src/pricing/order-items.ts +1 -1
  190. package/src/pricing/order-payment.ts +1 -1
  191. package/src/pricing/order-round.ts +1 -1
  192. package/src/pricing/plugins-index.test.ts +1 -1
  193. package/src/pricing/product-catalog-price.ts +1 -1
  194. package/src/pricing/product-discount.ts +2 -5
  195. package/src/pricing/product-price-rateconversion.ts +1 -1
  196. package/src/pricing/product-round.ts +1 -1
  197. package/src/pricing/product-swiss-tax.test.ts +112 -86
  198. package/src/pricing/product-swiss-tax.ts +11 -8
  199. package/src/pricing/tax/ch.test.ts +16 -16
  200. package/src/quotations/manual.ts +1 -1
  201. package/src/warehousing/eth-minter.ts +8 -6
  202. package/src/warehousing/store.ts +1 -1
  203. package/src/worker/bulk-import.ts +2 -2
  204. package/src/worker/email.ts +1 -1
  205. package/src/worker/enrollment-order-generator.ts +5 -5
  206. package/src/worker/error-notifications.ts +1 -1
  207. package/src/worker/export-token.ts +8 -3
  208. package/src/worker/external.ts +1 -1
  209. package/src/worker/heartbeat.ts +1 -1
  210. package/src/worker/http-request.ts +1 -1
  211. package/src/worker/message.ts +1 -2
  212. package/src/worker/push-notification.ts +1 -1
  213. package/src/worker/sms.ts +1 -1
  214. package/src/worker/update-coinbase-rates.ts +3 -3
  215. package/src/worker/update-ecb-rates.ts +3 -3
  216. package/src/worker/update-token-ownership.ts +1 -1
  217. package/src/worker/zombie-killer.ts +1 -1
@@ -1,11 +1,11 @@
1
- import { IPaymentAdapter } from '@unchainedshop/types/payments.js';
1
+ import { IPaymentAdapter } from '@unchainedshop/core-payment';
2
2
  import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
3
3
  import { ethers } from 'ethers';
4
4
  import { BIP32Factory } from 'bip32';
5
5
  import * as ecc from 'tiny-secp256k1';
6
6
  import { networks, payments } from 'bitcoinjs-lib';
7
7
  import { createLogger } from '@unchainedshop/logger';
8
- import { UnchainedCore } from '@unchainedshop/types/core.js';
8
+ import { UnchainedCore } from '@unchainedshop/core';
9
9
  import { OrderPricingSheet } from '@unchainedshop/core-orders';
10
10
  import { CryptopayModule } from './module/configureCryptopayModule.js';
11
11
 
@@ -1,7 +1,7 @@
1
- import { IPaymentAdapter } from '@unchainedshop/types/payments.js';
1
+ import { IPaymentAdapter } from '@unchainedshop/core-payment';
2
2
  import { PaymentAdapter, PaymentError, PaymentDirector } from '@unchainedshop/core-payment';
3
3
  import { createLogger } from '@unchainedshop/logger';
4
- import { PaymentPricingRowCategory } from '@unchainedshop/types/payments.pricing.js';
4
+ import { PaymentPricingRowCategory } from '@unchainedshop/core-payment';
5
5
  import createDatatransAPI from './api/index.js';
6
6
  import type {
7
7
  AuthorizeAuthenticatedResponseSuccess,
@@ -446,7 +446,7 @@ const Datatrans: IPaymentAdapter = {
446
446
  } else {
447
447
  settledTransaction = result as StatusResponseSuccess;
448
448
  }
449
- } catch (e) {
449
+ } catch {
450
450
  await cancel({ transactionId, refno: settledTransaction.refno });
451
451
  logger.error(
452
452
  `Transaction declined / Transaction ID ${transactionId} authorization cancelled`,
@@ -1,5 +1,5 @@
1
1
  import { createLogger } from '@unchainedshop/logger';
2
- import { Context } from '@unchainedshop/types/api.js';
2
+ import { Context } from '@unchainedshop/api';
3
3
  import generateSignature, { Security } from './generateSignature.js';
4
4
 
5
5
  import type { StatusResponseSuccess } from './api/types.js';
@@ -1,5 +1,5 @@
1
- import { UnchainedCore } from '@unchainedshop/types/core.js';
2
- import { Order } from '@unchainedshop/types/orders.js';
1
+ import { UnchainedCore } from '@unchainedshop/core';
2
+ import { Order } from '@unchainedshop/core-orders';
3
3
 
4
4
  const roundedAmountFromOrder = (
5
5
  order: Order,
@@ -1,4 +1,4 @@
1
- import { IPaymentAdapter } from '@unchainedshop/types/payments.js';
1
+ import { IPaymentAdapter } from '@unchainedshop/core-payment';
2
2
  import { PaymentDirector, PaymentAdapter, PaymentProviderType } from '@unchainedshop/core-payment';
3
3
 
4
4
  const InvoicePrepaid: IPaymentAdapter = {
@@ -1,4 +1,4 @@
1
- import { IPaymentAdapter } from '@unchainedshop/types/payments.js';
1
+ import { IPaymentAdapter } from '@unchainedshop/core-payment';
2
2
  import { PaymentDirector, PaymentAdapter, PaymentProviderType } from '@unchainedshop/core-payment';
3
3
 
4
4
  const Invoice: IPaymentAdapter = {
@@ -1,7 +1,13 @@
1
- import { IPaymentAdapter } from '@unchainedshop/types/payments.js';
1
+ import { IPaymentAdapter } from '@unchainedshop/core-payment';
2
2
  import { PaymentDirector, PaymentAdapter, PaymentError } from '@unchainedshop/core-payment';
3
3
  import { createLogger } from '@unchainedshop/logger';
4
- import checkoutNodeJssdk from '@paypal/checkout-server-sdk';
4
+
5
+ let checkoutNodeJssdk;
6
+ try {
7
+ checkoutNodeJssdk = await import('@paypal/checkout-server-sdk');
8
+ } catch {
9
+ /* */
10
+ }
5
11
 
6
12
  const logger = createLogger('unchained:core-payment');
7
13
 
@@ -1,4 +1,4 @@
1
- import { IPaymentAdapter } from '@unchainedshop/types/payments.js';
1
+ import { IPaymentAdapter } from '@unchainedshop/core-payment';
2
2
  import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
3
3
  import { createLogger } from '@unchainedshop/logger';
4
4
  import { mapOrderDataToGatewayObject, mapUserToGatewayObject } from './payrexx.js';
@@ -1,4 +1,4 @@
1
- import { Context } from '@unchainedshop/types/api.js';
1
+ import { Context } from '@unchainedshop/api';
2
2
  import { createLogger } from '@unchainedshop/logger';
3
3
 
4
4
  const logger = createLogger('unchained:core-payment:payrexx:webhook');
@@ -87,7 +87,7 @@ export const voidTransaction = async (transactionId: string): Promise<boolean> =
87
87
  try {
88
88
  await transactionVoidService.voidOnline(SPACE_ID, parseInt(transactionId, 10));
89
89
  return true;
90
- } catch (e) {
90
+ } catch {
91
91
  return false;
92
92
  }
93
93
  };
@@ -107,7 +107,7 @@ export const refundTransaction = async (
107
107
  try {
108
108
  await refundService.refund(SPACE_ID, refund);
109
109
  return true;
110
- } catch (e) {
110
+ } catch {
111
111
  return false;
112
112
  }
113
113
  };
@@ -117,7 +117,7 @@ export const confirmDeferredTransaction = async (transactionId: string): Promise
117
117
  try {
118
118
  await transactionCompletionService.completeOnline(SPACE_ID, parseInt(transactionId, 10));
119
119
  return true;
120
- } catch (e) {
120
+ } catch {
121
121
  return false;
122
122
  }
123
123
  };
@@ -2,7 +2,7 @@ import {
2
2
  IPaymentActions,
3
3
  IPaymentAdapter,
4
4
  PaymentChargeActionResult,
5
- } from '@unchainedshop/types/payments.js';
5
+ } from '@unchainedshop/core-payment';
6
6
  import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
7
7
  import { createLogger } from '@unchainedshop/logger';
8
8
 
@@ -1,4 +1,4 @@
1
- import { Context } from '@unchainedshop/types/api.js';
1
+ import { Context } from '@unchainedshop/api';
2
2
  import { createLogger } from '@unchainedshop/logger';
3
3
  import { WebhookData } from './types.js';
4
4
  import { getTransaction, getTransactionCompletion } from './api.js';
@@ -1,4 +1,4 @@
1
- import { Order, OrdersModule } from '@unchainedshop/types/orders.js';
1
+ import { Order, OrdersModule } from '@unchainedshop/core-orders';
2
2
  import * as pf from 'postfinancecheckout';
3
3
 
4
4
  const { PostFinanceCheckout } = pf;
@@ -1,6 +1,6 @@
1
- import { IPaymentAdapter } from '@unchainedshop/types/payments.js';
1
+ import { IPaymentAdapter } from '@unchainedshop/core-payment';
2
2
  import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
3
- import { UnchainedCore } from '@unchainedshop/types/core.js';
3
+ import { UnchainedCore } from '@unchainedshop/core';
4
4
  import { mongodb } from '@unchainedshop/mongodb';
5
5
  import { PaymentPageInitializeInput, SaferpayClient } from './api/index.js';
6
6
  import { buildSignature } from './buildSignature.js';
@@ -1,4 +1,4 @@
1
- import { OrderPayment } from '@unchainedshop/types/orders.payments.js';
1
+ import { OrderPayment } from '@unchainedshop/core-orders';
2
2
  import { TransactionCancelInput, TransactionCancelResponse } from '../models/TransactionCancel.js';
3
3
  import { TransactionCaptureInput, TransactionCaptureResponse } from '../models/TransactionCapture.js';
4
4
  import { PaymentPageAssertInput, PaymentPageAssertResponse } from '../models/PaymentPageAssert.js';
@@ -1,5 +1,5 @@
1
1
  import { mongodb } from '@unchainedshop/mongodb';
2
- import { TimestampFields } from '@unchainedshop/types/common.js';
2
+ import type { TimestampFields } from '@unchainedshop/mongodb';
3
3
 
4
4
  export type SaferpayTransaction = {
5
5
  orderPaymentId: any;
@@ -1,4 +1,4 @@
1
- import { Context } from '@unchainedshop/types/api.js';
1
+ import { Context } from '@unchainedshop/api';
2
2
  import { createLogger } from '@unchainedshop/logger';
3
3
  import { buildSignature } from './buildSignature.js';
4
4
  import { SaferpayTransactionsModule } from './module/configureSaferpayTransactionsModule.js';
@@ -1,4 +1,4 @@
1
- import { IPaymentAdapter } from '@unchainedshop/types/payments.js';
1
+ import { IPaymentAdapter } from '@unchainedshop/core-payment';
2
2
  import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
3
3
  import { createLogger } from '@unchainedshop/logger';
4
4
  import stripe, { createOrderPaymentIntent, createRegistrationIntent } from './stripe.js';
@@ -1,4 +1,4 @@
1
- import { Context } from '@unchainedshop/types/api.js';
1
+ import { Context } from '@unchainedshop/api';
2
2
  import { createLogger } from '@unchainedshop/logger';
3
3
  import stripe from './stripe.js';
4
4
 
@@ -80,9 +80,6 @@ export const stripeHandler = async (request, response) => {
80
80
  const order = await modules.orders.checkout(
81
81
  orderPayment.orderId,
82
82
  {
83
- transactionContext: {
84
- paymentIntentId: paymentIntent.id,
85
- },
86
83
  paymentContext: {
87
84
  paymentIntentId: paymentIntent.id,
88
85
  },
@@ -1,12 +1,12 @@
1
- import { Order } from '@unchainedshop/types/orders.js';
2
- import { OrderPayment } from '@unchainedshop/types/orders.payments.js';
3
- import { IOrderPricingSheet } from '@unchainedshop/types/orders.pricing.js';
1
+ import { Order } from '@unchainedshop/core-orders';
2
+ import { OrderPayment } from '@unchainedshop/core-orders';
3
+ import { IOrderPricingSheet } from '@unchainedshop/core-orders';
4
4
  import Stripe from 'stripe';
5
5
 
6
6
  const { STRIPE_SECRET, STRIPE_WEBHOOK_ENVIRONMENT, EMAIL_WEBSITE_NAME } = process.env;
7
7
 
8
8
  const stripe = new Stripe(STRIPE_SECRET, {
9
- apiVersion: '2024-04-10',
9
+ apiVersion: '2024-06-20',
10
10
  });
11
11
 
12
12
  const environment = STRIPE_WEBHOOK_ENVIRONMENT ?? null;
@@ -35,7 +35,7 @@ export const upsertCustomer = async ({ userId, name, email }): Promise<string> =
35
35
  }
36
36
 
37
37
  return existingCustomer.id;
38
- } catch (e) {
38
+ } catch {
39
39
  const customer = await stripe.customers.create({
40
40
  metadata: {
41
41
  userId,
@@ -65,7 +65,7 @@ export const createRegistrationIntent = async (
65
65
  options: Record<string, any> = {},
66
66
  ) => {
67
67
  const customer = options?.customer || (await upsertCustomer({ userId, name, email }));
68
- const description = `${descriptorPrefix || EMAIL_WEBSITE_NAME || 'Unchained'} ${userId}${email ? ` (#${email})` : ''}`;
68
+ const description = `${descriptorPrefix || EMAIL_WEBSITE_NAME || 'Unchained'}`.trim();
69
69
 
70
70
  const setupIntent = await stripe.setupIntents.create({
71
71
  description,
@@ -101,7 +101,7 @@ export const createOrderPaymentIntent = async (
101
101
  },
102
102
  options: Record<string, any> = {},
103
103
  ) => {
104
- const description = `${descriptorPrefix || EMAIL_WEBSITE_NAME || 'Unchained'} ${order._id}${order.orderNumber ? ` (#${order.orderNumber})` : ''}`;
104
+ const description = `${descriptorPrefix || EMAIL_WEBSITE_NAME || 'Unchained'}`.trim();
105
105
  const customer = options?.customer || (await upsertCustomer({ userId, name, email }));
106
106
  const { currency, amount } = pricing.total({ useNetPrice: false });
107
107
 
@@ -1,116 +1,69 @@
1
- import { ModuleInput, UnchainedCore } from '@unchainedshop/types/core.js';
2
1
  import express from 'express';
2
+ import { UnchainedCore } from '@unchainedshop/core';
3
+ import { ModuleInput } from '@unchainedshop/mongodb';
4
+
5
+ import baseModules from './presets/base-modules.js';
6
+ import './presets/countries/ch.js';
7
+ import cryptoModules from './presets/crypto-modules.js';
8
+
9
+ import connectCryptoToExpress from './presets/crypto-express.js';
10
+ import connectBaseToExpress from './presets/base-express.js';
3
11
 
4
12
  // Delivery
5
- import './delivery/post.js';
6
- import './delivery/pick-mup.js';
7
13
  import './delivery/send-message.js';
8
14
  import './delivery/stores.js';
9
15
 
10
16
  // Payment
11
- import './payment/invoice.js';
12
17
  import './payment/invoice-prepaid.js';
13
18
  import './payment/paypal-checkout.js';
14
19
  import { datatransHandler } from './payment/datatrans-v2/index.js';
15
- import { configureCryptopayModule, cryptopayHandler } from './payment/cryptopay/index.js';
16
20
  import { appleIAPHandler, configureAppleTransactionsModule } from './payment/apple-iap/index.js';
17
21
  import { stripeHandler } from './payment/stripe/index.js';
18
22
  import { postfinanceCheckoutHandler } from './payment/postfinance-checkout/index.js';
19
23
  import { configureSaferpayTransactionsModule, saferpayHandler } from './payment/saferpay/index.js';
20
24
  import { payrexxHandler } from './payment/payrexx/index.js';
21
25
 
22
- // Warehousing
23
- import './warehousing/store.js';
24
- import './warehousing/eth-minter.js';
25
-
26
- // Pricing
27
- import './pricing/free-payment.js';
28
- import './pricing/free-delivery.js';
29
- import './pricing/order-items.js';
30
- import './pricing/order-discount.js';
31
- import './pricing/order-delivery.js';
32
- import './pricing/order-payment.js';
33
- import './pricing/product-catalog-price.js';
34
- import './pricing/product-price-rateconversion.js';
35
- import './pricing/product-discount.js';
36
- import './pricing/product-swiss-tax.js';
37
- import './pricing/delivery-swiss-tax.js';
38
-
39
26
  // Filter & Search
40
27
  import './filters/strict-equal.js';
41
28
  import './filters/local-search.js';
42
29
 
43
- // Quotations
44
- import './quotations/manual.js';
45
-
46
- // Enrollments
47
- import './enrollments/licensed.js';
48
-
49
- // Event Queue
50
- import './events/node-event-emitter.js';
51
-
52
30
  // Workers
53
- import './worker/bulk-import.js';
54
- import './worker/zombie-killer.js';
55
- import './worker/message.js';
56
- import './worker/external.js';
57
- import './worker/http-request.js';
58
- import './worker/heartbeat.js';
59
- import './worker/email.js';
60
31
  import './worker/sms.js';
61
32
  import './worker/push-notification.js';
62
- import './worker/update-ecb-rates.js';
63
- import './worker/error-notifications.js';
64
- import './worker/update-coinbase-rates.js';
65
- import { configureExportToken } from './worker/export-token.js';
66
33
  import { configureGenerateOrderAutoscheduling } from './worker/enrollment-order-generator.js';
67
34
 
68
- // Asset Management
69
- import './files/gridfs/gridfs-adapter.js';
70
- import { gridfsHandler } from './files/gridfs/gridfs-webhook.js';
71
- import { configureGridFSFileUploadModule } from './files/gridfs/index.js';
72
-
73
35
  const {
74
- CRYPTOPAY_WEBHOOK_PATH = '/payment/cryptopay',
75
36
  STRIPE_WEBHOOK_PATH = '/payment/stripe',
76
37
  PAYREXX_WEBHOOK_PATH = '/payment/payrexx',
77
38
  PFCHECKOUT_WEBHOOK_PATH = '/payment/postfinance-checkout',
78
39
  DATATRANS_WEBHOOK_PATH = '/payment/datatrans/webhook',
79
40
  APPLE_IAP_WEBHOOK_PATH = '/payment/apple-iap',
80
- // MINIO_PUT_SERVER_PATH = '/minio',
81
- GRIDFS_PUT_SERVER_PATH = '/gridfs',
82
41
  SAFERPAY_WEBHOOK_PATH = '/payment/saferpay/webhook',
83
42
  } = process.env;
84
43
 
85
- // import './files/minio/minio-adapter';
86
- // import { minioHandler } from './files/minio/minio-webhook';
87
-
88
44
  export const defaultModules: Record<
89
45
  string,
90
46
  {
91
47
  configure: (params: ModuleInput<any>) => any;
92
48
  }
93
49
  > = {
50
+ ...baseModules,
51
+ ...cryptoModules,
94
52
  appleTransactions: {
95
53
  configure: configureAppleTransactionsModule,
96
54
  },
97
55
  saferpayTransactions: {
98
56
  configure: configureSaferpayTransactionsModule,
99
57
  },
100
- gridfsFileUploads: {
101
- configure: configureGridFSFileUploadModule,
102
- },
103
- cryptopay: {
104
- configure: configureCryptopayModule,
105
- },
106
58
  };
107
59
 
108
60
  export const connectDefaultPluginsToExpress4 = (
109
61
  app,
110
62
  { unchainedAPI }: { unchainedAPI: UnchainedCore },
111
63
  ) => {
112
- app.use(GRIDFS_PUT_SERVER_PATH, gridfsHandler);
113
- app.use(CRYPTOPAY_WEBHOOK_PATH, express.json(), cryptopayHandler);
64
+ connectBaseToExpress(app);
65
+ connectCryptoToExpress(app, unchainedAPI);
66
+
114
67
  app.use(STRIPE_WEBHOOK_PATH, express.raw({ type: 'application/json' }), stripeHandler);
115
68
  app.use(PFCHECKOUT_WEBHOOK_PATH, express.json(), postfinanceCheckoutHandler);
116
69
 
@@ -133,14 +86,5 @@ export const connectDefaultPluginsToExpress4 = (
133
86
  app.use(PAYREXX_WEBHOOK_PATH, express.json({ type: 'application/json' }), payrexxHandler);
134
87
  app.use(SAFERPAY_WEBHOOK_PATH, saferpayHandler);
135
88
 
136
- // app.use(
137
- // MINIO_PUT_SERVER_PATH,
138
- // express.json({
139
- // strict: false,
140
- // }),
141
- // minioHandler
142
- // );
143
-
144
- configureExportToken(unchainedAPI);
145
89
  configureGenerateOrderAutoscheduling();
146
90
  };
@@ -0,0 +1,7 @@
1
+ import { gridfsHandler } from '../files/gridfs/gridfs-webhook.js';
2
+
3
+ const { GRIDFS_PUT_SERVER_PATH = '/gridfs' } = process.env;
4
+
5
+ export default (app) => {
6
+ app.use(GRIDFS_PUT_SERVER_PATH, gridfsHandler);
7
+ };
@@ -0,0 +1,56 @@
1
+ import { ModuleInput } from '@unchainedshop/mongodb';
2
+
3
+ // Delivery
4
+ import '../delivery/post.js';
5
+
6
+ // Payment
7
+ import '../payment/invoice.js';
8
+
9
+ // Warehousing
10
+ import '../warehousing/store.js';
11
+
12
+ // Pricing
13
+ import '../pricing/free-payment.js';
14
+ import '../pricing/free-delivery.js';
15
+ import '../pricing/order-items.js';
16
+ import '../pricing/order-discount.js';
17
+ import '../pricing/order-delivery.js';
18
+ import '../pricing/order-payment.js';
19
+ import '../pricing/product-catalog-price.js';
20
+ import '../pricing/product-discount.js';
21
+
22
+ // Quotations
23
+ import '../quotations/manual.js';
24
+
25
+ // Enrollments
26
+ import '../enrollments/licensed.js';
27
+
28
+ // Event Queue
29
+ import '../events/node-event-emitter.js';
30
+
31
+ // Workers
32
+ import '../worker/bulk-import.js';
33
+ import '../worker/zombie-killer.js';
34
+ import '../worker/message.js';
35
+ import '../worker/external.js';
36
+ import '../worker/http-request.js';
37
+ import '../worker/heartbeat.js';
38
+ import '../worker/email.js';
39
+ import '../worker/error-notifications.js';
40
+
41
+ // Asset Management
42
+ import '../files/gridfs/gridfs-adapter.js';
43
+ import { configureGridFSFileUploadModule } from '../files/gridfs/index.js';
44
+
45
+ const modules: Record<
46
+ string,
47
+ {
48
+ configure: (params: ModuleInput<any>) => any;
49
+ }
50
+ > = {
51
+ gridfsFileUploads: {
52
+ configure: configureGridFSFileUploadModule,
53
+ },
54
+ };
55
+
56
+ export default modules;
@@ -0,0 +1,3 @@
1
+ import '../../delivery/pick-mup.js';
2
+ import '../../pricing/product-swiss-tax.js';
3
+ import '../../pricing/delivery-swiss-tax.js';
@@ -0,0 +1,12 @@
1
+ import { UnchainedCore } from '@unchainedshop/core';
2
+ import express from 'express';
3
+
4
+ import { cryptopayHandler } from '../payment/cryptopay/index.js';
5
+ import { configureExportToken } from '../worker/export-token.js';
6
+
7
+ const { CRYPTOPAY_WEBHOOK_PATH = '/payment/cryptopay' } = process.env;
8
+
9
+ export default (app, unchainedAPI: UnchainedCore) => {
10
+ app.use(CRYPTOPAY_WEBHOOK_PATH, express.json(), cryptopayHandler);
11
+ configureExportToken(unchainedAPI);
12
+ };
@@ -0,0 +1,23 @@
1
+ import { ModuleInput } from '@unchainedshop/mongodb';
2
+ import { configureCryptopayModule } from '../payment/cryptopay/index.js';
3
+
4
+ // Warehousing
5
+ import '../warehousing/eth-minter.js';
6
+
7
+ import '../pricing/product-price-rateconversion.js';
8
+ import '../worker/update-ecb-rates.js';
9
+ import '../worker/update-coinbase-rates.js';
10
+ import '../worker/export-token.js';
11
+
12
+ const modules: Record<
13
+ string,
14
+ {
15
+ configure: (params: ModuleInput<any>) => any;
16
+ }
17
+ > = {
18
+ cryptopay: {
19
+ configure: configureCryptopayModule,
20
+ },
21
+ };
22
+
23
+ export default modules;
@@ -1,11 +1,8 @@
1
1
  import { DeliveryPricingAdapter, DeliveryPricingDirector } from '@unchainedshop/core-delivery';
2
- import {
3
- DeliveryPricingRowCategory,
4
- IDeliveryPricingAdapter,
5
- } from '@unchainedshop/types/delivery.pricing.js';
2
+ import { DeliveryPricingRowCategory, IDeliveryPricingAdapter } from '@unchainedshop/core-delivery';
6
3
 
7
- import { Order } from '@unchainedshop/types/orders.js';
8
- import { DeliveryProvider } from '@unchainedshop/types/delivery.js';
4
+ import { Order } from '@unchainedshop/core-orders';
5
+ import { DeliveryProvider } from '@unchainedshop/core-delivery';
9
6
  import { SwissTaxCategories } from './tax/ch.js';
10
7
 
11
8
  const getTaxRate = ({ order, provider }: { order?: Order; provider?: DeliveryProvider }) => {
@@ -2,17 +2,17 @@ import { HundredOff } from './discount-100-off.js';
2
2
 
3
3
  describe('HundredOff', () => {
4
4
  it('isManualAdditionAllowed', async () => {
5
- let x
6
- expect(await HundredOff.isManualAdditionAllowed(x)).toBeTruthy();
5
+ let x;
6
+ expect(await HundredOff.isManualAdditionAllowed(x)).toBeTruthy();
7
7
  });
8
8
  it('isManualRemovalAllowed', async () => {
9
- expect(await HundredOff.isManualRemovalAllowed()).toBeTruthy();
9
+ expect(await HundredOff.isManualRemovalAllowed()).toBeTruthy();
10
10
  });
11
11
  it('isValidForSystemTriggering', async () => {
12
12
  const context = {};
13
13
  const actions = await HundredOff.actions({ context } as any);
14
14
  expect(await actions.isValidForSystemTriggering()).toBeFalsy();
15
- });
15
+ });
16
16
  it('isValidForCodeTriggering', async () => {
17
17
  const context = {};
18
18
  const actions = await HundredOff.actions({ context } as any);
@@ -24,8 +24,14 @@ describe('HundredOff', () => {
24
24
  const context = {};
25
25
  const actions = await HundredOff.actions({ context } as any);
26
26
  expect(
27
- actions.discountForPricingAdapterKey({ pricingAdapterKey: 'shop.unchained.pricing.order-discount' } as any)
27
+ actions.discountForPricingAdapterKey({
28
+ pricingAdapterKey: 'shop.unchained.pricing.order-discount',
29
+ } as any),
28
30
  ).toEqual({ fixedRate: 10000 });
29
- expect(actions.discountForPricingAdapterKey({ pricingAdapterKey: 'shop.unchained.pricing.other-discount' } as any)).toBeNull();
30
- });
31
+ expect(
32
+ actions.discountForPricingAdapterKey({
33
+ pricingAdapterKey: 'shop.unchained.pricing.other-discount',
34
+ } as any),
35
+ ).toBeNull();
36
+ });
31
37
  });
@@ -1,4 +1,4 @@
1
- import { IDiscountAdapter } from '@unchainedshop/types/discount.js';
1
+ import { IDiscountAdapter } from '@unchainedshop/utils';
2
2
  import {
3
3
  OrderDiscountDirector,
4
4
  OrderDiscountAdapter,
@@ -5,31 +5,37 @@ describe('HalfPriceManual', () => {
5
5
  let x;
6
6
  expect(await HalfPriceManual.isManualAdditionAllowed(x)).toBeTruthy();
7
7
  });
8
-
8
+
9
9
  it('isManualRemovalAllowed', async () => {
10
10
  expect(await HalfPriceManual.isManualRemovalAllowed()).toBeTruthy();
11
11
  });
12
-
12
+
13
13
  it('isValidForSystemTriggering', async () => {
14
14
  const context = {};
15
15
  const actions = await HalfPriceManual.actions({ context } as any);
16
16
  expect(await actions.isValidForSystemTriggering()).toBeFalsy();
17
17
  });
18
-
18
+
19
19
  it('isValidForCodeTriggering', async () => {
20
20
  const context = {};
21
21
  const actions = await HalfPriceManual.actions({ context } as any);
22
22
  expect(await actions.isValidForCodeTriggering({ code: 'HALFPRICE' })).toBeTruthy();
23
23
  expect(await actions.isValidForCodeTriggering({ code: 'othercode' })).toBeFalsy();
24
24
  });
25
-
25
+
26
26
  it('discountForPricingAdapterKey', async () => {
27
27
  const context = {};
28
28
  const actions = await HalfPriceManual.actions({ context } as any);
29
29
  expect(
30
- actions.discountForPricingAdapterKey({ pricingAdapterKey: 'shop.unchained.pricing.product-discount' } as any)
30
+ actions.discountForPricingAdapterKey({
31
+ pricingAdapterKey: 'shop.unchained.pricing.product-discount',
32
+ } as any),
31
33
  ).toEqual({ rate: 0.5 });
32
- expect(actions.discountForPricingAdapterKey({ pricingAdapterKey: 'shop.unchained.pricing.other-discount' } as any)).toBeNull();
34
+ expect(
35
+ actions.discountForPricingAdapterKey({
36
+ pricingAdapterKey: 'shop.unchained.pricing.other-discount',
37
+ } as any),
38
+ ).toBeNull();
33
39
  });
34
40
 
35
41
  it('Actions', async () => {
@@ -39,4 +45,4 @@ describe('HalfPriceManual', () => {
39
45
  expect(typeof actions.isValidForCodeTriggering).toBe('function');
40
46
  expect(typeof actions.discountForPricingAdapterKey).toBe('function');
41
47
  });
42
- });
48
+ });
@@ -1,4 +1,4 @@
1
- import { IDiscountAdapter } from '@unchainedshop/types/discount.js';
1
+ import { IDiscountAdapter } from '@unchainedshop/utils';
2
2
  import { OrderDiscountDirector, OrderDiscountAdapter } from '@unchainedshop/core-orders';
3
3
  import { ProductDiscountConfiguration } from '@unchainedshop/core-products';
4
4