@unchainedshop/plugins 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/delivery/pick-mup.js +1 -2
- package/lib/delivery/pick-mup.js.map +1 -1
- package/lib/delivery/post.js +2 -1
- package/lib/delivery/post.js.map +1 -1
- package/lib/delivery/send-message.js +2 -1
- package/lib/delivery/send-message.js.map +1 -1
- package/lib/delivery/stores.js +2 -1
- package/lib/delivery/stores.js.map +1 -1
- package/lib/enrollments/licensed.d.ts.map +1 -1
- package/lib/enrollments/licensed.js +1 -1
- package/lib/enrollments/licensed.js.map +1 -1
- package/lib/events/aws-eventbridge.d.ts +2 -0
- package/lib/events/aws-eventbridge.d.ts.map +1 -0
- package/lib/events/aws-eventbridge.js +36 -0
- package/lib/events/aws-eventbridge.js.map +1 -0
- package/lib/events/node-event-emitter.js +1 -2
- package/lib/events/node-event-emitter.js.map +1 -1
- package/lib/events/redis.js +4 -2
- package/lib/events/redis.js.map +1 -1
- package/lib/files/gridfs/gridfs-adapter.d.ts.map +1 -1
- package/lib/files/gridfs/gridfs-adapter.js +14 -5
- package/lib/files/gridfs/gridfs-adapter.js.map +1 -1
- package/lib/files/gridfs/gridfs-webhook.d.ts +1 -1
- package/lib/files/gridfs/gridfs-webhook.d.ts.map +1 -1
- package/lib/files/gridfs/gridfs-webhook.js +25 -6
- package/lib/files/gridfs/gridfs-webhook.js.map +1 -1
- package/lib/files/gridfs/sign.d.ts +1 -1
- package/lib/files/gridfs/sign.d.ts.map +1 -1
- package/lib/files/gridfs/sign.js +8 -7
- package/lib/files/gridfs/sign.js.map +1 -1
- package/lib/files/minio/minio-adapter.d.ts.map +1 -1
- package/lib/files/minio/minio-adapter.js +13 -9
- package/lib/files/minio/minio-adapter.js.map +1 -1
- package/lib/files/minio/minio-webhook.d.ts.map +1 -1
- package/lib/files/minio/minio-webhook.js +4 -3
- package/lib/files/minio/minio-webhook.js.map +1 -1
- package/lib/filters/local-search.d.ts +1 -1
- package/lib/filters/local-search.d.ts.map +1 -1
- package/lib/filters/local-search.js +1 -1
- package/lib/filters/local-search.js.map +1 -1
- package/lib/filters/strict-equal.js +1 -1
- package/lib/filters/strict-equal.js.map +1 -1
- package/lib/payment/apple-iap/adapter.d.ts.map +1 -1
- package/lib/payment/apple-iap/adapter.js +15 -20
- package/lib/payment/apple-iap/adapter.js.map +1 -1
- package/lib/payment/apple-iap/db/AppleTransactionsCollection.d.ts +1 -1
- package/lib/payment/apple-iap/db/AppleTransactionsCollection.d.ts.map +1 -1
- package/lib/payment/apple-iap/module/configureAppleTransactionsModule.d.ts +1 -1
- package/lib/payment/apple-iap/module/configureAppleTransactionsModule.d.ts.map +1 -1
- package/lib/payment/braintree.js +10 -8
- package/lib/payment/braintree.js.map +1 -1
- package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts +1 -1
- package/lib/payment/cryptopay/db/CryptopayTransactions.d.ts.map +1 -1
- package/lib/payment/cryptopay/middleware.d.ts.map +1 -1
- package/lib/payment/cryptopay/middleware.js +4 -4
- package/lib/payment/cryptopay/middleware.js.map +1 -1
- package/lib/payment/cryptopay/plugin.d.ts +1 -1
- package/lib/payment/cryptopay/plugin.d.ts.map +1 -1
- package/lib/payment/cryptopay/plugin.js +8 -9
- package/lib/payment/cryptopay/plugin.js.map +1 -1
- package/lib/payment/datatrans-v2/api/authorize.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/authorize.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/api/authorizeAuthenticated.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/authorizeAuthenticated.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/api/cancel.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/cancel.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/api/init.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/init.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/api/makeFetcher.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/api/makeFetcher.js +0 -1
- package/lib/payment/datatrans-v2/api/makeFetcher.js.map +1 -1
- package/lib/payment/datatrans-v2/api/secureFields.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/secureFields.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/api/settle.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/settle.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/api/status.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/status.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/api/types.d.ts +260 -0
- package/lib/payment/datatrans-v2/api/types.d.ts.map +1 -0
- package/lib/payment/datatrans-v2/api/types.js +2 -0
- package/lib/payment/datatrans-v2/api/types.js.map +1 -0
- package/lib/payment/datatrans-v2/api/validate.d.ts +1 -1
- package/lib/payment/datatrans-v2/api/validate.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/generateSignature copy.d.ts +11 -0
- package/lib/payment/datatrans-v2/generateSignature copy.d.ts.map +1 -0
- package/lib/payment/datatrans-v2/generateSignature copy.js +19 -0
- package/lib/payment/datatrans-v2/generateSignature copy.js.map +1 -0
- package/lib/payment/datatrans-v2/generateSignature.d.ts +1 -1
- package/lib/payment/datatrans-v2/generateSignature.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/generateSignature.js +7 -4
- package/lib/payment/datatrans-v2/generateSignature.js.map +1 -1
- package/lib/payment/datatrans-v2/index.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/index.js +31 -29
- package/lib/payment/datatrans-v2/index.js.map +1 -1
- package/lib/payment/datatrans-v2/middleware.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/middleware.js +7 -5
- package/lib/payment/datatrans-v2/middleware.js.map +1 -1
- package/lib/payment/datatrans-v2/parseRegistrationData.d.ts +4 -4
- package/lib/payment/datatrans-v2/parseRegistrationData.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/parseRegistrationData.js +5 -3
- package/lib/payment/datatrans-v2/parseRegistrationData.js.map +1 -1
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts +1 -2
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.js +6 -2
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.js.map +1 -1
- package/lib/payment/datatrans-v2/splitProperties.d.ts +0 -1
- package/lib/payment/datatrans-v2/splitProperties.d.ts.map +1 -1
- package/lib/payment/datatrans-v2/splitProperties.js +0 -3
- package/lib/payment/datatrans-v2/splitProperties.js.map +1 -1
- package/lib/payment/invoice-prepaid.js +4 -3
- package/lib/payment/invoice-prepaid.js.map +1 -1
- package/lib/payment/invoice.js +4 -3
- package/lib/payment/invoice.js.map +1 -1
- package/lib/payment/paypal-checkout.js +10 -6
- package/lib/payment/paypal-checkout.js.map +1 -1
- package/lib/payment/payrexx/api/makeFetcher.d.ts.map +1 -1
- package/lib/payment/payrexx/api/makeFetcher.js +2 -3
- package/lib/payment/payrexx/api/makeFetcher.js.map +1 -1
- package/lib/payment/payrexx/index.d.ts.map +1 -1
- package/lib/payment/payrexx/index.js +20 -14
- package/lib/payment/payrexx/index.js.map +1 -1
- package/lib/payment/payrexx/middleware.d.ts.map +1 -1
- package/lib/payment/payrexx/middleware.js +12 -9
- package/lib/payment/payrexx/middleware.js.map +1 -1
- package/lib/payment/postfinance-checkout/index.d.ts.map +1 -1
- package/lib/payment/postfinance-checkout/index.js +18 -13
- package/lib/payment/postfinance-checkout/index.js.map +1 -1
- package/lib/payment/postfinance-checkout/middleware.d.ts.map +1 -1
- package/lib/payment/postfinance-checkout/middleware.js +4 -3
- package/lib/payment/postfinance-checkout/middleware.js.map +1 -1
- package/lib/payment/postfinance-checkout/utils.d.ts +2 -2
- package/lib/payment/postfinance-checkout/utils.d.ts.map +1 -1
- package/lib/payment/postfinance-checkout/utils.js +6 -2
- package/lib/payment/postfinance-checkout/utils.js.map +1 -1
- package/lib/payment/saferpay/adapter.d.ts +1 -1
- package/lib/payment/saferpay/adapter.d.ts.map +1 -1
- package/lib/payment/saferpay/adapter.js +17 -11
- package/lib/payment/saferpay/adapter.js.map +1 -1
- package/lib/payment/saferpay/api/api/SaferpayConnection.d.ts.map +1 -1
- package/lib/payment/saferpay/api/api/SaferpayConnection.js +0 -1
- package/lib/payment/saferpay/api/api/SaferpayConnection.js.map +1 -1
- package/lib/payment/saferpay/api/models/TransactionCapture.d.ts +1 -1
- package/lib/payment/saferpay/api/models/TransactionCapture.d.ts.map +1 -1
- package/lib/payment/saferpay/db/SaferpayTransactionsCollection.d.ts +1 -1
- package/lib/payment/saferpay/db/SaferpayTransactionsCollection.d.ts.map +1 -1
- package/lib/payment/saferpay/middleware.d.ts.map +1 -1
- package/lib/payment/saferpay/middleware.js +4 -4
- package/lib/payment/saferpay/middleware.js.map +1 -1
- package/lib/payment/stripe/index.d.ts.map +1 -1
- package/lib/payment/stripe/index.js +17 -11
- package/lib/payment/stripe/index.js.map +1 -1
- package/lib/payment/stripe/middleware.d.ts.map +1 -1
- package/lib/payment/stripe/middleware.js +10 -10
- package/lib/payment/stripe/middleware.js.map +1 -1
- package/lib/payment/stripe/stripe.d.ts +3 -4
- package/lib/payment/stripe/stripe.d.ts.map +1 -1
- package/lib/payment/stripe/stripe.js +3 -1
- package/lib/payment/stripe/stripe.js.map +1 -1
- package/lib/pricing/delivery-swiss-tax.d.ts +1 -1
- package/lib/pricing/delivery-swiss-tax.d.ts.map +1 -1
- package/lib/pricing/delivery-swiss-tax.js +1 -2
- package/lib/pricing/delivery-swiss-tax.js.map +1 -1
- package/lib/pricing/discount-100-off.d.ts +2 -3
- package/lib/pricing/discount-100-off.d.ts.map +1 -1
- package/lib/pricing/discount-100-off.js +1 -1
- package/lib/pricing/discount-100-off.js.map +1 -1
- package/lib/pricing/discount-half-price-manual.d.ts +2 -3
- package/lib/pricing/discount-half-price-manual.d.ts.map +1 -1
- package/lib/pricing/discount-half-price-manual.js +1 -1
- package/lib/pricing/discount-half-price-manual.js.map +1 -1
- package/lib/pricing/discount-half-price.d.ts +2 -3
- package/lib/pricing/discount-half-price.d.ts.map +1 -1
- package/lib/pricing/discount-half-price.js +1 -1
- package/lib/pricing/discount-half-price.js.map +1 -1
- package/lib/pricing/free-delivery.d.ts +1 -1
- package/lib/pricing/free-delivery.d.ts.map +1 -1
- package/lib/pricing/free-delivery.js +1 -1
- package/lib/pricing/free-delivery.js.map +1 -1
- package/lib/pricing/free-payment.d.ts +1 -1
- package/lib/pricing/free-payment.d.ts.map +1 -1
- package/lib/pricing/free-payment.js +1 -1
- package/lib/pricing/free-payment.js.map +1 -1
- package/lib/pricing/order-delivery.d.ts +1 -1
- package/lib/pricing/order-delivery.d.ts.map +1 -1
- package/lib/pricing/order-delivery.js +6 -3
- package/lib/pricing/order-delivery.js.map +1 -1
- package/lib/pricing/order-discount.d.ts +1 -2
- package/lib/pricing/order-discount.d.ts.map +1 -1
- package/lib/pricing/order-discount.js +15 -8
- package/lib/pricing/order-discount.js.map +1 -1
- package/lib/pricing/order-items-discount.js +7 -4
- package/lib/pricing/order-items-discount.js.map +1 -1
- package/lib/pricing/order-items.js +7 -3
- package/lib/pricing/order-items.js.map +1 -1
- package/lib/pricing/order-payment.js +6 -3
- package/lib/pricing/order-payment.js.map +1 -1
- package/lib/pricing/order-round.d.ts +1 -1
- package/lib/pricing/order-round.d.ts.map +1 -1
- package/lib/pricing/order-round.js +1 -2
- package/lib/pricing/order-round.js.map +1 -1
- package/lib/pricing/product-catalog-price.d.ts +2 -2
- package/lib/pricing/product-catalog-price.d.ts.map +1 -1
- package/lib/pricing/product-catalog-price.js +7 -6
- package/lib/pricing/product-catalog-price.js.map +1 -1
- package/lib/pricing/product-discount.js +1 -2
- package/lib/pricing/product-discount.js.map +1 -1
- package/lib/pricing/product-price-rateconversion.d.ts +1 -1
- package/lib/pricing/product-price-rateconversion.d.ts.map +1 -1
- package/lib/pricing/product-price-rateconversion.js +1 -1
- package/lib/pricing/product-price-rateconversion.js.map +1 -1
- package/lib/pricing/product-round.d.ts +1 -1
- package/lib/pricing/product-round.d.ts.map +1 -1
- package/lib/pricing/product-round.js +1 -1
- package/lib/pricing/product-round.js.map +1 -1
- package/lib/pricing/product-swiss-tax.d.ts +4 -3
- package/lib/pricing/product-swiss-tax.d.ts.map +1 -1
- package/lib/pricing/product-swiss-tax.js +1 -2
- package/lib/pricing/product-swiss-tax.js.map +1 -1
- package/lib/quotations/manual.js +1 -1
- package/lib/quotations/manual.js.map +1 -1
- package/lib/warehousing/eth-minter.js +7 -4
- package/lib/warehousing/eth-minter.js.map +1 -1
- package/lib/warehousing/store.js +2 -1
- package/lib/warehousing/store.js.map +1 -1
- package/lib/worker/BaseWorker.d.ts +30 -0
- package/lib/worker/BaseWorker.d.ts.map +1 -0
- package/lib/worker/BaseWorker.js +81 -0
- package/lib/worker/BaseWorker.js.map +1 -0
- package/lib/worker/EventListenerWorker.d.ts +6 -0
- package/lib/worker/EventListenerWorker.d.ts.map +1 -0
- package/lib/worker/EventListenerWorker.js +46 -0
- package/lib/worker/EventListenerWorker.js.map +1 -0
- package/lib/worker/FailedRescheduler.d.ts +15 -0
- package/lib/worker/FailedRescheduler.d.ts.map +1 -0
- package/lib/worker/FailedRescheduler.js +45 -0
- package/lib/worker/FailedRescheduler.js.map +1 -0
- package/lib/worker/IntervalWorker.d.ts +10 -0
- package/lib/worker/IntervalWorker.d.ts.map +1 -0
- package/lib/worker/IntervalWorker.js +37 -0
- package/lib/worker/IntervalWorker.js.map +1 -0
- package/lib/worker/bulk-import.d.ts +1 -1
- package/lib/worker/bulk-import.d.ts.map +1 -1
- package/lib/worker/bulk-import.js +7 -8
- package/lib/worker/bulk-import.js.map +1 -1
- package/lib/worker/email.d.ts.map +1 -1
- package/lib/worker/email.js +1 -5
- package/lib/worker/email.js.map +1 -1
- package/lib/worker/enrollment-order-generator.d.ts.map +1 -1
- package/lib/worker/enrollment-order-generator.js +17 -15
- package/lib/worker/enrollment-order-generator.js.map +1 -1
- package/lib/worker/error-notifications.d.ts +1 -1
- package/lib/worker/error-notifications.d.ts.map +1 -1
- package/lib/worker/error-notifications.js +1 -1
- package/lib/worker/error-notifications.js.map +1 -1
- package/lib/worker/export-token.d.ts +1 -2
- package/lib/worker/export-token.d.ts.map +1 -1
- package/lib/worker/export-token.js +2 -1
- package/lib/worker/export-token.js.map +1 -1
- package/lib/worker/external.d.ts +1 -1
- package/lib/worker/external.d.ts.map +1 -1
- package/lib/worker/external.js +1 -1
- package/lib/worker/external.js.map +1 -1
- package/lib/worker/heartbeat.js +1 -1
- package/lib/worker/heartbeat.js.map +1 -1
- package/lib/worker/http-request.d.ts +1 -1
- package/lib/worker/http-request.d.ts.map +1 -1
- package/lib/worker/http-request.js +1 -5
- package/lib/worker/http-request.js.map +1 -1
- package/lib/worker/message.d.ts +2 -2
- package/lib/worker/message.d.ts.map +1 -1
- package/lib/worker/message.js +1 -5
- package/lib/worker/message.js.map +1 -1
- package/lib/worker/push-notification.js +1 -4
- package/lib/worker/push-notification.js.map +1 -1
- package/lib/worker/sms.js +1 -4
- package/lib/worker/sms.js.map +1 -1
- package/lib/worker/update-coinbase-rates.js +1 -1
- package/lib/worker/update-coinbase-rates.js.map +1 -1
- package/lib/worker/update-ecb-rates.js +1 -1
- package/lib/worker/update-ecb-rates.js.map +1 -1
- package/lib/worker/update-token-ownership.d.ts +1 -1
- package/lib/worker/update-token-ownership.d.ts.map +1 -1
- package/lib/worker/update-token-ownership.js +1 -1
- package/lib/worker/update-token-ownership.js.map +1 -1
- package/lib/worker/zombie-killer.d.ts +8 -2
- package/lib/worker/zombie-killer.d.ts.map +1 -1
- package/lib/worker/zombie-killer.js +12 -9
- package/lib/worker/zombie-killer.js.map +1 -1
- package/package.json +37 -82
- package/src/delivery/pick-mup.ts +2 -3
- package/src/delivery/post.ts +2 -2
- package/src/delivery/send-message.ts +2 -2
- package/src/delivery/stores.ts +2 -2
- package/src/enrollments/licensed.ts +1 -2
- package/src/events/aws-eventbridge.ts +43 -0
- package/src/events/node-event-emitter.ts +1 -2
- package/src/events/redis.ts +4 -2
- package/src/files/gridfs/gridfs-adapter.ts +15 -5
- package/src/files/gridfs/gridfs-webhook.ts +29 -9
- package/src/files/gridfs/sign.ts +20 -8
- package/src/files/minio/minio-adapter.ts +14 -11
- package/src/files/minio/minio-webhook.ts +5 -3
- package/src/filters/local-search.ts +1 -2
- package/src/filters/strict-equal.ts +1 -2
- package/src/payment/apple-iap/adapter.ts +22 -40
- package/src/payment/apple-iap/db/AppleTransactionsCollection.ts +1 -1
- package/src/payment/apple-iap/module/configureAppleTransactionsModule.ts +1 -1
- package/src/payment/braintree.ts +16 -9
- package/src/payment/cryptopay/db/CryptopayTransactions.ts +1 -1
- package/src/payment/cryptopay/middleware.ts +11 -8
- package/src/payment/cryptopay/plugin.ts +14 -11
- package/src/payment/datatrans-v2/api/authorize.ts +1 -1
- package/src/payment/datatrans-v2/api/authorizeAuthenticated.ts +1 -1
- package/src/payment/datatrans-v2/api/cancel.ts +1 -1
- package/src/payment/datatrans-v2/api/init.ts +1 -1
- package/src/payment/datatrans-v2/api/makeFetcher.ts +0 -1
- package/src/payment/datatrans-v2/api/secureFields.ts +1 -1
- package/src/payment/datatrans-v2/api/settle.ts +1 -1
- package/src/payment/datatrans-v2/api/status.ts +1 -1
- package/src/payment/datatrans-v2/api/validate.ts +1 -1
- package/src/payment/datatrans-v2/generateSignature.test.ts +15 -0
- package/src/payment/datatrans-v2/generateSignature.ts +18 -6
- package/src/payment/datatrans-v2/index.ts +41 -36
- package/src/payment/datatrans-v2/middleware.ts +8 -12
- package/src/payment/datatrans-v2/parseRegistrationData.ts +7 -5
- package/src/payment/datatrans-v2/roundedAmountFromOrder.ts +6 -6
- package/src/payment/datatrans-v2/splitProperties.ts +0 -5
- package/src/payment/invoice-prepaid.ts +4 -4
- package/src/payment/invoice.ts +4 -4
- package/src/payment/paypal-checkout.ts +16 -7
- package/src/payment/payrexx/api/makeFetcher.ts +2 -3
- package/src/payment/payrexx/index.ts +26 -15
- package/src/payment/payrexx/middleware.ts +14 -19
- package/src/payment/postfinance-checkout/index.ts +26 -17
- package/src/payment/postfinance-checkout/middleware.ts +6 -9
- package/src/payment/postfinance-checkout/utils.ts +6 -3
- package/src/payment/saferpay/adapter.ts +23 -13
- package/src/payment/saferpay/api/api/SaferpayConnection.ts +0 -1
- package/src/payment/saferpay/api/models/TransactionCapture.ts +1 -1
- package/src/payment/saferpay/db/SaferpayTransactionsCollection.ts +1 -1
- package/src/payment/saferpay/middleware.ts +6 -10
- package/src/payment/stripe/index.ts +23 -12
- package/src/payment/stripe/middleware.ts +15 -23
- package/src/payment/stripe/stripe.ts +6 -5
- package/src/pricing/delivery-swiss-tax.ts +6 -2
- package/src/pricing/discount-100-off.ts +4 -3
- package/src/pricing/discount-half-price-manual.ts +9 -5
- package/src/pricing/discount-half-price.ts +9 -5
- package/src/pricing/free-delivery.ts +1 -1
- package/src/pricing/free-payment.ts +1 -1
- package/src/pricing/order-delivery.ts +11 -8
- package/src/pricing/order-discount.ts +26 -11
- package/src/pricing/order-items-discount.ts +12 -5
- package/src/pricing/order-items.ts +12 -8
- package/src/pricing/order-payment.ts +11 -8
- package/src/pricing/order-round.ts +6 -2
- package/src/pricing/product-catalog-price.ts +12 -7
- package/src/pricing/product-discount.ts +5 -4
- package/src/pricing/product-price-rateconversion.ts +5 -2
- package/src/pricing/product-round.ts +5 -2
- package/src/pricing/product-swiss-tax.ts +5 -3
- package/src/quotations/manual.ts +1 -2
- package/src/warehousing/eth-minter.ts +11 -10
- package/src/warehousing/store.ts +2 -6
- package/src/worker/BaseWorker.ts +119 -0
- package/src/worker/EventListenerWorker.ts +61 -0
- package/src/worker/FailedRescheduler.ts +80 -0
- package/src/worker/IntervalWorker.ts +54 -0
- package/src/worker/bulk-import.ts +12 -13
- package/src/worker/email.ts +1 -8
- package/src/worker/enrollment-order-generator.ts +25 -34
- package/src/worker/error-notifications.ts +2 -2
- package/src/worker/export-token.ts +2 -8
- package/src/worker/external.ts +1 -2
- package/src/worker/heartbeat.ts +1 -2
- package/src/worker/http-request.ts +1 -8
- package/src/worker/message.ts +2 -6
- package/src/worker/push-notification.ts +1 -6
- package/src/worker/sms.ts +1 -7
- package/src/worker/update-coinbase-rates.ts +1 -3
- package/src/worker/update-ecb-rates.ts +1 -3
- package/src/worker/update-token-ownership.ts +1 -2
- package/src/worker/zombie-killer.ts +23 -23
- package/tsconfig.json +4 -5
- /package/src/payment/datatrans-v2/api/{types.d.ts → types.ts} +0 -0
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { IPaymentAdapter } from '@unchainedshop/core-payment';
|
|
2
|
-
import { PaymentAdapter, PaymentError, PaymentDirector } from '@unchainedshop/core-payment';
|
|
3
1
|
import { createLogger } from '@unchainedshop/logger';
|
|
4
|
-
import { PaymentPricingRowCategory } from '@unchainedshop/core-payment';
|
|
5
2
|
import createDatatransAPI from './api/index.js';
|
|
6
|
-
import
|
|
3
|
+
import {
|
|
7
4
|
AuthorizeAuthenticatedResponseSuccess,
|
|
8
5
|
AuthorizeResponseSuccess,
|
|
9
6
|
InitResponseSuccess,
|
|
@@ -13,6 +10,15 @@ import type {
|
|
|
13
10
|
} from './api/types.js';
|
|
14
11
|
import parseRegistrationData from './parseRegistrationData.js';
|
|
15
12
|
import roundedAmountFromOrder from './roundedAmountFromOrder.js';
|
|
13
|
+
import {
|
|
14
|
+
IPaymentAdapter,
|
|
15
|
+
PaymentAdapter,
|
|
16
|
+
PaymentDirector,
|
|
17
|
+
PaymentError,
|
|
18
|
+
PaymentPricingRowCategory,
|
|
19
|
+
PaymentPricingSheet,
|
|
20
|
+
OrderPricingSheet,
|
|
21
|
+
} from '@unchainedshop/core';
|
|
16
22
|
|
|
17
23
|
export * from './middleware.js';
|
|
18
24
|
|
|
@@ -57,11 +63,9 @@ const Datatrans: IPaymentAdapter = {
|
|
|
57
63
|
return type === 'GENERIC';
|
|
58
64
|
},
|
|
59
65
|
|
|
60
|
-
actions: (
|
|
61
|
-
const { modules } = params.context;
|
|
62
|
-
|
|
66
|
+
actions: (config, context) => {
|
|
63
67
|
const getMerchantId = (): string | undefined => {
|
|
64
|
-
return
|
|
68
|
+
return config.find((item) => item.key === 'merchantId')?.value || DATATRANS_MERCHANT_ID;
|
|
65
69
|
};
|
|
66
70
|
|
|
67
71
|
const api = () => {
|
|
@@ -70,7 +74,7 @@ const Datatrans: IPaymentAdapter = {
|
|
|
70
74
|
};
|
|
71
75
|
|
|
72
76
|
const shouldSettleInUnchained = () => {
|
|
73
|
-
return
|
|
77
|
+
return config.reduce((current, item) => {
|
|
74
78
|
if (item.key === 'settleInUnchained') return Boolean(item.value);
|
|
75
79
|
return current;
|
|
76
80
|
}, true);
|
|
@@ -83,18 +87,21 @@ const Datatrans: IPaymentAdapter = {
|
|
|
83
87
|
commission: number;
|
|
84
88
|
}[]
|
|
85
89
|
> => {
|
|
86
|
-
const { order, orderPayment } =
|
|
90
|
+
const { order, orderPayment } = context;
|
|
91
|
+
|
|
92
|
+
const pricingForOrderPayment = PaymentPricingSheet({
|
|
93
|
+
calculation: orderPayment.calculation,
|
|
94
|
+
currency: order.currency,
|
|
95
|
+
});
|
|
96
|
+
const pricing = OrderPricingSheet({
|
|
97
|
+
calculation: order.calculation,
|
|
98
|
+
currency: order.currency,
|
|
99
|
+
});
|
|
87
100
|
|
|
88
|
-
const pricingForOrderPayment = modules.orders.payments.pricingSheet(
|
|
89
|
-
orderPayment,
|
|
90
|
-
order.currency,
|
|
91
|
-
params.context,
|
|
92
|
-
);
|
|
93
|
-
const pricing = modules.orders.pricingSheet(order);
|
|
94
101
|
const { amount: total } = pricing.total({ useNetPrice: false });
|
|
95
102
|
|
|
96
103
|
return Promise.all(
|
|
97
|
-
|
|
104
|
+
config
|
|
98
105
|
.filter((item) => item.key === 'marketplaceSplit')
|
|
99
106
|
.map((item) => {
|
|
100
107
|
const [subMerchantId, staticDiscountId, sharePercentage] = item.value
|
|
@@ -119,11 +126,11 @@ const Datatrans: IPaymentAdapter = {
|
|
|
119
126
|
};
|
|
120
127
|
|
|
121
128
|
const authorize = async ({ paymentCredentials, ...arbitraryFields }): Promise<string> => {
|
|
122
|
-
const { order, orderPayment } =
|
|
129
|
+
const { order, orderPayment } = context;
|
|
123
130
|
const refno = Buffer.from(orderPayment._id, 'hex').toString('base64');
|
|
124
|
-
const userId = order?.userId ||
|
|
131
|
+
const userId = order?.userId || context?.userId;
|
|
125
132
|
const refno2 = userId;
|
|
126
|
-
const { currency, amount } = roundedAmountFromOrder(order
|
|
133
|
+
const { currency, amount } = roundedAmountFromOrder(order);
|
|
127
134
|
const splits = await getMarketplaceSplits();
|
|
128
135
|
const result = await api().authorize({
|
|
129
136
|
...arbitraryFields,
|
|
@@ -152,8 +159,8 @@ const Datatrans: IPaymentAdapter = {
|
|
|
152
159
|
refno2,
|
|
153
160
|
...arbitraryFields
|
|
154
161
|
}): Promise<string> => {
|
|
155
|
-
const { order } =
|
|
156
|
-
const { currency, amount } = roundedAmountFromOrder(order
|
|
162
|
+
const { order } = context;
|
|
163
|
+
const { currency, amount } = roundedAmountFromOrder(order);
|
|
157
164
|
const result = await api().authorizeAuthenticated({
|
|
158
165
|
...arbitraryFields,
|
|
159
166
|
transactionId,
|
|
@@ -168,13 +175,13 @@ const Datatrans: IPaymentAdapter = {
|
|
|
168
175
|
};
|
|
169
176
|
|
|
170
177
|
const isTransactionAmountValid = (transaction: StatusResponseSuccess): boolean => {
|
|
171
|
-
const { order } =
|
|
172
|
-
const { currency, amount } = roundedAmountFromOrder(order
|
|
178
|
+
const { order } = context;
|
|
179
|
+
const { currency, amount } = roundedAmountFromOrder(order);
|
|
173
180
|
if (
|
|
174
181
|
transaction.currency !== currency ||
|
|
175
182
|
(transaction.detail.authorize as any)?.amount !== amount
|
|
176
183
|
) {
|
|
177
|
-
logger.
|
|
184
|
+
logger.info(
|
|
178
185
|
`currency: ${transaction.currency} === ${currency} => ${
|
|
179
186
|
transaction.currency === currency
|
|
180
187
|
}, amount: ${(transaction.detail.authorize as any)?.amount} === ${amount} => ${
|
|
@@ -202,8 +209,8 @@ const Datatrans: IPaymentAdapter = {
|
|
|
202
209
|
};
|
|
203
210
|
|
|
204
211
|
const settle = async ({ transactionId, refno, refno2, extensions }): Promise<boolean> => {
|
|
205
|
-
const { order } =
|
|
206
|
-
const { currency, amount } = roundedAmountFromOrder(order
|
|
212
|
+
const { order } = context;
|
|
213
|
+
const { currency, amount } = roundedAmountFromOrder(order);
|
|
207
214
|
const splits = await getMarketplaceSplits();
|
|
208
215
|
const result = await api().settle({
|
|
209
216
|
transactionId,
|
|
@@ -232,7 +239,7 @@ const Datatrans: IPaymentAdapter = {
|
|
|
232
239
|
};
|
|
233
240
|
|
|
234
241
|
const adapterActions = {
|
|
235
|
-
...PaymentAdapter.actions(
|
|
242
|
+
...PaymentAdapter.actions(config, context),
|
|
236
243
|
|
|
237
244
|
configurationError() {
|
|
238
245
|
if (!getMerchantId() || !DATATRANS_SECRET || !DATATRANS_SIGN_KEY) {
|
|
@@ -252,15 +259,13 @@ const Datatrans: IPaymentAdapter = {
|
|
|
252
259
|
|
|
253
260
|
async sign(transactionContext: any = {}) {
|
|
254
261
|
const { useSecureFields = false, ...arbitraryFields } = transactionContext || {};
|
|
255
|
-
const { orderPayment, paymentProviderId, order } =
|
|
262
|
+
const { orderPayment, paymentProviderId, order } = context;
|
|
256
263
|
const refno = Buffer.from(orderPayment ? orderPayment._id : paymentProviderId, 'hex').toString(
|
|
257
264
|
'base64',
|
|
258
265
|
);
|
|
259
|
-
const userId = order?.userId ||
|
|
266
|
+
const userId = order?.userId || context?.userId;
|
|
260
267
|
const refno2 = userId;
|
|
261
|
-
const price: { amount?: number; currency?: string } = order
|
|
262
|
-
? roundedAmountFromOrder(order, params.context)
|
|
263
|
-
: {};
|
|
268
|
+
const price: { amount?: number; currency?: string } = order ? roundedAmountFromOrder(order) : {};
|
|
264
269
|
|
|
265
270
|
if (useSecureFields) {
|
|
266
271
|
const result = await api().secureFields({
|
|
@@ -314,7 +319,7 @@ const Datatrans: IPaymentAdapter = {
|
|
|
314
319
|
|
|
315
320
|
async confirm() {
|
|
316
321
|
if (!shouldSettleInUnchained()) return false;
|
|
317
|
-
const { orderPayment, transactionContext } =
|
|
322
|
+
const { orderPayment, transactionContext } = context;
|
|
318
323
|
const { transactionId } = orderPayment;
|
|
319
324
|
|
|
320
325
|
const { extensions } = transactionContext || {};
|
|
@@ -344,7 +349,7 @@ const Datatrans: IPaymentAdapter = {
|
|
|
344
349
|
|
|
345
350
|
async cancel() {
|
|
346
351
|
if (!shouldSettleInUnchained()) return false;
|
|
347
|
-
const { orderPayment } =
|
|
352
|
+
const { orderPayment } = context;
|
|
348
353
|
const { transactionId } = orderPayment;
|
|
349
354
|
if (!transactionId) {
|
|
350
355
|
return false;
|
|
@@ -437,7 +442,7 @@ const Datatrans: IPaymentAdapter = {
|
|
|
437
442
|
// at the dumbest possible moment
|
|
438
443
|
try {
|
|
439
444
|
checkIfTransactionAmountValid(transactionId, settledTransaction);
|
|
440
|
-
credentials = parseRegistrationData(settledTransaction);
|
|
445
|
+
credentials = await parseRegistrationData(settledTransaction);
|
|
441
446
|
const result = await api().status({
|
|
442
447
|
transactionId,
|
|
443
448
|
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { createLogger } from '@unchainedshop/logger';
|
|
2
2
|
import { Context } from '@unchainedshop/api';
|
|
3
3
|
import generateSignature, { Security } from './generateSignature.js';
|
|
4
|
-
|
|
5
|
-
import type { StatusResponseSuccess } from './api/types.js';
|
|
4
|
+
import { StatusResponseSuccess } from './api/types.js';
|
|
6
5
|
|
|
7
6
|
const {
|
|
8
7
|
DATATRANS_SIGN_KEY,
|
|
@@ -14,14 +13,14 @@ const logger = createLogger('unchained:core-payment:datatrans:webhook');
|
|
|
14
13
|
|
|
15
14
|
export const datatransHandler = async (req, res) => {
|
|
16
15
|
const resolvedContext = req.unchainedContext as Context;
|
|
17
|
-
const { modules } = resolvedContext;
|
|
16
|
+
const { modules, services } = resolvedContext;
|
|
18
17
|
const signature = req.headers['datatrans-signature'];
|
|
19
18
|
if (req.method === 'POST' && signature) {
|
|
20
19
|
const [rawTimestamp, rawHash] = signature.split(',');
|
|
21
20
|
const [, hash] = rawHash.split('=');
|
|
22
21
|
const [, timestamp] = rawTimestamp.split('=');
|
|
23
22
|
|
|
24
|
-
const comparableSignature = generateSignature({
|
|
23
|
+
const comparableSignature = await generateSignature({
|
|
25
24
|
security: DATATRANS_SECURITY as any,
|
|
26
25
|
signKey: DATATRANS_SIGN2_KEY || DATATRANS_SIGN_KEY,
|
|
27
26
|
})(timestamp, req.body);
|
|
@@ -35,7 +34,7 @@ export const datatransHandler = async (req, res) => {
|
|
|
35
34
|
|
|
36
35
|
const transaction: StatusResponseSuccess = JSON.parse(req.body) as StatusResponseSuccess;
|
|
37
36
|
|
|
38
|
-
logger.
|
|
37
|
+
logger.info(`received request`, {
|
|
39
38
|
type: transaction.type,
|
|
40
39
|
});
|
|
41
40
|
|
|
@@ -46,10 +45,9 @@ export const datatransHandler = async (req, res) => {
|
|
|
46
45
|
try {
|
|
47
46
|
if (transaction.type === 'card_check') {
|
|
48
47
|
const paymentProviderId = referenceId;
|
|
49
|
-
const paymentCredentials = await
|
|
48
|
+
const paymentCredentials = await services.orders.registerPaymentCredentials(
|
|
50
49
|
paymentProviderId,
|
|
51
50
|
{ userId, transactionContext: { transactionId: transaction.transactionId } },
|
|
52
|
-
resolvedContext,
|
|
53
51
|
);
|
|
54
52
|
logger.info(`registered payment credentials for ${userId}`, {
|
|
55
53
|
userId,
|
|
@@ -65,11 +63,9 @@ export const datatransHandler = async (req, res) => {
|
|
|
65
63
|
});
|
|
66
64
|
if (!orderPayment) throw new Error(`Order Payment with id ${orderPaymentId} not found`);
|
|
67
65
|
|
|
68
|
-
const order = await
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
resolvedContext,
|
|
72
|
-
);
|
|
66
|
+
const order = await services.orders.checkoutOrder(orderPayment.orderId, {
|
|
67
|
+
paymentContext: { userId, transactionId: transaction.transactionId },
|
|
68
|
+
});
|
|
73
69
|
res.writeHead(200);
|
|
74
70
|
logger.info(`confirmed checkout for order ${order.orderNumber}`, {
|
|
75
71
|
orderId: order._id,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import splitProperties from './splitProperties.js';
|
|
2
|
-
import
|
|
2
|
+
import { StatusResponseSuccess } from './api/types.js';
|
|
3
|
+
import { sha256 } from '@unchainedshop/utils';
|
|
3
4
|
|
|
4
|
-
export default function parseRegistrationData(transaction: StatusResponseSuccess) {
|
|
5
|
+
export default async function parseRegistrationData(transaction: StatusResponseSuccess) {
|
|
5
6
|
const parsed = Object.entries(transaction).reduce((acc, [objectKey, payload]) => {
|
|
6
|
-
const { token, info
|
|
7
|
+
const { token, info } = splitProperties({ objectKey, payload });
|
|
7
8
|
if (token) {
|
|
8
9
|
return {
|
|
9
|
-
_id,
|
|
10
10
|
token,
|
|
11
11
|
info,
|
|
12
12
|
objectKey,
|
|
@@ -14,14 +14,16 @@ export default function parseRegistrationData(transaction: StatusResponseSuccess
|
|
|
14
14
|
}
|
|
15
15
|
return acc;
|
|
16
16
|
}, {}) as {
|
|
17
|
-
_id?: string;
|
|
18
17
|
token?: Record<string, unknown>;
|
|
19
18
|
info?: Record<string, unknown>;
|
|
20
19
|
objectKey?: string;
|
|
21
20
|
};
|
|
22
21
|
if (parsed.objectKey) {
|
|
22
|
+
const _id = await sha256(parsed.token);
|
|
23
|
+
|
|
23
24
|
return {
|
|
24
25
|
...parsed,
|
|
26
|
+
_id,
|
|
25
27
|
paymentMethod: transaction.paymentMethod,
|
|
26
28
|
currency: transaction.currency,
|
|
27
29
|
language: transaction.language,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OrderPricingSheet } from '@unchainedshop/core';
|
|
2
2
|
import { Order } from '@unchainedshop/core-orders';
|
|
3
3
|
|
|
4
|
-
const roundedAmountFromOrder = (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const roundedAmountFromOrder = (order: Order): { currency: string; amount: number } => {
|
|
5
|
+
const pricing = OrderPricingSheet({
|
|
6
|
+
calculation: order.calculation,
|
|
7
|
+
currency: order.currency,
|
|
8
|
+
});
|
|
9
9
|
const { currency, amount } = pricing.total({ useNetPrice: false });
|
|
10
10
|
return {
|
|
11
11
|
currency,
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
// This method splits the return data of alias registration to the important properties needed for validation and the additional data
|
|
2
|
-
import crypto from 'crypto';
|
|
3
2
|
|
|
4
3
|
export default function splitProperties({ objectKey, payload }: { objectKey?: string; payload: any }): {
|
|
5
4
|
token?: string;
|
|
6
5
|
info: any;
|
|
7
|
-
_id?: string;
|
|
8
6
|
} {
|
|
9
7
|
if (!payload || !objectKey) return { info: {} };
|
|
10
8
|
|
|
@@ -21,12 +19,9 @@ export default function splitProperties({ objectKey, payload }: { objectKey?: st
|
|
|
21
19
|
expiryYear,
|
|
22
20
|
'3D': is3DActive ? payload['3D'] : undefined,
|
|
23
21
|
});
|
|
24
|
-
const _id = crypto.createHash('sha256').update(token).digest('hex');
|
|
25
|
-
|
|
26
22
|
return {
|
|
27
23
|
token,
|
|
28
24
|
info,
|
|
29
|
-
_id,
|
|
30
25
|
};
|
|
31
26
|
}
|
|
32
27
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IPaymentAdapter } from '@unchainedshop/core
|
|
2
|
-
import {
|
|
1
|
+
import { IPaymentAdapter, PaymentAdapter, PaymentDirector } from '@unchainedshop/core';
|
|
2
|
+
import { PaymentProviderType } from '@unchainedshop/core-payment';
|
|
3
3
|
|
|
4
4
|
const InvoicePrepaid: IPaymentAdapter = {
|
|
5
5
|
...PaymentAdapter,
|
|
@@ -14,9 +14,9 @@ const InvoicePrepaid: IPaymentAdapter = {
|
|
|
14
14
|
return type === PaymentProviderType.INVOICE;
|
|
15
15
|
},
|
|
16
16
|
|
|
17
|
-
actions: (
|
|
17
|
+
actions: (config, context) => {
|
|
18
18
|
return {
|
|
19
|
-
...PaymentAdapter.actions(
|
|
19
|
+
...PaymentAdapter.actions(config, context),
|
|
20
20
|
|
|
21
21
|
configurationError: () => {
|
|
22
22
|
return null;
|
package/src/payment/invoice.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IPaymentAdapter } from '@unchainedshop/core
|
|
2
|
-
import {
|
|
1
|
+
import { IPaymentAdapter, PaymentAdapter, PaymentDirector } from '@unchainedshop/core';
|
|
2
|
+
import { PaymentProviderType } from '@unchainedshop/core-payment';
|
|
3
3
|
|
|
4
4
|
const Invoice: IPaymentAdapter = {
|
|
5
5
|
...PaymentAdapter,
|
|
@@ -14,9 +14,9 @@ const Invoice: IPaymentAdapter = {
|
|
|
14
14
|
return type === PaymentProviderType.INVOICE;
|
|
15
15
|
},
|
|
16
16
|
|
|
17
|
-
actions: (
|
|
17
|
+
actions: (config, context) => {
|
|
18
18
|
return {
|
|
19
|
-
...PaymentAdapter.actions(
|
|
19
|
+
...PaymentAdapter.actions(config, context),
|
|
20
20
|
|
|
21
21
|
configurationError: () => {
|
|
22
22
|
return null;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
OrderPricingSheet,
|
|
3
|
+
IPaymentAdapter,
|
|
4
|
+
PaymentAdapter,
|
|
5
|
+
PaymentDirector,
|
|
6
|
+
PaymentError,
|
|
7
|
+
} from '@unchainedshop/core';
|
|
3
8
|
import { createLogger } from '@unchainedshop/logger';
|
|
4
9
|
|
|
5
10
|
let checkoutNodeJssdk;
|
|
6
11
|
try {
|
|
12
|
+
// eslint-disable-next-line
|
|
13
|
+
// @ts-ignore
|
|
7
14
|
checkoutNodeJssdk = await import('@paypal/checkout-server-sdk');
|
|
8
15
|
} catch {
|
|
9
16
|
/* */
|
|
@@ -41,9 +48,9 @@ const PaypalCheckout: IPaymentAdapter = {
|
|
|
41
48
|
return type === 'GENERIC';
|
|
42
49
|
},
|
|
43
50
|
|
|
44
|
-
actions: (
|
|
51
|
+
actions: (config, context) => {
|
|
45
52
|
const adapter = {
|
|
46
|
-
...PaymentAdapter.actions(
|
|
53
|
+
...PaymentAdapter.actions(config, context),
|
|
47
54
|
|
|
48
55
|
configurationError: () => {
|
|
49
56
|
const publicCredentialsValid = PAYPAL_CLIENT_ID && PAYPAL_SECRET;
|
|
@@ -68,8 +75,7 @@ const PaypalCheckout: IPaymentAdapter = {
|
|
|
68
75
|
},
|
|
69
76
|
|
|
70
77
|
charge: async ({ orderID }) => {
|
|
71
|
-
const {
|
|
72
|
-
const { order } = params.paymentContext;
|
|
78
|
+
const { order } = context;
|
|
73
79
|
|
|
74
80
|
if (!orderID) {
|
|
75
81
|
logger.warn('Paypal Native Plugin: PRICE MATCH');
|
|
@@ -81,7 +87,10 @@ const PaypalCheckout: IPaymentAdapter = {
|
|
|
81
87
|
const client = new checkoutNodeJssdk.core.PayPalHttpClient(environment());
|
|
82
88
|
const paypalOrder = await client.execute(request);
|
|
83
89
|
|
|
84
|
-
const pricing =
|
|
90
|
+
const pricing = OrderPricingSheet({
|
|
91
|
+
calculation: order.calculation,
|
|
92
|
+
currency: order.currency,
|
|
93
|
+
});
|
|
85
94
|
const ourTotal = (pricing.total({ useNetPrice: false }).amount / 100).toFixed(2);
|
|
86
95
|
const paypalTotal = paypalOrder.result.purchase_units[0].amount.value;
|
|
87
96
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference lib="dom" />
|
|
2
1
|
import fs from 'fs';
|
|
3
2
|
import util from 'util';
|
|
4
3
|
import { resolve } from 'path';
|
|
@@ -48,7 +47,7 @@ export default (
|
|
|
48
47
|
new TextEncoder().encode(secret),
|
|
49
48
|
{ name: 'HMAC', hash: 'SHA-256' },
|
|
50
49
|
false,
|
|
51
|
-
['sign'
|
|
50
|
+
['sign'],
|
|
52
51
|
);
|
|
53
52
|
const signature = await crypto.subtle.sign('HMAC', key, new TextEncoder().encode(query));
|
|
54
53
|
return btoa(String.fromCharCode(...new Uint8Array(signature)));
|
|
@@ -61,7 +60,7 @@ export default (
|
|
|
61
60
|
};
|
|
62
61
|
|
|
63
62
|
return async (path: string, method: 'GET' | 'DELETE' | 'POST', data?: any): Promise<Response> => {
|
|
64
|
-
logger.
|
|
63
|
+
logger.info(`${method} ${path}`);
|
|
65
64
|
if (method === 'POST') {
|
|
66
65
|
const queryParams = { ...data };
|
|
67
66
|
const signature = await buildSignature(new URLSearchParams(queryParams).toString());
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { IPaymentAdapter } from '@unchainedshop/core-payment';
|
|
2
|
-
import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
|
|
3
1
|
import { createLogger } from '@unchainedshop/logger';
|
|
4
2
|
import { mapOrderDataToGatewayObject, mapUserToGatewayObject } from './payrexx.js';
|
|
5
3
|
import createPayrexxAPI, { GatewayObjectStatus } from './api/index.js';
|
|
4
|
+
import {
|
|
5
|
+
OrderPricingSheet,
|
|
6
|
+
IPaymentAdapter,
|
|
7
|
+
PaymentAdapter,
|
|
8
|
+
PaymentDirector,
|
|
9
|
+
PaymentError,
|
|
10
|
+
} from '@unchainedshop/core';
|
|
6
11
|
|
|
7
12
|
export * from './middleware.js';
|
|
8
13
|
|
|
@@ -19,17 +24,17 @@ const Payrexx: IPaymentAdapter = {
|
|
|
19
24
|
return type === 'GENERIC';
|
|
20
25
|
},
|
|
21
26
|
|
|
22
|
-
actions: (
|
|
23
|
-
const { modules } =
|
|
27
|
+
actions: (config, context) => {
|
|
28
|
+
const { modules } = context;
|
|
24
29
|
|
|
25
30
|
const getInstance = () => {
|
|
26
|
-
return
|
|
31
|
+
return config.find((c) => c.key === 'instance')?.value;
|
|
27
32
|
};
|
|
28
33
|
|
|
29
34
|
const api = createPayrexxAPI(getInstance(), process.env.PAYREXX_SECRET);
|
|
30
35
|
|
|
31
36
|
const adapterActions = {
|
|
32
|
-
...PaymentAdapter.actions(
|
|
37
|
+
...PaymentAdapter.actions(config, context),
|
|
33
38
|
|
|
34
39
|
configurationError() {
|
|
35
40
|
if (!process.env.PAYREXX_SECRET) {
|
|
@@ -51,10 +56,13 @@ const Payrexx: IPaymentAdapter = {
|
|
|
51
56
|
},
|
|
52
57
|
|
|
53
58
|
sign: async (transactionContext = {}) => {
|
|
54
|
-
const { orderPayment, userId, order } =
|
|
59
|
+
const { orderPayment, userId, order } = context;
|
|
55
60
|
if (orderPayment) {
|
|
56
61
|
// Order Checkout signing (One-time payment)
|
|
57
|
-
const pricing =
|
|
62
|
+
const pricing = OrderPricingSheet({
|
|
63
|
+
calculation: order.calculation,
|
|
64
|
+
currency: order.currency,
|
|
65
|
+
});
|
|
58
66
|
const gatewayObject = mapOrderDataToGatewayObject(
|
|
59
67
|
{ order, orderPayment, pricing },
|
|
60
68
|
transactionContext,
|
|
@@ -94,13 +102,13 @@ const Payrexx: IPaymentAdapter = {
|
|
|
94
102
|
// transactionId,
|
|
95
103
|
// })) as StatusResponseSuccess;
|
|
96
104
|
// if (result.transactionId) {
|
|
97
|
-
// return parseRegistrationData(result);
|
|
105
|
+
// return await parseRegistrationData(result);
|
|
98
106
|
// }
|
|
99
107
|
return null;
|
|
100
108
|
},
|
|
101
109
|
|
|
102
110
|
async confirm() {
|
|
103
|
-
const { orderPayment } =
|
|
111
|
+
const { orderPayment } = context;
|
|
104
112
|
const { transactionId } = orderPayment;
|
|
105
113
|
|
|
106
114
|
if (!transactionId) {
|
|
@@ -133,7 +141,7 @@ const Payrexx: IPaymentAdapter = {
|
|
|
133
141
|
},
|
|
134
142
|
|
|
135
143
|
async cancel() {
|
|
136
|
-
const { orderPayment } =
|
|
144
|
+
const { orderPayment } = context;
|
|
137
145
|
const { transactionId } = orderPayment;
|
|
138
146
|
if (!transactionId) {
|
|
139
147
|
return false;
|
|
@@ -164,7 +172,7 @@ const Payrexx: IPaymentAdapter = {
|
|
|
164
172
|
throw new Error('You have to provide gatewayId or paymentCredentials');
|
|
165
173
|
}
|
|
166
174
|
|
|
167
|
-
const { order } =
|
|
175
|
+
const { order } = context;
|
|
168
176
|
const orderPayment = await modules.orders.payments.findOrderPayment({
|
|
169
177
|
orderPaymentId: order.paymentId,
|
|
170
178
|
});
|
|
@@ -175,7 +183,10 @@ const Payrexx: IPaymentAdapter = {
|
|
|
175
183
|
throw new Error('Could not load gateway from the Payrexx API');
|
|
176
184
|
}
|
|
177
185
|
|
|
178
|
-
const pricing =
|
|
186
|
+
const pricing = OrderPricingSheet({
|
|
187
|
+
calculation: order.calculation,
|
|
188
|
+
currency: order.currency,
|
|
189
|
+
});
|
|
179
190
|
const { currency, amount } = pricing.total({ useNetPrice: false });
|
|
180
191
|
|
|
181
192
|
if (
|
|
@@ -195,7 +206,7 @@ const Payrexx: IPaymentAdapter = {
|
|
|
195
206
|
}
|
|
196
207
|
|
|
197
208
|
// confirm will do the transition, to do a checkout those stati above are fine
|
|
198
|
-
logger.
|
|
209
|
+
logger.info(`Mark as charged, status is ${gatewayObject.status}`, {
|
|
199
210
|
orderPaymentId: gatewayObject.referenceId,
|
|
200
211
|
});
|
|
201
212
|
return {
|
|
@@ -214,7 +225,7 @@ const Payrexx: IPaymentAdapter = {
|
|
|
214
225
|
}
|
|
215
226
|
}
|
|
216
227
|
|
|
217
|
-
logger.
|
|
228
|
+
logger.info('Charge not possible', {
|
|
218
229
|
orderPaymentId: gatewayObject.referenceId,
|
|
219
230
|
status: gatewayObject.status,
|
|
220
231
|
});
|
|
@@ -5,12 +5,12 @@ const logger = createLogger('unchained:core-payment:payrexx:webhook');
|
|
|
5
5
|
|
|
6
6
|
export const payrexxHandler = async (request, response) => {
|
|
7
7
|
const resolvedContext = request.unchainedContext as Context;
|
|
8
|
-
const { modules } = resolvedContext;
|
|
8
|
+
const { modules, services } = resolvedContext;
|
|
9
9
|
|
|
10
10
|
const { transaction } = request.body;
|
|
11
11
|
|
|
12
12
|
if (!transaction) {
|
|
13
|
-
logger.
|
|
13
|
+
logger.info(`unhandled event type`, {
|
|
14
14
|
type: Object.keys(request.body).join(','),
|
|
15
15
|
});
|
|
16
16
|
response.writeHead(200);
|
|
@@ -25,7 +25,7 @@ export const payrexxHandler = async (request, response) => {
|
|
|
25
25
|
if (transaction.referenceId === '__IGNORE_WEBHOOK__' || transaction.status === 'waiting') {
|
|
26
26
|
// Ignore confirmed transactions, because those hooks are generated through calling the confirm()
|
|
27
27
|
// method in the payment adapter and could lead to double bookings.
|
|
28
|
-
logger.
|
|
28
|
+
logger.info(`unhandled transaction state: ${transaction.status}`);
|
|
29
29
|
response.writeHead(200);
|
|
30
30
|
response.end(
|
|
31
31
|
JSON.stringify({
|
|
@@ -36,7 +36,7 @@ export const payrexxHandler = async (request, response) => {
|
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
logger.
|
|
39
|
+
logger.info(`Processing event`, {
|
|
40
40
|
transactionId: transaction.id,
|
|
41
41
|
});
|
|
42
42
|
try {
|
|
@@ -44,12 +44,11 @@ export const payrexxHandler = async (request, response) => {
|
|
|
44
44
|
// Pre-Authorization Flow, referenceId is a userId
|
|
45
45
|
const { referenceId: paymentProviderId, invoice } = transaction;
|
|
46
46
|
const userId = '';
|
|
47
|
-
logger.
|
|
48
|
-
await
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
);
|
|
47
|
+
logger.info(`register credentials for: ${userId}`);
|
|
48
|
+
await services.orders.registerPaymentCredentials(paymentProviderId, {
|
|
49
|
+
userId,
|
|
50
|
+
transactionContext: { gatewayId: invoice.paymentRequestId },
|
|
51
|
+
});
|
|
53
52
|
logger.info(`registration successful`, {
|
|
54
53
|
paymentProviderId,
|
|
55
54
|
userId,
|
|
@@ -64,7 +63,7 @@ export const payrexxHandler = async (request, response) => {
|
|
|
64
63
|
);
|
|
65
64
|
} else {
|
|
66
65
|
const { referenceId: orderPaymentId, invoice } = transaction;
|
|
67
|
-
logger.
|
|
66
|
+
logger.info(`checkout with orderPaymentId: ${orderPaymentId}`);
|
|
68
67
|
await modules.orders.payments.logEvent(orderPaymentId, {
|
|
69
68
|
transactionId: transaction.id,
|
|
70
69
|
});
|
|
@@ -75,15 +74,11 @@ export const payrexxHandler = async (request, response) => {
|
|
|
75
74
|
throw new Error(`order payment not found with orderPaymentId: ${orderPaymentId}`);
|
|
76
75
|
}
|
|
77
76
|
|
|
78
|
-
const order = await
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
paymentContext: {
|
|
82
|
-
gatewayId: invoice.paymentRequestId,
|
|
83
|
-
},
|
|
77
|
+
const order = await services.orders.checkoutOrder(orderPayment.orderId, {
|
|
78
|
+
paymentContext: {
|
|
79
|
+
gatewayId: invoice.paymentRequestId,
|
|
84
80
|
},
|
|
85
|
-
|
|
86
|
-
);
|
|
81
|
+
});
|
|
87
82
|
logger.info(`checkout successful`, {
|
|
88
83
|
orderPaymentId,
|
|
89
84
|
orderId: order._id,
|