@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.
- package/lib/delivery/pick-mup.js +1 -1
- package/lib/delivery/pick-mup.js.map +1 -1
- package/lib/files/gridfs/gridfs-webhook.d.ts +1 -1
- package/lib/files/gridfs/gridfs-webhook.d.ts.map +1 -1
- package/lib/filters/local-search.d.ts +1 -1
- package/lib/filters/local-search.d.ts.map +1 -1
- package/lib/filters/local-search.js.map +1 -1
- package/lib/payment/apple-iap/db/AppleTransactionsCollection.d.ts +1 -1
- package/lib/payment/apple-iap/db/AppleTransactionsCollection.d.ts.map +1 -1
- package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts +1 -1
- package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts.map +1 -1
- package/lib/payment/cryptopay/plugin.d.ts +1 -1
- package/lib/payment/cryptopay/plugin.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/index.js +2 -2
- package/lib/payment/datatrans-v2/index.js.map +1 -1
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts +2 -2
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts.map +1 -1
- package/lib/payment/paypal-checkout.js +7 -1
- package/lib/payment/paypal-checkout.js.map +1 -1
- package/lib/payment/postfinance-checkout/api.js +3 -3
- package/lib/payment/postfinance-checkout/api.js.map +1 -1
- package/lib/payment/postfinance-checkout/utils.d.ts +1 -1
- package/lib/payment/postfinance-checkout/utils.d.ts.map +1 -1
- package/lib/payment/saferpay/adapter.d.ts +1 -1
- package/lib/payment/saferpay/adapter.d.ts.map +1 -1
- package/lib/payment/saferpay/api/api/SaferpayClient.d.ts +1 -1
- package/lib/payment/saferpay/api/api/SaferpayClient.d.ts.map +1 -1
- package/lib/payment/saferpay/db/SaferpayTransactionsCollection.d.ts +1 -1
- package/lib/payment/saferpay/db/SaferpayTransactionsCollection.d.ts.map +1 -1
- package/lib/payment/stripe/middleware.d.ts.map +1 -1
- package/lib/payment/stripe/middleware.js +0 -3
- package/lib/payment/stripe/middleware.js.map +1 -1
- package/lib/payment/stripe/stripe.d.ts +3 -3
- package/lib/payment/stripe/stripe.d.ts.map +1 -1
- package/lib/payment/stripe/stripe.js +4 -4
- package/lib/payment/stripe/stripe.js.map +1 -1
- package/lib/plugins-index.d.ts +3 -31
- package/lib/plugins-index.d.ts.map +1 -1
- package/lib/plugins-index.js +10 -61
- package/lib/plugins-index.js.map +1 -1
- package/lib/presets/base-express.d.ts +3 -0
- package/lib/presets/base-express.d.ts.map +1 -0
- package/lib/presets/base-express.js +6 -0
- package/lib/presets/base-express.js.map +1 -0
- package/lib/presets/base-modules.d.ts +29 -0
- package/lib/presets/base-modules.d.ts.map +1 -0
- package/lib/presets/base-modules.js +40 -0
- package/lib/presets/base-modules.js.map +1 -0
- package/lib/presets/countries/ch.d.ts +4 -0
- package/lib/presets/countries/ch.d.ts.map +1 -0
- package/lib/presets/countries/ch.js +4 -0
- package/lib/presets/countries/ch.js.map +1 -0
- package/lib/presets/crypto-express.d.ts +4 -0
- package/lib/presets/crypto-express.d.ts.map +1 -0
- package/lib/presets/crypto-express.js +9 -0
- package/lib/presets/crypto-express.js.map +1 -0
- package/lib/presets/crypto-modules.d.ts +11 -0
- package/lib/presets/crypto-modules.d.ts.map +1 -0
- package/lib/presets/crypto-modules.js +14 -0
- package/lib/presets/crypto-modules.js.map +1 -0
- package/lib/pricing/delivery-swiss-tax.d.ts +1 -1
- package/lib/pricing/delivery-swiss-tax.d.ts.map +1 -1
- package/lib/pricing/delivery-swiss-tax.js +1 -1
- package/lib/pricing/delivery-swiss-tax.js.map +1 -1
- package/lib/pricing/discount-100-off.d.ts +1 -1
- package/lib/pricing/discount-100-off.d.ts.map +1 -1
- package/lib/pricing/discount-half-price-manual.d.ts +1 -1
- package/lib/pricing/discount-half-price-manual.d.ts.map +1 -1
- package/lib/pricing/discount-half-price.d.ts +1 -1
- package/lib/pricing/discount-half-price.d.ts.map +1 -1
- package/lib/pricing/free-delivery.d.ts +1 -1
- package/lib/pricing/free-delivery.d.ts.map +1 -1
- package/lib/pricing/free-delivery.js +1 -1
- package/lib/pricing/free-delivery.js.map +1 -1
- package/lib/pricing/free-payment.d.ts +1 -1
- package/lib/pricing/free-payment.d.ts.map +1 -1
- package/lib/pricing/free-payment.js +1 -1
- package/lib/pricing/free-payment.js.map +1 -1
- package/lib/pricing/order-delivery.d.ts +1 -1
- package/lib/pricing/order-delivery.d.ts.map +1 -1
- package/lib/pricing/order-discount.d.ts +1 -1
- package/lib/pricing/order-discount.d.ts.map +1 -1
- package/lib/pricing/order-discount.js +1 -1
- package/lib/pricing/order-discount.js.map +1 -1
- package/lib/pricing/order-items-discount.js +1 -1
- package/lib/pricing/order-items-discount.js.map +1 -1
- package/lib/pricing/order-round.d.ts +1 -1
- package/lib/pricing/order-round.d.ts.map +1 -1
- package/lib/pricing/order-round.js +1 -1
- package/lib/pricing/order-round.js.map +1 -1
- package/lib/pricing/product-catalog-price.d.ts +1 -1
- package/lib/pricing/product-catalog-price.d.ts.map +1 -1
- package/lib/pricing/product-discount.js +1 -1
- package/lib/pricing/product-discount.js.map +1 -1
- package/lib/pricing/product-price-rateconversion.d.ts +1 -1
- package/lib/pricing/product-price-rateconversion.d.ts.map +1 -1
- package/lib/pricing/product-round.d.ts +1 -1
- package/lib/pricing/product-round.d.ts.map +1 -1
- package/lib/pricing/product-swiss-tax.d.ts +4 -12
- package/lib/pricing/product-swiss-tax.d.ts.map +1 -1
- package/lib/pricing/product-swiss-tax.js +3 -3
- package/lib/pricing/product-swiss-tax.js.map +1 -1
- package/lib/warehousing/eth-minter.js +4 -3
- package/lib/warehousing/eth-minter.js.map +1 -1
- package/lib/worker/bulk-import.d.ts +1 -1
- package/lib/worker/bulk-import.d.ts.map +1 -1
- package/lib/worker/bulk-import.js.map +1 -1
- package/lib/worker/error-notifications.d.ts +1 -1
- package/lib/worker/error-notifications.d.ts.map +1 -1
- package/lib/worker/error-notifications.js +1 -1
- package/lib/worker/error-notifications.js.map +1 -1
- package/lib/worker/export-token.d.ts +2 -2
- package/lib/worker/export-token.d.ts.map +1 -1
- package/lib/worker/export-token.js +1 -1
- package/lib/worker/export-token.js.map +1 -1
- package/lib/worker/external.d.ts +1 -1
- package/lib/worker/external.d.ts.map +1 -1
- package/lib/worker/http-request.d.ts +1 -1
- package/lib/worker/http-request.d.ts.map +1 -1
- package/lib/worker/message.d.ts +1 -1
- package/lib/worker/message.d.ts.map +1 -1
- package/lib/worker/message.js.map +1 -1
- package/lib/worker/update-coinbase-rates.js +1 -1
- package/lib/worker/update-coinbase-rates.js.map +1 -1
- package/lib/worker/update-ecb-rates.js +1 -1
- package/lib/worker/update-ecb-rates.js.map +1 -1
- package/lib/worker/update-token-ownership.d.ts +1 -1
- package/lib/worker/update-token-ownership.d.ts.map +1 -1
- package/lib/worker/zombie-killer.d.ts +1 -1
- package/lib/worker/zombie-killer.d.ts.map +1 -1
- package/package.json +28 -26
- package/src/delivery/pick-mup.ts +1 -1
- package/src/delivery/post.ts +1 -1
- package/src/delivery/send-message.ts +1 -1
- package/src/delivery/stores.ts +1 -1
- package/src/enrollments/licensed.ts +1 -1
- package/src/files/gridfs/gridfs-adapter.ts +1 -1
- package/src/files/gridfs/gridfs-webhook.ts +1 -1
- package/src/files/minio/minio-adapter.ts +1 -1
- package/src/filters/local-search.ts +4 -4
- package/src/filters/strict-equal.ts +1 -1
- package/src/payment/apple-iap/adapter.ts +3 -3
- package/src/payment/apple-iap/db/AppleTransactionsCollection.ts +1 -1
- package/src/payment/braintree.ts +1 -1
- package/src/payment/cryptopay/db/CryptopayTransactions.ts +1 -1
- package/src/payment/cryptopay/middleware.ts +3 -3
- package/src/payment/cryptopay/plugin.ts +2 -2
- package/src/payment/datatrans-v2/index.ts +3 -3
- package/src/payment/datatrans-v2/middleware.ts +1 -1
- package/src/payment/datatrans-v2/roundedAmountFromOrder.ts +2 -2
- package/src/payment/invoice-prepaid.ts +1 -1
- package/src/payment/invoice.ts +1 -1
- package/src/payment/paypal-checkout.ts +8 -2
- package/src/payment/payrexx/index.ts +1 -1
- package/src/payment/payrexx/middleware.ts +1 -1
- package/src/payment/postfinance-checkout/api.ts +3 -3
- package/src/payment/postfinance-checkout/index.ts +1 -1
- package/src/payment/postfinance-checkout/middleware.ts +1 -1
- package/src/payment/postfinance-checkout/utils.ts +1 -1
- package/src/payment/saferpay/adapter.ts +2 -2
- package/src/payment/saferpay/api/api/SaferpayClient.ts +1 -1
- package/src/payment/saferpay/db/SaferpayTransactionsCollection.ts +1 -1
- package/src/payment/saferpay/middleware.ts +1 -1
- package/src/payment/stripe/index.ts +1 -1
- package/src/payment/stripe/middleware.ts +1 -4
- package/src/payment/stripe/stripe.ts +7 -7
- package/src/plugins-index.ts +14 -70
- package/src/presets/base-express.ts +7 -0
- package/src/presets/base-modules.ts +56 -0
- package/src/presets/countries/ch.ts +3 -0
- package/src/presets/crypto-express.ts +12 -0
- package/src/presets/crypto-modules.ts +23 -0
- package/src/pricing/delivery-swiss-tax.ts +3 -6
- package/src/pricing/discount-100-off.test.ts +13 -7
- package/src/pricing/discount-100-off.ts +1 -1
- package/src/pricing/discount-half-price-manual.test.ts +13 -7
- package/src/pricing/discount-half-price-manual.ts +1 -1
- package/src/pricing/discount-half-price.test.ts +15 -7
- package/src/pricing/discount-half-price.ts +1 -1
- package/src/pricing/free-delivery.test.ts +3 -8
- package/src/pricing/free-delivery.ts +5 -2
- package/src/pricing/free-payment.ts +5 -2
- package/src/pricing/licenced-enrollment.test.ts +33 -34
- package/src/pricing/order-delivery.test.ts +3 -5
- package/src/pricing/order-delivery.ts +1 -1
- package/src/pricing/order-discount.test.ts +3 -3
- package/src/pricing/order-discount.ts +1 -1
- package/src/pricing/order-items-discount.ts +1 -1
- package/src/pricing/order-items.ts +1 -1
- package/src/pricing/order-payment.ts +1 -1
- package/src/pricing/order-round.ts +1 -1
- package/src/pricing/plugins-index.test.ts +1 -1
- package/src/pricing/product-catalog-price.ts +1 -1
- package/src/pricing/product-discount.ts +2 -5
- package/src/pricing/product-price-rateconversion.ts +1 -1
- package/src/pricing/product-round.ts +1 -1
- package/src/pricing/product-swiss-tax.test.ts +112 -86
- package/src/pricing/product-swiss-tax.ts +11 -8
- package/src/pricing/tax/ch.test.ts +16 -16
- package/src/quotations/manual.ts +1 -1
- package/src/warehousing/eth-minter.ts +8 -6
- package/src/warehousing/store.ts +1 -1
- package/src/worker/bulk-import.ts +2 -2
- package/src/worker/email.ts +1 -1
- package/src/worker/enrollment-order-generator.ts +5 -5
- package/src/worker/error-notifications.ts +1 -1
- package/src/worker/export-token.ts +8 -3
- package/src/worker/external.ts +1 -1
- package/src/worker/heartbeat.ts +1 -1
- package/src/worker/http-request.ts +1 -1
- package/src/worker/message.ts +1 -2
- package/src/worker/push-notification.ts +1 -1
- package/src/worker/sms.ts +1 -1
- package/src/worker/update-coinbase-rates.ts +3 -3
- package/src/worker/update-ecb-rates.ts +3 -3
- package/src/worker/update-token-ownership.ts +1 -1
- package/src/worker/zombie-killer.ts +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { IPaymentAdapter } from '@unchainedshop/
|
|
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/
|
|
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/
|
|
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/
|
|
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
|
|
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/
|
|
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/
|
|
2
|
-
import { Order } from '@unchainedshop/
|
|
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/
|
|
1
|
+
import { IPaymentAdapter } from '@unchainedshop/core-payment';
|
|
2
2
|
import { PaymentDirector, PaymentAdapter, PaymentProviderType } from '@unchainedshop/core-payment';
|
|
3
3
|
|
|
4
4
|
const InvoicePrepaid: IPaymentAdapter = {
|
package/src/payment/invoice.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IPaymentAdapter } from '@unchainedshop/
|
|
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/
|
|
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
|
-
|
|
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/
|
|
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';
|
|
@@ -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
|
|
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
|
|
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
|
|
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/
|
|
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/
|
|
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,6 +1,6 @@
|
|
|
1
|
-
import { IPaymentAdapter } from '@unchainedshop/
|
|
1
|
+
import { IPaymentAdapter } from '@unchainedshop/core-payment';
|
|
2
2
|
import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
|
|
3
|
-
import { UnchainedCore } from '@unchainedshop/
|
|
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/
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import { Context } from '@unchainedshop/
|
|
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/
|
|
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/
|
|
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/
|
|
2
|
-
import { OrderPayment } from '@unchainedshop/
|
|
3
|
-
import { IOrderPricingSheet } from '@unchainedshop/
|
|
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-
|
|
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
|
|
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'}
|
|
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'}
|
|
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
|
|
package/src/plugins-index.ts
CHANGED
|
@@ -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
|
|
113
|
-
app
|
|
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,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,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/
|
|
8
|
-
import { DeliveryProvider } from '@unchainedshop/
|
|
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
|
-
|
|
5
|
+
let x;
|
|
6
|
+
expect(await HundredOff.isManualAdditionAllowed(x)).toBeTruthy();
|
|
7
7
|
});
|
|
8
8
|
it('isManualRemovalAllowed', async () => {
|
|
9
|
-
|
|
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
|
-
|
|
27
|
+
actions.discountForPricingAdapterKey({
|
|
28
|
+
pricingAdapterKey: 'shop.unchained.pricing.order-discount',
|
|
29
|
+
} as any),
|
|
28
30
|
).toEqual({ fixedRate: 10000 });
|
|
29
|
-
expect(
|
|
30
|
-
|
|
31
|
+
expect(
|
|
32
|
+
actions.discountForPricingAdapterKey({
|
|
33
|
+
pricingAdapterKey: 'shop.unchained.pricing.other-discount',
|
|
34
|
+
} as any),
|
|
35
|
+
).toBeNull();
|
|
36
|
+
});
|
|
31
37
|
});
|
|
@@ -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({
|
|
30
|
+
actions.discountForPricingAdapterKey({
|
|
31
|
+
pricingAdapterKey: 'shop.unchained.pricing.product-discount',
|
|
32
|
+
} as any),
|
|
31
33
|
).toEqual({ rate: 0.5 });
|
|
32
|
-
expect(
|
|
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/
|
|
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
|
|