@unchainedshop/plugins 1.1.3 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/delivery/pick-mup.d.ts +1 -0
- package/lib/delivery/pick-mup.js +98 -0
- package/lib/delivery/pick-mup.js.map +1 -0
- package/lib/delivery/post.d.ts +1 -0
- package/lib/delivery/post.js +23 -0
- package/lib/delivery/post.js.map +1 -0
- package/lib/delivery/send-message.d.ts +1 -0
- package/lib/delivery/send-message.js +41 -0
- package/lib/delivery/send-message.js.map +1 -0
- package/lib/delivery/stores.d.ts +1 -0
- package/lib/delivery/stores.js +39 -0
- package/lib/delivery/stores.js.map +1 -0
- package/lib/enrollments/licensed.d.ts +1 -0
- package/lib/enrollments/licensed.js +40 -0
- package/lib/enrollments/licensed.js.map +1 -0
- package/lib/files/gridfs/gridfs-adapter.js +1 -1
- package/lib/files/gridfs/gridfs-adapter.js.map +1 -1
- package/lib/files/gridfs/gridfs-webhook.js +2 -2
- package/lib/files/gridfs/gridfs-webhook.js.map +1 -1
- package/lib/files/minio/minio-webhook.js +1 -1
- package/lib/files/minio/minio-webhook.js.map +1 -1
- package/lib/filters/local-search.d.ts +3 -0
- package/lib/filters/local-search.js +84 -0
- package/lib/filters/local-search.js.map +1 -0
- package/lib/filters/strict-equal.d.ts +1 -0
- package/lib/filters/strict-equal.js +25 -0
- package/lib/filters/strict-equal.js.map +1 -0
- package/lib/payment/apple-iap/adapter.d.ts +1 -0
- package/lib/payment/apple-iap/adapter.js +284 -0
- package/lib/payment/apple-iap/adapter.js.map +1 -0
- package/lib/payment/apple-iap/db/AppleTransactionsCollection.d.ts +7 -0
- package/lib/payment/apple-iap/db/AppleTransactionsCollection.js +5 -0
- package/lib/payment/apple-iap/db/AppleTransactionsCollection.js.map +1 -0
- package/lib/payment/apple-iap/index.d.ts +2 -0
- package/lib/payment/apple-iap/index.js +3 -0
- package/lib/payment/apple-iap/index.js.map +1 -0
- package/lib/payment/apple-iap/module/configureAppleTransactionsModule.d.ts +9 -0
- package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js +18 -0
- package/lib/payment/apple-iap/module/configureAppleTransactionsModule.js.map +1 -0
- package/lib/payment/bity/adapter.d.ts +1 -0
- package/lib/payment/bity/adapter.js +316 -0
- package/lib/payment/bity/adapter.js.map +1 -0
- package/lib/payment/bity/db/BityCredentialsCollection.d.ts +11 -0
- package/lib/payment/bity/db/BityCredentialsCollection.js +5 -0
- package/lib/payment/bity/db/BityCredentialsCollection.js.map +1 -0
- package/lib/payment/bity/index.d.ts +2 -0
- package/lib/payment/bity/index.js +3 -0
- package/lib/payment/bity/index.js.map +1 -0
- package/lib/payment/bity/module/configureBityModule.d.ts +11 -0
- package/lib/payment/bity/module/configureBityModule.js +33 -0
- package/lib/payment/bity/module/configureBityModule.js.map +1 -0
- package/lib/payment/braintree.d.ts +1 -0
- package/lib/payment/braintree.js +129 -0
- package/lib/payment/braintree.js.map +1 -0
- package/lib/payment/cryptopay.d.ts +1 -0
- package/lib/payment/cryptopay.js +159 -0
- package/lib/payment/cryptopay.js.map +1 -0
- package/lib/payment/datatrans-v2/api/authorize.d.ts +2 -0
- package/lib/payment/datatrans-v2/api/authorize.js +12 -0
- package/lib/payment/datatrans-v2/api/authorize.js.map +1 -0
- package/lib/payment/datatrans-v2/api/authorizeAuthenticated.d.ts +2 -0
- package/lib/payment/datatrans-v2/api/authorizeAuthenticated.js +11 -0
- package/lib/payment/datatrans-v2/api/authorizeAuthenticated.js.map +1 -0
- package/lib/payment/datatrans-v2/api/cancel.d.ts +2 -0
- package/lib/payment/datatrans-v2/api/cancel.js +10 -0
- package/lib/payment/datatrans-v2/api/cancel.js.map +1 -0
- package/lib/payment/datatrans-v2/api/index.d.ts +19 -0
- package/lib/payment/datatrans-v2/api/index.js +24 -0
- package/lib/payment/datatrans-v2/api/index.js.map +1 -0
- package/lib/payment/datatrans-v2/api/init.d.ts +2 -0
- package/lib/payment/datatrans-v2/api/init.js +31 -0
- package/lib/payment/datatrans-v2/api/init.js.map +1 -0
- package/lib/payment/datatrans-v2/api/makeFetcher.d.ts +2 -0
- package/lib/payment/datatrans-v2/api/makeFetcher.js +41 -0
- package/lib/payment/datatrans-v2/api/makeFetcher.js.map +1 -0
- package/lib/payment/datatrans-v2/api/secureFields.d.ts +2 -0
- package/lib/payment/datatrans-v2/api/secureFields.js +14 -0
- package/lib/payment/datatrans-v2/api/secureFields.js.map +1 -0
- package/lib/payment/datatrans-v2/api/settle.d.ts +2 -0
- package/lib/payment/datatrans-v2/api/settle.js +10 -0
- package/lib/payment/datatrans-v2/api/settle.js.map +1 -0
- package/lib/payment/datatrans-v2/api/status.d.ts +2 -0
- package/lib/payment/datatrans-v2/api/status.js +7 -0
- package/lib/payment/datatrans-v2/api/status.js.map +1 -0
- package/lib/payment/datatrans-v2/api/validate.d.ts +2 -0
- package/lib/payment/datatrans-v2/api/validate.js +10 -0
- package/lib/payment/datatrans-v2/api/validate.js.map +1 -0
- package/lib/payment/datatrans-v2/generateSignature.d.ts +10 -0
- package/lib/payment/datatrans-v2/generateSignature.js +19 -0
- package/lib/payment/datatrans-v2/generateSignature.js.map +1 -0
- package/lib/payment/datatrans-v2/getPaths.d.ts +9 -0
- package/lib/payment/datatrans-v2/getPaths.js +9 -0
- package/lib/payment/datatrans-v2/getPaths.js.map +1 -0
- package/lib/payment/datatrans-v2/index.d.ts +1 -0
- package/lib/payment/datatrans-v2/index.js +384 -0
- package/lib/payment/datatrans-v2/index.js.map +1 -0
- package/lib/payment/datatrans-v2/middleware.d.ts +1 -0
- package/lib/payment/datatrans-v2/middleware.js +111 -0
- package/lib/payment/datatrans-v2/middleware.js.map +1 -0
- package/lib/payment/datatrans-v2/parseRegistrationData.d.ts +11 -0
- package/lib/payment/datatrans-v2/parseRegistrationData.js +26 -0
- package/lib/payment/datatrans-v2/parseRegistrationData.js.map +1 -0
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.d.ts +7 -0
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.js +10 -0
- package/lib/payment/datatrans-v2/roundedAmountFromOrder.js.map +1 -0
- package/lib/payment/datatrans-v2/splitProperties.d.ts +8 -0
- package/lib/payment/datatrans-v2/splitProperties.js +58 -0
- package/lib/payment/datatrans-v2/splitProperties.js.map +1 -0
- package/lib/payment/invoice-prepaid.d.ts +1 -0
- package/lib/payment/invoice-prepaid.js +30 -0
- package/lib/payment/invoice-prepaid.js.map +1 -0
- package/lib/payment/invoice.d.ts +1 -0
- package/lib/payment/invoice.js +27 -0
- package/lib/payment/invoice.js.map +1 -0
- package/lib/payment/paypal-checkout.d.ts +1 -0
- package/lib/payment/paypal-checkout.js +82 -0
- package/lib/payment/paypal-checkout.js.map +1 -0
- package/lib/payment/postfinance-checkout/api.d.ts +11 -0
- package/lib/payment/postfinance-checkout/api.js +109 -0
- package/lib/payment/postfinance-checkout/api.js.map +1 -0
- package/lib/payment/postfinance-checkout/index.d.ts +1 -0
- package/lib/payment/postfinance-checkout/index.js +186 -0
- package/lib/payment/postfinance-checkout/index.js.map +1 -0
- package/lib/payment/postfinance-checkout/middleware.d.ts +1 -0
- package/lib/payment/postfinance-checkout/middleware.js +42 -0
- package/lib/payment/postfinance-checkout/middleware.js.map +1 -0
- package/lib/payment/postfinance-checkout/types.d.ts +23 -0
- package/lib/payment/postfinance-checkout/types.js +12 -0
- package/lib/payment/postfinance-checkout/types.js.map +1 -0
- package/lib/payment/postfinance-checkout/utils.d.ts +4 -0
- package/lib/payment/postfinance-checkout/utils.js +20 -0
- package/lib/payment/postfinance-checkout/utils.js.map +1 -0
- package/lib/payment/stripe.d.ts +1 -0
- package/lib/payment/stripe.js +214 -0
- package/lib/payment/stripe.js.map +1 -0
- package/lib/payment/worldline-saferpay/index.d.ts +1 -0
- package/lib/payment/worldline-saferpay/index.js +112 -0
- package/lib/payment/worldline-saferpay/index.js.map +1 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.d.ts +14 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.js +29 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.js.map +1 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayConnection.d.ts +9 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayConnection.js +28 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayConnection.js.map +1 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.d.ts +4 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.js +2 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/index.js.map +1 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentMethods.d.ts +1 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentMethods.js +2 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentMethods.js.map +1 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.d.ts +73 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.js +2 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.js.map +1 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.d.ts +53 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.js +2 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.js.map +1 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Request.d.ts +13 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Request.js +2 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Request.js.map +1 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Response.d.ts +9 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Response.js +2 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Response.js.map +1 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Transaction.d.ts +5 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Transaction.js +2 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/Transaction.js.map +1 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.d.ts +13 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.js +2 -0
- package/lib/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.js.map +1 -0
- package/lib/pricing/delivery-swiss-tax.d.ts +15 -0
- package/lib/pricing/delivery-swiss-tax.js +98 -0
- package/lib/pricing/delivery-swiss-tax.js.map +1 -0
- package/lib/pricing/discount-100-off.d.ts +1 -0
- package/lib/pricing/discount-100-off.js +34 -0
- package/lib/pricing/discount-100-off.js.map +1 -0
- package/lib/pricing/discount-half-price-manual.d.ts +1 -0
- package/lib/pricing/discount-half-price-manual.js +34 -0
- package/lib/pricing/discount-half-price-manual.js.map +1 -0
- package/lib/pricing/discount-half-price.d.ts +1 -0
- package/lib/pricing/discount-half-price.js +37 -0
- package/lib/pricing/discount-half-price.js.map +1 -0
- package/lib/pricing/free-delivery.d.ts +2 -0
- package/lib/pricing/free-delivery.js +26 -0
- package/lib/pricing/free-delivery.js.map +1 -0
- package/lib/pricing/free-payment.d.ts +2 -0
- package/lib/pricing/free-payment.js +26 -0
- package/lib/pricing/free-payment.js.map +1 -0
- package/lib/pricing/order-delivery.d.ts +1 -0
- package/lib/pricing/order-delivery.js +33 -0
- package/lib/pricing/order-delivery.js.map +1 -0
- package/lib/pricing/order-discount.d.ts +1 -0
- package/lib/pricing/order-discount.js +110 -0
- package/lib/pricing/order-discount.js.map +1 -0
- package/lib/pricing/order-items-discount.d.ts +1 -0
- package/lib/pricing/order-items-discount.js +88 -0
- package/lib/pricing/order-items-discount.js.map +1 -0
- package/lib/pricing/order-items.d.ts +1 -0
- package/lib/pricing/order-items.js +44 -0
- package/lib/pricing/order-items.js.map +1 -0
- package/lib/pricing/order-payment.d.ts +1 -0
- package/lib/pricing/order-payment.js +33 -0
- package/lib/pricing/order-payment.js.map +1 -0
- package/lib/pricing/product-catalog-price.d.ts +1 -0
- package/lib/pricing/product-catalog-price.js +37 -0
- package/lib/pricing/product-catalog-price.js.map +1 -0
- package/lib/pricing/product-discount.d.ts +1 -0
- package/lib/pricing/product-discount.js +55 -0
- package/lib/pricing/product-discount.js.map +1 -0
- package/lib/pricing/product-price-ECB-interbank-exchange.d.ts +1 -0
- package/lib/pricing/product-price-ECB-interbank-exchange.js +90 -0
- package/lib/pricing/product-price-ECB-interbank-exchange.js.map +1 -0
- package/lib/pricing/product-price-coinbase-exchange.d.ts +1 -0
- package/lib/pricing/product-price-coinbase-exchange.js +60 -0
- package/lib/pricing/product-price-coinbase-exchange.js.map +1 -0
- package/lib/pricing/product-price-cryptopay.d.ts +1 -0
- package/lib/pricing/product-price-cryptopay.js +21 -0
- package/lib/pricing/product-price-cryptopay.js.map +1 -0
- package/lib/pricing/product-price-rateconversion.d.ts +1 -0
- package/lib/pricing/product-price-rateconversion.js +51 -0
- package/lib/pricing/product-price-rateconversion.js.map +1 -0
- package/lib/pricing/product-price-round.d.ts +11 -0
- package/lib/pricing/product-price-round.js +54 -0
- package/lib/pricing/product-price-round.js.map +1 -0
- package/lib/pricing/product-swiss-tax.d.ts +13 -0
- package/lib/pricing/product-swiss-tax.js +102 -0
- package/lib/pricing/product-swiss-tax.js.map +1 -0
- package/lib/pricing/utils/cache.d.ts +8 -0
- package/lib/pricing/utils/cache.js +28 -0
- package/lib/pricing/utils/cache.js.map +1 -0
- package/lib/quotations/manual.d.ts +1 -0
- package/lib/quotations/manual.js +21 -0
- package/lib/quotations/manual.js.map +1 -0
- package/lib/warehousing/google-sheets.d.ts +1 -0
- package/lib/warehousing/google-sheets.js +153 -0
- package/lib/warehousing/google-sheets.js.map +1 -0
- package/lib/warehousing/store.d.ts +1 -0
- package/lib/warehousing/store.js +33 -0
- package/lib/warehousing/store.js.map +1 -0
- package/lib/worker/BulkImportWorker.js +3 -3
- package/lib/worker/BulkImportWorker.js.map +1 -1
- package/lib/worker/GenerateOrderWorker.js +1 -1
- package/lib/worker/GenerateOrderWorker.js.map +1 -1
- package/lib/worker/ZombieKillerWorker.js.map +1 -1
- package/lib/worker/email.js +55 -4
- package/lib/worker/email.js.map +1 -1
- package/license +274 -0
- package/package.json +29 -12
- package/src/delivery/pick-mup.ts +119 -0
- package/src/delivery/post.ts +30 -0
- package/src/delivery/send-message.ts +54 -0
- package/src/delivery/stores.ts +49 -0
- package/src/enrollments/licensed.ts +49 -0
- package/src/files/gridfs/gridfs-adapter.ts +1 -1
- package/src/files/gridfs/gridfs-webhook.js +2 -2
- package/src/files/minio/minio-webhook.js +1 -1
- package/src/filters/local-search.ts +105 -0
- package/src/filters/strict-equal.ts +31 -0
- package/src/payment/apple-iap/adapter.ts +390 -0
- package/src/payment/apple-iap/db/AppleTransactionsCollection.ts +13 -0
- package/src/payment/apple-iap/index.ts +3 -0
- package/src/payment/apple-iap/module/configureAppleTransactionsModule.ts +31 -0
- package/src/payment/bity/adapter.ts +417 -0
- package/src/payment/bity/db/BityCredentialsCollection.ts +17 -0
- package/src/payment/bity/index.ts +3 -0
- package/src/payment/bity/module/configureBityModule.ts +46 -0
- package/src/payment/braintree.ts +147 -0
- package/src/payment/cryptopay.ts +195 -0
- package/src/payment/datatrans-v2/api/authorize.ts +17 -0
- package/src/payment/datatrans-v2/api/authorizeAuthenticated.ts +20 -0
- package/src/payment/datatrans-v2/api/cancel.ts +13 -0
- package/src/payment/datatrans-v2/api/index.ts +24 -0
- package/src/payment/datatrans-v2/api/init.ts +40 -0
- package/src/payment/datatrans-v2/api/makeFetcher.ts +49 -0
- package/src/payment/datatrans-v2/api/secureFields.ts +19 -0
- package/src/payment/datatrans-v2/api/settle.ts +13 -0
- package/src/payment/datatrans-v2/api/status.ts +8 -0
- package/src/payment/datatrans-v2/api/types.d.ts +378 -0
- package/src/payment/datatrans-v2/api/validate.ts +13 -0
- package/src/payment/datatrans-v2/generateSignature.ts +24 -0
- package/src/payment/datatrans-v2/getPaths.ts +24 -0
- package/src/payment/datatrans-v2/index.ts +476 -0
- package/src/payment/datatrans-v2/middleware.ts +147 -0
- package/src/payment/datatrans-v2/parseRegistrationData.ts +32 -0
- package/src/payment/datatrans-v2/roundedAmountFromOrder.ts +16 -0
- package/src/payment/datatrans-v2/splitProperties.ts +63 -0
- package/src/payment/invoice-prepaid.ts +40 -0
- package/src/payment/invoice.ts +36 -0
- package/src/payment/paypal-checkout.ts +107 -0
- package/src/payment/postfinance-checkout/api.ts +142 -0
- package/src/payment/postfinance-checkout/index.ts +241 -0
- package/src/payment/postfinance-checkout/middleware.ts +54 -0
- package/src/payment/postfinance-checkout/types.ts +27 -0
- package/src/payment/postfinance-checkout/utils.ts +35 -0
- package/src/payment/stripe.ts +278 -0
- package/src/payment/worldline-saferpay/index.ts +140 -0
- package/src/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayClient.ts +54 -0
- package/src/payment/worldline-saferpay/worldline-saferpay-client/api/SaferpayConnection.ts +36 -0
- package/src/payment/worldline-saferpay/worldline-saferpay-client/index.ts +8 -0
- package/src/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentMethods.ts +26 -0
- package/src/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageAssert.ts +75 -0
- package/src/payment/worldline-saferpay/worldline-saferpay-client/models/PaymentPageInitialize.ts +55 -0
- package/src/payment/worldline-saferpay/worldline-saferpay-client/models/Request.ts +14 -0
- package/src/payment/worldline-saferpay/worldline-saferpay-client/models/Response.ts +9 -0
- package/src/payment/worldline-saferpay/worldline-saferpay-client/models/Transaction.ts +6 -0
- package/src/payment/worldline-saferpay/worldline-saferpay-client/models/TransactionCancel.ts +15 -0
- package/src/pricing/delivery-swiss-tax.ts +115 -0
- package/src/pricing/discount-100-off.ts +44 -0
- package/src/pricing/discount-half-price-manual.ts +43 -0
- package/src/pricing/discount-half-price.ts +46 -0
- package/src/pricing/free-delivery.ts +31 -0
- package/src/pricing/free-payment.ts +32 -0
- package/src/pricing/order-delivery.ts +45 -0
- package/src/pricing/order-discount.ts +158 -0
- package/src/pricing/order-items-discount.ts +116 -0
- package/src/pricing/order-items.ts +61 -0
- package/src/pricing/order-payment.ts +46 -0
- package/src/pricing/product-catalog-price.ts +56 -0
- package/src/pricing/product-discount.ts +69 -0
- package/src/pricing/product-price-ECB-interbank-exchange.ts +108 -0
- package/src/pricing/product-price-coinbase-exchange.ts +82 -0
- package/src/pricing/product-price-cryptopay.ts +25 -0
- package/src/pricing/product-price-rateconversion.ts +73 -0
- package/src/pricing/product-price-round.ts +78 -0
- package/src/pricing/product-swiss-tax.ts +117 -0
- package/src/pricing/utils/cache.js +32 -0
- package/src/quotations/manual.ts +27 -0
- package/src/warehousing/google-sheets.ts +165 -0
- package/src/warehousing/store.ts +47 -0
- package/src/worker/BulkImportWorker.ts +3 -3
- package/src/worker/GenerateOrderWorker.ts +1 -1
- package/src/worker/ZombieKillerWorker.ts +5 -5
- package/src/worker/email.ts +56 -4
- package/lib/worker/MessageWorker.d.ts +0 -10
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export enum IntegrationModes { // eslint-disable-line
|
|
2
|
+
PaymentPage = 'PaymentPage',
|
|
3
|
+
Lightbox = 'Lightbox',
|
|
4
|
+
iFrame = 'iFrame',
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export enum CompletionModes { // eslint-disable-line
|
|
8
|
+
Immediate = 'Immediate',
|
|
9
|
+
Deferred = 'Deferred',
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type SignResponse = {
|
|
13
|
+
transactionId: number;
|
|
14
|
+
location: string | null;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type listenerEntityTechnicalNames = 'TransactionCompletion';
|
|
18
|
+
|
|
19
|
+
export type WebhookData = {
|
|
20
|
+
eventId: number;
|
|
21
|
+
entityId: number;
|
|
22
|
+
listenerEntityId: number;
|
|
23
|
+
listenerEntityTechnicalName: listenerEntityTechnicalNames;
|
|
24
|
+
spaceId: number;
|
|
25
|
+
webhookListenerId: number;
|
|
26
|
+
timestamp: string; // "YYYY-MM-DDTHH:MM:ss+0000", e.g. "2022-02-18T12:40:42+0000"
|
|
27
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Order, OrdersModule } from '@unchainedshop/types/orders';
|
|
2
|
+
import { Transaction } from 'postfinancecheckout/src/models/Transaction';
|
|
3
|
+
import { TransactionState } from 'postfinancecheckout/src/models/TransactionState';
|
|
4
|
+
|
|
5
|
+
export const transactionIsPaid = async (
|
|
6
|
+
transaction: Transaction,
|
|
7
|
+
expectedCurrency: string,
|
|
8
|
+
expectedAmount: number,
|
|
9
|
+
): Promise<boolean> => {
|
|
10
|
+
if (transaction.state === TransactionState.FULFILL) {
|
|
11
|
+
return (
|
|
12
|
+
transaction.completedAmount !== undefined &&
|
|
13
|
+
transaction.completedAmount.toFixed(2) === expectedAmount.toFixed(2) &&
|
|
14
|
+
transaction.currency === expectedCurrency
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
if (transaction.state === TransactionState.AUTHORIZED) {
|
|
18
|
+
return (
|
|
19
|
+
transaction.authorizationAmount !== undefined &&
|
|
20
|
+
transaction.authorizationAmount.toFixed(2) === expectedAmount.toFixed(2) &&
|
|
21
|
+
transaction.currency === expectedCurrency
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const orderIsPaid = async (
|
|
28
|
+
order: Order,
|
|
29
|
+
transaction: Transaction,
|
|
30
|
+
orderModule: OrdersModule,
|
|
31
|
+
): Promise<boolean> => {
|
|
32
|
+
const pricing = orderModule.pricingSheet(order);
|
|
33
|
+
const totalAmount = pricing.total({ useNetPrice: false }).amount / 100;
|
|
34
|
+
return transactionIsPaid(transaction, order.currency, totalAmount);
|
|
35
|
+
};
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { Context } from '@unchainedshop/types/api';
|
|
2
|
+
import { IPaymentAdapter } from '@unchainedshop/types/payments';
|
|
3
|
+
import bodyParser from 'body-parser';
|
|
4
|
+
import { useMiddlewareWithCurrentContext } from '@unchainedshop/api';
|
|
5
|
+
import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
|
|
6
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
7
|
+
|
|
8
|
+
const logger = createLogger('unchained:core-payment:stripe');
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
STRIPE_SECRET,
|
|
12
|
+
STRIPE_ENDPOINT_SECRET,
|
|
13
|
+
EMAIL_WEBSITE_NAME,
|
|
14
|
+
STRIPE_WEBHOOK_PATH = '/graphql/stripe',
|
|
15
|
+
} = process.env;
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
Test Webhooks:
|
|
19
|
+
|
|
20
|
+
brew install stripe/stripe-cli/stripe
|
|
21
|
+
stripe login --api-key sk_....
|
|
22
|
+
stripe listen --forward-to http://localhost:3000/graphql/stripe
|
|
23
|
+
stripe trigger payment_intent.succeeded
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const stripe = require('stripe')(STRIPE_SECRET); // eslint-disable-line
|
|
27
|
+
|
|
28
|
+
useMiddlewareWithCurrentContext(STRIPE_WEBHOOK_PATH, bodyParser.raw({ type: 'application/json' }));
|
|
29
|
+
|
|
30
|
+
useMiddlewareWithCurrentContext(STRIPE_WEBHOOK_PATH, async (request, response) => {
|
|
31
|
+
const sig = request.headers['stripe-signature'];
|
|
32
|
+
const resolvedContext = request.unchainedContext as Context;
|
|
33
|
+
const { modules, services } = resolvedContext;
|
|
34
|
+
|
|
35
|
+
let event;
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
event = stripe.webhooks.constructEvent(request.body, sig, STRIPE_ENDPOINT_SECRET);
|
|
39
|
+
} catch (err) {
|
|
40
|
+
response.writeHead(400);
|
|
41
|
+
response.end(`Webhook Error: ${err.message}`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
if (event.type === 'payment_intent.succeeded') {
|
|
47
|
+
const paymentIntent = event.data.object;
|
|
48
|
+
const orderPaymentId = paymentIntent.metadata?.orderPaymentId;
|
|
49
|
+
|
|
50
|
+
await modules.orders.payments.logEvent(orderPaymentId, event, resolvedContext.userId);
|
|
51
|
+
|
|
52
|
+
const orderPayment = await modules.orders.payments.findOrderPayment({
|
|
53
|
+
orderPaymentId,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const order = await modules.orders.checkout(
|
|
57
|
+
orderPayment.orderId,
|
|
58
|
+
{
|
|
59
|
+
transactionContext: {
|
|
60
|
+
paymentIntentId: paymentIntent.id,
|
|
61
|
+
},
|
|
62
|
+
paymentContext: {
|
|
63
|
+
paymentIntentId: paymentIntent.id,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
resolvedContext,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
logger.info(`Stripe Webhook: Unchained confirmed checkout for order ${order.orderNumber}`, {
|
|
70
|
+
orderId: order._id,
|
|
71
|
+
});
|
|
72
|
+
} else if (event.type === 'setup_intent.succeeded') {
|
|
73
|
+
const setupIntent = event.data.object;
|
|
74
|
+
const { paymentProviderId, userId } = setupIntent.metadata;
|
|
75
|
+
|
|
76
|
+
await services.payment.registerPaymentCredentials(
|
|
77
|
+
paymentProviderId,
|
|
78
|
+
{
|
|
79
|
+
transactionContext: {
|
|
80
|
+
setupIntentId: setupIntent.id,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
resolvedContext,
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
logger.info(`Stripe Webhook: Unchained registered payment credentials for ${userId}`, {
|
|
87
|
+
userId,
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
response.writeHead(404);
|
|
91
|
+
response.end();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
} catch (err) {
|
|
95
|
+
response.writeHead(400);
|
|
96
|
+
response.end(`Webhook Error: ${err.message}`);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
// Return a 200 response to acknowledge receipt of the event
|
|
100
|
+
response.end(JSON.stringify({ received: true }));
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const createRegistrationIntent = async ({ userId, name, email, paymentProviderId }, options = {}) => {
|
|
104
|
+
const customer = await stripe.customers.create({
|
|
105
|
+
metadata: {
|
|
106
|
+
userId,
|
|
107
|
+
},
|
|
108
|
+
name,
|
|
109
|
+
email,
|
|
110
|
+
});
|
|
111
|
+
const setupIntent = await stripe.setupIntents.create({
|
|
112
|
+
customer: customer.id,
|
|
113
|
+
metadata: {
|
|
114
|
+
userId,
|
|
115
|
+
paymentProviderId,
|
|
116
|
+
},
|
|
117
|
+
...options,
|
|
118
|
+
});
|
|
119
|
+
return setupIntent;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const createOrderPaymentIntent = async ({ order, orderPayment, pricing }, options = {}) => {
|
|
123
|
+
const reference = EMAIL_WEBSITE_NAME || order._id;
|
|
124
|
+
const { currency, amount } = pricing.total({ useNetPrice: false });
|
|
125
|
+
const paymentIntent = await stripe.paymentIntents.create({
|
|
126
|
+
amount: Math.round(amount),
|
|
127
|
+
currency: currency.toLowerCase(),
|
|
128
|
+
description: `${reference} #${order.orderNumber}`,
|
|
129
|
+
statement_descriptor: order.orderNumber,
|
|
130
|
+
statement_descriptor_suffix: reference,
|
|
131
|
+
receipt_email: order.contact?.emailAddress,
|
|
132
|
+
setup_future_usage: 'off_session', // Verify your integration in this guide by including this parameter
|
|
133
|
+
metadata: {
|
|
134
|
+
orderPaymentId: orderPayment._id,
|
|
135
|
+
},
|
|
136
|
+
...options,
|
|
137
|
+
});
|
|
138
|
+
return paymentIntent;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const Stripe: IPaymentAdapter = {
|
|
142
|
+
...PaymentAdapter,
|
|
143
|
+
|
|
144
|
+
key: 'shop.unchained.payment.stripe',
|
|
145
|
+
label: 'Stripe',
|
|
146
|
+
version: '2.0',
|
|
147
|
+
|
|
148
|
+
typeSupported(type) {
|
|
149
|
+
return type === 'GENERIC';
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
actions: (params) => {
|
|
153
|
+
const { modules } = params.context;
|
|
154
|
+
|
|
155
|
+
const adapterActions = {
|
|
156
|
+
...PaymentAdapter.actions(params),
|
|
157
|
+
|
|
158
|
+
// eslint-disable-next-line
|
|
159
|
+
configurationError() {
|
|
160
|
+
// eslint-disable-line
|
|
161
|
+
if (!STRIPE_SECRET || !STRIPE_ENDPOINT_SECRET) {
|
|
162
|
+
return PaymentError.INCOMPLETE_CONFIGURATION;
|
|
163
|
+
}
|
|
164
|
+
return null;
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
isActive: () => {
|
|
168
|
+
if (adapterActions.configurationError() === null) return true;
|
|
169
|
+
return false;
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
isPayLaterAllowed() {
|
|
173
|
+
return false;
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
validate: async ({ token }) => {
|
|
177
|
+
const paymentMethod = await stripe.paymentMethods.retrieve(token);
|
|
178
|
+
// TODO: Add further checks like expiration of cards
|
|
179
|
+
return !!paymentMethod;
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
register: async ({ setupIntentId }) => {
|
|
183
|
+
if (!setupIntentId) {
|
|
184
|
+
throw new Error('You have to provide a setup intent id');
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const setupIntent = await stripe.setupIntents.retrieve(setupIntentId);
|
|
188
|
+
|
|
189
|
+
if (setupIntent.status === 'succeeded') {
|
|
190
|
+
return {
|
|
191
|
+
token: setupIntent.payment_method,
|
|
192
|
+
customer: setupIntent.customer,
|
|
193
|
+
// payment_method_options: setupIntent.payment_method_options,
|
|
194
|
+
payment_method_types: setupIntent.payment_method_types,
|
|
195
|
+
usage: setupIntent.usage,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
logger.warn('Stripe Plugin: Registration declined', setupIntentId);
|
|
200
|
+
return null;
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
sign: async (transactionContext = {}) => {
|
|
204
|
+
// eslint-disable-line
|
|
205
|
+
const { orderPayment, paymentProviderId } = params.paymentContext;
|
|
206
|
+
const { userId } = params.context;
|
|
207
|
+
|
|
208
|
+
if (orderPayment) {
|
|
209
|
+
const order = await modules.orders.findOrder({ orderId: orderPayment.orderId });
|
|
210
|
+
const pricing = await modules.orders.pricingSheet(order);
|
|
211
|
+
const paymentIntent = await createOrderPaymentIntent(
|
|
212
|
+
{ order, orderPayment, pricing },
|
|
213
|
+
transactionContext,
|
|
214
|
+
);
|
|
215
|
+
return paymentIntent.client_secret;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const user = await modules.users.findUserById(userId);
|
|
219
|
+
const email = modules.users.primaryEmail(user)?.address;
|
|
220
|
+
const name = user.profile.displayName || user.username || email;
|
|
221
|
+
|
|
222
|
+
const paymentIntent = await createRegistrationIntent(
|
|
223
|
+
{ userId, name, email, paymentProviderId },
|
|
224
|
+
transactionContext,
|
|
225
|
+
);
|
|
226
|
+
return paymentIntent.client_secret;
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
charge: async ({ paymentIntentId, paymentCredentials }) => {
|
|
230
|
+
if (!paymentIntentId && !paymentCredentials) {
|
|
231
|
+
throw new Error('You have to provide an existing intent or a payment method');
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const { order } = params.paymentContext;
|
|
235
|
+
const orderPayment = await modules.orders.payments.findOrderPayment({
|
|
236
|
+
orderPaymentId: order.paymentId,
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
const pricing = await modules.orders.pricingSheet(order);
|
|
240
|
+
|
|
241
|
+
const paymentIntentObject = paymentIntentId
|
|
242
|
+
? await stripe.paymentIntents.retrieve(paymentIntentId)
|
|
243
|
+
: await createOrderPaymentIntent(
|
|
244
|
+
{ orderPayment, order, pricing },
|
|
245
|
+
{
|
|
246
|
+
customer: paymentCredentials.meta?.customer,
|
|
247
|
+
confirm: true,
|
|
248
|
+
payment_method: paymentCredentials.token,
|
|
249
|
+
payment_method_types: paymentCredentials.meta?.payment_method_types, // eslint-disable-line
|
|
250
|
+
// payment_method_options: paymentCredentials.meta?.payment_method_options, // eslint-disable-line
|
|
251
|
+
},
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
const { currency, amount } = pricing.total({ useNetPrice: false });
|
|
255
|
+
|
|
256
|
+
if (
|
|
257
|
+
paymentIntentObject.currency !== currency.toLowerCase() ||
|
|
258
|
+
paymentIntentObject.amount !== Math.round(amount)
|
|
259
|
+
) {
|
|
260
|
+
throw new Error('The price has changed since you have created the intent!');
|
|
261
|
+
}
|
|
262
|
+
if (paymentIntentObject.metadata?.orderPaymentId !== orderPayment?._id) {
|
|
263
|
+
throw new Error('The order payment is different from the initiating intent!');
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (paymentIntentObject.status === 'succeeded') {
|
|
267
|
+
return paymentIntentObject;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return false;
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
return adapterActions;
|
|
275
|
+
},
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
PaymentDirector.registerAdapter(Stripe);
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { IPaymentAdapter } from '@unchainedshop/types/payments';
|
|
2
|
+
import { PaymentAdapter, PaymentDirector, PaymentError } from '@unchainedshop/core-payment';
|
|
3
|
+
import { PaymentPageInitializeInput, SaferpayClient } from './worldline-saferpay-client';
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
WORLDLINE_BASE_URL = 'https://test.saferpay.com/api',
|
|
7
|
+
WORLDLINE_CUSTOMER_ID,
|
|
8
|
+
WORLDLINE_USER,
|
|
9
|
+
WORLDLINE_PW,
|
|
10
|
+
WORLDLINE_SUCCESS_URL,
|
|
11
|
+
WORLDLINE_FAILED_URL,
|
|
12
|
+
} = process.env;
|
|
13
|
+
|
|
14
|
+
const WordlineSaferpay: IPaymentAdapter = {
|
|
15
|
+
...PaymentAdapter,
|
|
16
|
+
|
|
17
|
+
key: 'shop.unchained.payment.worldline-saferpay',
|
|
18
|
+
label: 'Worldline Saferpay',
|
|
19
|
+
version: '1.0',
|
|
20
|
+
|
|
21
|
+
typeSupported(type) {
|
|
22
|
+
return type === 'GENERIC';
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
actions: (params) => {
|
|
26
|
+
const { modules } = params.context;
|
|
27
|
+
|
|
28
|
+
const saferpayClient = new SaferpayClient(
|
|
29
|
+
WORLDLINE_BASE_URL,
|
|
30
|
+
WORLDLINE_CUSTOMER_ID,
|
|
31
|
+
WORLDLINE_USER,
|
|
32
|
+
WORLDLINE_PW,
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const adapter = {
|
|
36
|
+
...PaymentAdapter.actions(params),
|
|
37
|
+
|
|
38
|
+
getTerminalId() {
|
|
39
|
+
return params.config.find((item) => item.key === 'terminalId')?.value;
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
// eslint-disable-next-line
|
|
43
|
+
configurationError() {
|
|
44
|
+
// eslint-disable-line
|
|
45
|
+
if (
|
|
46
|
+
!WORLDLINE_BASE_URL ||
|
|
47
|
+
!WORLDLINE_CUSTOMER_ID ||
|
|
48
|
+
!WORLDLINE_USER ||
|
|
49
|
+
!WORLDLINE_PW ||
|
|
50
|
+
!adapter.getTerminalId()
|
|
51
|
+
) {
|
|
52
|
+
return PaymentError.INCOMPLETE_CONFIGURATION;
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
isActive() {
|
|
58
|
+
if (adapter.configurationError() === null) return true;
|
|
59
|
+
return false;
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
isPayLaterAllowed() {
|
|
63
|
+
return false;
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
sign: async (transactionContext: any = {}) => {
|
|
67
|
+
const { orderPayment } = params.paymentContext;
|
|
68
|
+
const order = await modules.orders.findOrder({
|
|
69
|
+
orderId: orderPayment.orderId,
|
|
70
|
+
});
|
|
71
|
+
const pricing = modules.orders.pricingSheet(order);
|
|
72
|
+
const totalAmount = pricing?.total({ useNetPrice: false }).amount;
|
|
73
|
+
const paymentPageInitInput: PaymentPageInitializeInput = {
|
|
74
|
+
RequestHeader: saferpayClient.buildRequestHeader(orderPayment._id, 0),
|
|
75
|
+
TerminalId: adapter.getTerminalId(),
|
|
76
|
+
Payment: {
|
|
77
|
+
Amount: {
|
|
78
|
+
Value: totalAmount.toString(),
|
|
79
|
+
CurrencyCode: order.currency,
|
|
80
|
+
},
|
|
81
|
+
OrderId: order._id,
|
|
82
|
+
Description: transactionContext.description || 'Bestellung',
|
|
83
|
+
},
|
|
84
|
+
ReturnUrls: {
|
|
85
|
+
Success: `${WORLDLINE_SUCCESS_URL}?order_id=${order._id}`,
|
|
86
|
+
Fail: `${WORLDLINE_FAILED_URL}?order_id=${order._id}`,
|
|
87
|
+
Abort: `${WORLDLINE_FAILED_URL}?order_id=${order._id}`,
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
const paymentPageInit = await saferpayClient.paymentPageInitialize(paymentPageInitInput);
|
|
91
|
+
return JSON.stringify({
|
|
92
|
+
location: paymentPageInit.RedirectUrl,
|
|
93
|
+
transactionId: paymentPageInit.Token,
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
charge: async ({ transactionId }: { transactionId: string }) => {
|
|
98
|
+
const { orderPayment } = params.paymentContext;
|
|
99
|
+
const order = await modules.orders.findOrder({ orderId: orderPayment.orderId });
|
|
100
|
+
const pricing = modules.orders.pricingSheet(order);
|
|
101
|
+
const totalAmount = pricing.total({ useNetPrice: false }).amount;
|
|
102
|
+
const paymentPageAssert = await saferpayClient.paymentPageAssert({
|
|
103
|
+
RequestHeader: saferpayClient.buildRequestHeader(orderPayment._id, 0),
|
|
104
|
+
Token: transactionId,
|
|
105
|
+
});
|
|
106
|
+
return (
|
|
107
|
+
!paymentPageAssert.ErrorMessage &&
|
|
108
|
+
paymentPageAssert.Transaction.Amount.Value === totalAmount.toString() &&
|
|
109
|
+
paymentPageAssert.Transaction.Amount.CurrencyCode === order.currency &&
|
|
110
|
+
(paymentPageAssert.Transaction.Status === 'AUTHORIZED' ||
|
|
111
|
+
paymentPageAssert.Transaction.Status === 'CAPTURED')
|
|
112
|
+
);
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
cancel: async () => {
|
|
116
|
+
const { orderPayment } = params.paymentContext;
|
|
117
|
+
if (!orderPayment) return false;
|
|
118
|
+
const token = orderPayment.context?.token;
|
|
119
|
+
if (!token) return false;
|
|
120
|
+
const paymentPageAssert = await saferpayClient.paymentPageAssert({
|
|
121
|
+
RequestHeader: saferpayClient.buildRequestHeader(orderPayment._id, 0),
|
|
122
|
+
Token: token,
|
|
123
|
+
});
|
|
124
|
+
const transactionId = paymentPageAssert.Transaction?.Id;
|
|
125
|
+
if (paymentPageAssert.Transaction.Status !== 'AUTHORIZED' || !transactionId) return false;
|
|
126
|
+
const transactionCancelRes = await saferpayClient.transactionCancel({
|
|
127
|
+
RequestHeader: saferpayClient.buildRequestHeader(orderPayment._id, 0),
|
|
128
|
+
TransactionReference: {
|
|
129
|
+
TransactionId: transactionId,
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
return transactionCancelRes.TransactionId === transactionId;
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
return adapter;
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
PaymentDirector.registerAdapter(WordlineSaferpay);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { TransactionCancelInput, TransactionCancelResponse } from '../models/TransactionCancel';
|
|
2
|
+
import { PaymentPageAssertInput, PaymentPageAssertResponse } from '../models/PaymentPageAssert';
|
|
3
|
+
import {
|
|
4
|
+
PaymentPageInitializeInput,
|
|
5
|
+
PaymentPageInitializeResponse,
|
|
6
|
+
} from '../models/PaymentPageInitialize';
|
|
7
|
+
import { RequestHeader } from '../models/Request';
|
|
8
|
+
import { SaferpayConnection } from './SaferpayConnection';
|
|
9
|
+
|
|
10
|
+
export class SaferpayClient {
|
|
11
|
+
private conn: SaferpayConnection;
|
|
12
|
+
|
|
13
|
+
private customerId: string;
|
|
14
|
+
|
|
15
|
+
private specVersion: string;
|
|
16
|
+
|
|
17
|
+
public constructor(
|
|
18
|
+
baseUrl: string,
|
|
19
|
+
customerId: string,
|
|
20
|
+
user: string,
|
|
21
|
+
password: string,
|
|
22
|
+
specVersion?: string,
|
|
23
|
+
) {
|
|
24
|
+
this.customerId = customerId;
|
|
25
|
+
this.specVersion = specVersion || '1.27';
|
|
26
|
+
this.conn = new SaferpayConnection(baseUrl, user, password);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public buildRequestHeader(requestId: string, retryIndicator: number): RequestHeader {
|
|
30
|
+
return {
|
|
31
|
+
SpecVersion: this.specVersion,
|
|
32
|
+
CustomerId: this.customerId,
|
|
33
|
+
RequestId: requestId,
|
|
34
|
+
RetryIndicator: retryIndicator,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public async paymentPageInitialize(
|
|
39
|
+
input: PaymentPageInitializeInput,
|
|
40
|
+
): Promise<PaymentPageInitializeResponse> {
|
|
41
|
+
return this.conn.post(
|
|
42
|
+
'/Payment/v1/PaymentPage/Initialize',
|
|
43
|
+
input,
|
|
44
|
+
) as Promise<PaymentPageInitializeResponse>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public async paymentPageAssert(input: PaymentPageAssertInput): Promise<PaymentPageAssertResponse> {
|
|
48
|
+
return this.conn.post('/Payment/v1/PaymentPage/Assert', input) as Promise<PaymentPageAssertResponse>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public async transactionCancel(input: TransactionCancelInput): Promise<TransactionCancelResponse> {
|
|
52
|
+
return this.conn.post('/Payment/v1/Transaction/Cancel', input) as Promise<TransactionCancelResponse>;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import fetch from 'node-fetch';
|
|
2
|
+
|
|
3
|
+
export class SaferpayConnection {
|
|
4
|
+
private baseUrl: string;
|
|
5
|
+
|
|
6
|
+
private user: string;
|
|
7
|
+
|
|
8
|
+
private password: string;
|
|
9
|
+
|
|
10
|
+
public constructor(baseUrl: string, user: string, password: string) {
|
|
11
|
+
this.baseUrl = baseUrl;
|
|
12
|
+
this.user = user;
|
|
13
|
+
this.password = password;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
private buildUrl(uri: string): string {
|
|
17
|
+
return this.baseUrl + uri;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
private getHeaders() {
|
|
21
|
+
return {
|
|
22
|
+
'Content-Type': 'application/json',
|
|
23
|
+
Authorization: `Basic ${Buffer.from(`${this.user}:${this.password}`, 'binary').toString(
|
|
24
|
+
'base64',
|
|
25
|
+
)}`,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public async post(uri: string, data: object): Promise<any> {
|
|
30
|
+
return fetch(this.buildUrl(uri), {
|
|
31
|
+
method: 'POST',
|
|
32
|
+
body: JSON.stringify(data),
|
|
33
|
+
headers: this.getHeaders(),
|
|
34
|
+
}).then((res: any) => res.json());
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { SaferpayClient } from './api/SaferpayClient';
|
|
2
|
+
|
|
3
|
+
export {
|
|
4
|
+
PaymentPageInitializeInput,
|
|
5
|
+
PaymentPageInitializeResponse,
|
|
6
|
+
} from './models/PaymentPageInitialize';
|
|
7
|
+
export { PaymentPageAssertInput, PaymentPageAssertResponse } from './models/PaymentPageAssert';
|
|
8
|
+
export { TransactionCancelInput, TransactionCancelResponse } from './models/TransactionCancel';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type PaymentMethods =
|
|
2
|
+
| 'ALIPAY'
|
|
3
|
+
| 'AMEX'
|
|
4
|
+
| 'BANCONTACT'
|
|
5
|
+
| 'BONUS'
|
|
6
|
+
| 'DINERS'
|
|
7
|
+
| 'DIRECTDEBIT'
|
|
8
|
+
| 'EPRZELEWY'
|
|
9
|
+
| 'EPS'
|
|
10
|
+
| 'GIROPAY'
|
|
11
|
+
| 'IDEAL'
|
|
12
|
+
| 'INVOICE'
|
|
13
|
+
| 'JCB'
|
|
14
|
+
| 'KLARNA'
|
|
15
|
+
| 'MAESTRO'
|
|
16
|
+
| 'MASTERCARD'
|
|
17
|
+
| 'MYONE'
|
|
18
|
+
| 'PAYPAL'
|
|
19
|
+
| 'PAYDIREKT'
|
|
20
|
+
| 'POSTCARD'
|
|
21
|
+
| 'POSTFINANCE'
|
|
22
|
+
| 'SOFORT'
|
|
23
|
+
| 'TWINT'
|
|
24
|
+
| 'UNIONPAY'
|
|
25
|
+
| 'VISA'
|
|
26
|
+
| 'WLCRYPTOPAYMENTS';
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Response } from './Response';
|
|
2
|
+
import { Request } from './Request';
|
|
3
|
+
import { TransactionAmount, TransactionStatus } from './Transaction';
|
|
4
|
+
import { PaymentMethods } from './PaymentMethods';
|
|
5
|
+
|
|
6
|
+
export interface PaymentPageAssertInput extends Request {
|
|
7
|
+
Token: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface PaymentPageAssertResponse extends Response {
|
|
11
|
+
Transaction: {
|
|
12
|
+
Type: 'PAYMENT';
|
|
13
|
+
Status: TransactionStatus;
|
|
14
|
+
Id: string;
|
|
15
|
+
CaptureId?: string;
|
|
16
|
+
Date: string;
|
|
17
|
+
Amount: TransactionAmount;
|
|
18
|
+
OrderId?: string;
|
|
19
|
+
AcquirerName?: string;
|
|
20
|
+
AcquirerReference?: string;
|
|
21
|
+
SixTransactionReference: string;
|
|
22
|
+
ApprovalCode?: string;
|
|
23
|
+
DirectDebit?: string;
|
|
24
|
+
MandateId: string;
|
|
25
|
+
CreditorId: string;
|
|
26
|
+
Invoice: {
|
|
27
|
+
Payee: Map<string, string>;
|
|
28
|
+
};
|
|
29
|
+
ReasonForTransfer?: string;
|
|
30
|
+
DueDate?: string;
|
|
31
|
+
IssuerReference?: Map<string, string>;
|
|
32
|
+
};
|
|
33
|
+
PaymentMeans: {
|
|
34
|
+
Brand: {
|
|
35
|
+
PaymentMethod?: PaymentMethods;
|
|
36
|
+
Name: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
DisplayText: string;
|
|
40
|
+
Wallet?: string;
|
|
41
|
+
Card: {
|
|
42
|
+
MaskedNumber: string;
|
|
43
|
+
ExpYear: number;
|
|
44
|
+
ExpMonth: number;
|
|
45
|
+
HolderName?: string;
|
|
46
|
+
HolderSegment?: string;
|
|
47
|
+
CountryCode?: string;
|
|
48
|
+
HashValue?: string;
|
|
49
|
+
};
|
|
50
|
+
BankAccount?: Map<string, string>;
|
|
51
|
+
Twint?: Map<string, string>;
|
|
52
|
+
Paypal?: Map<string, string>;
|
|
53
|
+
Payer?: object;
|
|
54
|
+
BillingAddress?: Map<string, string>;
|
|
55
|
+
RegistrationResult?: {
|
|
56
|
+
Success: boolean;
|
|
57
|
+
Alias?: string;
|
|
58
|
+
Id: string;
|
|
59
|
+
Lifetime: number;
|
|
60
|
+
Error?: {
|
|
61
|
+
ErrorName?: string;
|
|
62
|
+
ErrorMessage?: string;
|
|
63
|
+
};
|
|
64
|
+
AuthenticationResult?: {
|
|
65
|
+
Result: 'OK' | 'NOT_SUPPORTED';
|
|
66
|
+
};
|
|
67
|
+
Message: string;
|
|
68
|
+
};
|
|
69
|
+
Liability?: object;
|
|
70
|
+
Dcc?: object;
|
|
71
|
+
MastercardIssuerInstallments?: object;
|
|
72
|
+
FraudPrevention?: {
|
|
73
|
+
Result?: 'APPROVED' | 'MANUAL_REVIEW';
|
|
74
|
+
};
|
|
75
|
+
}
|