@unchainedshop/plugins 1.1.3 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/delivery/pick-mup.d.ts +1 -0
- package/lib/delivery/pick-mup.js +98 -0
- package/lib/delivery/pick-mup.js.map +1 -0
- package/lib/delivery/post.d.ts +1 -0
- package/lib/delivery/post.js +23 -0
- package/lib/delivery/post.js.map +1 -0
- package/lib/delivery/send-message.d.ts +1 -0
- package/lib/delivery/send-message.js +41 -0
- package/lib/delivery/send-message.js.map +1 -0
- package/lib/delivery/stores.d.ts +1 -0
- package/lib/delivery/stores.js +39 -0
- package/lib/delivery/stores.js.map +1 -0
- package/lib/enrollments/licensed.d.ts +1 -0
- package/lib/enrollments/licensed.js +40 -0
- package/lib/enrollments/licensed.js.map +1 -0
- package/lib/files/gridfs/gridfs-adapter.js +1 -1
- package/lib/files/gridfs/gridfs-adapter.js.map +1 -1
- package/lib/files/gridfs/gridfs-webhook.js +2 -2
- package/lib/files/gridfs/gridfs-webhook.js.map +1 -1
- package/lib/files/minio/minio-webhook.js +1 -1
- package/lib/files/minio/minio-webhook.js.map +1 -1
- package/lib/filters/local-search.d.ts +3 -0
- package/lib/filters/local-search.js +84 -0
- package/lib/filters/local-search.js.map +1 -0
- package/lib/filters/strict-equal.d.ts +1 -0
- package/lib/filters/strict-equal.js +25 -0
- package/lib/filters/strict-equal.js.map +1 -0
- package/lib/payment/apple-iap/adapter.d.ts +1 -0
- package/lib/payment/apple-iap/adapter.js +284 -0
- package/lib/payment/apple-iap/adapter.js.map +1 -0
- package/lib/payment/apple-iap/db/AppleTransactionsCollection.d.ts +7 -0
- package/lib/payment/apple-iap/db/AppleTransactionsCollection.js +5 -0
- package/lib/payment/apple-iap/db/AppleTransactionsCollection.js.map +1 -0
- package/lib/payment/apple-iap/index.d.ts +2 -0
- package/lib/payment/apple-iap/index.js +3 -0
- package/lib/payment/apple-iap/index.js.map +1 -0
- package/lib/payment/apple-iap/module/configureAppleTransactionsModule.d.ts +9 -0
- package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js +18 -0
- package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js.map +1 -0
- package/lib/payment/bity/adapter.d.ts +1 -0
- package/lib/payment/bity/adapter.js +316 -0
- package/lib/payment/bity/adapter.js.map +1 -0
- package/lib/payment/bity/db/BityCredentialsCollection.d.ts +11 -0
- package/lib/payment/bity/db/BityCredentialsCollection.js +5 -0
- package/lib/payment/bity/db/BityCredentialsCollection.js.map +1 -0
- package/lib/payment/bity/index.d.ts +2 -0
- package/lib/payment/bity/index.js +3 -0
- package/lib/payment/bity/index.js.map +1 -0
- package/lib/payment/bity/module/configureBityModule.d.ts +11 -0
- package/lib/payment/bity/module/configureBityModule.js +33 -0
- package/lib/payment/bity/module/configureBityModule.js.map +1 -0
- package/lib/payment/braintree.d.ts +1 -0
- package/lib/payment/braintree.js +129 -0
- package/lib/payment/braintree.js.map +1 -0
- package/lib/payment/cryptopay.d.ts +1 -0
- package/lib/payment/cryptopay.js +159 -0
- package/lib/payment/cryptopay.js.map +1 -0
- package/lib/payment/datatrans-v2/api/authorize.d.ts +2 -0
- package/lib/payment/datatrans-v2/api/authorize.js +12 -0
- package/lib/payment/datatrans-v2/api/authorize.js.map +1 -0
- package/lib/payment/datatrans-v2/api/authorizeAuthenticated.d.ts +2 -0
- package/lib/payment/datatrans-v2/api/authorizeAuthenticated.js +11 -0
- package/lib/payment/datatrans-v2/api/authorizeAuthenticated.js.map +1 -0
- package/lib/payment/datatrans-v2/api/cancel.d.ts +2 -0
- package/lib/payment/datatrans-v2/api/cancel.js +10 -0
- package/lib/payment/datatrans-v2/api/cancel.js.map +1 -0
- package/lib/payment/datatrans-v2/api/index.d.ts +19 -0
- package/lib/payment/datatrans-v2/api/index.js +24 -0
- package/lib/payment/datatrans-v2/api/index.js.map +1 -0
- package/lib/payment/datatrans-v2/api/init.d.ts +2 -0
- package/lib/payment/datatrans-v2/api/init.js +31 -0
- package/lib/payment/datatrans-v2/api/init.js.map +1 -0
- package/lib/payment/datatrans-v2/api/makeFetcher.d.ts +2 -0
- package/lib/payment/datatrans-v2/api/makeFetcher.js +41 -0
- package/lib/payment/datatrans-v2/api/makeFetcher.js.map +1 -0
- package/lib/payment/datatrans-v2/api/secureFields.d.ts +2 -0
- package/lib/payment/datatrans-v2/api/secureFields.js +14 -0
- package/lib/payment/datatrans-v2/api/secureFields.js.map +1 -0
- package/lib/payment/datatrans-v2/api/settle.d.ts +2 -0
- package/lib/payment/datatrans-v2/api/settle.js +10 -0
- package/lib/payment/datatrans-v2/api/settle.js.map +1 -0
- package/lib/payment/datatrans-v2/api/status.d.ts +2 -0
- package/lib/payment/datatrans-v2/api/status.js +7 -0
- package/lib/payment/datatrans-v2/api/status.js.map +1 -0
- package/lib/payment/datatrans-v2/api/validate.d.ts +2 -0
- package/lib/payment/datatrans-v2/api/validate.js +10 -0
- package/lib/payment/datatrans-v2/api/validate.js.map +1 -0
- package/lib/payment/datatrans-v2/generateSignature.d.ts +10 -0
- package/lib/payment/datatrans-v2/generateSignature.js +19 -0
- package/lib/payment/datatrans-v2/generateSignature.js.map +1 -0
- package/lib/payment/datatrans-v2/getPaths.d.ts +9 -0
- package/lib/payment/datatrans-v2/getPaths.js +9 -0
- package/lib/payment/datatrans-v2/getPaths.js.map +1 -0
- package/lib/payment/datatrans-v2/index.d.ts +1 -0
- package/lib/payment/datatrans-v2/index.js +384 -0
- package/lib/payment/datatrans-v2/index.js.map +1 -0
- package/lib/payment/datatrans-v2/middleware.d.ts +1 -0
- package/lib/payment/datatrans-v2/middleware.js +111 -0
- package/lib/payment/datatrans-v2/middleware.js.map +1 -0
- package/lib/payment/datatrans-v2/parseRegistrationData.d.ts +11 -0
- package/lib/payment/datatrans-v2/parseRegistrationData.js +26 -0
- package/lib/payment/datatrans-v2/parseRegistrationData.js.map +1 -0
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts +7 -0
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.js +10 -0
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.js.map +1 -0
- package/lib/payment/datatrans-v2/splitProperties.d.ts +8 -0
- package/lib/payment/datatrans-v2/splitProperties.js +58 -0
- package/lib/payment/datatrans-v2/splitProperties.js.map +1 -0
- package/lib/payment/invoice-prepaid.d.ts +1 -0
- package/lib/payment/invoice-prepaid.js +30 -0
- package/lib/payment/invoice-prepaid.js.map +1 -0
- package/lib/payment/invoice.d.ts +1 -0
- package/lib/payment/invoice.js +27 -0
- package/lib/payment/invoice.js.map +1 -0
- package/lib/payment/paypal-checkout.d.ts +1 -0
- package/lib/payment/paypal-checkout.js +82 -0
- package/lib/payment/paypal-checkout.js.map +1 -0
- package/lib/payment/postfinance-checkout/api.d.ts +11 -0
- package/lib/payment/postfinance-checkout/api.js +109 -0
- package/lib/payment/postfinance-checkout/api.js.map +1 -0
- package/lib/payment/postfinance-checkout/index.d.ts +1 -0
- package/lib/payment/postfinance-checkout/index.js +186 -0
- package/lib/payment/postfinance-checkout/index.js.map +1 -0
- package/lib/payment/postfinance-checkout/middleware.d.ts +1 -0
- package/lib/payment/postfinance-checkout/middleware.js +42 -0
- package/lib/payment/postfinance-checkout/middleware.js.map +1 -0
- package/lib/payment/postfinance-checkout/types.d.ts +23 -0
- package/lib/payment/postfinance-checkout/types.js +12 -0
- package/lib/payment/postfinance-checkout/types.js.map +1 -0
- package/lib/payment/postfinance-checkout/utils.d.ts +4 -0
- package/lib/payment/postfinance-checkout/utils.js +20 -0
- package/lib/payment/postfinance-checkout/utils.js.map +1 -0
- package/lib/payment/stripe.d.ts +1 -0
- package/lib/payment/stripe.js +214 -0
- package/lib/payment/stripe.js.map +1 -0
- package/lib/payment/worldline-saferpay/index.d.ts +1 -0
- package/lib/payment/worldline-saferpay/index.js +112 -0
- package/lib/payment/worldline-saferpay/index.js.map +1 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.d.ts +14 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.js +29 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.js.map +1 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayConnection.d.ts +9 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayConnection.js +28 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayConnection.js.map +1 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.d.ts +4 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.js +2 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.js.map +1 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentMethods.d.ts +1 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentMethods.js +2 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentMethods.js.map +1 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.d.ts +73 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.js +2 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.js.map +1 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.d.ts +53 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.js +2 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.js.map +1 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Request.d.ts +13 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Request.js +2 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Request.js.map +1 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Response.d.ts +9 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Response.js +2 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Response.js.map +1 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Transaction.d.ts +5 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Transaction.js +2 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Transaction.js.map +1 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.d.ts +13 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.js +2 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.js.map +1 -0
- package/lib/pricing/delivery-swiss-tax.d.ts +15 -0
- package/lib/pricing/delivery-swiss-tax.js +98 -0
- package/lib/pricing/delivery-swiss-tax.js.map +1 -0
- package/lib/pricing/discount-100-off.d.ts +1 -0
- package/lib/pricing/discount-100-off.js +34 -0
- package/lib/pricing/discount-100-off.js.map +1 -0
- package/lib/pricing/discount-half-price-manual.d.ts +1 -0
- package/lib/pricing/discount-half-price-manual.js +34 -0
- package/lib/pricing/discount-half-price-manual.js.map +1 -0
- package/lib/pricing/discount-half-price.d.ts +1 -0
- package/lib/pricing/discount-half-price.js +37 -0
- package/lib/pricing/discount-half-price.js.map +1 -0
- package/lib/pricing/free-delivery.d.ts +2 -0
- package/lib/pricing/free-delivery.js +26 -0
- package/lib/pricing/free-delivery.js.map +1 -0
- package/lib/pricing/free-payment.d.ts +2 -0
- package/lib/pricing/free-payment.js +26 -0
- package/lib/pricing/free-payment.js.map +1 -0
- package/lib/pricing/order-delivery.d.ts +1 -0
- package/lib/pricing/order-delivery.js +33 -0
- package/lib/pricing/order-delivery.js.map +1 -0
- package/lib/pricing/order-discount.d.ts +1 -0
- package/lib/pricing/order-discount.js +110 -0
- package/lib/pricing/order-discount.js.map +1 -0
- package/lib/pricing/order-items-discount.d.ts +1 -0
- package/lib/pricing/order-items-discount.js +88 -0
- package/lib/pricing/order-items-discount.js.map +1 -0
- package/lib/pricing/order-items.d.ts +1 -0
- package/lib/pricing/order-items.js +44 -0
- package/lib/pricing/order-items.js.map +1 -0
- package/lib/pricing/order-payment.d.ts +1 -0
- package/lib/pricing/order-payment.js +33 -0
- package/lib/pricing/order-payment.js.map +1 -0
- package/lib/pricing/product-catalog-price.d.ts +1 -0
- package/lib/pricing/product-catalog-price.js +37 -0
- package/lib/pricing/product-catalog-price.js.map +1 -0
- package/lib/pricing/product-discount.d.ts +1 -0
- package/lib/pricing/product-discount.js +55 -0
- package/lib/pricing/product-discount.js.map +1 -0
- package/lib/pricing/product-price-ECB-interbank-exchange.d.ts +1 -0
- package/lib/pricing/product-price-ECB-interbank-exchange.js +90 -0
- package/lib/pricing/product-price-ECB-interbank-exchange.js.map +1 -0
- package/lib/pricing/product-price-coinbase-exchange.d.ts +1 -0
- package/lib/pricing/product-price-coinbase-exchange.js +60 -0
- package/lib/pricing/product-price-coinbase-exchange.js.map +1 -0
- package/lib/pricing/product-price-cryptopay.d.ts +1 -0
- package/lib/pricing/product-price-cryptopay.js +21 -0
- package/lib/pricing/product-price-cryptopay.js.map +1 -0
- package/lib/pricing/product-price-rateconversion.d.ts +1 -0
- package/lib/pricing/product-price-rateconversion.js +51 -0
- package/lib/pricing/product-price-rateconversion.js.map +1 -0
- package/lib/pricing/product-price-round.d.ts +11 -0
- package/lib/pricing/product-price-round.js +54 -0
- package/lib/pricing/product-price-round.js.map +1 -0
- package/lib/pricing/product-swiss-tax.d.ts +13 -0
- package/lib/pricing/product-swiss-tax.js +102 -0
- package/lib/pricing/product-swiss-tax.js.map +1 -0
- package/lib/pricing/utils/cache.d.ts +8 -0
- package/lib/pricing/utils/cache.js +28 -0
- package/lib/pricing/utils/cache.js.map +1 -0
- package/lib/quotations/manual.d.ts +1 -0
- package/lib/quotations/manual.js +21 -0
- package/lib/quotations/manual.js.map +1 -0
- package/lib/warehousing/google-sheets.d.ts +1 -0
- package/lib/warehousing/google-sheets.js +153 -0
- package/lib/warehousing/google-sheets.js.map +1 -0
- package/lib/warehousing/store.d.ts +1 -0
- package/lib/warehousing/store.js +33 -0
- package/lib/warehousing/store.js.map +1 -0
- package/lib/worker/BulkImportWorker.js +3 -3
- package/lib/worker/BulkImportWorker.js.map +1 -1
- package/lib/worker/GenerateOrderWorker.js +1 -1
- package/lib/worker/GenerateOrderWorker.js.map +1 -1
- package/lib/worker/ZombieKillerWorker.js.map +1 -1
- package/lib/worker/email.js +55 -4
- package/lib/worker/email.js.map +1 -1
- package/license +274 -0
- package/package.json +29 -12
- package/src/delivery/pick-mup.ts +119 -0
- package/src/delivery/post.ts +30 -0
- package/src/delivery/send-message.ts +54 -0
- package/src/delivery/stores.ts +49 -0
- package/src/enrollments/licensed.ts +49 -0
- package/src/files/gridfs/gridfs-adapter.ts +1 -1
- package/src/files/gridfs/gridfs-webhook.js +2 -2
- package/src/files/minio/minio-webhook.js +1 -1
- package/src/filters/local-search.ts +105 -0
- package/src/filters/strict-equal.ts +31 -0
- package/src/payment/apple-iap/adapter.ts +390 -0
- package/src/payment/apple-iap/db/AppleTransactionsCollection.ts +13 -0
- package/src/payment/apple-iap/index.ts +3 -0
- package/src/payment/apple-iap/module/configureAppleTransactionsModule.ts +31 -0
- package/src/payment/bity/adapter.ts +417 -0
- package/src/payment/bity/db/BityCredentialsCollection.ts +17 -0
- package/src/payment/bity/index.ts +3 -0
- package/src/payment/bity/module/configureBityModule.ts +46 -0
- package/src/payment/braintree.ts +147 -0
- package/src/payment/cryptopay.ts +195 -0
- package/src/payment/datatrans-v2/api/authorize.ts +17 -0
- package/src/payment/datatrans-v2/api/authorizeAuthenticated.ts +20 -0
- package/src/payment/datatrans-v2/api/cancel.ts +13 -0
- package/src/payment/datatrans-v2/api/index.ts +24 -0
- package/src/payment/datatrans-v2/api/init.ts +40 -0
- package/src/payment/datatrans-v2/api/makeFetcher.ts +49 -0
- package/src/payment/datatrans-v2/api/secureFields.ts +19 -0
- package/src/payment/datatrans-v2/api/settle.ts +13 -0
- package/src/payment/datatrans-v2/api/status.ts +8 -0
- package/src/payment/datatrans-v2/api/types.d.ts +378 -0
- package/src/payment/datatrans-v2/api/validate.ts +13 -0
- package/src/payment/datatrans-v2/generateSignature.ts +24 -0
- package/src/payment/datatrans-v2/getPaths.ts +24 -0
- package/src/payment/datatrans-v2/index.ts +476 -0
- package/src/payment/datatrans-v2/middleware.ts +147 -0
- package/src/payment/datatrans-v2/parseRegistrationData.ts +32 -0
- package/src/payment/datatrans-v2/roundedAmountFromOrder.ts +16 -0
- package/src/payment/datatrans-v2/splitProperties.ts +63 -0
- package/src/payment/invoice-prepaid.ts +40 -0
- package/src/payment/invoice.ts +36 -0
- package/src/payment/paypal-checkout.ts +107 -0
- package/src/payment/postfinance-checkout/api.ts +142 -0
- package/src/payment/postfinance-checkout/index.ts +241 -0
- package/src/payment/postfinance-checkout/middleware.ts +54 -0
- package/src/payment/postfinance-checkout/types.ts +27 -0
- package/src/payment/postfinance-checkout/utils.ts +35 -0
- package/src/payment/stripe.ts +278 -0
- package/src/payment/worldline-saferpay/index.ts +140 -0
- package/src/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.ts +54 -0
- package/src/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayConnection.ts +36 -0
- package/src/payment/worldline-saferpay/worldline-saferpay-client/index.ts +8 -0
- package/src/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentMethods.ts +26 -0
- package/src/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.ts +75 -0
- package/src/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.ts +55 -0
- package/src/payment/worldline-saferpay/worldline-saferpay-client/models/Request.ts +14 -0
- package/src/payment/worldline-saferpay/worldline-saferpay-client/models/Response.ts +9 -0
- package/src/payment/worldline-saferpay/worldline-saferpay-client/models/Transaction.ts +6 -0
- package/src/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.ts +15 -0
- package/src/pricing/delivery-swiss-tax.ts +115 -0
- package/src/pricing/discount-100-off.ts +44 -0
- package/src/pricing/discount-half-price-manual.ts +43 -0
- package/src/pricing/discount-half-price.ts +46 -0
- package/src/pricing/free-delivery.ts +31 -0
- package/src/pricing/free-payment.ts +32 -0
- package/src/pricing/order-delivery.ts +45 -0
- package/src/pricing/order-discount.ts +158 -0
- package/src/pricing/order-items-discount.ts +116 -0
- package/src/pricing/order-items.ts +61 -0
- package/src/pricing/order-payment.ts +46 -0
- package/src/pricing/product-catalog-price.ts +56 -0
- package/src/pricing/product-discount.ts +69 -0
- package/src/pricing/product-price-ECB-interbank-exchange.ts +108 -0
- package/src/pricing/product-price-coinbase-exchange.ts +82 -0
- package/src/pricing/product-price-cryptopay.ts +25 -0
- package/src/pricing/product-price-rateconversion.ts +73 -0
- package/src/pricing/product-price-round.ts +78 -0
- package/src/pricing/product-swiss-tax.ts +117 -0
- package/src/pricing/utils/cache.js +32 -0
- package/src/quotations/manual.ts +27 -0
- package/src/warehousing/google-sheets.ts +165 -0
- package/src/warehousing/store.ts +47 -0
- package/src/worker/BulkImportWorker.ts +3 -3
- package/src/worker/GenerateOrderWorker.ts +1 -1
- package/src/worker/ZombieKillerWorker.ts +5 -5
- package/src/worker/email.ts +56 -4
- package/lib/worker/MessageWorker.d.ts +0 -10
package/src/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { PaymentMethods } from './PaymentMethods';
|
|
2
|
+
import { Request } from './Request';
|
|
3
|
+
import { Response } from './Response';
|
|
4
|
+
import { TransactionAmount } from './Transaction';
|
|
5
|
+
|
|
6
|
+
export interface PaymentPageInitializeInput extends Request {
|
|
7
|
+
ConfigSet?: string;
|
|
8
|
+
TerminalId: string;
|
|
9
|
+
Payment: {
|
|
10
|
+
Amount: TransactionAmount;
|
|
11
|
+
OrderId?: string;
|
|
12
|
+
PayerNote?: string;
|
|
13
|
+
Description: string;
|
|
14
|
+
MandateId?: string;
|
|
15
|
+
Options?: {
|
|
16
|
+
PreAuth?: boolean;
|
|
17
|
+
AllowPartialAuthorization?: boolean;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
Recurring?: {
|
|
21
|
+
initial: boolean;
|
|
22
|
+
};
|
|
23
|
+
Installment?: {
|
|
24
|
+
initial: boolean;
|
|
25
|
+
};
|
|
26
|
+
PaymentMethods?: PaymentMethods[];
|
|
27
|
+
PaymentMethodsOptions?: Map<string, Map<string, string>>;
|
|
28
|
+
Authentication?: {
|
|
29
|
+
Exemption?: string;
|
|
30
|
+
ThreeDsChallenge?: string;
|
|
31
|
+
};
|
|
32
|
+
Wallets?: string[];
|
|
33
|
+
Payer?: {
|
|
34
|
+
IpAddress?: string;
|
|
35
|
+
LanguageCode?: string;
|
|
36
|
+
};
|
|
37
|
+
BillingAddress?: Map<string, string>;
|
|
38
|
+
DeliveryAddress?: Map<string, string>;
|
|
39
|
+
RegisterAlias?: {
|
|
40
|
+
IdGenerator: 'MANUAL' | 'RANDOM' | 'RANDOM_UNIQUE';
|
|
41
|
+
Id?: string;
|
|
42
|
+
Lifetime?: number;
|
|
43
|
+
};
|
|
44
|
+
ReturnUrls: {
|
|
45
|
+
Success: string;
|
|
46
|
+
Fail: string;
|
|
47
|
+
Abort?: string;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface PaymentPageInitializeResponse extends Response {
|
|
52
|
+
Token: string;
|
|
53
|
+
Expiration: string; // ISO8601 UTC
|
|
54
|
+
RedirectUrl: string;
|
|
55
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface RequestHeader {
|
|
2
|
+
SpecVersion: string;
|
|
3
|
+
CustomerId: string;
|
|
4
|
+
RequestId: string;
|
|
5
|
+
RetryIndicator: number;
|
|
6
|
+
ClientInfo?: {
|
|
7
|
+
ShopInfo?: string;
|
|
8
|
+
OsInfo?: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface Request {
|
|
13
|
+
RequestHeader: RequestHeader;
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Response } from './Response';
|
|
2
|
+
import { Request } from './Request';
|
|
3
|
+
|
|
4
|
+
export interface TransactionCancelInput extends Request {
|
|
5
|
+
TransactionReference: {
|
|
6
|
+
TransactionId: string;
|
|
7
|
+
OrderId?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface TransactionCancelResponse extends Response {
|
|
12
|
+
TransactionId: string;
|
|
13
|
+
OrderId?: string;
|
|
14
|
+
Date: string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
import { DeliveryPricingAdapter, DeliveryPricingDirector } from '@unchainedshop/core-delivery';
|
|
3
|
+
import {
|
|
4
|
+
DeliveryPricingAdapterContext,
|
|
5
|
+
IDeliveryPricingAdapter,
|
|
6
|
+
} from '@unchainedshop/types/delivery.pricing';
|
|
7
|
+
|
|
8
|
+
// https://www.ch.ch/de/mehrwertsteuersatz-schweiz/
|
|
9
|
+
export const SwissTaxCategories = {
|
|
10
|
+
DEFAULT: {
|
|
11
|
+
rate: (date) => {
|
|
12
|
+
const referenceDate = moment(date);
|
|
13
|
+
if (referenceDate.isBefore('2018-01-01')) {
|
|
14
|
+
return 0.08;
|
|
15
|
+
}
|
|
16
|
+
return 0.077;
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
REDUCED: {
|
|
20
|
+
value: 'reduced',
|
|
21
|
+
rate: () => {
|
|
22
|
+
return 0.025;
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
SPECIAL: {
|
|
26
|
+
value: 'special',
|
|
27
|
+
rate: () => {
|
|
28
|
+
return 0.037;
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const getTaxRate = (context: DeliveryPricingAdapterContext) => {
|
|
34
|
+
const date = context.order && context.order.ordered ? new Date(context.order.ordered) : new Date();
|
|
35
|
+
|
|
36
|
+
const taxCategoryFromProvider = context.deliveryProvider?.configuration?.find(({ key }) => {
|
|
37
|
+
if (key === 'swiss-tax-category') return true;
|
|
38
|
+
return null;
|
|
39
|
+
})?.value;
|
|
40
|
+
|
|
41
|
+
if (taxCategoryFromProvider === SwissTaxCategories.REDUCED.value) {
|
|
42
|
+
return SwissTaxCategories.REDUCED.rate();
|
|
43
|
+
}
|
|
44
|
+
if (taxCategoryFromProvider === SwissTaxCategories.SPECIAL.value) {
|
|
45
|
+
return SwissTaxCategories.SPECIAL.rate();
|
|
46
|
+
}
|
|
47
|
+
return SwissTaxCategories.DEFAULT.rate(date);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const isDeliveryAddressInSwitzerland = ({ orderDelivery, order, country = null }) => {
|
|
51
|
+
let countryCode = country?.toUpperCase().trim() || order.countryCode;
|
|
52
|
+
|
|
53
|
+
const address = orderDelivery?.context?.address || order?.billingAddress;
|
|
54
|
+
|
|
55
|
+
if (address?.countryCode > '') {
|
|
56
|
+
countryCode = address.countryCode?.toUpperCase().trim();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return countryCode === 'CH' || countryCode === 'LI';
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const DeliverySwissTax: IDeliveryPricingAdapter = {
|
|
63
|
+
...DeliveryPricingAdapter,
|
|
64
|
+
|
|
65
|
+
key: 'shop.unchained.pricing.delivery-swiss-tax',
|
|
66
|
+
version: '1.0',
|
|
67
|
+
label: 'Apply Swiss Tax on Delivery Fees',
|
|
68
|
+
orderIndex: 20,
|
|
69
|
+
|
|
70
|
+
isActivatedFor: (context) => {
|
|
71
|
+
return isDeliveryAddressInSwitzerland(context);
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
actions: (params) => {
|
|
75
|
+
const pricingAdapter = DeliveryPricingAdapter.actions(params);
|
|
76
|
+
const { context } = params;
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
...pricingAdapter,
|
|
80
|
+
|
|
81
|
+
calculate: async () => {
|
|
82
|
+
const taxRate = getTaxRate(context);
|
|
83
|
+
DeliveryPricingAdapter.log(`DeliverySwissTax -> Tax Multiplicator: ${taxRate}`);
|
|
84
|
+
params.calculationSheet.filterBy({ isTaxable: true }).forEach(({ isNetPrice, ...row }) => {
|
|
85
|
+
if (!isNetPrice) {
|
|
86
|
+
const taxAmount = row.amount - row.amount / (1 + taxRate);
|
|
87
|
+
pricingAdapter.resultSheet().calculation.push({
|
|
88
|
+
...row,
|
|
89
|
+
amount: -taxAmount,
|
|
90
|
+
isTaxable: false,
|
|
91
|
+
isNetPrice: false,
|
|
92
|
+
meta: { adapter: DeliverySwissTax.key },
|
|
93
|
+
});
|
|
94
|
+
pricingAdapter.resultSheet().addTax({
|
|
95
|
+
amount: taxAmount,
|
|
96
|
+
rate: taxRate,
|
|
97
|
+
meta: { adapter: DeliverySwissTax.key },
|
|
98
|
+
});
|
|
99
|
+
} else {
|
|
100
|
+
const taxAmount = row.amount * taxRate;
|
|
101
|
+
pricingAdapter.resultSheet().addTax({
|
|
102
|
+
amount: taxAmount,
|
|
103
|
+
rate: taxRate,
|
|
104
|
+
meta: { adapter: DeliverySwissTax.key },
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
return pricingAdapter.calculate();
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
DeliveryPricingDirector.registerAdapter(DeliverySwissTax);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { IDiscountAdapter } from '@unchainedshop/types/discount';
|
|
2
|
+
import { OrderDiscountDirector, OrderDiscountAdapter } from '@unchainedshop/core-orders';
|
|
3
|
+
|
|
4
|
+
const HundredOff: IDiscountAdapter = {
|
|
5
|
+
...OrderDiscountAdapter,
|
|
6
|
+
|
|
7
|
+
key: 'shop.unchained.discount.100-off',
|
|
8
|
+
label: '100 Off',
|
|
9
|
+
version: '1.0',
|
|
10
|
+
orderIndex: 1,
|
|
11
|
+
|
|
12
|
+
// return true if a discount is allowed to get added manually by a user
|
|
13
|
+
isManualAdditionAllowed: async () => {
|
|
14
|
+
return true;
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
// return true if a discount is allowed to get removed manually by a user
|
|
18
|
+
isManualRemovalAllowed: async () => {
|
|
19
|
+
return true;
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
actions: async ({ context }) => ({
|
|
23
|
+
...(await OrderDiscountAdapter.actions({ context })),
|
|
24
|
+
|
|
25
|
+
isValidForSystemTriggering: async () => {
|
|
26
|
+
return false;
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
isValidForCodeTriggering: async ({ code }) => {
|
|
30
|
+
return code.toUpperCase() === '100OFF';
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
// returns the appropriate discount context for a calculation adapter
|
|
34
|
+
discountForPricingAdapterKey: ({ pricingAdapterKey }) => {
|
|
35
|
+
if (pricingAdapterKey === 'shop.unchained.pricing.order-discount') {
|
|
36
|
+
return { fixedRate: 10000 };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return null;
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
OrderDiscountDirector.registerAdapter(HundredOff);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { IDiscountAdapter } from '@unchainedshop/types/discount';
|
|
2
|
+
import { OrderDiscountDirector, OrderDiscountAdapter } from '@unchainedshop/core-orders';
|
|
3
|
+
|
|
4
|
+
const HalfPriceManual: IDiscountAdapter = {
|
|
5
|
+
...OrderDiscountAdapter,
|
|
6
|
+
|
|
7
|
+
key: 'shop.unchained.discount.half-price-manual',
|
|
8
|
+
label: 'Half Price',
|
|
9
|
+
version: '1.0',
|
|
10
|
+
orderIndex: 2,
|
|
11
|
+
|
|
12
|
+
// return true if a discount is allowed to get added manually by a user
|
|
13
|
+
isManualAdditionAllowed: async () => {
|
|
14
|
+
return true;
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
// return true if a discount is allowed to get removed manually by a user
|
|
18
|
+
isManualRemovalAllowed: async () => {
|
|
19
|
+
return true;
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
actions: async ({ context }) => ({
|
|
23
|
+
...(await OrderDiscountAdapter.actions({ context })),
|
|
24
|
+
|
|
25
|
+
isValidForSystemTriggering: async () => {
|
|
26
|
+
return false;
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
isValidForCodeTriggering: async ({ code }) => {
|
|
30
|
+
return code === 'HALFPRICE';
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
// returns the appropriate discount context for a calculation adapter
|
|
34
|
+
discountForPricingAdapterKey({ pricingAdapterKey }) {
|
|
35
|
+
if (pricingAdapterKey === 'shop.unchained.pricing.product-discount') {
|
|
36
|
+
return { rate: 0.5 };
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
},
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
OrderDiscountDirector.registerAdapter(HalfPriceManual);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { IDiscountAdapter } from '@unchainedshop/types/discount';
|
|
2
|
+
import { OrderDiscountDirector, OrderDiscountAdapter } from '@unchainedshop/core-orders';
|
|
3
|
+
|
|
4
|
+
const HalfPrice: IDiscountAdapter = {
|
|
5
|
+
...OrderDiscountAdapter,
|
|
6
|
+
|
|
7
|
+
key: 'shop.unchained.discount.half-price',
|
|
8
|
+
label: 'Half Price',
|
|
9
|
+
version: '1.0',
|
|
10
|
+
orderIndex: 3,
|
|
11
|
+
|
|
12
|
+
// return true if a discount is allowed to get added manually by a user
|
|
13
|
+
isManualAdditionAllowed: async () => {
|
|
14
|
+
return false;
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
// return true if a discount is allowed to get removed manually by a user
|
|
18
|
+
isManualRemovalAllowed: async () => {
|
|
19
|
+
return false;
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
actions: async ({ context }) => ({
|
|
23
|
+
...(await OrderDiscountAdapter.actions({ context })),
|
|
24
|
+
|
|
25
|
+
isValidForSystemTriggering: async () => {
|
|
26
|
+
const { order } = context;
|
|
27
|
+
const user = await context.modules.users.findUserById(order.userId);
|
|
28
|
+
const isUserEligibleForHalfPrice = user?.tags && user.tags.indexOf('half-price') !== -1;
|
|
29
|
+
return !!isUserEligibleForHalfPrice;
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
isValidForCodeTriggering: async () => {
|
|
33
|
+
return false;
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
// returns the appropriate discount context for a calculation adapter
|
|
37
|
+
discountForPricingAdapterKey({ pricingAdapterKey }) {
|
|
38
|
+
if (pricingAdapterKey === 'shop.unchained.pricing.product-discount') {
|
|
39
|
+
return { rate: 0.5 };
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
OrderDiscountDirector.registerAdapter(HalfPrice);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DeliveryPricingAdapter, DeliveryPricingDirector } from '@unchainedshop/core-delivery';
|
|
2
|
+
import { IDeliveryPricingAdapter } from '@unchainedshop/types/delivery.pricing';
|
|
3
|
+
|
|
4
|
+
export const DeliveryFreePrice: IDeliveryPricingAdapter = {
|
|
5
|
+
...DeliveryPricingAdapter,
|
|
6
|
+
|
|
7
|
+
key: 'shop.unchained.pricing.delivery-free',
|
|
8
|
+
version: '1.0',
|
|
9
|
+
label: 'Free Delivery',
|
|
10
|
+
orderIndex: 0,
|
|
11
|
+
|
|
12
|
+
isActivatedFor: () => {
|
|
13
|
+
return true;
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
actions: (params) => {
|
|
17
|
+
const pricingAdapter = DeliveryPricingAdapter.actions(params);
|
|
18
|
+
return {
|
|
19
|
+
...pricingAdapter,
|
|
20
|
+
calculate: async () => {
|
|
21
|
+
pricingAdapter.resultSheet().addFee({
|
|
22
|
+
amount: 0,
|
|
23
|
+
meta: { adapter: DeliveryFreePrice.key },
|
|
24
|
+
});
|
|
25
|
+
return pricingAdapter.calculate();
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
DeliveryPricingDirector.registerAdapter(DeliveryFreePrice);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PaymentPricingAdapter, PaymentPricingDirector } from '@unchainedshop/core-payment';
|
|
2
|
+
import { IPaymentPricingAdapter } from '@unchainedshop/types/payments.pricing';
|
|
3
|
+
|
|
4
|
+
export const PaymentFreePrice: IPaymentPricingAdapter = {
|
|
5
|
+
...PaymentPricingAdapter,
|
|
6
|
+
|
|
7
|
+
key: 'shop.unchained.pricing.payment-free',
|
|
8
|
+
version: '1.0',
|
|
9
|
+
label: 'Free Payment',
|
|
10
|
+
orderIndex: 0,
|
|
11
|
+
|
|
12
|
+
isActivatedFor: () => {
|
|
13
|
+
return true;
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
actions: (params) => {
|
|
17
|
+
const pricingAdapter = PaymentPricingAdapter.actions(params);
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
...pricingAdapter,
|
|
21
|
+
calculate: async () => {
|
|
22
|
+
pricingAdapter.resultSheet().addFee({
|
|
23
|
+
amount: 0,
|
|
24
|
+
meta: { adapter: PaymentFreePrice.key },
|
|
25
|
+
});
|
|
26
|
+
return pricingAdapter.calculate();
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
PaymentPricingDirector.registerAdapter(PaymentFreePrice);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { IOrderPricingAdapter } from '@unchainedshop/types/orders.pricing';
|
|
2
|
+
import { OrderPricingDirector, OrderPricingAdapter } from '@unchainedshop/core-orders';
|
|
3
|
+
|
|
4
|
+
const OrderDelivery: IOrderPricingAdapter = {
|
|
5
|
+
...OrderPricingAdapter,
|
|
6
|
+
|
|
7
|
+
key: 'shop.unchained.pricing.order-delivery',
|
|
8
|
+
version: '1.0',
|
|
9
|
+
label: 'Add Delivery Fees to Order',
|
|
10
|
+
orderIndex: 10,
|
|
11
|
+
|
|
12
|
+
isActivatedFor: () => {
|
|
13
|
+
return true;
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
actions: (params) => {
|
|
17
|
+
const pricingAdapter = OrderPricingAdapter.actions(params);
|
|
18
|
+
const { order, orderDelivery, modules } = params.context;
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
...pricingAdapter,
|
|
22
|
+
|
|
23
|
+
calculate: async () => {
|
|
24
|
+
// just add tax + net price to order pricing
|
|
25
|
+
if (!orderDelivery) return null;
|
|
26
|
+
const pricing = modules.orders.deliveries.pricingSheet(
|
|
27
|
+
orderDelivery,
|
|
28
|
+
order.currency,
|
|
29
|
+
params.context,
|
|
30
|
+
);
|
|
31
|
+
const tax = pricing.taxSum();
|
|
32
|
+
const shipping = pricing.gross();
|
|
33
|
+
|
|
34
|
+
pricingAdapter.resultSheet().addDelivery({ amount: shipping });
|
|
35
|
+
if (tax !== 0) {
|
|
36
|
+
pricingAdapter.resultSheet().addTax({ amount: tax });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return pricingAdapter.calculate();
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
OrderPricingDirector.registerAdapter(OrderDelivery);
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { IOrderPricingAdapter, OrderPricingRowCategory } from '@unchainedshop/types/orders.pricing';
|
|
2
|
+
import { OrderPricingDirector, OrderPricingAdapter } from '@unchainedshop/core-orders';
|
|
3
|
+
|
|
4
|
+
const resolveRatioAndTaxDivisorForPricingSheet = (pricing, total) => {
|
|
5
|
+
if (total === 0 || !pricing) {
|
|
6
|
+
return {
|
|
7
|
+
ratio: 1,
|
|
8
|
+
taxDivisor: 1,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
const tax = pricing.taxSum();
|
|
12
|
+
const gross = pricing.gross();
|
|
13
|
+
if (gross - tax === 0) {
|
|
14
|
+
return {
|
|
15
|
+
ratio: 0,
|
|
16
|
+
taxDivisor: 0,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
ratio: gross / total,
|
|
21
|
+
taxDivisor: gross / (gross - tax),
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const resolveAmountAndTax = ({ ratio, taxDivisor }, amount) => {
|
|
26
|
+
const shareAmount = Number.isFinite(ratio) ? amount * ratio : 0;
|
|
27
|
+
const shareTaxAmount =
|
|
28
|
+
Number.isFinite(taxDivisor) && taxDivisor !== 0 ? shareAmount - shareAmount / taxDivisor : 0;
|
|
29
|
+
return [shareAmount, shareTaxAmount];
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const applyDiscountToMultipleShares = (shares, amount) => {
|
|
33
|
+
return shares.reduce(
|
|
34
|
+
([currentDiscountAmount, currentTaxAmount], share) => {
|
|
35
|
+
const [shareAmount, shareTaxAmount] = resolveAmountAndTax(share, amount);
|
|
36
|
+
return [currentDiscountAmount + shareAmount, currentTaxAmount + shareTaxAmount];
|
|
37
|
+
},
|
|
38
|
+
[0, 0],
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const calculateAmountToSplit = (configuration, amount) => {
|
|
43
|
+
const deductionAmount = configuration.rate ? amount * configuration.rate : configuration.fixedRate;
|
|
44
|
+
|
|
45
|
+
const leftInDiscount = Math.max(0, deductionAmount - (configuration.alreadyDeductedForDiscount || 0));
|
|
46
|
+
const leftToDeduct = Math.min(configuration.amountLeft, leftInDiscount);
|
|
47
|
+
return Math.max(0, leftToDeduct);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const OrderDiscount: IOrderPricingAdapter = {
|
|
51
|
+
...OrderPricingAdapter,
|
|
52
|
+
|
|
53
|
+
key: 'shop.unchained.pricing.order-discount',
|
|
54
|
+
version: '1.0',
|
|
55
|
+
label: 'Apply Discounts on Total Order Value',
|
|
56
|
+
orderIndex: 90,
|
|
57
|
+
|
|
58
|
+
isActivatedFor: () => {
|
|
59
|
+
return true;
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
actions: (params) => {
|
|
63
|
+
const pricingAdapter = OrderPricingAdapter.actions(params);
|
|
64
|
+
const { order, orderDelivery, orderPositions, orderPayment, modules } = params.context;
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
...pricingAdapter,
|
|
68
|
+
|
|
69
|
+
calculate: async () => {
|
|
70
|
+
// discounts need to provide a *fixedRate*
|
|
71
|
+
// if you want to add percentual discounts,
|
|
72
|
+
// add it to the order item calculation
|
|
73
|
+
const totalAmountOfItems = params.calculationSheet.sum({
|
|
74
|
+
category: OrderPricingRowCategory.Items,
|
|
75
|
+
});
|
|
76
|
+
const totalAmountOfPaymentAndDelivery =
|
|
77
|
+
params.calculationSheet.sum({
|
|
78
|
+
category: OrderPricingRowCategory.Payment,
|
|
79
|
+
}) +
|
|
80
|
+
params.calculationSheet.sum({
|
|
81
|
+
category: OrderPricingRowCategory.Delivery,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const itemShares = orderPositions.map((orderPosition) =>
|
|
85
|
+
resolveRatioAndTaxDivisorForPricingSheet(
|
|
86
|
+
modules.orders.positions.pricingSheet(orderPosition, order.currency, params.context),
|
|
87
|
+
totalAmountOfItems,
|
|
88
|
+
),
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
const deliveryShare = resolveRatioAndTaxDivisorForPricingSheet(
|
|
92
|
+
orderDelivery &&
|
|
93
|
+
modules.orders.deliveries.pricingSheet(orderDelivery, order.currency, params.context),
|
|
94
|
+
totalAmountOfPaymentAndDelivery,
|
|
95
|
+
);
|
|
96
|
+
const paymentShare = resolveRatioAndTaxDivisorForPricingSheet(
|
|
97
|
+
orderPayment &&
|
|
98
|
+
modules.orders.payments.pricingSheet(orderPayment, order.currency, params.context),
|
|
99
|
+
totalAmountOfPaymentAndDelivery,
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
let amountLeft = totalAmountOfPaymentAndDelivery + totalAmountOfItems;
|
|
103
|
+
|
|
104
|
+
params.discounts.forEach(({ configuration, discountId }) => {
|
|
105
|
+
// First, we deduce the discount from the items
|
|
106
|
+
let alreadyDeductedForDiscount = 0;
|
|
107
|
+
const [itemsDiscountAmount, itemsTaxAmount] = applyDiscountToMultipleShares(
|
|
108
|
+
itemShares,
|
|
109
|
+
calculateAmountToSplit(
|
|
110
|
+
{ ...configuration, amountLeft, alreadyDeductedForDiscount },
|
|
111
|
+
totalAmountOfItems,
|
|
112
|
+
),
|
|
113
|
+
);
|
|
114
|
+
amountLeft -= itemsDiscountAmount;
|
|
115
|
+
alreadyDeductedForDiscount += itemsDiscountAmount;
|
|
116
|
+
|
|
117
|
+
// After the items, we deduct the remaining discount from payment & delivery fees
|
|
118
|
+
const [deliveryAndPaymentDiscountAmount, deliveryAndPaymentTaxAmount] =
|
|
119
|
+
applyDiscountToMultipleShares(
|
|
120
|
+
[deliveryShare, paymentShare],
|
|
121
|
+
calculateAmountToSplit(
|
|
122
|
+
{ ...configuration, amountLeft, alreadyDeductedForDiscount },
|
|
123
|
+
totalAmountOfPaymentAndDelivery,
|
|
124
|
+
),
|
|
125
|
+
);
|
|
126
|
+
amountLeft -= deliveryAndPaymentDiscountAmount;
|
|
127
|
+
alreadyDeductedForDiscount += itemsDiscountAmount;
|
|
128
|
+
|
|
129
|
+
const discountAmount = itemsDiscountAmount + deliveryAndPaymentDiscountAmount;
|
|
130
|
+
const taxAmount = itemsTaxAmount + deliveryAndPaymentTaxAmount;
|
|
131
|
+
|
|
132
|
+
if (discountAmount) {
|
|
133
|
+
pricingAdapter.resultSheet().addDiscount({
|
|
134
|
+
amount: discountAmount * -1,
|
|
135
|
+
discountId,
|
|
136
|
+
meta: {
|
|
137
|
+
adapter: OrderDiscount.key,
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
if (taxAmount !== 0) {
|
|
141
|
+
pricingAdapter.resultSheet().addTax({
|
|
142
|
+
amount: taxAmount * -1,
|
|
143
|
+
meta: {
|
|
144
|
+
discountId,
|
|
145
|
+
adapter: OrderDiscount.key,
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
return pricingAdapter.calculate();
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
OrderPricingDirector.registerAdapter(OrderDiscount);
|