@unchainedshop/plugins 4.7.2 → 4.8.0
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/README.md +2 -0
- package/lib/delivery/post.d.ts +1 -0
- package/lib/delivery/post.js +23 -0
- package/lib/delivery/send-message.d.ts +1 -0
- package/lib/delivery/send-message.js +40 -0
- package/lib/delivery/stores.d.ts +1 -0
- package/lib/delivery/stores.js +43 -0
- package/lib/enrollments/licensed.d.ts +4 -0
- package/lib/enrollments/licensed.js +52 -0
- package/lib/events/node-event-emitter.d.ts +1 -3
- package/lib/events/node-event-emitter.js +3 -3
- package/lib/files/gridfs/adapter.d.ts +2 -2
- package/lib/files/gridfs/adapter.js +5 -2
- package/lib/files/gridfs/handler-express.d.ts +9 -0
- package/lib/files/gridfs/handler-express.js +110 -0
- package/lib/files/gridfs/handler-fastify.d.ts +3 -0
- package/lib/files/gridfs/handler-fastify.js +138 -0
- package/lib/files/gridfs/index.d.ts +4 -5
- package/lib/files/gridfs/index.js +3 -30
- package/lib/files/minio/handler-express.d.ts +2 -0
- package/lib/files/minio/handler-express.js +36 -0
- package/lib/files/minio/handler-fastify.d.ts +3 -0
- package/lib/files/minio/handler-fastify.js +40 -0
- package/lib/files/minio/index.d.ts +5 -4
- package/lib/files/minio/index.js +157 -18
- package/lib/filters/local-search.d.ts +3 -0
- package/lib/filters/local-search.js +66 -0
- package/lib/filters/strict-equal.d.ts +1 -0
- package/lib/filters/strict-equal.js +24 -0
- package/lib/payment/apple-iap/adapter.d.ts +1 -2
- package/lib/payment/apple-iap/adapter.js +3 -2
- package/lib/payment/apple-iap/handler-express.d.ts +2 -0
- package/lib/payment/apple-iap/handler-express.js +103 -0
- package/lib/payment/apple-iap/handler-fastify.d.ts +3 -0
- package/lib/payment/apple-iap/handler-fastify.js +102 -0
- package/lib/payment/apple-iap/index.d.ts +4 -6
- package/lib/payment/apple-iap/index.js +3 -28
- package/lib/payment/braintree.d.ts +1 -0
- package/lib/payment/braintree.js +138 -0
- package/lib/payment/cryptopay/handler-express.d.ts +2 -0
- package/lib/payment/cryptopay/handler-express.js +19 -0
- package/lib/payment/cryptopay/handler-fastify.d.ts +3 -0
- package/lib/payment/cryptopay/handler-fastify.js +17 -0
- package/lib/payment/cryptopay/index.d.ts +4 -5
- package/lib/payment/cryptopay/index.js +3 -31
- package/lib/payment/cryptopay/plugin.d.ts +3 -0
- package/lib/payment/cryptopay/plugin.js +159 -0
- package/lib/payment/datatrans-v2/handler-express.d.ts +1 -0
- package/lib/payment/datatrans-v2/handler-express.js +71 -0
- package/lib/payment/datatrans-v2/handler-fastify.d.ts +2 -0
- package/lib/payment/datatrans-v2/handler-fastify.js +71 -0
- package/lib/payment/datatrans-v2/index.d.ts +1 -4
- package/lib/payment/datatrans-v2/index.js +400 -17
- package/lib/payment/invoice-prepaid.d.ts +1 -0
- package/lib/payment/invoice-prepaid.js +30 -0
- package/lib/payment/invoice.d.ts +1 -0
- package/lib/payment/invoice.js +27 -0
- package/lib/payment/paypal-checkout.d.ts +1 -0
- package/lib/payment/paypal-checkout.js +87 -0
- package/lib/payment/payrexx/handler-express.d.ts +1 -0
- package/lib/payment/payrexx/handler-express.js +85 -0
- package/lib/payment/payrexx/handler-fastify.d.ts +2 -0
- package/lib/payment/payrexx/handler-fastify.js +91 -0
- package/lib/payment/payrexx/index.d.ts +1 -4
- package/lib/payment/payrexx/index.js +158 -19
- package/lib/payment/postfinance-checkout/handler-express.d.ts +1 -0
- package/lib/payment/postfinance-checkout/handler-express.js +37 -0
- package/lib/payment/postfinance-checkout/handler-fastify.d.ts +2 -0
- package/lib/payment/postfinance-checkout/handler-fastify.js +40 -0
- package/lib/payment/postfinance-checkout/index.d.ts +0 -5
- package/lib/payment/postfinance-checkout/index.js +186 -25
- package/lib/payment/saferpay/adapter.js +2 -1
- package/lib/payment/saferpay/handler-express.d.ts +1 -0
- package/lib/payment/saferpay/handler-express.js +59 -0
- package/lib/payment/saferpay/handler-fastify.d.ts +2 -0
- package/lib/payment/saferpay/handler-fastify.js +62 -0
- package/lib/payment/saferpay/index.d.ts +4 -5
- package/lib/payment/saferpay/index.js +3 -29
- package/lib/payment/stripe/handler-express.d.ts +5 -0
- package/lib/payment/stripe/handler-express.js +121 -0
- package/lib/payment/stripe/handler-fastify.d.ts +6 -0
- package/lib/payment/stripe/handler-fastify.js +131 -0
- package/lib/payment/stripe/index.d.ts +1 -4
- package/lib/payment/stripe/index.js +116 -22
- package/lib/payment/stripe/stripe.js +4 -1
- package/lib/presets/all-express.d.ts +6 -0
- package/lib/presets/all-express.js +26 -0
- package/lib/presets/all-fastify.d.ts +6 -0
- package/lib/presets/all-fastify.js +49 -0
- package/lib/presets/all.d.ts +70 -1
- package/lib/presets/all.js +27 -41
- package/lib/presets/base-express.d.ts +2 -0
- package/lib/presets/base-express.js +5 -0
- package/lib/presets/base-fastify.d.ts +3 -0
- package/lib/presets/base-fastify.js +16 -0
- package/lib/presets/base.d.ts +25 -1
- package/lib/presets/base.js +25 -56
- package/lib/presets/countries/ch.d.ts +2 -1
- package/lib/presets/countries/ch.js +2 -7
- package/lib/presets/crypto-express.d.ts +3 -0
- package/lib/presets/crypto-express.js +8 -0
- package/lib/presets/crypto-fastify.d.ts +3 -0
- package/lib/presets/crypto-fastify.js +11 -0
- package/lib/presets/crypto.d.ts +7 -3
- package/lib/presets/crypto.js +7 -18
- package/lib/pricing/delivery-swiss-tax.d.ts +2 -0
- package/lib/pricing/delivery-swiss-tax.js +62 -0
- package/lib/pricing/discount-100-off.d.ts +2 -0
- package/lib/pricing/discount-100-off.js +30 -0
- package/lib/pricing/discount-half-price-manual.d.ts +2 -0
- package/lib/pricing/discount-half-price-manual.js +30 -0
- package/lib/pricing/discount-half-price.d.ts +2 -0
- package/lib/pricing/discount-half-price.js +33 -0
- package/lib/pricing/free-delivery.d.ts +2 -0
- package/lib/pricing/free-delivery.js +27 -0
- package/lib/pricing/free-payment.d.ts +2 -0
- package/lib/pricing/free-payment.js +27 -0
- package/lib/pricing/order-delivery.d.ts +2 -0
- package/lib/pricing/order-delivery.js +33 -0
- package/lib/pricing/order-discount.d.ts +2 -0
- package/lib/pricing/order-discount.js +74 -0
- package/lib/pricing/order-items-discount.d.ts +2 -0
- package/lib/pricing/order-items-discount.js +50 -0
- package/lib/pricing/order-items.d.ts +2 -0
- package/lib/pricing/order-items.js +43 -0
- package/lib/pricing/order-payment.d.ts +2 -0
- package/lib/pricing/order-payment.js +33 -0
- package/lib/pricing/order-round.d.ts +10 -0
- package/lib/pricing/order-round.js +135 -0
- package/lib/pricing/product-catalog-price-options.d.ts +2 -0
- package/lib/pricing/product-catalog-price-options.js +51 -0
- package/lib/pricing/product-catalog-price.d.ts +2 -0
- package/lib/pricing/product-catalog-price.js +60 -0
- package/lib/pricing/product-discount.d.ts +2 -0
- package/lib/pricing/product-discount.js +69 -0
- package/lib/pricing/product-price-rateconversion.d.ts +2 -0
- package/lib/pricing/product-price-rateconversion.js +53 -0
- package/lib/pricing/product-round.d.ts +10 -0
- package/lib/pricing/product-round.js +44 -0
- package/lib/pricing/product-swiss-tax.d.ts +2 -0
- package/lib/pricing/product-swiss-tax.js +76 -0
- package/lib/quotations/manual.d.ts +1 -0
- package/lib/quotations/manual.js +20 -0
- package/lib/warehousing/eth-minter.d.ts +1 -0
- package/lib/warehousing/eth-minter.js +120 -0
- package/lib/warehousing/store.d.ts +1 -0
- package/lib/warehousing/store.js +34 -0
- package/lib/worker/budgetsms.d.ts +9 -0
- package/lib/worker/budgetsms.js +169 -0
- package/lib/worker/bulk-export.d.ts +2 -0
- package/lib/worker/bulk-export.js +64 -0
- package/lib/worker/bulk-import.d.ts +2 -0
- package/lib/worker/bulk-import.js +65 -0
- package/lib/worker/bulkgate.d.ts +1 -0
- package/lib/worker/bulkgate.js +91 -0
- package/lib/worker/email.d.ts +1 -0
- package/lib/worker/email.js +136 -0
- package/lib/worker/enrollment-order-generator.d.ts +1 -0
- package/lib/worker/enrollment-order-generator.js +77 -0
- package/lib/worker/error-notifications.d.ts +9 -0
- package/lib/worker/error-notifications.js +61 -0
- package/lib/worker/export-token.d.ts +4 -0
- package/lib/worker/export-token.js +26 -0
- package/lib/worker/external.d.ts +2 -0
- package/lib/worker/external.js +13 -0
- package/lib/worker/heartbeat.d.ts +1 -0
- package/lib/worker/heartbeat.js +26 -0
- package/lib/worker/http-request.d.ts +8 -0
- package/lib/worker/http-request.js +56 -0
- package/lib/worker/message.d.ts +10 -0
- package/lib/worker/message.js +42 -0
- package/lib/worker/push-notification.d.ts +1 -0
- package/lib/worker/push-notification.js +87 -0
- package/lib/worker/twilio.d.ts +1 -0
- package/lib/worker/twilio.js +59 -0
- package/lib/worker/update-coinbase-rates.d.ts +1 -0
- package/lib/worker/update-coinbase-rates.js +59 -0
- package/lib/worker/update-ecb-rates.d.ts +1 -0
- package/lib/worker/update-ecb-rates.js +92 -0
- package/lib/worker/update-token-ownership.d.ts +3 -0
- package/lib/worker/update-token-ownership.js +57 -0
- package/lib/worker/zombie-killer.d.ts +13 -0
- package/lib/worker/zombie-killer.js +91 -0
- package/package.json +10 -15
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import connectCryptoToFastify from "./crypto-fastify.js";
|
|
2
|
+
import connectBaseToFastify from "./base-fastify.js";
|
|
3
|
+
import { stripeHandler } from "../payment/stripe/handler-fastify.js";
|
|
4
|
+
import { postfinanceCheckoutHandler } from "../payment/postfinance-checkout/handler-fastify.js";
|
|
5
|
+
import { datatransHandler } from "../payment/datatrans-v2/handler-fastify.js";
|
|
6
|
+
import { appleIAPHandler } from "../payment/apple-iap/handler-fastify.js";
|
|
7
|
+
import { payrexxHandler } from "../payment/payrexx/handler-fastify.js";
|
|
8
|
+
import { saferpayHandler } from "../payment/saferpay/handler-fastify.js";
|
|
9
|
+
import { configureGenerateOrderAutoscheduling } from "../worker/enrollment-order-generator.js";
|
|
10
|
+
const { STRIPE_WEBHOOK_PATH = '/payment/stripe', PAYREXX_WEBHOOK_PATH = '/payment/payrexx', PFCHECKOUT_WEBHOOK_PATH = '/payment/postfinance-checkout', DATATRANS_WEBHOOK_PATH = '/payment/datatrans/webhook', APPLE_IAP_WEBHOOK_PATH = '/payment/apple-iap', SAFERPAY_WEBHOOK_PATH = '/payment/saferpay/webhook', } = process.env;
|
|
11
|
+
export default (fastify, { unchainedAPI }) => {
|
|
12
|
+
connectBaseToFastify(fastify);
|
|
13
|
+
connectCryptoToFastify(fastify, unchainedAPI);
|
|
14
|
+
fastify.register((s, opts, registered) => {
|
|
15
|
+
s.addContentTypeParser('application/json', { parseAs: 'string', bodyLimit: 1024 * 1024 }, s.defaultTextParser);
|
|
16
|
+
s.route({
|
|
17
|
+
url: STRIPE_WEBHOOK_PATH,
|
|
18
|
+
method: 'POST',
|
|
19
|
+
handler: stripeHandler,
|
|
20
|
+
});
|
|
21
|
+
s.route({
|
|
22
|
+
url: DATATRANS_WEBHOOK_PATH,
|
|
23
|
+
method: 'POST',
|
|
24
|
+
handler: datatransHandler,
|
|
25
|
+
});
|
|
26
|
+
registered();
|
|
27
|
+
});
|
|
28
|
+
fastify.route({
|
|
29
|
+
url: PFCHECKOUT_WEBHOOK_PATH,
|
|
30
|
+
method: 'POST',
|
|
31
|
+
handler: postfinanceCheckoutHandler,
|
|
32
|
+
});
|
|
33
|
+
fastify.route({
|
|
34
|
+
url: APPLE_IAP_WEBHOOK_PATH,
|
|
35
|
+
method: 'POST',
|
|
36
|
+
handler: appleIAPHandler,
|
|
37
|
+
});
|
|
38
|
+
fastify.route({
|
|
39
|
+
url: PAYREXX_WEBHOOK_PATH,
|
|
40
|
+
method: 'POST',
|
|
41
|
+
handler: payrexxHandler,
|
|
42
|
+
});
|
|
43
|
+
fastify.route({
|
|
44
|
+
url: SAFERPAY_WEBHOOK_PATH,
|
|
45
|
+
method: 'GET',
|
|
46
|
+
handler: saferpayHandler,
|
|
47
|
+
});
|
|
48
|
+
configureGenerateOrderAutoscheduling();
|
|
49
|
+
};
|
package/lib/presets/all.d.ts
CHANGED
|
@@ -1 +1,70 @@
|
|
|
1
|
-
|
|
1
|
+
import './countries/ch.ts';
|
|
2
|
+
import '../delivery/send-message.ts';
|
|
3
|
+
import '../delivery/stores.ts';
|
|
4
|
+
import '../payment/invoice-prepaid.ts';
|
|
5
|
+
import '../payment/paypal-checkout.ts';
|
|
6
|
+
import '../payment/stripe/index.ts';
|
|
7
|
+
import '../payment/postfinance-checkout/index.ts';
|
|
8
|
+
import '../payment/datatrans-v2/index.ts';
|
|
9
|
+
import '../payment/payrexx/index.ts';
|
|
10
|
+
import '../filters/strict-equal.ts';
|
|
11
|
+
import '../filters/local-search.ts';
|
|
12
|
+
import '../worker/twilio.ts';
|
|
13
|
+
import '../worker/bulkgate.ts';
|
|
14
|
+
import '../worker/budgetsms.ts';
|
|
15
|
+
import '../worker/push-notification.ts';
|
|
16
|
+
import '../worker/enrollment-order-generator.ts';
|
|
17
|
+
declare const modules: {
|
|
18
|
+
saferpayTransactions: {
|
|
19
|
+
configure: ({ db }: {
|
|
20
|
+
db: import("mongodb").Db;
|
|
21
|
+
}) => Promise<{
|
|
22
|
+
findTransactionById: (_id: import("bson").ObjectId) => Promise<import("mongodb").WithId<import("../payment/saferpay/db/SaferpayTransactionsCollection.ts").SaferpayTransaction> | null>;
|
|
23
|
+
createTransaction: (orderPaymentId: any) => Promise<import("bson").ObjectId>;
|
|
24
|
+
setToken: (_id: import("bson").ObjectId, token: string) => Promise<void>;
|
|
25
|
+
}>;
|
|
26
|
+
};
|
|
27
|
+
appleTransactions: {
|
|
28
|
+
configure: ({ db }: {
|
|
29
|
+
db: any;
|
|
30
|
+
}) => Promise<{
|
|
31
|
+
findTransactionById: (transactionIdentifier: string) => Promise<import("../payment/apple-iap/db/AppleTransactionsCollection.ts").AppleTransaction | null>;
|
|
32
|
+
createTransaction: (doc: Omit<import("../payment/apple-iap/db/AppleTransactionsCollection.ts").AppleTransaction, "_id" | "created"> & Pick<Partial<import("../payment/apple-iap/db/AppleTransactionsCollection.ts").AppleTransaction>, "_id" | "created">) => Promise<string>;
|
|
33
|
+
}>;
|
|
34
|
+
};
|
|
35
|
+
cryptopay: {
|
|
36
|
+
configure: ({ db }: {
|
|
37
|
+
db: any;
|
|
38
|
+
}) => {
|
|
39
|
+
getWalletAddress: (address: string, contract?: string) => Promise<import("../payment/cryptopay/db/CryptopayTransactions.ts").CryptopayTransaction | null>;
|
|
40
|
+
updateMostRecentBlock: (currencyCode: string, blockHeight: number) => Promise<void>;
|
|
41
|
+
updateWalletAddress: ({ address, blockHeight, amount, contract, currencyCode, decimals, }: {
|
|
42
|
+
address: string;
|
|
43
|
+
blockHeight: number;
|
|
44
|
+
amount: string | number;
|
|
45
|
+
contract?: string;
|
|
46
|
+
currencyCode: string;
|
|
47
|
+
decimals: number;
|
|
48
|
+
}) => Promise<import("../payment/cryptopay/db/CryptopayTransactions.ts").CryptopayTransaction>;
|
|
49
|
+
mapOrderPaymentToWalletAddress: ({ address, contract, currencyCode, orderPaymentId, }: {
|
|
50
|
+
address: string;
|
|
51
|
+
contract?: string;
|
|
52
|
+
currencyCode: string;
|
|
53
|
+
orderPaymentId: string;
|
|
54
|
+
}) => Promise<import("../payment/cryptopay/db/CryptopayTransactions.ts").CryptopayTransaction>;
|
|
55
|
+
getNextDerivationNumber: (currencyCode: string) => Promise<number>;
|
|
56
|
+
getWalletAddressesByOrderPaymentId: (orderPaymentId: string) => Promise<import("../payment/cryptopay/db/CryptopayTransactions.ts").CryptopayTransaction[]>;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
gridfsFileUploads: {
|
|
60
|
+
configure: ({ db }: {
|
|
61
|
+
db: any;
|
|
62
|
+
}) => {
|
|
63
|
+
createWriteStream: (directoryName: any, fileId: any, fileName: any, uploadOptions: import("mongodb").GridFSBucketWriteStream["options"]) => Promise<import("mongodb").GridFSBucketWriteStream>;
|
|
64
|
+
getFileInfo: (directoryName: any, fileId: any) => Promise<import("mongodb").GridFSFile | null>;
|
|
65
|
+
createReadStream: (directoryName: any, fileId: any) => Promise<import("mongodb").GridFSBucketReadStream>;
|
|
66
|
+
removeFileFromBucket: (directoryName: any, fileId: any) => Promise<void>;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export default modules;
|
package/lib/presets/all.js
CHANGED
|
@@ -1,41 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
pluginRegistry.register(PayrexxPlugin);
|
|
29
|
-
pluginRegistry.register(PostfinanceCheckoutPlugin);
|
|
30
|
-
pluginRegistry.register(SaferpayPlugin);
|
|
31
|
-
pluginRegistry.register(InvoicePrepaidPlugin);
|
|
32
|
-
pluginRegistry.register(SendMessagePlugin);
|
|
33
|
-
pluginRegistry.register(PickMupPlugin);
|
|
34
|
-
pluginRegistry.register(StrictQualFilterPlugin);
|
|
35
|
-
pluginRegistry.register(LocalSearchPlugin);
|
|
36
|
-
pluginRegistry.register(TwilioPlugin);
|
|
37
|
-
pluginRegistry.register(BulkGatePlugin);
|
|
38
|
-
pluginRegistry.register(BudgetSMSPlugin);
|
|
39
|
-
pluginRegistry.register(PushNotificationPlugin);
|
|
40
|
-
pluginRegistry.register(EnrollmentOrderGeneratorPlugin);
|
|
41
|
-
}
|
|
1
|
+
import baseModules from "./base.js";
|
|
2
|
+
import "./countries/ch.js";
|
|
3
|
+
import cryptoModules from "./crypto.js";
|
|
4
|
+
import "../delivery/send-message.js";
|
|
5
|
+
import "../delivery/stores.js";
|
|
6
|
+
import "../payment/invoice-prepaid.js";
|
|
7
|
+
import "../payment/paypal-checkout.js";
|
|
8
|
+
import appleTransactionsModules from "../payment/apple-iap/index.js";
|
|
9
|
+
import saferpayTransactionsModules from "../payment/saferpay/index.js";
|
|
10
|
+
import "../payment/stripe/index.js";
|
|
11
|
+
import "../payment/postfinance-checkout/index.js";
|
|
12
|
+
import "../payment/datatrans-v2/index.js";
|
|
13
|
+
import "../payment/payrexx/index.js";
|
|
14
|
+
import "../filters/strict-equal.js";
|
|
15
|
+
import "../filters/local-search.js";
|
|
16
|
+
import "../worker/twilio.js";
|
|
17
|
+
import "../worker/bulkgate.js";
|
|
18
|
+
import "../worker/budgetsms.js";
|
|
19
|
+
import "../worker/push-notification.js";
|
|
20
|
+
import "../worker/enrollment-order-generator.js";
|
|
21
|
+
const modules = {
|
|
22
|
+
...baseModules,
|
|
23
|
+
...cryptoModules,
|
|
24
|
+
...appleTransactionsModules,
|
|
25
|
+
...saferpayTransactionsModules,
|
|
26
|
+
};
|
|
27
|
+
export default modules;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import handler from "../files/gridfs/handler-fastify.js";
|
|
2
|
+
const { GRIDFS_PUT_SERVER_PATH = '/gridfs' } = process.env;
|
|
3
|
+
export default (fastify) => {
|
|
4
|
+
fastify.register((s, opts, registered) => {
|
|
5
|
+
s.removeAllContentTypeParsers();
|
|
6
|
+
s.addContentTypeParser('*', function (req, payload, done) {
|
|
7
|
+
done(null);
|
|
8
|
+
});
|
|
9
|
+
s.route({
|
|
10
|
+
url: GRIDFS_PUT_SERVER_PATH + '/:directoryName/:fileName',
|
|
11
|
+
method: ['GET', 'PUT', 'OPTIONS'],
|
|
12
|
+
handler,
|
|
13
|
+
});
|
|
14
|
+
registered();
|
|
15
|
+
});
|
|
16
|
+
};
|
package/lib/presets/base.d.ts
CHANGED
|
@@ -1 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
import '../delivery/post.ts';
|
|
2
|
+
import '../payment/invoice.ts';
|
|
3
|
+
import '../warehousing/store.ts';
|
|
4
|
+
import '../pricing/free-payment.ts';
|
|
5
|
+
import '../pricing/free-delivery.ts';
|
|
6
|
+
import '../pricing/order-items.ts';
|
|
7
|
+
import '../pricing/order-discount.ts';
|
|
8
|
+
import '../pricing/order-delivery.ts';
|
|
9
|
+
import '../pricing/order-payment.ts';
|
|
10
|
+
import '../pricing/product-catalog-price.ts';
|
|
11
|
+
import '../pricing/product-discount.ts';
|
|
12
|
+
import '../quotations/manual.ts';
|
|
13
|
+
import '../enrollments/licensed.ts';
|
|
14
|
+
import '../events/node-event-emitter.ts';
|
|
15
|
+
import '../worker/bulk-import.ts';
|
|
16
|
+
import '../worker/zombie-killer.ts';
|
|
17
|
+
import '../worker/message.ts';
|
|
18
|
+
import '../worker/external.ts';
|
|
19
|
+
import '../worker/http-request.ts';
|
|
20
|
+
import '../worker/heartbeat.ts';
|
|
21
|
+
import '../worker/email.ts';
|
|
22
|
+
import '../worker/error-notifications.ts';
|
|
23
|
+
import '../worker/bulk-export.ts';
|
|
24
|
+
import gridfsModules from '../files/gridfs/index.ts';
|
|
25
|
+
export default gridfsModules;
|
package/lib/presets/base.js
CHANGED
|
@@ -1,56 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
|
|
26
|
-
import { EmailPlugin } from "../worker/email/index.js";
|
|
27
|
-
import { ErrorNotificationsPlugin } from "../worker/error-notifications/index.js";
|
|
28
|
-
import { BulkExportPlugin } from "../worker/bulk-export/index.js";
|
|
29
|
-
export function registerBasePlugins() {
|
|
30
|
-
pluginRegistry.register(GridFSPlugin);
|
|
31
|
-
pluginRegistry.register(TempUploadPlugin);
|
|
32
|
-
pluginRegistry.register(InvoicePlugin);
|
|
33
|
-
pluginRegistry.register(PostPlugin);
|
|
34
|
-
pluginRegistry.register(StorePlugin);
|
|
35
|
-
pluginRegistry.register(ERCMetadataPlugin);
|
|
36
|
-
pluginRegistry.register(PaymentFreePricePlugin);
|
|
37
|
-
pluginRegistry.register(DeliveryFreePricePlugin);
|
|
38
|
-
pluginRegistry.register(OrderItemsPlugin);
|
|
39
|
-
pluginRegistry.register(OrderDiscountPlugin);
|
|
40
|
-
pluginRegistry.register(OrderDeliveryPlugin);
|
|
41
|
-
pluginRegistry.register(OrderPaymentPlugin);
|
|
42
|
-
pluginRegistry.register(ProductPricePlugin);
|
|
43
|
-
pluginRegistry.register(ProductDiscountPlugin);
|
|
44
|
-
pluginRegistry.register(ManualOfferingPlugin);
|
|
45
|
-
pluginRegistry.register(LicensedEnrollmentsPlugin);
|
|
46
|
-
setEmitAdapter(NodeEventEmitter());
|
|
47
|
-
pluginRegistry.register(BulkImportPlugin);
|
|
48
|
-
pluginRegistry.register(ZombieKillerPlugin);
|
|
49
|
-
pluginRegistry.register(MessagePlugin);
|
|
50
|
-
pluginRegistry.register(ExternalPlugin);
|
|
51
|
-
pluginRegistry.register(HttpRequestPlugin);
|
|
52
|
-
pluginRegistry.register(HeartbeatPlugin);
|
|
53
|
-
pluginRegistry.register(EmailPlugin);
|
|
54
|
-
pluginRegistry.register(ErrorNotificationsPlugin);
|
|
55
|
-
pluginRegistry.register(BulkExportPlugin);
|
|
56
|
-
}
|
|
1
|
+
import "../delivery/post.js";
|
|
2
|
+
import "../payment/invoice.js";
|
|
3
|
+
import "../warehousing/store.js";
|
|
4
|
+
import "../pricing/free-payment.js";
|
|
5
|
+
import "../pricing/free-delivery.js";
|
|
6
|
+
import "../pricing/order-items.js";
|
|
7
|
+
import "../pricing/order-discount.js";
|
|
8
|
+
import "../pricing/order-delivery.js";
|
|
9
|
+
import "../pricing/order-payment.js";
|
|
10
|
+
import "../pricing/product-catalog-price.js";
|
|
11
|
+
import "../pricing/product-discount.js";
|
|
12
|
+
import "../quotations/manual.js";
|
|
13
|
+
import "../enrollments/licensed.js";
|
|
14
|
+
import "../events/node-event-emitter.js";
|
|
15
|
+
import "../worker/bulk-import.js";
|
|
16
|
+
import "../worker/zombie-killer.js";
|
|
17
|
+
import "../worker/message.js";
|
|
18
|
+
import "../worker/external.js";
|
|
19
|
+
import "../worker/http-request.js";
|
|
20
|
+
import "../worker/heartbeat.js";
|
|
21
|
+
import "../worker/email.js";
|
|
22
|
+
import "../worker/error-notifications.js";
|
|
23
|
+
import "../worker/bulk-export.js";
|
|
24
|
+
import gridfsModules from "../files/gridfs/index.js";
|
|
25
|
+
export default gridfsModules;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import '../../pricing/product-swiss-tax.ts';
|
|
2
|
+
import '../../pricing/delivery-swiss-tax.ts';
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { pluginRegistry } from '@unchainedshop/core';
|
|
4
|
-
export function registerSwissTaxPlugins() {
|
|
5
|
-
pluginRegistry.register(ProductSwissTaxPlugin);
|
|
6
|
-
pluginRegistry.register(DeliverySwissTaxPlugin);
|
|
7
|
-
}
|
|
1
|
+
import "../../pricing/product-swiss-tax.js";
|
|
2
|
+
import "../../pricing/delivery-swiss-tax.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import handler from "../payment/cryptopay/handler-express.js";
|
|
3
|
+
import { configureExportToken } from "../worker/export-token.js";
|
|
4
|
+
const { CRYPTOPAY_WEBHOOK_PATH = '/payment/cryptopay' } = process.env;
|
|
5
|
+
export default (app, unchainedAPI) => {
|
|
6
|
+
app.use(CRYPTOPAY_WEBHOOK_PATH, express.json(), handler);
|
|
7
|
+
configureExportToken(unchainedAPI);
|
|
8
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import handler from "../payment/cryptopay/handler-fastify.js";
|
|
2
|
+
import { configureExportToken } from "../worker/export-token.js";
|
|
3
|
+
const { CRYPTOPAY_WEBHOOK_PATH = '/payment/cryptopay' } = process.env;
|
|
4
|
+
export default (fastify, unchainedAPI) => {
|
|
5
|
+
fastify.route({
|
|
6
|
+
url: CRYPTOPAY_WEBHOOK_PATH,
|
|
7
|
+
method: 'POST',
|
|
8
|
+
handler,
|
|
9
|
+
});
|
|
10
|
+
configureExportToken(unchainedAPI);
|
|
11
|
+
};
|
package/lib/presets/crypto.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import cryptopayModules from '../payment/cryptopay/index.ts';
|
|
2
|
+
import '../warehousing/eth-minter.ts';
|
|
3
|
+
import '../pricing/product-price-rateconversion.ts';
|
|
4
|
+
import '../worker/update-ecb-rates.ts';
|
|
5
|
+
import '../worker/update-coinbase-rates.ts';
|
|
6
|
+
import '../worker/export-token.ts';
|
|
7
|
+
export default cryptopayModules;
|
package/lib/presets/crypto.js
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
import { UpdateTokenOwnershipPlugin } from "../worker/update-token-ownership/index.js";
|
|
9
|
-
export default {};
|
|
10
|
-
export function registerCryptoPlugins() {
|
|
11
|
-
pluginRegistry.register(CryptopayPlugin);
|
|
12
|
-
pluginRegistry.register(ETHMinterPlugin);
|
|
13
|
-
pluginRegistry.register(ProductPriceRateConversionPlugin);
|
|
14
|
-
pluginRegistry.register(ExportTokenPlugin);
|
|
15
|
-
pluginRegistry.register(UpdateECBRatesPlugin);
|
|
16
|
-
pluginRegistry.register(UpdateCoinbaseRatesPlugin);
|
|
17
|
-
pluginRegistry.register(UpdateTokenOwnershipPlugin);
|
|
18
|
-
}
|
|
1
|
+
import cryptopayModules from "../payment/cryptopay/index.js";
|
|
2
|
+
import "../warehousing/eth-minter.js";
|
|
3
|
+
import "../pricing/product-price-rateconversion.js";
|
|
4
|
+
import "../worker/update-ecb-rates.js";
|
|
5
|
+
import "../worker/update-coinbase-rates.js";
|
|
6
|
+
import "../worker/export-token.js";
|
|
7
|
+
export default cryptopayModules;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { DeliveryPricingRowCategory, DeliveryPricingAdapter, DeliveryPricingDirector, } from '@unchainedshop/core';
|
|
2
|
+
import { resolveTaxCategoryFromDeliveryProvider, SwissTaxCategories } from "./tax/ch.js";
|
|
3
|
+
import isDeliveryAddressInCountry from "./utils/isDeliveryAddressInCountry.js";
|
|
4
|
+
export const DeliverySwissTax = {
|
|
5
|
+
...DeliveryPricingAdapter,
|
|
6
|
+
key: 'shop.unchained.pricing.delivery-swiss-tax',
|
|
7
|
+
version: '1.0.0',
|
|
8
|
+
label: 'Apply Swiss Tax on Delivery Fees',
|
|
9
|
+
orderIndex: 80,
|
|
10
|
+
isActivatedFor: (context) => {
|
|
11
|
+
if (!context.order)
|
|
12
|
+
return false;
|
|
13
|
+
if (!context.orderDelivery)
|
|
14
|
+
return false;
|
|
15
|
+
return isDeliveryAddressInCountry({
|
|
16
|
+
order: context.order,
|
|
17
|
+
orderDelivery: context.orderDelivery,
|
|
18
|
+
countryCode: context.countryCode,
|
|
19
|
+
}, ['CH', 'LI']);
|
|
20
|
+
},
|
|
21
|
+
actions: (params) => {
|
|
22
|
+
const pricingAdapter = DeliveryPricingAdapter.actions(params);
|
|
23
|
+
const { context } = params;
|
|
24
|
+
return {
|
|
25
|
+
...pricingAdapter,
|
|
26
|
+
calculate: async () => {
|
|
27
|
+
const taxCategory = resolveTaxCategoryFromDeliveryProvider(context.provider) || SwissTaxCategories.DEFAULT;
|
|
28
|
+
const taxRate = taxCategory.rate(context.order?.ordered);
|
|
29
|
+
DeliveryPricingAdapter.log(`DeliverySwissTax -> Tax Multiplicator: ${taxRate}`);
|
|
30
|
+
params.calculationSheet.filterBy({ isTaxable: true }).forEach(({ isNetPrice, ...row }) => {
|
|
31
|
+
if (!isNetPrice) {
|
|
32
|
+
const taxAmount = row.amount - row.amount / (1 + taxRate);
|
|
33
|
+
pricingAdapter.resultSheet().calculation.push({
|
|
34
|
+
...row,
|
|
35
|
+
amount: -taxAmount,
|
|
36
|
+
isTaxable: false,
|
|
37
|
+
isNetPrice: false,
|
|
38
|
+
meta: { adapter: DeliverySwissTax.key },
|
|
39
|
+
});
|
|
40
|
+
pricingAdapter.resultSheet().addTax({
|
|
41
|
+
amount: taxAmount,
|
|
42
|
+
rate: taxRate,
|
|
43
|
+
baseCategory: DeliveryPricingRowCategory.Delivery,
|
|
44
|
+
meta: { adapter: DeliverySwissTax.key },
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const taxAmount = row.amount * taxRate;
|
|
49
|
+
pricingAdapter.resultSheet().addTax({
|
|
50
|
+
amount: taxAmount,
|
|
51
|
+
rate: taxRate,
|
|
52
|
+
baseCategory: DeliveryPricingRowCategory.Delivery,
|
|
53
|
+
meta: { adapter: DeliverySwissTax.key },
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return pricingAdapter.calculate();
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
DeliveryPricingDirector.registerAdapter(DeliverySwissTax);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { OrderDiscountDirector, OrderDiscountAdapter, } from '@unchainedshop/core';
|
|
2
|
+
export const HundredOff = {
|
|
3
|
+
...OrderDiscountAdapter,
|
|
4
|
+
key: 'shop.unchained.discount.100-off',
|
|
5
|
+
label: '100 Off',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
orderIndex: 10,
|
|
8
|
+
isManualAdditionAllowed: async () => {
|
|
9
|
+
return true;
|
|
10
|
+
},
|
|
11
|
+
isManualRemovalAllowed: async () => {
|
|
12
|
+
return true;
|
|
13
|
+
},
|
|
14
|
+
actions: async ({ context }) => ({
|
|
15
|
+
...(await OrderDiscountAdapter.actions({ context })),
|
|
16
|
+
isValidForSystemTriggering: async () => {
|
|
17
|
+
return false;
|
|
18
|
+
},
|
|
19
|
+
isValidForCodeTriggering: async ({ code }) => {
|
|
20
|
+
return code.toUpperCase() === '100OFF';
|
|
21
|
+
},
|
|
22
|
+
discountForPricingAdapterKey: ({ pricingAdapterKey }) => {
|
|
23
|
+
if (pricingAdapterKey === 'shop.unchained.pricing.order-discount') {
|
|
24
|
+
return { fixedRate: 10000 };
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
OrderDiscountDirector.registerAdapter(HundredOff);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { OrderDiscountDirector, OrderDiscountAdapter, } from '@unchainedshop/core';
|
|
2
|
+
export const HalfPriceManual = {
|
|
3
|
+
...OrderDiscountAdapter,
|
|
4
|
+
key: 'shop.unchained.discount.half-price-manual',
|
|
5
|
+
label: 'Half Price Manual',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
orderIndex: 10,
|
|
8
|
+
isManualAdditionAllowed: async () => {
|
|
9
|
+
return true;
|
|
10
|
+
},
|
|
11
|
+
isManualRemovalAllowed: async () => {
|
|
12
|
+
return true;
|
|
13
|
+
},
|
|
14
|
+
actions: async ({ context }) => ({
|
|
15
|
+
...(await OrderDiscountAdapter.actions({ context })),
|
|
16
|
+
isValidForSystemTriggering: async () => {
|
|
17
|
+
return false;
|
|
18
|
+
},
|
|
19
|
+
isValidForCodeTriggering: async ({ code }) => {
|
|
20
|
+
return code === 'HALFPRICE';
|
|
21
|
+
},
|
|
22
|
+
discountForPricingAdapterKey({ pricingAdapterKey }) {
|
|
23
|
+
if (pricingAdapterKey === 'shop.unchained.pricing.product-discount') {
|
|
24
|
+
return { rate: 0.5 };
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
OrderDiscountDirector.registerAdapter(HalfPriceManual);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { OrderDiscountDirector, OrderDiscountAdapter, } from '@unchainedshop/core';
|
|
2
|
+
export const HalfPrice = {
|
|
3
|
+
...OrderDiscountAdapter,
|
|
4
|
+
key: 'shop.unchained.discount.half-price',
|
|
5
|
+
label: 'Half Price',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
orderIndex: 10,
|
|
8
|
+
isManualAdditionAllowed: async () => {
|
|
9
|
+
return false;
|
|
10
|
+
},
|
|
11
|
+
isManualRemovalAllowed: async () => {
|
|
12
|
+
return false;
|
|
13
|
+
},
|
|
14
|
+
actions: async ({ context }) => ({
|
|
15
|
+
...(await OrderDiscountAdapter.actions({ context })),
|
|
16
|
+
isValidForSystemTriggering: async () => {
|
|
17
|
+
const { order } = context;
|
|
18
|
+
const user = await context.modules.users.findUserById(order.userId);
|
|
19
|
+
const isUserEligibleForHalfPrice = user?.tags && user.tags.indexOf('half-price') !== -1;
|
|
20
|
+
return !!isUserEligibleForHalfPrice;
|
|
21
|
+
},
|
|
22
|
+
isValidForCodeTriggering: async () => {
|
|
23
|
+
return false;
|
|
24
|
+
},
|
|
25
|
+
discountForPricingAdapterKey({ pricingAdapterKey }) {
|
|
26
|
+
if (pricingAdapterKey === 'shop.unchained.pricing.product-discount') {
|
|
27
|
+
return { rate: 0.5 };
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
33
|
+
OrderDiscountDirector.registerAdapter(HalfPrice);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DeliveryPricingAdapter, DeliveryPricingDirector, } from '@unchainedshop/core';
|
|
2
|
+
export const DeliveryFreePrice = {
|
|
3
|
+
...DeliveryPricingAdapter,
|
|
4
|
+
key: 'shop.unchained.pricing.delivery-free',
|
|
5
|
+
label: 'Free Delivery',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
orderIndex: 0,
|
|
8
|
+
isActivatedFor: () => {
|
|
9
|
+
return true;
|
|
10
|
+
},
|
|
11
|
+
actions: (params) => {
|
|
12
|
+
const pricingAdapter = DeliveryPricingAdapter.actions(params);
|
|
13
|
+
return {
|
|
14
|
+
...pricingAdapter,
|
|
15
|
+
calculate: async () => {
|
|
16
|
+
pricingAdapter.resultSheet().addFee({
|
|
17
|
+
amount: 0,
|
|
18
|
+
isTaxable: false,
|
|
19
|
+
isNetPrice: false,
|
|
20
|
+
meta: { adapter: DeliveryFreePrice.key },
|
|
21
|
+
});
|
|
22
|
+
return pricingAdapter.calculate();
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
DeliveryPricingDirector.registerAdapter(DeliveryFreePrice);
|