@unchainedshop/plugins 3.1.10 → 4.0.0-rc.2

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 (211) 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/module.d.ts +2 -2
  4. package/lib/files/gridfs/module.d.ts.map +1 -1
  5. package/lib/filters/local-search.d.ts.map +1 -1
  6. package/lib/filters/local-search.js +9 -2
  7. package/lib/filters/local-search.js.map +1 -1
  8. package/lib/payment/apple-iap/adapter.js +5 -12
  9. package/lib/payment/apple-iap/adapter.js.map +1 -1
  10. package/lib/payment/apple-iap/fix-periods.d.ts.map +1 -1
  11. package/lib/payment/apple-iap/fix-periods.js +3 -5
  12. package/lib/payment/apple-iap/fix-periods.js.map +1 -1
  13. package/lib/payment/apple-iap/handler-express.js +3 -3
  14. package/lib/payment/apple-iap/handler-express.js.map +1 -1
  15. package/lib/payment/apple-iap/handler-fastify.js +3 -3
  16. package/lib/payment/apple-iap/handler-fastify.js.map +1 -1
  17. package/lib/payment/apple-iap/module.d.ts +2 -2
  18. package/lib/payment/apple-iap/module.d.ts.map +1 -1
  19. package/lib/payment/braintree.js +3 -4
  20. package/lib/payment/braintree.js.map +1 -1
  21. package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts +1 -2
  22. package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts.map +1 -1
  23. package/lib/payment/cryptopay/db/CryptopayTransactions.js.map +1 -1
  24. package/lib/payment/cryptopay/de.d.ts +2 -0
  25. package/lib/payment/cryptopay/de.d.ts.map +1 -0
  26. package/lib/payment/cryptopay/de.js +10 -0
  27. package/lib/payment/cryptopay/de.js.map +1 -0
  28. package/lib/payment/cryptopay/denote-amount.d.ts +25 -0
  29. package/lib/payment/cryptopay/denote-amount.d.ts.map +1 -0
  30. package/lib/payment/cryptopay/denote-amount.js +31 -0
  31. package/lib/payment/cryptopay/denote-amount.js.map +1 -0
  32. package/lib/payment/cryptopay/derive-btc-address.d.ts +3 -0
  33. package/lib/payment/cryptopay/derive-btc-address.d.ts.map +1 -0
  34. package/lib/payment/cryptopay/derive-btc-address.js +39 -0
  35. package/lib/payment/cryptopay/derive-btc-address.js.map +1 -0
  36. package/lib/payment/cryptopay/derive-btc-address.test copy.d.ts +2 -0
  37. package/lib/payment/cryptopay/derive-btc-address.test copy.d.ts.map +1 -0
  38. package/lib/payment/cryptopay/derive-btc-address.test copy.js +10 -0
  39. package/lib/payment/cryptopay/derive-btc-address.test copy.js.map +1 -0
  40. package/lib/payment/cryptopay/derive-eth-address.d.ts +3 -0
  41. package/lib/payment/cryptopay/derive-eth-address.d.ts.map +1 -0
  42. package/lib/payment/cryptopay/derive-eth-address.js +32 -0
  43. package/lib/payment/cryptopay/derive-eth-address.js.map +1 -0
  44. package/lib/payment/cryptopay/handle-webhook.d.ts +26 -0
  45. package/lib/payment/cryptopay/handle-webhook.d.ts.map +1 -0
  46. package/lib/payment/cryptopay/handle-webhook.js +61 -0
  47. package/lib/payment/cryptopay/handle-webhook.js.map +1 -0
  48. package/lib/payment/cryptopay/handler-express.d.ts.map +1 -1
  49. package/lib/payment/cryptopay/handler-express.js +3 -56
  50. package/lib/payment/cryptopay/handler-express.js.map +1 -1
  51. package/lib/payment/cryptopay/handler-fastify.d.ts.map +1 -1
  52. package/lib/payment/cryptopay/handler-fastify.js +3 -55
  53. package/lib/payment/cryptopay/handler-fastify.js.map +1 -1
  54. package/lib/payment/cryptopay/module.d.ts +26 -26
  55. package/lib/payment/cryptopay/module.d.ts.map +1 -1
  56. package/lib/payment/cryptopay/module.js +26 -24
  57. package/lib/payment/cryptopay/module.js.map +1 -1
  58. package/lib/payment/cryptopay/plugin.d.ts.map +1 -1
  59. package/lib/payment/cryptopay/plugin.js +33 -79
  60. package/lib/payment/cryptopay/plugin.js.map +1 -1
  61. package/lib/payment/datatrans-v2/api/types.d.ts +41 -41
  62. package/lib/payment/datatrans-v2/api/types.d.ts.map +1 -1
  63. package/lib/payment/datatrans-v2/getPaths.d.ts +2 -2
  64. package/lib/payment/datatrans-v2/getPaths.d.ts.map +1 -1
  65. package/lib/payment/datatrans-v2/index.js +16 -14
  66. package/lib/payment/datatrans-v2/index.js.map +1 -1
  67. package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts +1 -1
  68. package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts.map +1 -1
  69. package/lib/payment/datatrans-v2/roundedAmountFromOrder.js +3 -3
  70. package/lib/payment/datatrans-v2/roundedAmountFromOrder.js.map +1 -1
  71. package/lib/payment/paypal-checkout.js +1 -1
  72. package/lib/payment/paypal-checkout.js.map +1 -1
  73. package/lib/payment/payrexx/api/index.d.ts +2 -2
  74. package/lib/payment/payrexx/api/index.d.ts.map +1 -1
  75. package/lib/payment/payrexx/api/makeFetcher.d.ts.map +1 -1
  76. package/lib/payment/payrexx/api/makeFetcher.js.map +1 -1
  77. package/lib/payment/payrexx/index.js +4 -4
  78. package/lib/payment/payrexx/index.js.map +1 -1
  79. package/lib/payment/payrexx/payrexx.js +2 -2
  80. package/lib/payment/payrexx/payrexx.js.map +1 -1
  81. package/lib/payment/postfinance-checkout/index.js +3 -5
  82. package/lib/payment/postfinance-checkout/index.js.map +1 -1
  83. package/lib/payment/postfinance-checkout/types.d.ts +4 -4
  84. package/lib/payment/postfinance-checkout/types.d.ts.map +1 -1
  85. package/lib/payment/postfinance-checkout/utils.js +2 -2
  86. package/lib/payment/postfinance-checkout/utils.js.map +1 -1
  87. package/lib/payment/saferpay/adapter.d.ts.map +1 -1
  88. package/lib/payment/saferpay/adapter.js +4 -6
  89. package/lib/payment/saferpay/adapter.js.map +1 -1
  90. package/lib/payment/saferpay/api/models/Transaction.d.ts +2 -2
  91. package/lib/payment/saferpay/api/models/Transaction.d.ts.map +1 -1
  92. package/lib/payment/saferpay/module.d.ts +2 -2
  93. package/lib/payment/saferpay/module.d.ts.map +1 -1
  94. package/lib/payment/stripe/index.js +5 -5
  95. package/lib/payment/stripe/index.js.map +1 -1
  96. package/lib/payment/stripe/stripe.js +3 -3
  97. package/lib/payment/stripe/stripe.js.map +1 -1
  98. package/lib/presets/all.d.ts +12 -12
  99. package/lib/presets/all.d.ts.map +1 -1
  100. package/lib/pricing/delivery-swiss-tax.d.ts.map +1 -1
  101. package/lib/pricing/delivery-swiss-tax.js +2 -2
  102. package/lib/pricing/delivery-swiss-tax.js.map +1 -1
  103. package/lib/pricing/order-delivery.js +1 -1
  104. package/lib/pricing/order-delivery.js.map +1 -1
  105. package/lib/pricing/order-discount.js +3 -3
  106. package/lib/pricing/order-discount.js.map +1 -1
  107. package/lib/pricing/order-items-discount.js +1 -1
  108. package/lib/pricing/order-items-discount.js.map +1 -1
  109. package/lib/pricing/order-items.js +1 -1
  110. package/lib/pricing/order-items.js.map +1 -1
  111. package/lib/pricing/order-payment.js +1 -1
  112. package/lib/pricing/order-payment.js.map +1 -1
  113. package/lib/pricing/order-round.d.ts +1 -1
  114. package/lib/pricing/order-round.d.ts.map +1 -1
  115. package/lib/pricing/order-round.js +8 -8
  116. package/lib/pricing/order-round.js.map +1 -1
  117. package/lib/pricing/product-catalog-price.d.ts +0 -1
  118. package/lib/pricing/product-catalog-price.d.ts.map +1 -1
  119. package/lib/pricing/product-catalog-price.js +6 -18
  120. package/lib/pricing/product-catalog-price.js.map +1 -1
  121. package/lib/pricing/product-price-rateconversion.js +2 -2
  122. package/lib/pricing/product-price-rateconversion.js.map +1 -1
  123. package/lib/pricing/product-round.d.ts +1 -1
  124. package/lib/pricing/product-round.d.ts.map +1 -1
  125. package/lib/pricing/product-round.js +2 -2
  126. package/lib/pricing/product-round.js.map +1 -1
  127. package/lib/pricing/product-swiss-tax.d.ts +1 -1
  128. package/lib/pricing/product-swiss-tax.d.ts.map +1 -1
  129. package/lib/pricing/product-swiss-tax.js +2 -2
  130. package/lib/pricing/product-swiss-tax.js.map +1 -1
  131. package/lib/warehousing/eth-minter.js +2 -2
  132. package/lib/warehousing/eth-minter.js.map +1 -1
  133. package/lib/worker/bulk-import.js +1 -1
  134. package/lib/worker/bulk-import.js.map +1 -1
  135. package/lib/worker/enrollment-order-generator.js +1 -1
  136. package/lib/worker/enrollment-order-generator.js.map +1 -1
  137. package/lib/worker/error-notifications.d.ts +4 -4
  138. package/lib/worker/error-notifications.d.ts.map +1 -1
  139. package/lib/worker/message.d.ts +1 -1
  140. package/lib/worker/message.d.ts.map +1 -1
  141. package/lib/worker/sms.js +16 -16
  142. package/lib/worker/sms.js.map +1 -1
  143. package/lib/worker/update-coinbase-rates.js +1 -1
  144. package/lib/worker/update-coinbase-rates.js.map +1 -1
  145. package/lib/worker/update-ecb-rates.js.map +1 -1
  146. package/package.json +37 -53
  147. package/src/delivery/pick-mup.ts +0 -2
  148. package/src/files/gridfs/module.ts +2 -2
  149. package/src/filters/local-search.ts +11 -2
  150. package/src/payment/apple-iap/adapter.ts +6 -13
  151. package/src/payment/apple-iap/fix-periods.ts +4 -7
  152. package/src/payment/apple-iap/handler-express.ts +3 -3
  153. package/src/payment/apple-iap/handler-fastify.ts +3 -3
  154. package/src/payment/apple-iap/module.ts +2 -2
  155. package/src/payment/braintree.ts +3 -4
  156. package/src/payment/cryptopay/db/CryptopayTransactions.ts +1 -2
  157. package/src/payment/cryptopay/denote-amount.test.ts +28 -0
  158. package/src/payment/cryptopay/denote-amount.ts +29 -0
  159. package/src/payment/cryptopay/derive-btc-address.test.ts +22 -0
  160. package/src/payment/cryptopay/derive-btc-address.ts +48 -0
  161. package/src/payment/cryptopay/derive-eth-address.test.ts +22 -0
  162. package/src/payment/cryptopay/derive-eth-address.ts +38 -0
  163. package/src/payment/cryptopay/handle-webhook.ts +103 -0
  164. package/src/payment/cryptopay/handler-express.ts +3 -69
  165. package/src/payment/cryptopay/handler-fastify.ts +5 -70
  166. package/src/payment/cryptopay/module.ts +44 -40
  167. package/src/payment/cryptopay/plugin.ts +50 -87
  168. package/src/payment/cryptopay/readme.md +23 -1
  169. package/src/payment/datatrans-v2/api/types.ts +41 -41
  170. package/src/payment/datatrans-v2/getPaths.ts +2 -2
  171. package/src/payment/datatrans-v2/index.ts +17 -15
  172. package/src/payment/datatrans-v2/roundedAmountFromOrder.ts +4 -4
  173. package/src/payment/paypal-checkout.ts +1 -1
  174. package/src/payment/payrexx/api/index.ts +2 -2
  175. package/src/payment/payrexx/api/makeFetcher.ts +1 -1
  176. package/src/payment/payrexx/index.ts +4 -4
  177. package/src/payment/payrexx/payrexx.ts +2 -2
  178. package/src/payment/postfinance-checkout/index.ts +3 -5
  179. package/src/payment/postfinance-checkout/types.ts +6 -6
  180. package/src/payment/postfinance-checkout/utils.ts +2 -2
  181. package/src/payment/saferpay/adapter.ts +4 -6
  182. package/src/payment/saferpay/api/models/Transaction.ts +2 -2
  183. package/src/payment/saferpay/module.ts +2 -2
  184. package/src/payment/stripe/index.ts +5 -5
  185. package/src/payment/stripe/stripe.ts +3 -3
  186. package/src/pricing/delivery-swiss-tax.ts +6 -2
  187. package/src/pricing/order-delivery.ts +1 -1
  188. package/src/pricing/order-discount.ts +3 -3
  189. package/src/pricing/order-items-discount.ts +1 -1
  190. package/src/pricing/order-items.ts +1 -1
  191. package/src/pricing/order-payment.ts +1 -1
  192. package/src/pricing/order-round.ts +9 -9
  193. package/src/pricing/product-catalog-price.ts +6 -25
  194. package/src/pricing/product-price-rateconversion.ts +2 -2
  195. package/src/pricing/product-round.ts +3 -3
  196. package/src/pricing/product-swiss-tax.test.ts +6 -6
  197. package/src/pricing/product-swiss-tax.ts +2 -2
  198. package/src/warehousing/eth-minter.ts +2 -2
  199. package/src/worker/bulk-import.ts +1 -1
  200. package/src/worker/enrollment-order-generator.ts +3 -3
  201. package/src/worker/error-notifications.ts +4 -4
  202. package/src/worker/heartbeat.ts +2 -2
  203. package/src/worker/message.ts +1 -1
  204. package/src/worker/push-notification.ts +2 -2
  205. package/src/worker/sms.ts +19 -17
  206. package/src/worker/update-coinbase-rates.ts +3 -6
  207. package/src/worker/update-ecb-rates.ts +3 -3
  208. package/src/worker/BaseWorker.ts +0 -116
  209. package/src/worker/EventListenerWorker.ts +0 -61
  210. package/src/worker/FailedRescheduler.ts +0 -80
  211. package/src/worker/IntervalWorker.ts +0 -54
@@ -59,7 +59,7 @@ const Payrexx: IPaymentAdapter = {
59
59
  // Order Checkout signing (One-time payment)
60
60
  const pricing = OrderPricingSheet({
61
61
  calculation: order.calculation,
62
- currency: order.currency,
62
+ currencyCode: order.currencyCode,
63
63
  });
64
64
  const gatewayObject = mapOrderDataToGatewayObject(
65
65
  { order, orderPayment, pricing },
@@ -183,9 +183,9 @@ const Payrexx: IPaymentAdapter = {
183
183
 
184
184
  const pricing = OrderPricingSheet({
185
185
  calculation: order.calculation,
186
- currency: order.currency,
186
+ currencyCode: order.currencyCode,
187
187
  });
188
- const { currency, amount } = pricing.total({ useNetPrice: false });
188
+ const { currencyCode, amount } = pricing.total({ useNetPrice: false });
189
189
 
190
190
  if (
191
191
  // gatewayObject.status === 'authorized' || // authorized is only used for tokenization!
@@ -194,7 +194,7 @@ const Payrexx: IPaymentAdapter = {
194
194
  ) {
195
195
  try {
196
196
  if (
197
- gatewayObject.currency !== currency.toUpperCase() ||
197
+ gatewayObject.currency !== currencyCode.toUpperCase() ||
198
198
  gatewayObject.amount !== Math.round(amount)
199
199
  ) {
200
200
  throw new Error('The price has changed since the intent has been created');
@@ -14,7 +14,7 @@ const getRedirects = () => {
14
14
  };
15
15
 
16
16
  export const mapOrderDataToGatewayObject = ({ order, orderPayment, pricing }, options = {}) => {
17
- const { currency, amount } = pricing.total({ useNetPrice: false });
17
+ const { currencyCode, amount } = pricing.total({ useNetPrice: false });
18
18
 
19
19
  const customerData = {};
20
20
  if (order.contact?.emailAddress) {
@@ -29,7 +29,7 @@ export const mapOrderDataToGatewayObject = ({ order, orderPayment, pricing }, op
29
29
 
30
30
  const gatewayObject = {
31
31
  amount: Math.round(amount),
32
- currency: currency.toUpperCase(),
32
+ currency: currencyCode.toUpperCase(),
33
33
  purpose: encodeURIComponent(`${process.env.EMAIL_WEBSITE_NAME || 'Unchained'} #${order._id}`),
34
34
  reservation: true,
35
35
  skipResultPage: true,
@@ -66,9 +66,7 @@ const PostfinanceCheckout: IPaymentAdapter = {
66
66
  );
67
67
  },
68
68
 
69
- // eslint-disable-next-line
70
69
  configurationError() {
71
- // eslint-disable-line
72
70
  if (
73
71
  !PFCHECKOUT_SPACE_ID ||
74
72
  !PFCHECKOUT_USER_ID ||
@@ -105,13 +103,13 @@ const PostfinanceCheckout: IPaymentAdapter = {
105
103
  const completionMode = adapter.getCompletionMode();
106
104
  const pricing = OrderPricingSheet({
107
105
  calculation: order.calculation,
108
- currency: order.currency,
106
+ currencyCode: order.currencyCode,
109
107
  });
110
108
 
111
109
  const totalAmount = pricing?.total({ useNetPrice: false }).amount;
112
110
  const transaction = new PostFinanceCheckout.model.TransactionCreate();
113
111
  const userId = order?.userId || context?.userId;
114
- transaction.currency = order.currency;
112
+ transaction.currency = order.currencyCode;
115
113
  transaction.metaData = {
116
114
  orderPaymentId: orderPayment._id,
117
115
  };
@@ -219,7 +217,7 @@ const PostfinanceCheckout: IPaymentAdapter = {
219
217
  const refund = transaction.state === PostFinanceCheckout.model.TransactionState.FULFILL;
220
218
  const pricing = OrderPricingSheet({
221
219
  calculation: order.calculation,
222
- currency: order.currency,
220
+ currencyCode: order.currencyCode,
223
221
  });
224
222
 
225
223
  const totalAmount = pricing?.total({ useNetPrice: false }).amount;
@@ -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
+ }
@@ -32,8 +32,8 @@ export const orderIsPaid = async (
32
32
  ): Promise<boolean> => {
33
33
  const pricing = OrderPricingSheet({
34
34
  calculation: order.calculation,
35
- currency: order.currency,
35
+ currencyCode: order.currencyCode,
36
36
  });
37
37
  const totalAmount = pricing.total({ useNetPrice: false }).amount / 100;
38
- return transactionIsPaid(transaction, order.currency, totalAmount);
38
+ return transactionIsPaid(transaction, order.currencyCode, totalAmount);
39
39
  };
@@ -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-02-24.acacia',
21
+ apiVersion: '2025-05-28.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
@@ -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({
@@ -23,7 +23,7 @@ export const ProductPriceRateConversion: IProductPricingAdapter = {
23
23
  ...pricingAdapter,
24
24
 
25
25
  calculate: async () => {
26
- const { product, country, quantity, currency: targetCurrency } = params.context;
26
+ const { product, countryCode, quantity, currencyCode: targetCurrency } = params.context;
27
27
 
28
28
  const { calculation = [] } = params.calculationSheet;
29
29
  if (calculation?.length) {
@@ -33,7 +33,7 @@ export const ProductPriceRateConversion: IProductPricingAdapter = {
33
33
  }
34
34
 
35
35
  const productPrice = await modules.products.prices.price(product, {
36
- country,
36
+ countryCode,
37
37
  quantity,
38
38
  });
39
39
 
@@ -6,7 +6,7 @@ import {
6
6
 
7
7
  interface PriceRoundSettings {
8
8
  defaultPrecision: number;
9
- roundTo: (value: number, precision: number, currency: string) => number;
9
+ roundTo: (value: number, precision: number, currencyCode: string) => number;
10
10
  }
11
11
 
12
12
  export const ProductRound: IProductPricingAdapter & {
@@ -41,7 +41,7 @@ export const ProductRound: IProductPricingAdapter & {
41
41
  ...pricingAdapter,
42
42
 
43
43
  calculate: async () => {
44
- const { currency } = params.context;
44
+ const { currencyCode } = params.context;
45
45
  const { defaultPrecision, roundTo } = ProductRound.settings;
46
46
  const { calculation = [] } = params.calculationSheet;
47
47
 
@@ -49,7 +49,7 @@ export const ProductRound: IProductPricingAdapter & {
49
49
  pricingAdapter.resultSheet().resetCalculation(params.calculationSheet);
50
50
 
51
51
  calculation.forEach((item) => {
52
- const newAmount = roundTo(item.amount, defaultPrecision, currency);
52
+ const newAmount = roundTo(item.amount, defaultPrecision, currencyCode);
53
53
  pricingAdapter.resultSheet().calculation.push({
54
54
  ...item,
55
55
  amount: newAmount,
@@ -70,25 +70,25 @@ describe('ProductSwissTax', () => {
70
70
  deliveryId: 'CH',
71
71
  billingAddress: { countryCode: 'LI' },
72
72
  },
73
- country: 'CH',
73
+ countryCode: 'CH',
74
74
  };
75
75
  it('Should return true when passed country code CH', async () => {
76
76
  assert.strictEqual(
77
- await isDeliveryAddressInSwitzerland({ ...context, country: 'ch', order: null } as any),
77
+ await isDeliveryAddressInSwitzerland({ ...context, countryCode: 'ch', order: null } as any),
78
78
  true,
79
79
  );
80
80
  });
81
81
 
82
82
  it('Should return true when passed country code LI', async () => {
83
83
  assert.strictEqual(
84
- await isDeliveryAddressInSwitzerland({ ...context, country: 'LI', order: null } as any),
84
+ await isDeliveryAddressInSwitzerland({ ...context, countryCode: 'LI', order: null } as any),
85
85
  true,
86
86
  );
87
87
  });
88
88
 
89
89
  it('Should return false when country is neither CH nor LI and order is null', async () => {
90
90
  assert.strictEqual(
91
- await isDeliveryAddressInSwitzerland({ ...context, country: 'ET', order: null } as any),
91
+ await isDeliveryAddressInSwitzerland({ ...context, countryCode: 'ET', order: null } as any),
92
92
  false,
93
93
  );
94
94
  });
@@ -98,7 +98,7 @@ describe('ProductSwissTax', () => {
98
98
  assert.strictEqual(
99
99
  await isDeliveryAddressInSwitzerland({
100
100
  ...context,
101
- country: 'CH',
101
+ countryCode: 'CH',
102
102
  order: {
103
103
  deliveryId: 'ET',
104
104
  billingAddress: { countryCode: 'ET' },
@@ -112,7 +112,7 @@ describe('ProductSwissTax', () => {
112
112
  assert.strictEqual(
113
113
  await isDeliveryAddressInSwitzerland({
114
114
  ...context,
115
- country: 'IT',
115
+ countryCode: 'IT',
116
116
  order: {
117
117
  deliveryId: null,
118
118
  billingAddress: { countryCode: 'CH' },
@@ -24,10 +24,10 @@ export const getTaxRate = (context: ProductPricingAdapterContext) => {
24
24
 
25
25
  export const isDeliveryAddressInSwitzerland = async ({
26
26
  order,
27
- country,
27
+ countryCode: forceCountryCode,
28
28
  modules,
29
29
  }: ProductPricingAdapterContext & { modules: UnchainedCore['modules'] }) => {
30
- let countryCode = country?.toUpperCase().trim();
30
+ let countryCode = forceCountryCode?.toUpperCase().trim() || order.countryCode;
31
31
 
32
32
  if (order) {
33
33
  const orderDelivery = await modules.orders.deliveries.findDelivery({
@@ -119,12 +119,12 @@ const ETHMinter: IWarehousingAdapter = {
119
119
  const url = signedUrl && (await modules.files.normalizeUrl(signedUrl, {}));
120
120
  const text = await modules.products.texts.findLocalizedText({
121
121
  productId: product._id,
122
- locale: locale?.baseName || systemLocale.baseName,
122
+ locale: locale || systemLocale,
123
123
  });
124
124
 
125
125
  const name = `${text.title} #${chainTokenId}`;
126
126
 
127
- const isDefaultLanguageActive = locale ? locale?.language === systemLocale.language : true;
127
+ const isDefaultLanguageActive = locale ? locale.language === systemLocale.language : true;
128
128
  const localization = isDefaultLanguageActive
129
129
  ? {
130
130
  uri: `${ROOT_URL}/erc-metadata/${product._id}/{locale}/${tokenId}.json`,
@@ -44,7 +44,7 @@ const streamPayloadToBulkImporter = async (
44
44
  { highWaterMark: 100, lowWaterMark: 5 },
45
45
  );
46
46
 
47
- for await (const event of eventIterator) { // eslint-disable-line
47
+ for await (const event of eventIterator) {
48
48
  await bulkImporter.prepare(event, unchainedAPI);
49
49
  }
50
50
 
@@ -12,8 +12,8 @@ import {
12
12
  const generateOrder = async (
13
13
  enrollment: Enrollment,
14
14
  params: {
15
- orderPositions: Array<OrderPosition>;
16
- } & { [x: string]: any },
15
+ orderPositions: OrderPosition[];
16
+ } & Record<string, any>,
17
17
  unchainedAPI: Pick<UnchainedCore, 'modules' | 'services'>,
18
18
  ) => {
19
19
  if (!enrollment.payment || !enrollment.delivery) return null;
@@ -22,7 +22,7 @@ const generateOrder = async (
22
22
  const { orderPositions, ...configuration } = params;
23
23
  let order = await modules.orders.create({
24
24
  userId: enrollment.userId,
25
- currency: enrollment.currencyCode,
25
+ currencyCode: enrollment.currencyCode,
26
26
  countryCode: enrollment.countryCode,
27
27
  contact: enrollment.contact,
28
28
  billingAddress: enrollment.billingAddress,
@@ -2,13 +2,13 @@ import { WorkStatus } from '@unchainedshop/core-worker';
2
2
  import { IWorkerAdapter, WorkerDirector, WorkerAdapter } from '@unchainedshop/core';
3
3
  import later from '@breejs/later';
4
4
 
5
- type Arg = {
5
+ interface Arg {
6
6
  secondsPassed?: number;
7
- };
7
+ }
8
8
 
9
- type Result = {
9
+ interface Result {
10
10
  forked?: string;
11
- };
11
+ }
12
12
 
13
13
  const everyDayAtFourInTheNight = later.parse.cron('0 3 * * *');
14
14
 
@@ -8,10 +8,10 @@ const wait = async (time: number) => {
8
8
  });
9
9
  };
10
10
 
11
- type Arg = {
11
+ interface Arg {
12
12
  wait?: number;
13
13
  fails?: boolean;
14
- };
14
+ }
15
15
 
16
16
  type Result = Arg;
17
17