@unchainedshop/core 3.0.0-alpha7 → 3.0.0-rc2
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/core-index.d.ts +8 -61
- package/lib/core-index.d.ts.map +1 -1
- package/lib/core-index.js +9 -140
- package/lib/core-index.js.map +1 -1
- package/lib/core-index_BACKUP_57582.d.ts +26 -0
- package/lib/core-index_BACKUP_57582.d.ts.map +1 -0
- package/lib/core-index_BACKUP_57582.js +30 -0
- package/lib/core-index_BACKUP_57582.js.map +1 -0
- package/lib/core-index_BASE_57582.d.ts +74 -0
- package/lib/core-index_BASE_57582.d.ts.map +1 -0
- package/lib/core-index_BASE_57582.js +145 -0
- package/lib/core-index_BASE_57582.js.map +1 -0
- package/lib/core-index_LOCAL_57582.d.ts +26 -0
- package/lib/core-index_LOCAL_57582.d.ts.map +1 -0
- package/lib/core-index_LOCAL_57582.js +31 -0
- package/lib/core-index_LOCAL_57582.js.map +1 -0
- package/lib/core-index_REMOTE_57582.d.ts +74 -0
- package/lib/core-index_REMOTE_57582.d.ts.map +1 -0
- package/lib/core-index_REMOTE_57582.js +146 -0
- package/lib/core-index_REMOTE_57582.js.map +1 -0
- package/lib/directors/BaseDiscountAdapter.d.ts +38 -0
- package/lib/directors/BaseDiscountAdapter.d.ts.map +1 -0
- package/lib/directors/BaseDiscountAdapter.js +48 -0
- package/lib/directors/BaseDiscountAdapter.js.map +1 -0
- package/lib/directors/BaseDiscountDirector.d.ts +12 -0
- package/lib/directors/BaseDiscountDirector.d.ts.map +1 -0
- package/lib/directors/BaseDiscountDirector.js +45 -0
- package/lib/directors/BaseDiscountDirector.js.map +1 -0
- package/lib/directors/BasePricingAdapter.d.ts +39 -0
- package/lib/directors/BasePricingAdapter.d.ts.map +1 -0
- package/lib/directors/BasePricingAdapter.js +25 -0
- package/lib/directors/BasePricingAdapter.js.map +1 -0
- package/lib/directors/BasePricingDirector.d.ts +17 -0
- package/lib/directors/BasePricingDirector.d.ts.map +1 -0
- package/lib/directors/BasePricingDirector.js +70 -0
- package/lib/directors/BasePricingDirector.js.map +1 -0
- package/lib/directors/BasePricingSheet.d.ts +46 -0
- package/lib/directors/BasePricingSheet.d.ts.map +1 -0
- package/lib/directors/BasePricingSheet.js +74 -0
- package/lib/directors/BasePricingSheet.js.map +1 -0
- package/lib/directors/DeliveryAdapter.d.ts +46 -0
- package/lib/directors/DeliveryAdapter.d.ts.map +1 -0
- package/lib/directors/DeliveryAdapter.js +50 -0
- package/lib/directors/DeliveryAdapter.js.map +1 -0
- package/lib/directors/DeliveryDirector.d.ts +15 -0
- package/lib/directors/DeliveryDirector.d.ts.map +1 -0
- package/lib/directors/DeliveryDirector.js +96 -0
- package/lib/directors/DeliveryDirector.js.map +1 -0
- package/lib/directors/DeliveryPricingAdapter.d.ts +49 -0
- package/lib/directors/DeliveryPricingAdapter.d.ts.map +1 -0
- package/lib/directors/DeliveryPricingAdapter.js +25 -0
- package/lib/directors/DeliveryPricingAdapter.js.map +1 -0
- package/lib/directors/DeliveryPricingDirector.d.ts +20 -0
- package/lib/directors/DeliveryPricingDirector.d.ts.map +1 -0
- package/lib/directors/DeliveryPricingDirector.js +50 -0
- package/lib/directors/DeliveryPricingDirector.js.map +1 -0
- package/lib/directors/DeliveryPricingSheet.d.ts +10 -0
- package/lib/directors/DeliveryPricingSheet.d.ts.map +1 -0
- package/lib/directors/DeliveryPricingSheet.js +75 -0
- package/lib/directors/DeliveryPricingSheet.js.map +1 -0
- package/lib/directors/EnrollmentAdapter.d.ts +27 -0
- package/lib/directors/EnrollmentAdapter.d.ts.map +1 -0
- package/lib/directors/EnrollmentAdapter.js +73 -0
- package/lib/directors/EnrollmentAdapter.js.map +1 -0
- package/lib/directors/EnrollmentDirector.d.ts +14 -0
- package/lib/directors/EnrollmentDirector.d.ts.map +1 -0
- package/lib/directors/EnrollmentDirector.js +44 -0
- package/lib/directors/EnrollmentDirector.js.map +1 -0
- package/lib/directors/FilterAdapter.d.ts +54 -0
- package/lib/directors/FilterAdapter.d.ts.map +1 -0
- package/lib/directors/FilterAdapter.js +38 -0
- package/lib/directors/FilterAdapter.js.map +1 -0
- package/lib/directors/FilterDirector.d.ts +40 -0
- package/lib/directors/FilterDirector.d.ts.map +1 -0
- package/lib/directors/FilterDirector.js +173 -0
- package/lib/directors/FilterDirector.js.map +1 -0
- package/lib/directors/MessagingDirector.d.ts +46 -0
- package/lib/directors/MessagingDirector.d.ts.map +1 -0
- package/lib/directors/MessagingDirector.js +10 -0
- package/lib/directors/MessagingDirector.js.map +1 -0
- package/lib/directors/OrderDiscountAdapter.d.ts +3 -0
- package/lib/directors/OrderDiscountAdapter.d.ts.map +1 -0
- package/lib/directors/OrderDiscountAdapter.js +3 -0
- package/lib/directors/OrderDiscountAdapter.js.map +1 -0
- package/lib/directors/OrderDiscountConfiguration.d.ts +6 -0
- package/lib/directors/OrderDiscountConfiguration.d.ts.map +1 -0
- package/lib/directors/OrderDiscountConfiguration.js +2 -0
- package/lib/directors/OrderDiscountConfiguration.js.map +1 -0
- package/lib/directors/OrderDiscountDirector.d.ts +3 -0
- package/lib/directors/OrderDiscountDirector.d.ts.map +1 -0
- package/lib/directors/OrderDiscountDirector.js +3 -0
- package/lib/directors/OrderDiscountDirector.js.map +1 -0
- package/lib/directors/OrderPricingAdapter.d.ts +18 -0
- package/lib/directors/OrderPricingAdapter.d.ts.map +1 -0
- package/lib/directors/OrderPricingAdapter.js +24 -0
- package/lib/directors/OrderPricingAdapter.js.map +1 -0
- package/lib/directors/OrderPricingDirector.d.ts +18 -0
- package/lib/directors/OrderPricingDirector.d.ts.map +1 -0
- package/lib/directors/OrderPricingDirector.js +31 -0
- package/lib/directors/OrderPricingDirector.js.map +1 -0
- package/lib/directors/OrderPricingSheet.d.ts +37 -0
- package/lib/directors/OrderPricingSheet.d.ts.map +1 -0
- package/lib/directors/OrderPricingSheet.js +108 -0
- package/lib/directors/OrderPricingSheet.js.map +1 -0
- package/lib/directors/PaymentAdapter.d.ts +50 -0
- package/lib/directors/PaymentAdapter.d.ts.map +1 -0
- package/lib/directors/PaymentAdapter.js +55 -0
- package/lib/directors/PaymentAdapter.js.map +1 -0
- package/lib/directors/PaymentDirector.d.ts +21 -0
- package/lib/directors/PaymentDirector.d.ts.map +1 -0
- package/lib/directors/PaymentDirector.js +172 -0
- package/lib/directors/PaymentDirector.js.map +1 -0
- package/lib/directors/PaymentPricingAdapter.d.ts +48 -0
- package/lib/directors/PaymentPricingAdapter.d.ts.map +1 -0
- package/lib/directors/PaymentPricingAdapter.js +25 -0
- package/lib/directors/PaymentPricingAdapter.js.map +1 -0
- package/lib/directors/PaymentPricingDirector.d.ts +18 -0
- package/lib/directors/PaymentPricingDirector.d.ts.map +1 -0
- package/lib/directors/PaymentPricingDirector.js +51 -0
- package/lib/directors/PaymentPricingDirector.js.map +1 -0
- package/lib/directors/PaymentPricingSheet.d.ts +9 -0
- package/lib/directors/PaymentPricingSheet.d.ts.map +1 -0
- package/lib/directors/PaymentPricingSheet.js +75 -0
- package/lib/directors/PaymentPricingSheet.js.map +1 -0
- package/lib/directors/ProductDiscountAdapter.d.ts +3 -0
- package/lib/directors/ProductDiscountAdapter.d.ts.map +1 -0
- package/lib/directors/ProductDiscountAdapter.js +3 -0
- package/lib/directors/ProductDiscountAdapter.js.map +1 -0
- package/lib/directors/ProductDiscountConfiguration.d.ts +13 -0
- package/lib/directors/ProductDiscountConfiguration.d.ts.map +1 -0
- package/lib/directors/ProductDiscountConfiguration.js +2 -0
- package/lib/directors/ProductDiscountConfiguration.js.map +1 -0
- package/lib/directors/ProductDiscountDirector.d.ts +3 -0
- package/lib/directors/ProductDiscountDirector.d.ts.map +1 -0
- package/lib/directors/ProductDiscountDirector.js +3 -0
- package/lib/directors/ProductDiscountDirector.js.map +1 -0
- package/lib/directors/ProductPricingAdapter.d.ts +17 -0
- package/lib/directors/ProductPricingAdapter.d.ts.map +1 -0
- package/lib/directors/ProductPricingAdapter.js +24 -0
- package/lib/directors/ProductPricingAdapter.js.map +1 -0
- package/lib/directors/ProductPricingDirector.d.ts +21 -0
- package/lib/directors/ProductPricingDirector.d.ts.map +1 -0
- package/lib/directors/ProductPricingDirector.js +52 -0
- package/lib/directors/ProductPricingDirector.js.map +1 -0
- package/lib/directors/ProductPricingSheet.d.ts +38 -0
- package/lib/directors/ProductPricingSheet.d.ts.map +1 -0
- package/lib/directors/ProductPricingSheet.js +83 -0
- package/lib/directors/ProductPricingSheet.js.map +1 -0
- package/lib/directors/QuotationAdapter.d.ts +28 -0
- package/lib/directors/QuotationAdapter.d.ts.map +1 -0
- package/lib/directors/QuotationAdapter.js +46 -0
- package/lib/directors/QuotationAdapter.js.map +1 -0
- package/lib/directors/QuotationDirector.d.ts +7 -0
- package/lib/directors/QuotationDirector.d.ts.map +1 -0
- package/lib/directors/QuotationDirector.js +84 -0
- package/lib/directors/QuotationDirector.js.map +1 -0
- package/lib/directors/WarehousingAdapter.d.ts +40 -0
- package/lib/directors/WarehousingAdapter.d.ts.map +1 -0
- package/lib/directors/WarehousingAdapter.js +32 -0
- package/lib/directors/WarehousingAdapter.js.map +1 -0
- package/lib/directors/WarehousingDirector.d.ts +38 -0
- package/lib/directors/WarehousingDirector.d.ts.map +1 -0
- package/lib/directors/WarehousingDirector.js +169 -0
- package/lib/directors/WarehousingDirector.js.map +1 -0
- package/lib/directors/WorkerAdapter.d.ts +17 -0
- package/lib/directors/WorkerAdapter.d.ts.map +1 -0
- package/lib/directors/WorkerAdapter.js +11 -0
- package/lib/directors/WorkerAdapter.js.map +1 -0
- package/lib/directors/WorkerDirector.d.ts +26 -0
- package/lib/directors/WorkerDirector.d.ts.map +1 -0
- package/lib/directors/WorkerDirector.js +102 -0
- package/lib/directors/WorkerDirector.js.map +1 -0
- package/lib/directors/index.d.ts +39 -0
- package/lib/directors/index.d.ts.map +1 -0
- package/lib/directors/index.js +39 -0
- package/lib/directors/index.js.map +1 -0
- package/lib/modules.d.ts +61 -0
- package/lib/modules.d.ts.map +1 -0
- package/lib/modules.js +132 -0
- package/lib/modules.js.map +1 -0
- package/lib/services/activateEnrollment.d.ts +4 -0
- package/lib/services/activateEnrollment.d.ts.map +1 -0
- package/lib/services/activateEnrollment.js +25 -0
- package/lib/services/activateEnrollment.js.map +1 -0
- package/lib/services/calculateDiscountTotal.d.ts +7 -0
- package/lib/services/calculateDiscountTotal.d.ts.map +1 -0
- package/lib/services/calculateDiscountTotal.js +49 -0
- package/lib/services/calculateDiscountTotal.js.map +1 -0
- package/lib/services/checkoutOrder.d.ts +9 -0
- package/lib/services/checkoutOrder.d.ts.map +1 -0
- package/lib/services/checkoutOrder.js +28 -0
- package/lib/services/checkoutOrder.js.map +1 -0
- package/lib/services/confirmOrder.d.ts +9 -0
- package/lib/services/confirmOrder.d.ts.map +1 -0
- package/lib/services/confirmOrder.js +17 -0
- package/lib/services/confirmOrder.js.map +1 -0
- package/lib/services/createDownloadStream.d.ts +5 -0
- package/lib/services/createDownloadStream.d.ts.map +1 -0
- package/lib/services/createDownloadStream.js +8 -0
- package/lib/services/createDownloadStream.js.map +1 -0
- package/lib/services/createDownloadStreamService.d.ts +11 -0
- package/lib/services/createDownloadStreamService.d.ts.map +1 -0
- package/lib/services/createDownloadStreamService.js +9 -0
- package/lib/services/createDownloadStreamService.js.map +1 -0
- package/lib/services/createEnrollmentFromCheckout.d.ts +15 -0
- package/lib/services/createEnrollmentFromCheckout.d.ts.map +1 -0
- package/lib/services/createEnrollmentFromCheckout.js +40 -0
- package/lib/services/createEnrollmentFromCheckout.js.map +1 -0
- package/lib/services/createManualOrderDiscount.d.ts +7 -0
- package/lib/services/createManualOrderDiscount.d.ts.map +1 -0
- package/lib/services/createManualOrderDiscount.js +47 -0
- package/lib/services/createManualOrderDiscount.js.map +1 -0
- package/lib/services/createSignedURL.d.ts +8 -0
- package/lib/services/createSignedURL.d.ts.map +1 -0
- package/lib/services/createSignedURL.js +15 -0
- package/lib/services/createSignedURL.js.map +1 -0
- package/lib/services/createSignedURLService.d.ts +13 -0
- package/lib/services/createSignedURLService.d.ts.map +1 -0
- package/lib/services/createSignedURLService.js +14 -0
- package/lib/services/createSignedURLService.js.map +1 -0
- package/lib/services/deleteUser.d.ts +5 -0
- package/lib/services/deleteUser.d.ts.map +1 -0
- package/lib/services/deleteUser.js +26 -0
- package/lib/services/deleteUser.js.map +1 -0
- package/lib/services/deleteUserCartService.d.ts +6 -0
- package/lib/services/deleteUserCartService.d.ts.map +1 -0
- package/lib/services/deleteUserCartService.js +20 -0
- package/lib/services/deleteUserCartService.js.map +1 -0
- package/lib/services/deleteUserCarts.d.ts +5 -0
- package/lib/services/deleteUserCarts.d.ts.map +1 -0
- package/lib/services/deleteUserCarts.js +18 -0
- package/lib/services/deleteUserCarts.js.map +1 -0
- package/lib/services/deleteUserCartsService.d.ts +5 -0
- package/lib/services/deleteUserCartsService.d.ts.map +1 -0
- package/lib/services/deleteUserCartsService.js +18 -0
- package/lib/services/deleteUserCartsService.js.map +1 -0
- package/lib/services/discountedEntities.d.ts +5 -0
- package/lib/services/discountedEntities.d.ts.map +1 -0
- package/lib/services/discountedEntities.js +61 -0
- package/lib/services/discountedEntities.js.map +1 -0
- package/lib/services/ercMetadata.d.ts +7 -0
- package/lib/services/ercMetadata.d.ts.map +1 -0
- package/lib/services/ercMetadata.js +22 -0
- package/lib/services/ercMetadata.js.map +1 -0
- package/lib/services/fullfillQuotation.d.ts +4 -0
- package/lib/services/fullfillQuotation.d.ts.map +1 -0
- package/lib/services/fullfillQuotation.js +12 -0
- package/lib/services/fullfillQuotation.js.map +1 -0
- package/lib/services/index.d.ts +110 -0
- package/lib/services/index.d.ts.map +1 -0
- package/lib/services/index.js +124 -0
- package/lib/services/index.js.map +1 -0
- package/lib/services/index_BACKUP_58089.d.ts +246 -0
- package/lib/services/index_BACKUP_58089.d.ts.map +1 -0
- package/lib/services/index_BACKUP_58089.js +103 -0
- package/lib/services/index_BACKUP_58089.js.map +1 -0
- package/lib/services/index_BASE_58089.d.ts +31 -0
- package/lib/services/index_BASE_58089.d.ts.map +1 -0
- package/lib/services/index_BASE_58089.js +42 -0
- package/lib/services/index_BASE_58089.js.map +1 -0
- package/lib/services/index_LOCAL_58089.d.ts +246 -0
- package/lib/services/index_LOCAL_58089.d.ts.map +1 -0
- package/lib/services/index_LOCAL_58089.js +103 -0
- package/lib/services/index_LOCAL_58089.js.map +1 -0
- package/lib/services/index_REMOTE_58089.d.ts +34 -0
- package/lib/services/index_REMOTE_58089.d.ts.map +1 -0
- package/lib/services/index_REMOTE_58089.js +44 -0
- package/lib/services/index_REMOTE_58089.js.map +1 -0
- package/lib/services/initCartProviders.d.ts +4 -0
- package/lib/services/initCartProviders.d.ts.map +1 -0
- package/lib/services/initCartProviders.js +55 -0
- package/lib/services/initCartProviders.js.map +1 -0
- package/lib/services/initializeEnrollment.d.ts +7 -0
- package/lib/services/initializeEnrollment.d.ts.map +1 -0
- package/lib/services/initializeEnrollment.js +28 -0
- package/lib/services/initializeEnrollment.js.map +1 -0
- package/lib/services/invalidateFilterCache.d.ts +3 -0
- package/lib/services/invalidateFilterCache.d.ts.map +1 -0
- package/lib/services/invalidateFilterCache.js +12 -0
- package/lib/services/invalidateFilterCache.js.map +1 -0
- package/lib/services/linkFileService.d.ts +7 -0
- package/lib/services/linkFileService.d.ts.map +1 -0
- package/lib/services/linkFileService.js +18 -0
- package/lib/services/linkFileService.js.map +1 -0
- package/lib/services/loadFilterOptions.d.ts +14 -0
- package/lib/services/loadFilterOptions.d.ts.map +1 -0
- package/lib/services/loadFilterOptions.js +30 -0
- package/lib/services/loadFilterOptions.js.map +1 -0
- package/lib/services/loadFilters.d.ts +14 -0
- package/lib/services/loadFilters.d.ts.map +1 -0
- package/lib/services/loadFilters.js +36 -0
- package/lib/services/loadFilters.js.map +1 -0
- package/lib/services/migrateBookmarks.d.ts +8 -0
- package/lib/services/migrateBookmarks.d.ts.map +1 -0
- package/lib/services/migrateBookmarks.js +26 -0
- package/lib/services/migrateBookmarks.js.map +1 -0
- package/lib/services/migrateBookmarksService.d.ts +13 -0
- package/lib/services/migrateBookmarksService.d.ts.map +1 -0
- package/lib/services/migrateBookmarksService.js +26 -0
- package/lib/services/migrateBookmarksService.js.map +1 -0
- package/lib/services/migrateOrderCart.d.ts +8 -0
- package/lib/services/migrateOrderCart.d.ts.map +1 -0
- package/lib/services/migrateOrderCart.js +32 -0
- package/lib/services/migrateOrderCart.js.map +1 -0
- package/lib/services/migrateOrderCartService.d.ts +23 -0
- package/lib/services/migrateOrderCartService.d.ts.map +1 -0
- package/lib/services/migrateOrderCartService.js +32 -0
- package/lib/services/migrateOrderCartService.js.map +1 -0
- package/lib/services/migrateUserData.d.ts +2 -0
- package/lib/services/migrateUserData.d.ts.map +1 -0
- package/lib/services/migrateUserData.js +20 -0
- package/lib/services/migrateUserData.js.map +1 -0
- package/lib/services/migrateUserDataService.d.ts +19 -0
- package/lib/services/migrateUserDataService.d.ts.map +1 -0
- package/lib/services/migrateUserDataService.js +18 -0
- package/lib/services/migrateUserDataService.js.map +1 -0
- package/lib/services/nextUserCart.d.ts +9 -0
- package/lib/services/nextUserCart.d.ts.map +1 -0
- package/lib/services/nextUserCart.js +34 -0
- package/lib/services/nextUserCart.js.map +1 -0
- package/lib/services/nextUserCartService.d.ts +22 -0
- package/lib/services/nextUserCartService.d.ts.map +1 -0
- package/lib/services/nextUserCartService.js +35 -0
- package/lib/services/nextUserCartService.js.map +1 -0
- package/lib/services/processEnrollment.d.ts +4 -0
- package/lib/services/processEnrollment.d.ts.map +1 -0
- package/lib/services/processEnrollment.js +33 -0
- package/lib/services/processEnrollment.js.map +1 -0
- package/lib/services/processOrder.d.ts +9 -0
- package/lib/services/processOrder.d.ts.map +1 -0
- package/lib/services/processOrder.js +161 -0
- package/lib/services/processOrder.js.map +1 -0
- package/lib/services/processQuotation.d.ts +6 -0
- package/lib/services/processQuotation.d.ts.map +1 -0
- package/lib/services/processQuotation.js +60 -0
- package/lib/services/processQuotation.js.map +1 -0
- package/lib/services/proposeQuotation.d.ts +6 -0
- package/lib/services/proposeQuotation.d.ts.map +1 -0
- package/lib/services/proposeQuotation.js +12 -0
- package/lib/services/proposeQuotation.js.map +1 -0
- package/lib/services/registerPaymentCredentials.d.ts +5 -0
- package/lib/services/registerPaymentCredentials.d.ts.map +1 -0
- package/lib/services/registerPaymentCredentials.js +21 -0
- package/lib/services/registerPaymentCredentials.js.map +1 -0
- package/lib/services/rejectOrder.d.ts +9 -0
- package/lib/services/rejectOrder.d.ts.map +1 -0
- package/lib/services/rejectOrder.js +17 -0
- package/lib/services/rejectOrder.js.map +1 -0
- package/lib/services/rejectQuotation.d.ts +6 -0
- package/lib/services/rejectQuotation.d.ts.map +1 -0
- package/lib/services/rejectQuotation.js +12 -0
- package/lib/services/rejectQuotation.js.map +1 -0
- package/lib/services/removeFiles.d.ts +5 -0
- package/lib/services/removeFiles.d.ts.map +1 -0
- package/lib/services/removeFiles.js +19 -0
- package/lib/services/removeFiles.js.map +1 -0
- package/lib/services/removeFilesService.d.ts +10 -0
- package/lib/services/removeFilesService.d.ts.map +1 -0
- package/lib/services/removeFilesService.js +20 -0
- package/lib/services/removeFilesService.js.map +1 -0
- package/lib/services/removeProduct.d.ts +5 -0
- package/lib/services/removeProduct.d.ts.map +1 -0
- package/lib/services/removeProduct.js +26 -0
- package/lib/services/removeProduct.js.map +1 -0
- package/lib/services/removeProductService.d.ts +20 -0
- package/lib/services/removeProductService.d.ts.map +1 -0
- package/lib/services/removeProductService.js +27 -0
- package/lib/services/removeProductService.js.map +1 -0
- package/lib/services/searchAssortments.d.ts +19 -0
- package/lib/services/searchAssortments.d.ts.map +1 -0
- package/lib/services/searchAssortments.js +33 -0
- package/lib/services/searchAssortments.js.map +1 -0
- package/lib/services/searchProducts.d.ts +16 -0
- package/lib/services/searchProducts.d.ts.map +1 -0
- package/lib/services/searchProducts.js +41 -0
- package/lib/services/searchProducts.js.map +1 -0
- package/lib/services/supportedDeliveryProviders.d.ts +5 -0
- package/lib/services/supportedDeliveryProviders.d.ts.map +1 -0
- package/lib/services/supportedDeliveryProviders.js +14 -0
- package/lib/services/supportedDeliveryProviders.js.map +1 -0
- package/lib/services/supportedPaymentProviders.d.ts +5 -0
- package/lib/services/supportedPaymentProviders.d.ts.map +1 -0
- package/lib/services/supportedPaymentProviders.js +14 -0
- package/lib/services/supportedPaymentProviders.js.map +1 -0
- package/lib/services/supportedWarehousingProviders.d.ts +5 -0
- package/lib/services/supportedWarehousingProviders.d.ts.map +1 -0
- package/lib/services/supportedWarehousingProviders.js +10 -0
- package/lib/services/supportedWarehousingProviders.js.map +1 -0
- package/lib/services/terminateEnrollment.d.ts +3 -0
- package/lib/services/terminateEnrollment.d.ts.map +1 -0
- package/lib/services/terminateEnrollment.js +25 -0
- package/lib/services/terminateEnrollment.js.map +1 -0
- package/lib/services/updateCalculation.d.ts +3 -0
- package/lib/services/updateCalculation.d.ts.map +1 -0
- package/lib/services/updateCalculation.js +101 -0
- package/lib/services/updateCalculation.js.map +1 -0
- package/lib/services/updateCalculationService.d.ts +17 -0
- package/lib/services/updateCalculationService.d.ts.map +1 -0
- package/lib/services/updateCalculationService.js +68 -0
- package/lib/services/updateCalculationService.js.map +1 -0
- package/lib/services/updateScheduling.d.ts +8 -0
- package/lib/services/updateScheduling.d.ts.map +1 -0
- package/lib/services/updateScheduling.js +42 -0
- package/lib/services/updateScheduling.js.map +1 -0
- package/lib/services/updateUserAvatarAfterUpload.d.ts +6 -0
- package/lib/services/updateUserAvatarAfterUpload.d.ts.map +1 -0
- package/lib/services/updateUserAvatarAfterUpload.js +25 -0
- package/lib/services/updateUserAvatarAfterUpload.js.map +1 -0
- package/lib/services/updateUserAvatarAfterUploadService.d.ts +18 -0
- package/lib/services/updateUserAvatarAfterUploadService.d.ts.map +1 -0
- package/lib/services/updateUserAvatarAfterUploadService.js +25 -0
- package/lib/services/updateUserAvatarAfterUploadService.js.map +1 -0
- package/lib/services/uploadFileFromStream.d.ts +8 -0
- package/lib/services/uploadFileFromStream.d.ts.map +1 -0
- package/lib/services/uploadFileFromStream.js +11 -0
- package/lib/services/uploadFileFromStream.js.map +1 -0
- package/lib/services/uploadFileFromStreamService.d.ts +12 -0
- package/lib/services/uploadFileFromStreamService.d.ts.map +1 -0
- package/lib/services/uploadFileFromStreamService.js +10 -0
- package/lib/services/uploadFileFromStreamService.js.map +1 -0
- package/lib/services/uploadFileFromURL.d.ts +13 -0
- package/lib/services/uploadFileFromURL.d.ts.map +1 -0
- package/lib/services/uploadFileFromURL.js +11 -0
- package/lib/services/uploadFileFromURL.js.map +1 -0
- package/lib/services/uploadFileFromURLService.d.ts +17 -0
- package/lib/services/uploadFileFromURLService.d.ts.map +1 -0
- package/lib/services/uploadFileFromURLService.js +10 -0
- package/lib/services/uploadFileFromURLService.js.map +1 -0
- package/lib/services/validateOrder.d.ts +4 -0
- package/lib/services/validateOrder.d.ts.map +1 -0
- package/lib/services/validateOrder.js +45 -0
- package/lib/services/validateOrder.js.map +1 -0
- package/lib/services/verifyQuotation.d.ts +6 -0
- package/lib/services/verifyQuotation.d.ts.map +1 -0
- package/lib/services/verifyQuotation.js +12 -0
- package/lib/services/verifyQuotation.js.map +1 -0
- package/package.json +28 -28
- package/src/core-index.ts +14 -241
- package/src/directors/BaseDiscountAdapter.test.ts +49 -0
- package/src/directors/BaseDiscountAdapter.ts +91 -0
- package/src/directors/BaseDiscountDirector.ts +72 -0
- package/src/directors/BasePricingAdapter.ts +82 -0
- package/src/directors/BasePricingDirector.ts +136 -0
- package/src/directors/BasePricingSheet.test.ts +43 -0
- package/src/directors/BasePricingSheet.ts +140 -0
- package/src/directors/DeliveryAdapter.ts +110 -0
- package/src/directors/DeliveryDirector.ts +135 -0
- package/src/directors/DeliveryPricingAdapter.ts +87 -0
- package/src/directors/DeliveryPricingDirector.ts +92 -0
- package/src/directors/DeliveryPricingSheet.ts +86 -0
- package/src/directors/EnrollmentAdapter.ts +109 -0
- package/src/directors/EnrollmentDirector.ts +70 -0
- package/src/directors/FilterAdapter.ts +103 -0
- package/src/directors/FilterDirector.ts +309 -0
- package/src/directors/MessagingDirector.test.ts +5 -0
- package/src/directors/MessagingDirector.ts +59 -0
- package/src/directors/OrderDiscountAdapter.ts +10 -0
- package/src/directors/OrderDiscountConfiguration.ts +5 -0
- package/src/directors/OrderDiscountDirector.ts +6 -0
- package/src/directors/OrderPricingAdapter.ts +63 -0
- package/src/directors/OrderPricingDirector.ts +74 -0
- package/src/directors/OrderPricingSheet.ts +147 -0
- package/src/directors/PaymentAdapter.ts +118 -0
- package/src/directors/PaymentDirector.ts +275 -0
- package/src/directors/PaymentPricingAdapter.ts +86 -0
- package/src/directors/PaymentPricingDirector.ts +94 -0
- package/src/directors/PaymentPricingSheet.ts +91 -0
- package/src/directors/ProductDiscountAdapter.ts +10 -0
- package/src/directors/ProductDiscountConfiguration.ts +18 -0
- package/src/directors/ProductDiscountDirector.ts +5 -0
- package/src/directors/ProductPricingAdapter.ts +56 -0
- package/src/directors/ProductPricingDirector.ts +100 -0
- package/src/directors/ProductPricingSheet.test.ts +129 -0
- package/src/directors/ProductPricingSheet.ts +127 -0
- package/src/directors/QuotationAdapter.ts +86 -0
- package/src/directors/QuotationDirector.ts +105 -0
- package/src/directors/WarehousingAdapter.ts +83 -0
- package/src/directors/WarehousingDirector.ts +235 -0
- package/src/directors/WorkerAdapter.ts +30 -0
- package/src/directors/WorkerDirector.ts +154 -0
- package/src/directors/index.ts +49 -0
- package/src/directors/periodForReferenceDate.test.ts +23 -0
- package/src/modules.ts +215 -0
- package/src/services/activateEnrollment.ts +30 -0
- package/src/services/calculateDiscountTotal.ts +71 -0
- package/src/services/checkoutOrder.ts +43 -0
- package/src/services/confirmOrder.ts +26 -0
- package/src/services/createDownloadStream.ts +16 -0
- package/src/services/createEnrollmentFromCheckout.ts +66 -0
- package/src/services/createManualOrderDiscount.ts +56 -0
- package/src/services/createSignedURL.ts +20 -0
- package/src/services/deleteUser.ts +33 -0
- package/src/services/discountedEntities.ts +81 -0
- package/src/services/ercMetadata.ts +33 -0
- package/src/services/fullfillQuotation.ts +14 -0
- package/src/services/index.ts +154 -0
- package/src/services/initCartProviders.ts +86 -0
- package/src/services/initializeEnrollment.ts +38 -0
- package/src/services/invalidateFilterCache.ts +16 -0
- package/src/services/linkFileService.ts +22 -0
- package/src/services/loadFilterOptions.ts +50 -0
- package/src/services/loadFilters.ts +52 -0
- package/src/services/migrateBookmarks.ts +39 -0
- package/src/services/migrateOrderCart.ts +52 -0
- package/src/services/migrateUserData.ts +22 -0
- package/src/services/nextUserCart.ts +52 -0
- package/src/services/processEnrollment.ts +37 -0
- package/src/services/processOrder.ts +241 -0
- package/src/services/processQuotation.ts +75 -0
- package/src/services/proposeQuotation.ts +18 -0
- package/src/services/registerPaymentCredentials.ts +30 -0
- package/src/services/rejectOrder.ts +26 -0
- package/src/services/rejectQuotation.ts +18 -0
- package/src/services/removeFiles.ts +25 -0
- package/src/services/removeProduct.ts +34 -0
- package/src/services/searchAssortments.ts +58 -0
- package/src/services/searchProducts.ts +73 -0
- package/src/services/supportedDeliveryProviders.ts +24 -0
- package/src/services/supportedPaymentProviders.ts +25 -0
- package/src/services/supportedWarehousingProviders.ts +18 -0
- package/src/services/terminateEnrollment.ts +29 -0
- package/src/services/updateCalculation.ts +143 -0
- package/src/services/updateScheduling.ts +64 -0
- package/src/services/updateUserAvatarAfterUpload.ts +30 -0
- package/src/services/uploadFileFromStream.ts +15 -0
- package/src/services/uploadFileFromURL.ts +29 -0
- package/src/services/validateOrder.ts +53 -0
- package/src/services/verifyQuotation.ts +18 -0
- package/tsconfig.json +5 -7
- package/src/types.ts +0 -7
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { log, LogLevel } from '@unchainedshop/logger';
|
|
2
|
+
import { IBaseAdapter } from '@unchainedshop/utils';
|
|
3
|
+
import { Order, OrderPayment } from '@unchainedshop/core-orders';
|
|
4
|
+
import { PaymentConfiguration, PaymentProvider, PaymentProviderType } from '@unchainedshop/core-payment';
|
|
5
|
+
import { Modules } from '../modules.js';
|
|
6
|
+
|
|
7
|
+
export enum PaymentError {
|
|
8
|
+
ADAPTER_NOT_FOUND = 'ADAPTER_NOT_FOUND',
|
|
9
|
+
NOT_IMPLEMENTED = 'NOT_IMPLEMENTED',
|
|
10
|
+
INCOMPLETE_CONFIGURATION = 'INCOMPLETE_CONFIGURATION',
|
|
11
|
+
WRONG_CREDENTIALS = 'WRONG_CREDENTIALS',
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type ChargeResult = {
|
|
15
|
+
transactionId?: string;
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type PaymentChargeActionResult = ChargeResult & {
|
|
20
|
+
credentials?: {
|
|
21
|
+
token: string;
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export interface IPaymentActions {
|
|
26
|
+
charge: (transactionContext?: any) => Promise<PaymentChargeActionResult | false>;
|
|
27
|
+
configurationError: (transactionContext?: any) => PaymentError;
|
|
28
|
+
isActive: (transactionContext?: any) => boolean;
|
|
29
|
+
isPayLaterAllowed: (transactionContext?: any) => boolean;
|
|
30
|
+
register: (transactionContext?: any) => Promise<any>;
|
|
31
|
+
sign: (transactionContext?: any) => Promise<string>;
|
|
32
|
+
validate: (token?: any) => Promise<boolean>;
|
|
33
|
+
cancel: (transactionContext?: any) => Promise<boolean>;
|
|
34
|
+
confirm: (transactionContext?: any) => Promise<boolean>;
|
|
35
|
+
}
|
|
36
|
+
export interface PaymentContext {
|
|
37
|
+
userId?: string;
|
|
38
|
+
order?: Order;
|
|
39
|
+
orderPayment?: OrderPayment;
|
|
40
|
+
transactionContext?: any; // User for singing and charging a payment
|
|
41
|
+
token?: any; // Used for validation
|
|
42
|
+
meta?: any;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type IPaymentAdapter = IBaseAdapter & {
|
|
46
|
+
initialConfiguration: PaymentConfiguration;
|
|
47
|
+
|
|
48
|
+
typeSupported: (type: PaymentProviderType) => boolean;
|
|
49
|
+
|
|
50
|
+
actions: (
|
|
51
|
+
config: PaymentConfiguration,
|
|
52
|
+
context: PaymentContext & {
|
|
53
|
+
paymentProviderId: string;
|
|
54
|
+
paymentProvider: PaymentProvider;
|
|
55
|
+
modules: Modules;
|
|
56
|
+
},
|
|
57
|
+
) => IPaymentActions;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const PaymentAdapter: Omit<IPaymentAdapter, 'key' | 'label' | 'version'> = {
|
|
61
|
+
initialConfiguration: [],
|
|
62
|
+
|
|
63
|
+
typeSupported: () => {
|
|
64
|
+
return false;
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
actions: () => {
|
|
68
|
+
return {
|
|
69
|
+
configurationError: () => {
|
|
70
|
+
return PaymentError.NOT_IMPLEMENTED;
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
isActive: () => {
|
|
74
|
+
return false;
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
isPayLaterAllowed: () => {
|
|
78
|
+
return false;
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
charge: async () => {
|
|
82
|
+
// if you return true, the status will be changed to PAID
|
|
83
|
+
|
|
84
|
+
// if you return false, the order payment status stays the
|
|
85
|
+
// same but the order status might change
|
|
86
|
+
|
|
87
|
+
// if you throw an error, you cancel the checkout process
|
|
88
|
+
return false;
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
register: async () => {
|
|
92
|
+
return {
|
|
93
|
+
token: '',
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
sign: async () => {
|
|
98
|
+
return null;
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
validate: async () => {
|
|
102
|
+
return false;
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
cancel: async () => {
|
|
106
|
+
return false;
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
confirm: async () => {
|
|
110
|
+
return false;
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
log(message: string, { level = LogLevel.Debug, ...options } = {}) {
|
|
116
|
+
return log(message, { level, ...options });
|
|
117
|
+
},
|
|
118
|
+
};
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { BaseDirector, IBaseDirector } from '@unchainedshop/utils';
|
|
2
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
3
|
+
import { PaymentError, IPaymentActions, IPaymentAdapter, PaymentContext } from './PaymentAdapter.js';
|
|
4
|
+
import { PaymentProvider } from '@unchainedshop/core-payment';
|
|
5
|
+
import { OrderPayment, OrderPaymentStatus } from '@unchainedshop/core-orders';
|
|
6
|
+
|
|
7
|
+
const buildPaymentProviderActionsContext = (
|
|
8
|
+
orderPayment: OrderPayment,
|
|
9
|
+
{ transactionContext, ...rest }: { transactionContext: any; userId: string },
|
|
10
|
+
) => ({
|
|
11
|
+
...rest,
|
|
12
|
+
orderPayment,
|
|
13
|
+
paymentProviderId: orderPayment.paymentProviderId,
|
|
14
|
+
transactionContext: {
|
|
15
|
+
...(transactionContext || {}),
|
|
16
|
+
...(orderPayment.context || {}),
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export type IPaymentDirector = IBaseDirector<IPaymentAdapter> & {
|
|
21
|
+
confirmOrderPayment: (
|
|
22
|
+
orderPayment: OrderPayment,
|
|
23
|
+
paymentContext: {
|
|
24
|
+
transactionContext: any;
|
|
25
|
+
userId: string;
|
|
26
|
+
},
|
|
27
|
+
unchainedAPI,
|
|
28
|
+
) => Promise<OrderPayment>;
|
|
29
|
+
|
|
30
|
+
cancelOrderPayment: (
|
|
31
|
+
orderPayment: OrderPayment,
|
|
32
|
+
paymentContext: {
|
|
33
|
+
transactionContext: any;
|
|
34
|
+
userId: string;
|
|
35
|
+
},
|
|
36
|
+
unchainedAPI,
|
|
37
|
+
) => Promise<OrderPayment>;
|
|
38
|
+
|
|
39
|
+
chargeOrderPayment: (
|
|
40
|
+
orderPayment: OrderPayment,
|
|
41
|
+
context: {
|
|
42
|
+
transactionContext: any;
|
|
43
|
+
userId: string;
|
|
44
|
+
},
|
|
45
|
+
unchainedAPI,
|
|
46
|
+
) => Promise<OrderPayment>;
|
|
47
|
+
|
|
48
|
+
actions: (
|
|
49
|
+
paymentProvider: PaymentProvider,
|
|
50
|
+
paymentContext: PaymentContext,
|
|
51
|
+
unchainedAPI,
|
|
52
|
+
) => Promise<IPaymentActions>;
|
|
53
|
+
};
|
|
54
|
+
const logger = createLogger('unchained:core-payment');
|
|
55
|
+
const baseDirector = BaseDirector<IPaymentAdapter>('PaymentDirector');
|
|
56
|
+
|
|
57
|
+
export const PaymentDirector: IPaymentDirector = {
|
|
58
|
+
...baseDirector,
|
|
59
|
+
|
|
60
|
+
actions: async (paymentProvider, paymentContext, unchainedAPI) => {
|
|
61
|
+
const Adapter = baseDirector.getAdapter(paymentProvider.adapterKey) as IPaymentAdapter;
|
|
62
|
+
|
|
63
|
+
if (!Adapter) {
|
|
64
|
+
throw new Error(`Payment Plugin ${paymentProvider.adapterKey} not available`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const newPaymentContext: PaymentContext = {
|
|
68
|
+
...paymentContext,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
if (paymentContext?.orderPayment) {
|
|
72
|
+
const { modules } = unchainedAPI;
|
|
73
|
+
const { orderId } = paymentContext.orderPayment;
|
|
74
|
+
const order =
|
|
75
|
+
paymentContext?.order ||
|
|
76
|
+
(await modules.orders.findOrder({
|
|
77
|
+
orderId,
|
|
78
|
+
}));
|
|
79
|
+
|
|
80
|
+
newPaymentContext.order = order;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const adapter = Adapter.actions(paymentProvider.configuration, {
|
|
84
|
+
paymentProvider,
|
|
85
|
+
paymentProviderId: paymentProvider._id,
|
|
86
|
+
...newPaymentContext,
|
|
87
|
+
...unchainedAPI,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
configurationError: () => {
|
|
92
|
+
try {
|
|
93
|
+
const error = adapter.configurationError();
|
|
94
|
+
return error;
|
|
95
|
+
} catch {
|
|
96
|
+
return PaymentError.ADAPTER_NOT_FOUND;
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
isActive: () => {
|
|
101
|
+
try {
|
|
102
|
+
return adapter.isActive(paymentContext.transactionContext);
|
|
103
|
+
} catch (error) {
|
|
104
|
+
logger.error(error.message);
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
isPayLaterAllowed: () => {
|
|
110
|
+
try {
|
|
111
|
+
return adapter.isPayLaterAllowed(paymentContext.transactionContext);
|
|
112
|
+
} catch (error) {
|
|
113
|
+
logger.error(error.message);
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
charge: async () => {
|
|
119
|
+
return adapter.charge(paymentContext.transactionContext);
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
register: async () => {
|
|
123
|
+
return adapter.register(paymentContext.transactionContext);
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
sign: async () => {
|
|
127
|
+
return adapter.sign(paymentContext.transactionContext);
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
validate: async () => {
|
|
131
|
+
const validated = await adapter.validate(paymentContext.token);
|
|
132
|
+
return !!validated;
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
cancel: async () => {
|
|
136
|
+
return adapter.cancel(paymentContext.transactionContext);
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
confirm: async () => {
|
|
140
|
+
return adapter.confirm(paymentContext.transactionContext);
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
confirmOrderPayment: async (
|
|
146
|
+
orderPayment: OrderPayment,
|
|
147
|
+
paymentContext: {
|
|
148
|
+
transactionContext: any;
|
|
149
|
+
userId: string;
|
|
150
|
+
},
|
|
151
|
+
unchainedAPI,
|
|
152
|
+
): Promise<OrderPayment> => {
|
|
153
|
+
const { modules } = unchainedAPI;
|
|
154
|
+
|
|
155
|
+
if (modules.orders.payments.normalizedStatus(orderPayment) !== OrderPaymentStatus.PAID) {
|
|
156
|
+
return orderPayment;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const paymentProvider = await modules.payment.paymentProviders.findProvider({
|
|
160
|
+
paymentProviderId: orderPayment.paymentProviderId,
|
|
161
|
+
});
|
|
162
|
+
const actions = await PaymentDirector.actions(
|
|
163
|
+
paymentProvider,
|
|
164
|
+
buildPaymentProviderActionsContext(orderPayment, paymentContext),
|
|
165
|
+
unchainedAPI,
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
const arbitraryResponseData = await actions.confirm();
|
|
169
|
+
|
|
170
|
+
if (arbitraryResponseData) {
|
|
171
|
+
return modules.orders.payments.updateStatus(orderPayment._id, {
|
|
172
|
+
status: OrderPaymentStatus.PAID,
|
|
173
|
+
info: JSON.stringify(arbitraryResponseData),
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return orderPayment;
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
cancelOrderPayment: async (
|
|
181
|
+
orderPayment: OrderPayment,
|
|
182
|
+
paymentContext: {
|
|
183
|
+
transactionContext: any;
|
|
184
|
+
userId: string;
|
|
185
|
+
},
|
|
186
|
+
unchainedAPI,
|
|
187
|
+
): Promise<OrderPayment> => {
|
|
188
|
+
const { modules } = unchainedAPI;
|
|
189
|
+
|
|
190
|
+
if (modules.orders.payments.normalizedStatus(orderPayment) !== OrderPaymentStatus.PAID) {
|
|
191
|
+
return orderPayment;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const paymentProvider = await modules.payment.paymentProviders.findProvider({
|
|
195
|
+
paymentProviderId: orderPayment.paymentProviderId,
|
|
196
|
+
});
|
|
197
|
+
const actions = await PaymentDirector.actions(
|
|
198
|
+
paymentProvider,
|
|
199
|
+
buildPaymentProviderActionsContext(orderPayment, paymentContext),
|
|
200
|
+
unchainedAPI,
|
|
201
|
+
);
|
|
202
|
+
const arbitraryResponseData = await actions.cancel();
|
|
203
|
+
|
|
204
|
+
if (arbitraryResponseData) {
|
|
205
|
+
return modules.orders.payments.updateStatus(orderPayment._id, {
|
|
206
|
+
status: OrderPaymentStatus.REFUNDED,
|
|
207
|
+
info: JSON.stringify(arbitraryResponseData),
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return orderPayment;
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
chargeOrderPayment: async (
|
|
215
|
+
orderPayment: OrderPayment,
|
|
216
|
+
context: {
|
|
217
|
+
transactionContext: any;
|
|
218
|
+
userId: string;
|
|
219
|
+
},
|
|
220
|
+
unchainedAPI,
|
|
221
|
+
): Promise<OrderPayment> => {
|
|
222
|
+
const { modules } = unchainedAPI;
|
|
223
|
+
|
|
224
|
+
if (modules.orders.payments.normalizedStatus(orderPayment) !== OrderPaymentStatus.OPEN) {
|
|
225
|
+
return orderPayment;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const paymentCredentials =
|
|
229
|
+
context.transactionContext?.paymentCredentials ||
|
|
230
|
+
(await modules.payment.paymentCredentials.findPaymentCredential({
|
|
231
|
+
userId: context.userId,
|
|
232
|
+
paymentProviderId: orderPayment.paymentProviderId,
|
|
233
|
+
isPreferred: true,
|
|
234
|
+
}));
|
|
235
|
+
|
|
236
|
+
const paymentContext = buildPaymentProviderActionsContext(orderPayment, {
|
|
237
|
+
...context,
|
|
238
|
+
transactionContext: {
|
|
239
|
+
...context.transactionContext,
|
|
240
|
+
paymentCredentials,
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
const paymentProvider = await modules.payment.paymentProviders.findProvider({
|
|
245
|
+
paymentProviderId: orderPayment.paymentProviderId,
|
|
246
|
+
});
|
|
247
|
+
const actions = await PaymentDirector.actions(paymentProvider, paymentContext, unchainedAPI);
|
|
248
|
+
const result = await actions.charge();
|
|
249
|
+
|
|
250
|
+
if (!result) return orderPayment;
|
|
251
|
+
|
|
252
|
+
const { credentials, ...arbitraryResponseData } = result;
|
|
253
|
+
|
|
254
|
+
if (credentials) {
|
|
255
|
+
const { token, ...meta } = credentials;
|
|
256
|
+
await modules.payment.paymentCredentials.upsertCredentials({
|
|
257
|
+
userId: paymentContext.userId,
|
|
258
|
+
paymentProviderId: orderPayment.paymentProviderId,
|
|
259
|
+
token,
|
|
260
|
+
...meta,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (arbitraryResponseData) {
|
|
265
|
+
const { transactionId, ...info } = arbitraryResponseData;
|
|
266
|
+
return modules.orders.payments.updateStatus(orderPayment._id, {
|
|
267
|
+
transactionId,
|
|
268
|
+
status: OrderPaymentStatus.PAID,
|
|
269
|
+
info: JSON.stringify(info),
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return orderPayment;
|
|
274
|
+
},
|
|
275
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { PricingCalculation } from '@unchainedshop/utils';
|
|
2
|
+
import {
|
|
3
|
+
BasePricingAdapter,
|
|
4
|
+
BasePricingAdapterContext,
|
|
5
|
+
IPricingAdapter,
|
|
6
|
+
IPricingSheet,
|
|
7
|
+
} from '../directors/index.js';
|
|
8
|
+
import { PaymentPricingSheet } from './PaymentPricingSheet.js';
|
|
9
|
+
import { PaymentProvider } from '@unchainedshop/core-payment';
|
|
10
|
+
import { OrderDiscount, OrderPayment, Order } from '@unchainedshop/core-orders';
|
|
11
|
+
import { User } from '@unchainedshop/core-users';
|
|
12
|
+
import { Modules } from '../modules.js';
|
|
13
|
+
|
|
14
|
+
export interface PaymentPricingCalculation extends PricingCalculation {
|
|
15
|
+
discountId?: string;
|
|
16
|
+
isTaxable: boolean;
|
|
17
|
+
isNetPrice: boolean;
|
|
18
|
+
rate?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface PaymentPricingAdapterContext extends BasePricingAdapterContext {
|
|
21
|
+
country?: string;
|
|
22
|
+
currency?: string;
|
|
23
|
+
user: User;
|
|
24
|
+
orderPayment: OrderPayment;
|
|
25
|
+
order: Order;
|
|
26
|
+
provider: PaymentProvider;
|
|
27
|
+
discounts: Array<OrderDiscount>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type IPaymentPricingSheet = IPricingSheet<PaymentPricingCalculation> & {
|
|
31
|
+
addFee: (params: { amount: number; isTaxable: boolean; isNetPrice: boolean; meta?: any }) => void;
|
|
32
|
+
addTax: (params: {
|
|
33
|
+
amount: number;
|
|
34
|
+
rate: number;
|
|
35
|
+
baseCategory?: string;
|
|
36
|
+
discountId?: string;
|
|
37
|
+
meta?: any;
|
|
38
|
+
}) => void;
|
|
39
|
+
addDiscount: (params: {
|
|
40
|
+
amount: number;
|
|
41
|
+
isTaxable: boolean;
|
|
42
|
+
isNetPrice: boolean;
|
|
43
|
+
discountId: string;
|
|
44
|
+
meta?: any;
|
|
45
|
+
}) => void;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type IPaymentPricingAdapter<DiscountConfiguration = unknown> = IPricingAdapter<
|
|
49
|
+
PaymentPricingAdapterContext & { modules: Modules },
|
|
50
|
+
PaymentPricingCalculation,
|
|
51
|
+
IPaymentPricingSheet,
|
|
52
|
+
DiscountConfiguration
|
|
53
|
+
>;
|
|
54
|
+
|
|
55
|
+
const basePricingAdapter = BasePricingAdapter<PaymentPricingAdapterContext, PaymentPricingCalculation>();
|
|
56
|
+
|
|
57
|
+
export const PaymentPricingAdapter: IPricingAdapter<
|
|
58
|
+
PaymentPricingAdapterContext,
|
|
59
|
+
PaymentPricingCalculation,
|
|
60
|
+
IPaymentPricingSheet
|
|
61
|
+
> = {
|
|
62
|
+
...basePricingAdapter,
|
|
63
|
+
|
|
64
|
+
isActivatedFor: () => {
|
|
65
|
+
return false;
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
actions: (params) => {
|
|
69
|
+
const { context } = params;
|
|
70
|
+
const { currency } = context.order;
|
|
71
|
+
const baseActions = basePricingAdapter.actions(params);
|
|
72
|
+
const resultSheet = PaymentPricingSheet({ currency });
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
...baseActions,
|
|
76
|
+
calculate: async () => {
|
|
77
|
+
const resultRaw = resultSheet.getRawPricingSheet();
|
|
78
|
+
resultRaw.forEach(({ amount, category }) =>
|
|
79
|
+
basePricingAdapter.log(`Payment Calculation -> ${category} ${amount}`),
|
|
80
|
+
);
|
|
81
|
+
return resultRaw;
|
|
82
|
+
},
|
|
83
|
+
resultSheet: () => resultSheet,
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BasePricingDirector,
|
|
3
|
+
IPricingDirector,
|
|
4
|
+
IPaymentPricingAdapter,
|
|
5
|
+
IPaymentPricingSheet,
|
|
6
|
+
PaymentPricingAdapterContext,
|
|
7
|
+
PaymentPricingCalculation,
|
|
8
|
+
} from '../directors/index.js';
|
|
9
|
+
import { PaymentPricingSheet } from './PaymentPricingSheet.js';
|
|
10
|
+
import { PaymentProvider } from '@unchainedshop/core-payment';
|
|
11
|
+
import { OrderPayment, Order } from '@unchainedshop/core-orders';
|
|
12
|
+
import { User } from '@unchainedshop/core-users';
|
|
13
|
+
|
|
14
|
+
export type PaymentPricingContext =
|
|
15
|
+
| {
|
|
16
|
+
country?: string;
|
|
17
|
+
currency?: string;
|
|
18
|
+
user: User;
|
|
19
|
+
order: Order;
|
|
20
|
+
provider: PaymentProvider;
|
|
21
|
+
providerContext?: any;
|
|
22
|
+
}
|
|
23
|
+
| {
|
|
24
|
+
currency: string;
|
|
25
|
+
item: OrderPayment;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type IPaymentPricingDirector<DiscountConfiguration = unknown> = IPricingDirector<
|
|
29
|
+
PaymentPricingContext,
|
|
30
|
+
PaymentPricingCalculation,
|
|
31
|
+
PaymentPricingAdapterContext,
|
|
32
|
+
IPaymentPricingSheet,
|
|
33
|
+
IPaymentPricingAdapter<DiscountConfiguration>
|
|
34
|
+
>;
|
|
35
|
+
|
|
36
|
+
const baseDirector = BasePricingDirector<
|
|
37
|
+
PaymentPricingContext,
|
|
38
|
+
PaymentPricingAdapterContext,
|
|
39
|
+
PaymentPricingCalculation,
|
|
40
|
+
IPaymentPricingAdapter
|
|
41
|
+
>('PaymentPricingDirector');
|
|
42
|
+
|
|
43
|
+
export const PaymentPricingDirector: IPaymentPricingDirector<any> = {
|
|
44
|
+
...baseDirector,
|
|
45
|
+
|
|
46
|
+
async buildPricingContext(context, unchainedAPI) {
|
|
47
|
+
const { modules } = unchainedAPI;
|
|
48
|
+
|
|
49
|
+
if ('item' in context) {
|
|
50
|
+
const { item, currency } = context;
|
|
51
|
+
const order = await modules.orders.findOrder({
|
|
52
|
+
orderId: item.orderId,
|
|
53
|
+
});
|
|
54
|
+
const provider = await modules.payment.paymentProviders.findProvider({
|
|
55
|
+
paymentProviderId: item.paymentProviderId,
|
|
56
|
+
});
|
|
57
|
+
const user = await modules.users.findUserById(order.userId);
|
|
58
|
+
const discounts = await modules.orders.discounts.findOrderDiscounts({
|
|
59
|
+
orderId: item.orderId,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
...unchainedAPI,
|
|
64
|
+
country: order.countryCode,
|
|
65
|
+
currency,
|
|
66
|
+
order,
|
|
67
|
+
provider,
|
|
68
|
+
user,
|
|
69
|
+
discounts,
|
|
70
|
+
orderPayment: item,
|
|
71
|
+
providerContext: null,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
...unchainedAPI,
|
|
77
|
+
country: context.country,
|
|
78
|
+
currency: context.currency,
|
|
79
|
+
order: context.order,
|
|
80
|
+
provider: context.provider,
|
|
81
|
+
user: context.user,
|
|
82
|
+
discounts: [],
|
|
83
|
+
orderPayment: null,
|
|
84
|
+
providerContext: context.providerContext,
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
calculationSheet(pricingContext, calculation) {
|
|
89
|
+
return PaymentPricingSheet({
|
|
90
|
+
calculation,
|
|
91
|
+
currency: pricingContext.currency,
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PaymentPricingCalculation,
|
|
3
|
+
IPaymentPricingSheet,
|
|
4
|
+
BasePricingSheet,
|
|
5
|
+
IBasePricingSheet,
|
|
6
|
+
PricingSheetParams,
|
|
7
|
+
} from '../directors/index.js';
|
|
8
|
+
|
|
9
|
+
export enum PaymentPricingRowCategory {
|
|
10
|
+
Item = 'ITEM',
|
|
11
|
+
Payment = 'PAYMENT',
|
|
12
|
+
Discount = 'DISCOUNT',
|
|
13
|
+
Tax = 'TAX',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const PaymentPricingSheet = (
|
|
17
|
+
params: PricingSheetParams<PaymentPricingCalculation>,
|
|
18
|
+
): IPaymentPricingSheet => {
|
|
19
|
+
const basePricingSheet: IBasePricingSheet<PaymentPricingCalculation> = BasePricingSheet(params);
|
|
20
|
+
|
|
21
|
+
const pricingSheet: IPaymentPricingSheet = {
|
|
22
|
+
...basePricingSheet,
|
|
23
|
+
|
|
24
|
+
addDiscount({ amount, isTaxable, isNetPrice, discountId, meta }) {
|
|
25
|
+
basePricingSheet.calculation.push({
|
|
26
|
+
category: PaymentPricingRowCategory.Discount,
|
|
27
|
+
amount,
|
|
28
|
+
isTaxable,
|
|
29
|
+
isNetPrice,
|
|
30
|
+
discountId,
|
|
31
|
+
meta,
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
addFee({ amount, isTaxable, isNetPrice, meta }) {
|
|
36
|
+
basePricingSheet.calculation.push({
|
|
37
|
+
category: PaymentPricingRowCategory.Payment,
|
|
38
|
+
amount,
|
|
39
|
+
isTaxable,
|
|
40
|
+
isNetPrice,
|
|
41
|
+
meta,
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
addTax({ amount, rate, meta }) {
|
|
46
|
+
basePricingSheet.calculation.push({
|
|
47
|
+
category: PaymentPricingRowCategory.Tax,
|
|
48
|
+
amount,
|
|
49
|
+
isTaxable: false,
|
|
50
|
+
isNetPrice: false,
|
|
51
|
+
rate,
|
|
52
|
+
meta,
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
taxSum(filter) {
|
|
57
|
+
return basePricingSheet.sum({
|
|
58
|
+
category: PaymentPricingRowCategory.Tax,
|
|
59
|
+
...(filter || {}),
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
discountPrices(explicitDiscountId) {
|
|
64
|
+
const discountIds = pricingSheet
|
|
65
|
+
.filterBy({
|
|
66
|
+
category: PaymentPricingRowCategory.Discount,
|
|
67
|
+
discountId: explicitDiscountId,
|
|
68
|
+
})
|
|
69
|
+
.map(({ discountId }) => discountId);
|
|
70
|
+
|
|
71
|
+
return [...new Set(discountIds)]
|
|
72
|
+
.map((discountId) => {
|
|
73
|
+
const amount = basePricingSheet.sum({
|
|
74
|
+
category: PaymentPricingRowCategory.Discount,
|
|
75
|
+
discountId,
|
|
76
|
+
});
|
|
77
|
+
if (!amount) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
discountId,
|
|
82
|
+
amount: Math.round(amount),
|
|
83
|
+
currency: basePricingSheet.currency,
|
|
84
|
+
};
|
|
85
|
+
})
|
|
86
|
+
.filter(Boolean);
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
return pricingSheet;
|
|
91
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseDiscountAdapter,
|
|
3
|
+
IDiscountAdapter,
|
|
4
|
+
ProductDiscountConfiguration,
|
|
5
|
+
} from '../directors/index.js';
|
|
6
|
+
|
|
7
|
+
export const ProductDiscountAdapter: Omit<
|
|
8
|
+
IDiscountAdapter<ProductDiscountConfiguration, any>,
|
|
9
|
+
'key' | 'label' | 'version'
|
|
10
|
+
> = BaseDiscountAdapter;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Product, ProductConfiguration } from '@unchainedshop/core-products';
|
|
2
|
+
|
|
3
|
+
type ResolvedConfiguration = {
|
|
4
|
+
fixedRate?: number;
|
|
5
|
+
rate?: number;
|
|
6
|
+
isNetPrice?: boolean;
|
|
7
|
+
taxRate?: number;
|
|
8
|
+
} & Record<string, any>;
|
|
9
|
+
|
|
10
|
+
export type PriceConfigurationResolver = (
|
|
11
|
+
product: Product,
|
|
12
|
+
quantity: number,
|
|
13
|
+
configuration: Array<ProductConfiguration>,
|
|
14
|
+
) => ResolvedConfiguration | null;
|
|
15
|
+
|
|
16
|
+
export interface ProductDiscountConfiguration extends ResolvedConfiguration {
|
|
17
|
+
customPriceConfigurationResolver?: PriceConfigurationResolver;
|
|
18
|
+
}
|