@swichpay/react-native 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/LICENSE +21 -0
- package/README.md +82 -2
- package/docs/checkouts.md +98 -0
- package/docs/getting-started.md +140 -0
- package/docs/going-live.md +45 -0
- package/docs/own-screen.md +81 -0
- package/docs/results-and-errors.md +75 -0
- package/docs/server.md +163 -0
- package/docs/troubleshooting.md +57 -0
- package/lib/commonjs/HostedCheckout.js +115 -0
- package/lib/commonjs/checkout-webview.js +85 -0
- package/lib/commonjs/checkouts/PaymentSheet.js +1317 -0
- package/lib/commonjs/checkouts/direct.js +671 -0
- package/lib/commonjs/context.js +64 -0
- package/lib/commonjs/core/api/direct-payment-api.js +425 -0
- package/lib/commonjs/core/api/discount-api.js +19 -0
- package/lib/commonjs/core/api/gateway-api.js +366 -0
- package/lib/commonjs/core/api/payments-api.js +79 -0
- package/lib/commonjs/core/api/repositories.js +5 -0
- package/lib/commonjs/core/assets/images.js +12 -0
- package/lib/commonjs/core/assets/method-logos.js +19 -0
- package/lib/commonjs/core/assets/pwa-images.js +13 -0
- package/lib/commonjs/core/browser/clipboard.js +30 -0
- package/lib/commonjs/core/browser/dom.js +71 -0
- package/lib/commonjs/core/browser/hosted-checkout.js +107 -0
- package/lib/commonjs/core/browser/index.js +119 -0
- package/lib/commonjs/core/browser/qr.js +109 -0
- package/lib/commonjs/core/browser/three-ds.js +151 -0
- package/lib/commonjs/core/client.js +344 -0
- package/lib/commonjs/core/config.js +132 -0
- package/lib/commonjs/core/environment.js +34 -0
- package/lib/commonjs/core/errors.js +138 -0
- package/lib/commonjs/core/events.js +57 -0
- package/lib/commonjs/core/flows/controller.js +106 -0
- package/lib/commonjs/core/flows/countdown.js +41 -0
- package/lib/commonjs/core/flows/direct-bank-transfer.js +236 -0
- package/lib/commonjs/core/flows/direct-card.js +354 -0
- package/lib/commonjs/core/flows/direct-ewallet.js +124 -0
- package/lib/commonjs/core/flows/direct-one-bill.js +172 -0
- package/lib/commonjs/core/flows/direct-qr.js +109 -0
- package/lib/commonjs/core/flows/direct-rtp.js +302 -0
- package/lib/commonjs/core/flows/discount-lookup.js +80 -0
- package/lib/commonjs/core/flows/headless.js +94 -0
- package/lib/commonjs/core/flows/payment-sheet.js +1321 -0
- package/lib/commonjs/core/flows/services.js +31 -0
- package/lib/commonjs/core/flows/shared.js +90 -0
- package/lib/commonjs/core/http/api-client.js +208 -0
- package/lib/commonjs/core/http/endpoints.js +61 -0
- package/lib/commonjs/core/http/token-manager.js +46 -0
- package/lib/commonjs/core/http/transport.js +134 -0
- package/lib/commonjs/core/index.js +688 -0
- package/lib/commonjs/core/models/category.js +113 -0
- package/lib/commonjs/core/models/discount.js +51 -0
- package/lib/commonjs/core/models/payment.js +95 -0
- package/lib/commonjs/core/models/session.js +131 -0
- package/lib/commonjs/core/server/index.js +64 -0
- package/lib/commonjs/core/server/node.js +60 -0
- package/lib/commonjs/core/server/proxy.js +194 -0
- package/lib/commonjs/core/server/verify.js +122 -0
- package/lib/commonjs/core/swichpay.js +72 -0
- package/lib/commonjs/core/utils/crypto.js +78 -0
- package/lib/commonjs/core/utils/formatters.js +68 -0
- package/lib/commonjs/core/utils/json.js +110 -0
- package/lib/commonjs/core/utils/log.js +75 -0
- package/lib/commonjs/core/utils/runtime.js +34 -0
- package/lib/commonjs/core/utils/validators.js +59 -0
- package/lib/commonjs/hooks.js +77 -0
- package/lib/commonjs/index.js +203 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/polyfills.js +3 -0
- package/lib/commonjs/presenter.js +61 -0
- package/lib/commonjs/provider.js +192 -0
- package/lib/commonjs/swichpay.js +192 -0
- package/lib/commonjs/theme.js +54 -0
- package/lib/commonjs/ui.js +1142 -0
- package/lib/commonjs/webviews.js +279 -0
- package/lib/module/HostedCheckout.js +111 -0
- package/lib/module/checkout-webview.js +83 -0
- package/lib/module/checkouts/PaymentSheet.js +1313 -0
- package/lib/module/checkouts/direct.js +661 -0
- package/lib/module/context.js +58 -0
- package/lib/module/core/api/direct-payment-api.js +413 -0
- package/lib/module/core/api/discount-api.js +14 -0
- package/lib/module/core/api/gateway-api.js +358 -0
- package/lib/module/core/api/payments-api.js +73 -0
- package/lib/module/core/api/repositories.js +3 -0
- package/lib/module/core/assets/images.js +8 -0
- package/lib/module/core/assets/method-logos.js +15 -0
- package/lib/module/core/assets/pwa-images.js +9 -0
- package/lib/module/core/browser/clipboard.js +27 -0
- package/lib/module/core/browser/dom.js +63 -0
- package/lib/module/core/browser/hosted-checkout.js +102 -0
- package/lib/module/core/browser/index.js +12 -0
- package/lib/module/core/browser/qr.js +100 -0
- package/lib/module/core/browser/three-ds.js +145 -0
- package/lib/module/core/client.js +338 -0
- package/lib/module/core/config.js +128 -0
- package/lib/module/core/environment.js +29 -0
- package/lib/module/core/errors.js +125 -0
- package/lib/module/core/events.js +51 -0
- package/lib/module/core/flows/controller.js +101 -0
- package/lib/module/core/flows/countdown.js +36 -0
- package/lib/module/core/flows/direct-bank-transfer.js +231 -0
- package/lib/module/core/flows/direct-card.js +349 -0
- package/lib/module/core/flows/direct-ewallet.js +119 -0
- package/lib/module/core/flows/direct-one-bill.js +167 -0
- package/lib/module/core/flows/direct-qr.js +104 -0
- package/lib/module/core/flows/direct-rtp.js +297 -0
- package/lib/module/core/flows/discount-lookup.js +75 -0
- package/lib/module/core/flows/headless.js +90 -0
- package/lib/module/core/flows/payment-sheet.js +1315 -0
- package/lib/module/core/flows/services.js +27 -0
- package/lib/module/core/flows/shared.js +78 -0
- package/lib/module/core/http/api-client.js +203 -0
- package/lib/module/core/http/endpoints.js +57 -0
- package/lib/module/core/http/token-manager.js +41 -0
- package/lib/module/core/http/transport.js +126 -0
- package/lib/module/core/index.js +52 -0
- package/lib/module/core/models/category.js +104 -0
- package/lib/module/core/models/discount.js +46 -0
- package/lib/module/core/models/payment.js +89 -0
- package/lib/module/core/models/session.js +120 -0
- package/lib/module/core/server/index.js +11 -0
- package/lib/module/core/server/node.js +56 -0
- package/lib/module/core/server/proxy.js +191 -0
- package/lib/module/core/server/verify.js +115 -0
- package/lib/module/core/swichpay.js +68 -0
- package/lib/module/core/utils/crypto.js +72 -0
- package/lib/module/core/utils/formatters.js +56 -0
- package/lib/module/core/utils/json.js +94 -0
- package/lib/module/core/utils/log.js +67 -0
- package/lib/module/core/utils/runtime.js +28 -0
- package/lib/module/core/utils/validators.js +54 -0
- package/lib/module/hooks.js +72 -0
- package/lib/module/index.js +36 -0
- package/lib/module/polyfills.js +4 -0
- package/lib/module/presenter.js +58 -0
- package/lib/module/provider.js +188 -0
- package/lib/module/swichpay.js +187 -0
- package/lib/module/theme.js +50 -0
- package/lib/module/ui.js +1116 -0
- package/lib/module/webviews.js +272 -0
- package/lib/typescript/commonjs/HostedCheckout.d.ts +17 -0
- package/lib/typescript/commonjs/checkout-webview.d.ts +14 -0
- package/lib/typescript/commonjs/checkouts/PaymentSheet.d.ts +14 -0
- package/lib/typescript/commonjs/checkouts/direct.d.ts +18 -0
- package/lib/typescript/commonjs/context.d.ts +20 -0
- package/lib/typescript/commonjs/core/api/direct-payment-api.d.ts +103 -0
- package/lib/typescript/commonjs/core/api/discount-api.d.ts +10 -0
- package/lib/typescript/commonjs/core/api/gateway-api.d.ts +150 -0
- package/lib/typescript/commonjs/core/api/payments-api.d.ts +22 -0
- package/lib/typescript/commonjs/core/api/repositories.d.ts +86 -0
- package/lib/typescript/commonjs/core/assets/images.d.ts +5 -0
- package/lib/typescript/commonjs/core/assets/method-logos.d.ts +12 -0
- package/lib/typescript/commonjs/core/assets/pwa-images.d.ts +7 -0
- package/lib/typescript/commonjs/core/browser/clipboard.d.ts +3 -0
- package/lib/typescript/commonjs/core/browser/dom.d.ts +11 -0
- package/lib/typescript/commonjs/core/browser/hosted-checkout.d.ts +27 -0
- package/lib/typescript/commonjs/core/browser/index.d.ts +11 -0
- package/lib/typescript/commonjs/core/browser/qr.d.ts +18 -0
- package/lib/typescript/commonjs/core/browser/three-ds.d.ts +45 -0
- package/lib/typescript/commonjs/core/client.d.ts +181 -0
- package/lib/typescript/commonjs/core/config.d.ts +86 -0
- package/lib/typescript/commonjs/core/environment.d.ts +22 -0
- package/lib/typescript/commonjs/core/errors.d.ts +78 -0
- package/lib/typescript/commonjs/core/events.d.ts +19 -0
- package/lib/typescript/commonjs/core/flows/controller.d.ts +41 -0
- package/lib/typescript/commonjs/core/flows/countdown.d.ts +15 -0
- package/lib/typescript/commonjs/core/flows/direct-bank-transfer.d.ts +49 -0
- package/lib/typescript/commonjs/core/flows/direct-card.d.ts +94 -0
- package/lib/typescript/commonjs/core/flows/direct-ewallet.d.ts +39 -0
- package/lib/typescript/commonjs/core/flows/direct-one-bill.d.ts +38 -0
- package/lib/typescript/commonjs/core/flows/direct-qr.d.ts +25 -0
- package/lib/typescript/commonjs/core/flows/direct-rtp.d.ts +72 -0
- package/lib/typescript/commonjs/core/flows/discount-lookup.d.ts +37 -0
- package/lib/typescript/commonjs/core/flows/headless.d.ts +38 -0
- package/lib/typescript/commonjs/core/flows/payment-sheet.d.ts +263 -0
- package/lib/typescript/commonjs/core/flows/services.d.ts +22 -0
- package/lib/typescript/commonjs/core/flows/shared.d.ts +40 -0
- package/lib/typescript/commonjs/core/http/api-client.d.ts +37 -0
- package/lib/typescript/commonjs/core/http/endpoints.d.ts +39 -0
- package/lib/typescript/commonjs/core/http/token-manager.d.ts +19 -0
- package/lib/typescript/commonjs/core/http/transport.d.ts +37 -0
- package/lib/typescript/commonjs/core/index.d.ts +42 -0
- package/lib/typescript/commonjs/core/models/category.d.ts +35 -0
- package/lib/typescript/commonjs/core/models/discount.d.ts +41 -0
- package/lib/typescript/commonjs/core/models/payment.d.ts +104 -0
- package/lib/typescript/commonjs/core/models/session.d.ts +87 -0
- package/lib/typescript/commonjs/core/server/index.d.ts +10 -0
- package/lib/typescript/commonjs/core/server/node.d.ts +19 -0
- package/lib/typescript/commonjs/core/server/proxy.d.ts +30 -0
- package/lib/typescript/commonjs/core/server/verify.d.ts +61 -0
- package/lib/typescript/commonjs/core/swichpay.d.ts +40 -0
- package/lib/typescript/commonjs/core/utils/crypto.d.ts +19 -0
- package/lib/typescript/commonjs/core/utils/formatters.d.ts +19 -0
- package/lib/typescript/commonjs/core/utils/json.d.ts +27 -0
- package/lib/typescript/commonjs/core/utils/log.d.ts +15 -0
- package/lib/typescript/commonjs/core/utils/runtime.d.ts +12 -0
- package/lib/typescript/commonjs/core/utils/validators.d.ts +23 -0
- package/lib/typescript/commonjs/hooks.d.ts +21 -0
- package/lib/typescript/commonjs/index.d.ts +26 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/polyfills.d.ts +2 -0
- package/lib/typescript/commonjs/presenter.d.ts +25 -0
- package/lib/typescript/commonjs/provider.d.ts +22 -0
- package/lib/typescript/commonjs/swichpay.d.ts +125 -0
- package/lib/typescript/commonjs/theme.d.ts +52 -0
- package/lib/typescript/commonjs/ui.d.ts +583 -0
- package/lib/typescript/commonjs/webviews.d.ts +40 -0
- package/lib/typescript/module/HostedCheckout.d.ts +17 -0
- package/lib/typescript/module/checkout-webview.d.ts +14 -0
- package/lib/typescript/module/checkouts/PaymentSheet.d.ts +14 -0
- package/lib/typescript/module/checkouts/direct.d.ts +18 -0
- package/lib/typescript/module/context.d.ts +20 -0
- package/lib/typescript/module/core/api/direct-payment-api.d.ts +103 -0
- package/lib/typescript/module/core/api/discount-api.d.ts +10 -0
- package/lib/typescript/module/core/api/gateway-api.d.ts +150 -0
- package/lib/typescript/module/core/api/payments-api.d.ts +22 -0
- package/lib/typescript/module/core/api/repositories.d.ts +86 -0
- package/lib/typescript/module/core/assets/images.d.ts +5 -0
- package/lib/typescript/module/core/assets/method-logos.d.ts +12 -0
- package/lib/typescript/module/core/assets/pwa-images.d.ts +7 -0
- package/lib/typescript/module/core/browser/clipboard.d.ts +3 -0
- package/lib/typescript/module/core/browser/dom.d.ts +11 -0
- package/lib/typescript/module/core/browser/hosted-checkout.d.ts +27 -0
- package/lib/typescript/module/core/browser/index.d.ts +11 -0
- package/lib/typescript/module/core/browser/qr.d.ts +18 -0
- package/lib/typescript/module/core/browser/three-ds.d.ts +45 -0
- package/lib/typescript/module/core/client.d.ts +181 -0
- package/lib/typescript/module/core/config.d.ts +86 -0
- package/lib/typescript/module/core/environment.d.ts +22 -0
- package/lib/typescript/module/core/errors.d.ts +78 -0
- package/lib/typescript/module/core/events.d.ts +19 -0
- package/lib/typescript/module/core/flows/controller.d.ts +41 -0
- package/lib/typescript/module/core/flows/countdown.d.ts +15 -0
- package/lib/typescript/module/core/flows/direct-bank-transfer.d.ts +49 -0
- package/lib/typescript/module/core/flows/direct-card.d.ts +94 -0
- package/lib/typescript/module/core/flows/direct-ewallet.d.ts +39 -0
- package/lib/typescript/module/core/flows/direct-one-bill.d.ts +38 -0
- package/lib/typescript/module/core/flows/direct-qr.d.ts +25 -0
- package/lib/typescript/module/core/flows/direct-rtp.d.ts +72 -0
- package/lib/typescript/module/core/flows/discount-lookup.d.ts +37 -0
- package/lib/typescript/module/core/flows/headless.d.ts +38 -0
- package/lib/typescript/module/core/flows/payment-sheet.d.ts +263 -0
- package/lib/typescript/module/core/flows/services.d.ts +22 -0
- package/lib/typescript/module/core/flows/shared.d.ts +40 -0
- package/lib/typescript/module/core/http/api-client.d.ts +37 -0
- package/lib/typescript/module/core/http/endpoints.d.ts +39 -0
- package/lib/typescript/module/core/http/token-manager.d.ts +19 -0
- package/lib/typescript/module/core/http/transport.d.ts +37 -0
- package/lib/typescript/module/core/index.d.ts +42 -0
- package/lib/typescript/module/core/models/category.d.ts +35 -0
- package/lib/typescript/module/core/models/discount.d.ts +41 -0
- package/lib/typescript/module/core/models/payment.d.ts +104 -0
- package/lib/typescript/module/core/models/session.d.ts +87 -0
- package/lib/typescript/module/core/server/index.d.ts +10 -0
- package/lib/typescript/module/core/server/node.d.ts +19 -0
- package/lib/typescript/module/core/server/proxy.d.ts +30 -0
- package/lib/typescript/module/core/server/verify.d.ts +61 -0
- package/lib/typescript/module/core/swichpay.d.ts +40 -0
- package/lib/typescript/module/core/utils/crypto.d.ts +19 -0
- package/lib/typescript/module/core/utils/formatters.d.ts +19 -0
- package/lib/typescript/module/core/utils/json.d.ts +27 -0
- package/lib/typescript/module/core/utils/log.d.ts +15 -0
- package/lib/typescript/module/core/utils/runtime.d.ts +12 -0
- package/lib/typescript/module/core/utils/validators.d.ts +23 -0
- package/lib/typescript/module/hooks.d.ts +21 -0
- package/lib/typescript/module/index.d.ts +26 -0
- package/lib/typescript/module/polyfills.d.ts +2 -0
- package/lib/typescript/module/presenter.d.ts +25 -0
- package/lib/typescript/module/provider.d.ts +22 -0
- package/lib/typescript/module/swichpay.d.ts +125 -0
- package/lib/typescript/module/theme.d.ts +52 -0
- package/lib/typescript/module/ui.d.ts +583 -0
- package/lib/typescript/module/webviews.d.ts +40 -0
- package/package.json +129 -4
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.nativeFlowServices = exports.SwichPayContext = exports.DismissContext = void 0;
|
|
7
|
+
exports.useDismissHandler = useDismissHandler;
|
|
8
|
+
exports.useFlowServices = useFlowServices;
|
|
9
|
+
exports.useSwichPayClient = useSwichPayClient;
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
var _reactNative = require("react-native");
|
|
12
|
+
var _swichpay = require("./core/swichpay.js");
|
|
13
|
+
var _services = require("./core/flows/services.js");
|
|
14
|
+
var _webviews = require("./webviews.js");
|
|
15
|
+
var _hooks = require("./hooks.js");
|
|
16
|
+
/**
|
|
17
|
+
* `FlowServices` for React Native: 3-D Secure device-data collection in a hidden WebView;
|
|
18
|
+
* "copy" / QR save and share open the system share sheet (React Native has no built-in
|
|
19
|
+
* clipboard or file APIs, and the SDK adds no native dependencies for them).
|
|
20
|
+
*/
|
|
21
|
+
const nativeFlowServices = exports.nativeFlowServices = (0, _services.resolveServices)({
|
|
22
|
+
runDeviceDataCollection: _webviews.runDeviceDataCollectionNative,
|
|
23
|
+
copyText: async text => {
|
|
24
|
+
await _reactNative.Share.share({
|
|
25
|
+
message: text
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
downloadQr: async payload => {
|
|
29
|
+
await _reactNative.Share.share({
|
|
30
|
+
message: payload
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
shareQr: async payload => {
|
|
34
|
+
await _reactNative.Share.share({
|
|
35
|
+
message: payload
|
|
36
|
+
});
|
|
37
|
+
return 'shared';
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const SwichPayContext = exports.SwichPayContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
41
|
+
|
|
42
|
+
/** The provider's client, or the one from `SwichPay.initialize()` when used outside a provider. */
|
|
43
|
+
function useSwichPayClient() {
|
|
44
|
+
return (0, _react.useContext)(SwichPayContext)?.client ?? _swichpay.SwichPay.client;
|
|
45
|
+
}
|
|
46
|
+
function useFlowServices(overrides) {
|
|
47
|
+
const base = (0, _react.useContext)(SwichPayContext)?.services ?? nativeFlowServices;
|
|
48
|
+
return overrides ? {
|
|
49
|
+
...base,
|
|
50
|
+
...overrides
|
|
51
|
+
} : base;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** A presented checkout registers what Android's back button / swipe-down should do. */
|
|
55
|
+
const DismissContext = exports.DismissContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
56
|
+
function useDismissHandler(handler) {
|
|
57
|
+
const register = (0, _react.useContext)(DismissContext);
|
|
58
|
+
const ref = (0, _hooks.useLatest)(handler);
|
|
59
|
+
(0, _react.useEffect)(() => {
|
|
60
|
+
if (!register) return;
|
|
61
|
+
register(() => ref.current());
|
|
62
|
+
return () => register(null);
|
|
63
|
+
}, [register, ref]);
|
|
64
|
+
}
|
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DirectPaymentApi = void 0;
|
|
7
|
+
exports.extractVendorMessage = extractVendorMessage;
|
|
8
|
+
exports.isSuccessCode = isSuccessCode;
|
|
9
|
+
exports.parseDirectCardResult = parseDirectCardResult;
|
|
10
|
+
exports.parseDirectCardStatus = parseDirectCardStatus;
|
|
11
|
+
exports.parseDirectPaymentResponse = parseDirectPaymentResponse;
|
|
12
|
+
exports.parseRtpResponse = parseRtpResponse;
|
|
13
|
+
exports.parseTokenizedPaymentResult = parseTokenizedPaymentResult;
|
|
14
|
+
var _endpoints = require("../http/endpoints.js");
|
|
15
|
+
var _payment = require("../models/payment.js");
|
|
16
|
+
var _session = require("../models/session.js");
|
|
17
|
+
var _formatters = require("../utils/formatters.js");
|
|
18
|
+
var _json = require("../utils/json.js");
|
|
19
|
+
/** Strips vendor messages to whatever's between `[` and `]` when present. */
|
|
20
|
+
function extractVendorMessage(message) {
|
|
21
|
+
if (message == null) return null;
|
|
22
|
+
const start = message.indexOf('[');
|
|
23
|
+
const end = message.indexOf(']');
|
|
24
|
+
if (start !== -1 && end !== -1 && end > start) return message.slice(start + 1, end);
|
|
25
|
+
return message;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** `code` in {0000, 0, 00} (string or number) or `status == success`. */
|
|
29
|
+
function isSuccessCode(json) {
|
|
30
|
+
const code = json.code;
|
|
31
|
+
const normalized = typeof code === 'string' ? code.trim() : typeof code === 'number' ? String(Math.trunc(code)) : null;
|
|
32
|
+
const status = (0, _json.str)(json.status)?.toLowerCase();
|
|
33
|
+
return normalized === '0000' || normalized === '0' || normalized === '00' || status === 'success';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Shared shape for e-wallet / bank transfer; OTP required = success code && !isTransactionCompleted. */
|
|
37
|
+
function parseDirectPaymentResponse(json) {
|
|
38
|
+
const success = isSuccessCode(json);
|
|
39
|
+
const otpRequired = success && json.isTransactionCompleted === false;
|
|
40
|
+
return (0, _payment.createPaymentResult)({
|
|
41
|
+
isSuccess: success && !otpRequired,
|
|
42
|
+
status: otpRequired ? 'otp_required' : success ? 'success' : 'failed',
|
|
43
|
+
code: (0, _json.str)(json.code),
|
|
44
|
+
message: extractVendorMessage((0, _json.str)(json.message)),
|
|
45
|
+
timestamp: (0, _json.str)(json.timestamp),
|
|
46
|
+
orderId: (0, _json.str)(json.orderId),
|
|
47
|
+
otpRequired,
|
|
48
|
+
bankTransactionId: (0, _json.str)(json.transactionId),
|
|
49
|
+
transactionReferenceNo: (0, _json.str)(json.transactionReferenceNo),
|
|
50
|
+
retreivalReferenceNo: (0, _json.str)(json.retreivalReferenceNo)
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Shared shape for RTP Now / RTP E-wallet; prefers `success`, falls back to code/status. */
|
|
55
|
+
function parseRtpResponse(json) {
|
|
56
|
+
const success = typeof json.success === 'boolean' ? json.success : isSuccessCode(json);
|
|
57
|
+
return (0, _payment.createPaymentResult)({
|
|
58
|
+
isSuccess: success,
|
|
59
|
+
status: success ? 'success' : 'failed',
|
|
60
|
+
code: (0, _json.str)(json.code),
|
|
61
|
+
message: extractVendorMessage((0, _json.str)(json.message)),
|
|
62
|
+
timestamp: (0, _json.str)(json.timestamp),
|
|
63
|
+
orderId: (0, _json.str)(json.orderId),
|
|
64
|
+
vendorTransactionId: (0, _json.str)(json.transactionId)
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* `PaymentV3`: `nextAction.type == "iframe_collect"` is a DDC step; any other non-`complete`
|
|
70
|
+
* `nextAction` with a `url` is a step-up; `complete` (or no `nextAction` with code 0000) is final.
|
|
71
|
+
*/
|
|
72
|
+
function parseDirectCardResult(json, fallbackVendorTransactionId) {
|
|
73
|
+
const code = (0, _json.normalizedCode)(json.code);
|
|
74
|
+
const message = (0, _json.str)(json.message);
|
|
75
|
+
const nextAction = (0, _json.mapOrNull)(json.nextAction);
|
|
76
|
+
const nextActionType = typeof nextAction?.type === 'string' ? nextAction.type : null;
|
|
77
|
+
const isDdcStep = nextActionType === 'iframe_collect';
|
|
78
|
+
// `complete` is a final verdict, not a step - its `url` is just the merchant redirect.
|
|
79
|
+
const isComplete = nextActionType === 'complete';
|
|
80
|
+
const completeStatus = isComplete ? (0, _json.str)(nextAction?.status)?.toLowerCase() ?? null : null;
|
|
81
|
+
const continuation = (0, _json.mapOrNull)(nextAction?.continuation);
|
|
82
|
+
const proceeds = code === '0000' || nextAction != null && completeStatus !== 'failed';
|
|
83
|
+
if (!proceeds) {
|
|
84
|
+
return (0, _payment.createPaymentResult)({
|
|
85
|
+
isSuccess: false,
|
|
86
|
+
status: 'failed',
|
|
87
|
+
code,
|
|
88
|
+
message: extractVendorMessage(message) ?? 'Payment failed',
|
|
89
|
+
orderId: (0, _json.str)(json.orderId),
|
|
90
|
+
retryable: json.retryable === true
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const url = typeof nextAction?.url === 'string' ? nextAction.url : null;
|
|
94
|
+
const ddcCollectionUrl = isDdcStep ? url : null;
|
|
95
|
+
const stepUpUrl = !isDdcStep && !isComplete ? url : null;
|
|
96
|
+
const hasNextStep = ddcCollectionUrl != null && ddcCollectionUrl !== '' || stepUpUrl != null && stepUpUrl !== '';
|
|
97
|
+
// With nothing left to do only code 0000 is confirmed; anything else is verified by polling.
|
|
98
|
+
const isSuccess = !hasNextStep && code === '0000';
|
|
99
|
+
return (0, _payment.createPaymentResult)({
|
|
100
|
+
isSuccess,
|
|
101
|
+
status: isSuccess ? 'success' : 'pending',
|
|
102
|
+
code,
|
|
103
|
+
message,
|
|
104
|
+
orderId: (0, _json.str)(json.orderId),
|
|
105
|
+
timestamp: (0, _json.str)(json.timestamp),
|
|
106
|
+
vendorTransactionId: (0, _json.str)(continuation?.vendorTransactionId) ?? (0, _json.str)(json.orderId) ?? fallbackVendorTransactionId,
|
|
107
|
+
ddcCollectionUrl,
|
|
108
|
+
stepUpUrl,
|
|
109
|
+
redirectFormFields: (0, _json.stringMap)((0, _json.mapOrNull)(nextAction?.formFields))
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* `CompleteTokenPayment`: the step-up is under `next_action` (snake_case), whose `nextAction` is a
|
|
115
|
+
* string step type and whose `token` is the JWT to POST.
|
|
116
|
+
*/
|
|
117
|
+
function parseTokenizedPaymentResult(json, fallbackVendorTransactionId) {
|
|
118
|
+
const code = (0, _json.normalizedCode)(json.code);
|
|
119
|
+
const message = (0, _json.str)(json.message);
|
|
120
|
+
const nextAction = (0, _json.mapOrNull)(json.next_action);
|
|
121
|
+
const isStepUpStep = nextAction?.nextAction === 'redirect';
|
|
122
|
+
const stepUpUrl = isStepUpStep ? (0, _json.str)(nextAction?.url) : null;
|
|
123
|
+
const stepUpToken = (0, _json.str)(nextAction?.token);
|
|
124
|
+
const hasNextStep = stepUpUrl != null && stepUpUrl !== '';
|
|
125
|
+
const success = code === '0000' || (0, _json.str)(json.status)?.toLowerCase() === 'success';
|
|
126
|
+
if (!hasNextStep && !success) {
|
|
127
|
+
return (0, _payment.createPaymentResult)({
|
|
128
|
+
isSuccess: false,
|
|
129
|
+
status: 'failed',
|
|
130
|
+
code,
|
|
131
|
+
message: extractVendorMessage(message) ?? 'Payment failed',
|
|
132
|
+
orderId: (0, _json.str)(json.orderId),
|
|
133
|
+
retryable: json.retryable === true
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return (0, _payment.createPaymentResult)({
|
|
137
|
+
isSuccess: !hasNextStep,
|
|
138
|
+
status: hasNextStep ? 'pending' : 'success',
|
|
139
|
+
code,
|
|
140
|
+
message,
|
|
141
|
+
orderId: (0, _json.str)(json.orderId),
|
|
142
|
+
timestamp: (0, _json.str)(json.timestamp),
|
|
143
|
+
vendorTransactionId: (0, _json.str)(json.vendorTransactionId) ?? fallbackVendorTransactionId,
|
|
144
|
+
stepUpUrl,
|
|
145
|
+
redirectFormFields: stepUpToken == null ? null : {
|
|
146
|
+
JWT: stepUpToken
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** `InquireV3`: `transactionStatus` is authoritative; `Initiated` means still pending. */
|
|
152
|
+
function parseDirectCardStatus(json, tracker) {
|
|
153
|
+
const status = (0, _json.str)(json.transactionStatus) ?? '';
|
|
154
|
+
const code = (0, _json.normalizedCode)(json.code);
|
|
155
|
+
const lower = status.toLowerCase();
|
|
156
|
+
const normalized = lower === 'initiated' ? 'pending' : lower;
|
|
157
|
+
const isSuccess = normalized === '' ? code === '0000' : normalized === 'success';
|
|
158
|
+
return (0, _payment.createPaymentResult)({
|
|
159
|
+
isSuccess,
|
|
160
|
+
status: normalized === '' ? isSuccess ? 'success' : 'failed' : normalized,
|
|
161
|
+
code,
|
|
162
|
+
message: (0, _json.str)(json.message) ?? status,
|
|
163
|
+
orderId: (0, _json.str)(json.orderId),
|
|
164
|
+
redirectUrl: (0, _json.str)(json.redirectUrl),
|
|
165
|
+
vendorTransactionId: tracker,
|
|
166
|
+
retryable: !isSuccess && json.retryable === true
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
const DIRECT_QR_KEYS = ['qrString', 'qrPayload', 'qrCode', 'qrData', 'qr'];
|
|
170
|
+
/** Direct (session-less) payments on the gateway's `payin` endpoints and the payment-api host. */
|
|
171
|
+
class DirectPaymentApi {
|
|
172
|
+
constructor(client, now = Date.now) {
|
|
173
|
+
this.client = client;
|
|
174
|
+
this.now = now;
|
|
175
|
+
}
|
|
176
|
+
async directEwalletPayment(input) {
|
|
177
|
+
const d = input.details;
|
|
178
|
+
const json = await this.client.postToGateway(_endpoints.Endpoints.directEwallet, {
|
|
179
|
+
customerTransactionId: d.customerTransactionId,
|
|
180
|
+
categoryId: input.categoryId ?? 2,
|
|
181
|
+
channelId: input.channelId,
|
|
182
|
+
item: d.item,
|
|
183
|
+
UCID: '',
|
|
184
|
+
amount: d.amount,
|
|
185
|
+
msisdn: input.msisdn,
|
|
186
|
+
cnic: d.cnic,
|
|
187
|
+
email: d.email
|
|
188
|
+
});
|
|
189
|
+
return parseDirectPaymentResponse(json);
|
|
190
|
+
}
|
|
191
|
+
async directBankTransfer(input) {
|
|
192
|
+
const d = input.details;
|
|
193
|
+
const json = await this.client.postToGateway(_endpoints.Endpoints.directBankOtp, {
|
|
194
|
+
customerTransactionId: d.customerTransactionId,
|
|
195
|
+
bankCode: input.bankCode,
|
|
196
|
+
item: d.item,
|
|
197
|
+
billReferenceNo: d.billReferenceNo,
|
|
198
|
+
description: d.description ?? d.item,
|
|
199
|
+
amount: d.amount,
|
|
200
|
+
accountNo: input.accountNo,
|
|
201
|
+
cnic: d.cnic,
|
|
202
|
+
email: d.email,
|
|
203
|
+
msisdn: d.msisdn,
|
|
204
|
+
consumerName: d.consumerName
|
|
205
|
+
});
|
|
206
|
+
return parseDirectPaymentResponse(json);
|
|
207
|
+
}
|
|
208
|
+
async confirmDirectBankTransfer(input) {
|
|
209
|
+
const asInt = /^[-+]?\d+$/.test(input.transactionId.trim()) ? Number.parseInt(input.transactionId, 10) : null;
|
|
210
|
+
const json = await this.client.postToGateway(_endpoints.Endpoints.directBankConfirm, {
|
|
211
|
+
customerTransactionId: input.customerTransactionId,
|
|
212
|
+
billReferenceNo: input.billReferenceNo ?? '',
|
|
213
|
+
transactionId: asInt != null && Number.isSafeInteger(asInt) ? asInt : input.transactionId,
|
|
214
|
+
orderId: input.orderId,
|
|
215
|
+
transactionReferenceNo: input.transactionReferenceNo,
|
|
216
|
+
retreivalReferenceNo: input.retreivalReferenceNo,
|
|
217
|
+
otp: input.otp
|
|
218
|
+
});
|
|
219
|
+
return parseDirectPaymentResponse(json);
|
|
220
|
+
}
|
|
221
|
+
fetchDirectBankList() {
|
|
222
|
+
return this.fetchBanks(_endpoints.Endpoints.directBankList);
|
|
223
|
+
}
|
|
224
|
+
async generateDirectOneBill(input) {
|
|
225
|
+
const d = input.details;
|
|
226
|
+
const json = await this.client.postToGateway(_endpoints.Endpoints.directBiller, {
|
|
227
|
+
customerTransactionId: d.customerTransactionId,
|
|
228
|
+
categoryId: input.categoryId ?? 3,
|
|
229
|
+
channelId: input.channelId ?? 11,
|
|
230
|
+
ucid: input.ucid ?? '',
|
|
231
|
+
item: d.item,
|
|
232
|
+
amount: d.amount,
|
|
233
|
+
msisdn: d.msisdn,
|
|
234
|
+
email: d.email,
|
|
235
|
+
cnic: d.cnic,
|
|
236
|
+
bankMnemonic: input.bankMnemonic ?? '',
|
|
237
|
+
prefix: input.prefix ?? '',
|
|
238
|
+
reserved: input.reserved ?? ''
|
|
239
|
+
});
|
|
240
|
+
const success = isSuccessCode(json);
|
|
241
|
+
return (0, _payment.createPaymentResult)({
|
|
242
|
+
isSuccess: success,
|
|
243
|
+
status: success ? 'success' : 'failed',
|
|
244
|
+
code: (0, _json.str)(json.code),
|
|
245
|
+
message: (0, _json.str)(json.message),
|
|
246
|
+
timestamp: (0, _json.str)(json.timestamp),
|
|
247
|
+
orderId: (0, _json.str)(json.orderId),
|
|
248
|
+
consumerNumber: (0, _json.str)(json.consumerNumber)
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
async checkDirectOneBillStatus(customerTransactionId) {
|
|
252
|
+
const json = await this.client.get(_endpoints.Endpoints.directBillerInquire, {
|
|
253
|
+
CustomerTransactionId: customerTransactionId
|
|
254
|
+
});
|
|
255
|
+
const transaction = (0, _json.mapOrNull)(json.transaction);
|
|
256
|
+
const status = (0, _json.str)(transaction?.transactionStatus) ?? 'failed';
|
|
257
|
+
const success = status.toLowerCase() === 'success';
|
|
258
|
+
return (0, _payment.createPaymentResult)({
|
|
259
|
+
isSuccess: success,
|
|
260
|
+
status: status.toLowerCase(),
|
|
261
|
+
message: success ? null : `Payment status: ${status}`,
|
|
262
|
+
timestamp: (0, _json.str)(json.timestamp),
|
|
263
|
+
orderId: (0, _json.str)(transaction?.orderId)
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
async generateDirectQrPayment(details) {
|
|
267
|
+
const json = await this.client.postToGateway(_endpoints.Endpoints.directQrGenerate, {
|
|
268
|
+
customerTransactionId: details.customerTransactionId,
|
|
269
|
+
billReferenceNo: details.orderNumber,
|
|
270
|
+
transactionType: '00003',
|
|
271
|
+
name: details.item,
|
|
272
|
+
amount: details.amount,
|
|
273
|
+
msisdn: details.msisdn,
|
|
274
|
+
email: details.email,
|
|
275
|
+
cnic: details.cnic,
|
|
276
|
+
currency: details.currency
|
|
277
|
+
});
|
|
278
|
+
const success = isSuccessCode(json);
|
|
279
|
+
let qrString = null;
|
|
280
|
+
for (const key of DIRECT_QR_KEYS) {
|
|
281
|
+
const value = json[key];
|
|
282
|
+
if (typeof value === 'string' && value !== '') {
|
|
283
|
+
qrString = value;
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return (0, _payment.createPaymentResult)({
|
|
288
|
+
isSuccess: success,
|
|
289
|
+
status: success ? 'success' : 'failed',
|
|
290
|
+
code: (0, _json.str)(json.code),
|
|
291
|
+
message: (0, _json.str)(json.message),
|
|
292
|
+
timestamp: (0, _json.str)(json.timestamp),
|
|
293
|
+
orderId: (0, _json.str)(json.orderId),
|
|
294
|
+
qrString
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
async checkDirectQrStatus(customerTransactionId) {
|
|
298
|
+
const json = await this.client.postToGateway(_endpoints.Endpoints.directQrInquire, {
|
|
299
|
+
customerTransactionId
|
|
300
|
+
});
|
|
301
|
+
const status = (0, _json.str)(json.paymentStatus) ?? 'failed';
|
|
302
|
+
const success = status.toLowerCase() === 'success';
|
|
303
|
+
return (0, _payment.createPaymentResult)({
|
|
304
|
+
isSuccess: success,
|
|
305
|
+
status: status.toLowerCase(),
|
|
306
|
+
message: success ? null : `Payment status: ${status}`,
|
|
307
|
+
timestamp: (0, _json.str)(json.timestamp)
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
fetchDirectRtpNowBanks() {
|
|
311
|
+
return this.fetchBanks(_endpoints.Endpoints.directRtpNowBanks);
|
|
312
|
+
}
|
|
313
|
+
async directRtpNowPayment(input) {
|
|
314
|
+
const d = input.details;
|
|
315
|
+
const body = {
|
|
316
|
+
customerTransactionId: d.customerTransactionId,
|
|
317
|
+
billReferenceNo: d.billReferenceNo
|
|
318
|
+
};
|
|
319
|
+
if (input.bankCode != null) body.bankCode = input.bankCode;
|
|
320
|
+
if (input.accountTitle != null) body.accountTitle = input.accountTitle;
|
|
321
|
+
if (input.accountNumber != null) body.accountNumber = input.accountNumber;
|
|
322
|
+
if (input.accountNumberAlias != null) body.accountNumberAlias = input.accountNumberAlias;
|
|
323
|
+
Object.assign(body, {
|
|
324
|
+
transactionType: input.transactionType ?? '00002',
|
|
325
|
+
// `name` is always sent alongside `accountTitle`, regardless of mode.
|
|
326
|
+
name: d.consumerName,
|
|
327
|
+
amount: d.amount,
|
|
328
|
+
msisdn: input.msisdn,
|
|
329
|
+
rtpId: input.rtpId,
|
|
330
|
+
email: d.email,
|
|
331
|
+
cnic: d.cnic,
|
|
332
|
+
currency: d.currency
|
|
333
|
+
});
|
|
334
|
+
return parseRtpResponse(await this.client.postToGateway(_endpoints.Endpoints.directRtpPurchase, body));
|
|
335
|
+
}
|
|
336
|
+
fetchDirectRtpEwalletBanks() {
|
|
337
|
+
return this.fetchBanks(_endpoints.Endpoints.directRtpEwalletBanks);
|
|
338
|
+
}
|
|
339
|
+
async directRtpEwalletPayment(input) {
|
|
340
|
+
const d = input.details;
|
|
341
|
+
const json = await this.client.postToGateway(_endpoints.Endpoints.directRtpPurchase, {
|
|
342
|
+
orderId: d.orderNumber,
|
|
343
|
+
customerTransactionId: d.customerTransactionId,
|
|
344
|
+
billReferenceNo: d.billReferenceNo,
|
|
345
|
+
amount: (0, _formatters.dartDoubleString)(d.amount),
|
|
346
|
+
currency: d.currency,
|
|
347
|
+
customerName: d.consumerName,
|
|
348
|
+
customerEmail: d.email,
|
|
349
|
+
customerPhone: d.msisdn,
|
|
350
|
+
cnic: d.cnic,
|
|
351
|
+
bankCode: input.bankCode,
|
|
352
|
+
msisdn: input.msisdn ?? '',
|
|
353
|
+
iban: input.iban ?? ''
|
|
354
|
+
});
|
|
355
|
+
return parseRtpResponse(json);
|
|
356
|
+
}
|
|
357
|
+
async directCardPayment(input) {
|
|
358
|
+
const {
|
|
359
|
+
details: d,
|
|
360
|
+
card
|
|
361
|
+
} = input;
|
|
362
|
+
const expYear = card.expYear < 100 ? 2000 + card.expYear : card.expYear;
|
|
363
|
+
const json = await this.client.postToPaymentApi(_endpoints.Endpoints.directCardPayment, {
|
|
364
|
+
customerTransactionId: d.customerTransactionId,
|
|
365
|
+
billReferenceNo: d.billReferenceNo,
|
|
366
|
+
// Always true, matching native's `chargeWithNewCard`.
|
|
367
|
+
doCapture: true,
|
|
368
|
+
doCardOnFile: input.doCardOnFile ?? false,
|
|
369
|
+
orderNumber: String(this.now()),
|
|
370
|
+
consumerName: d.consumerName,
|
|
371
|
+
amount: d.amount,
|
|
372
|
+
description: d.description ?? d.item,
|
|
373
|
+
cardNumber: card.number,
|
|
374
|
+
month: String(card.expMonth).padStart(2, '0'),
|
|
375
|
+
year: String(expYear),
|
|
376
|
+
cvc: card.cvv,
|
|
377
|
+
currency: d.currency,
|
|
378
|
+
email: d.email,
|
|
379
|
+
msisdn: d.msisdn,
|
|
380
|
+
cnic: d.cnic,
|
|
381
|
+
clientId: input.clientId,
|
|
382
|
+
item: d.item,
|
|
383
|
+
isRecurringPayment: false,
|
|
384
|
+
recurringPaymentType: 0,
|
|
385
|
+
recurringFrequency: 0,
|
|
386
|
+
recievedCheckSum: input.checksum,
|
|
387
|
+
merchantId: input.merchantId,
|
|
388
|
+
discountAmount: 0,
|
|
389
|
+
IsDiscountApplicable: true,
|
|
390
|
+
convertedAmount: 0,
|
|
391
|
+
discountableAmount: 0,
|
|
392
|
+
// Boolean - PaymentV3 400s on the string form.
|
|
393
|
+
isApi: true
|
|
394
|
+
});
|
|
395
|
+
return parseDirectCardResult(json, d.customerTransactionId);
|
|
396
|
+
}
|
|
397
|
+
async executeDirectCardTokenizedPayment(input) {
|
|
398
|
+
const json = await this.client.postToPaymentApi(_endpoints.Endpoints.directCardTokenizedPayment, {
|
|
399
|
+
customerTransactionId: input.customerTransactionId,
|
|
400
|
+
billReferenceNo: input.billReferenceNo,
|
|
401
|
+
doCapture: true,
|
|
402
|
+
// The "save card" choice was already sent on PaymentV3.
|
|
403
|
+
doCardOnFile: false,
|
|
404
|
+
vendorTransactionId: input.vendorTransactionId,
|
|
405
|
+
sessionId: input.sessionId,
|
|
406
|
+
failedRedirectUrl: '',
|
|
407
|
+
sucessRedirectUrl: ''
|
|
408
|
+
});
|
|
409
|
+
return parseTokenizedPaymentResult(json, input.vendorTransactionId);
|
|
410
|
+
}
|
|
411
|
+
async checkDirectCardPaymentStatus(tracker) {
|
|
412
|
+
const json = await this.client.postToPaymentApi(_endpoints.Endpoints.directCardInquire, {
|
|
413
|
+
tracker,
|
|
414
|
+
paymentMethod: 'card',
|
|
415
|
+
// Matches native - always true, even mid-poll.
|
|
416
|
+
forceTimeout: true
|
|
417
|
+
});
|
|
418
|
+
return parseDirectCardStatus(json, tracker);
|
|
419
|
+
}
|
|
420
|
+
async fetchBanks(path) {
|
|
421
|
+
const json = await this.client.get(path);
|
|
422
|
+
return (0, _json.listOfMaps)(json.data).map(_session.parseDirectBank);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
exports.DirectPaymentApi = DirectPaymentApi;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DiscountApi = void 0;
|
|
7
|
+
var _endpoints = require("../http/endpoints.js");
|
|
8
|
+
var _discount = require("../models/discount.js");
|
|
9
|
+
/** Calls to the standalone Discount API host. */
|
|
10
|
+
class DiscountApi {
|
|
11
|
+
constructor(client) {
|
|
12
|
+
this.client = client;
|
|
13
|
+
}
|
|
14
|
+
async getDiscount(request) {
|
|
15
|
+
const json = await this.client.postToDiscount(_endpoints.Endpoints.getDiscount, (0, _discount.discountRequestToJson)(request));
|
|
16
|
+
return (0, _discount.parseDiscountResult)(json);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.DiscountApi = DiscountApi;
|