@phonepe-pg/pg-sdk-node 2.0.4
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/LICENSE +202 -0
- package/README.md +221 -0
- package/dist/src/Env.d.ts +4 -0
- package/dist/src/Env.js +23 -0
- package/dist/src/EnvConfig.d.ts +11 -0
- package/dist/src/EnvConfig.js +42 -0
- package/dist/src/common/BaseClient.d.ts +33 -0
- package/dist/src/common/BaseClient.js +103 -0
- package/dist/src/common/CommonUtils.d.ts +9 -0
- package/dist/src/common/CommonUtils.js +45 -0
- package/dist/src/common/configs/CredentialConfig.d.ts +25 -0
- package/dist/src/common/configs/CredentialConfig.js +64 -0
- package/dist/src/common/configs/index.d.ts +1 -0
- package/dist/src/common/configs/index.js +32 -0
- package/dist/src/common/constants/BaseUrl.d.ts +12 -0
- package/dist/src/common/constants/BaseUrl.js +30 -0
- package/dist/src/common/constants/Headers.d.ts +16 -0
- package/dist/src/common/constants/Headers.js +36 -0
- package/dist/src/common/events/Constants.d.ts +10 -0
- package/dist/src/common/events/Constants.js +29 -0
- package/dist/src/common/events/EventQueueHandler.d.ts +11 -0
- package/dist/src/common/events/EventQueueHandler.js +57 -0
- package/dist/src/common/events/builders/BaseEventBuilder.d.ts +17 -0
- package/dist/src/common/events/builders/BaseEventBuilder.js +46 -0
- package/dist/src/common/events/builders/EventBuillder.d.ts +16 -0
- package/dist/src/common/events/builders/EventBuillder.js +195 -0
- package/dist/src/common/events/builders/EventDataBuilder.d.ts +55 -0
- package/dist/src/common/events/builders/EventDataBuilder.js +115 -0
- package/dist/src/common/events/models/BaseEvent.d.ts +11 -0
- package/dist/src/common/events/models/BaseEvent.js +31 -0
- package/dist/src/common/events/models/BulkEvent.d.ts +18 -0
- package/dist/src/common/events/models/BulkEvent.js +56 -0
- package/dist/src/common/events/models/EventData.d.ts +32 -0
- package/dist/src/common/events/models/EventData.js +53 -0
- package/dist/src/common/events/models/enums/EventState.d.ts +5 -0
- package/dist/src/common/events/models/enums/EventState.js +24 -0
- package/dist/src/common/events/models/enums/EventType.d.ts +19 -0
- package/dist/src/common/events/models/enums/EventType.js +38 -0
- package/dist/src/common/events/models/enums/FlowType.d.ts +3 -0
- package/dist/src/common/events/models/enums/FlowType.js +22 -0
- package/dist/src/common/events/publisher/DefaultEventPublisher.d.ts +7 -0
- package/dist/src/common/events/publisher/DefaultEventPublisher.js +31 -0
- package/dist/src/common/events/publisher/EventPublisher.d.ts +6 -0
- package/dist/src/common/events/publisher/EventPublisher.js +21 -0
- package/dist/src/common/events/publisher/EventPublisherFactory.d.ts +9 -0
- package/dist/src/common/events/publisher/EventPublisherFactory.js +38 -0
- package/dist/src/common/events/publisher/QueuedEventPublisher.d.ts +21 -0
- package/dist/src/common/events/publisher/QueuedEventPublisher.js +124 -0
- package/dist/src/common/exception/Constants.d.ts +3 -0
- package/dist/src/common/exception/Constants.js +24 -0
- package/dist/src/common/exception/Exceptions.d.ts +45 -0
- package/dist/src/common/exception/Exceptions.js +102 -0
- package/dist/src/common/exception/index.d.ts +1 -0
- package/dist/src/common/exception/index.js +32 -0
- package/dist/src/common/http/HttpCommand.d.ts +15 -0
- package/dist/src/common/http/HttpCommand.js +93 -0
- package/dist/src/common/http/HttpMethodType.d.ts +4 -0
- package/dist/src/common/http/HttpMethodType.js +23 -0
- package/dist/src/common/http/PhonePeResponse.d.ts +12 -0
- package/dist/src/common/http/PhonePeResponse.js +21 -0
- package/dist/src/common/http/index.d.ts +2 -0
- package/dist/src/common/http/index.js +33 -0
- package/dist/src/common/index.d.ts +5 -0
- package/dist/src/common/index.js +36 -0
- package/dist/src/common/models/MetaInfo.d.ts +26 -0
- package/dist/src/common/models/MetaInfo.js +61 -0
- package/dist/src/common/models/PaymentFlow.d.ts +5 -0
- package/dist/src/common/models/PaymentFlow.js +24 -0
- package/dist/src/common/models/PaymentFlowType.d.ts +4 -0
- package/dist/src/common/models/PaymentFlowType.js +23 -0
- package/dist/src/common/models/PgV2InstrumentType.d.ts +9 -0
- package/dist/src/common/models/PgV2InstrumentType.js +28 -0
- package/dist/src/common/models/index.d.ts +6 -0
- package/dist/src/common/models/index.js +37 -0
- package/dist/src/common/models/request/AccountConstraint.d.ts +18 -0
- package/dist/src/common/models/request/AccountConstraint.js +49 -0
- package/dist/src/common/models/request/DeviceContext.d.ts +17 -0
- package/dist/src/common/models/request/DeviceContext.js +46 -0
- package/dist/src/common/models/request/InstrumentConstraint.d.ts +5 -0
- package/dist/src/common/models/request/InstrumentConstraint.js +24 -0
- package/dist/src/common/models/request/PaymentInstrumentType.d.ts +3 -0
- package/dist/src/common/models/request/PaymentInstrumentType.js +22 -0
- package/dist/src/common/models/request/RefundRequest.d.ts +20 -0
- package/dist/src/common/models/request/RefundRequest.js +51 -0
- package/dist/src/common/models/request/index.d.ts +5 -0
- package/dist/src/common/models/request/index.js +36 -0
- package/dist/src/common/models/request/instruments/BillingAddress.d.ts +29 -0
- package/dist/src/common/models/request/instruments/BillingAddress.js +60 -0
- package/dist/src/common/models/request/instruments/CardPayRequestBuilder.d.ts +39 -0
- package/dist/src/common/models/request/instruments/CardPayRequestBuilder.js +113 -0
- package/dist/src/common/models/request/instruments/CardPaymentV2Instrument.d.ts +22 -0
- package/dist/src/common/models/request/instruments/CardPaymentV2Instrument.js +56 -0
- package/dist/src/common/models/request/instruments/CollectPaymentDetails.d.ts +5 -0
- package/dist/src/common/models/request/instruments/CollectPaymentDetails.js +24 -0
- package/dist/src/common/models/request/instruments/CollectPaymentDetailsType.d.ts +4 -0
- package/dist/src/common/models/request/instruments/CollectPaymentDetailsType.js +23 -0
- package/dist/src/common/models/request/instruments/CollectPaymentV2Instrument.d.ts +19 -0
- package/dist/src/common/models/request/instruments/CollectPaymentV2Instrument.js +49 -0
- package/dist/src/common/models/request/instruments/Expiry.d.ts +14 -0
- package/dist/src/common/models/request/instruments/Expiry.js +43 -0
- package/dist/src/common/models/request/instruments/IntentPaymentV2Instrument.d.ts +12 -0
- package/dist/src/common/models/request/instruments/IntentPaymentV2Instrument.js +41 -0
- package/dist/src/common/models/request/instruments/NetBankingPayRequestBuilder.d.ts +25 -0
- package/dist/src/common/models/request/instruments/NetBankingPayRequestBuilder.js +71 -0
- package/dist/src/common/models/request/instruments/NetBankingPaymentV2Instrument.d.ts +15 -0
- package/dist/src/common/models/request/instruments/NetBankingPaymentV2Instrument.js +46 -0
- package/dist/src/common/models/request/instruments/NewCardDetails.d.ts +29 -0
- package/dist/src/common/models/request/instruments/NewCardDetails.js +61 -0
- package/dist/src/common/models/request/instruments/PaymentV2Instrument.d.ts +7 -0
- package/dist/src/common/models/request/instruments/PaymentV2Instrument.js +24 -0
- package/dist/src/common/models/request/instruments/PhoneNumberCollectPaymentDetails.d.ts +12 -0
- package/dist/src/common/models/request/instruments/PhoneNumberCollectPaymentDetails.js +41 -0
- package/dist/src/common/models/request/instruments/TokenDetails.d.ts +39 -0
- package/dist/src/common/models/request/instruments/TokenDetails.js +81 -0
- package/dist/src/common/models/request/instruments/TokenPayRequestBuilder.d.ts +41 -0
- package/dist/src/common/models/request/instruments/TokenPayRequestBuilder.js +118 -0
- package/dist/src/common/models/request/instruments/TokenPaymentV2Instrument.d.ts +19 -0
- package/dist/src/common/models/request/instruments/TokenPaymentV2Instrument.js +51 -0
- package/dist/src/common/models/request/instruments/UpiCollectPayViaPhoneNumberRequestBuilder.d.ts +25 -0
- package/dist/src/common/models/request/instruments/UpiCollectPayViaPhoneNumberRequestBuilder.js +73 -0
- package/dist/src/common/models/request/instruments/UpiCollectPayViaVpaRequestBuilder.d.ts +25 -0
- package/dist/src/common/models/request/instruments/UpiCollectPayViaVpaRequestBuilder.js +71 -0
- package/dist/src/common/models/request/instruments/UpiIntentPayRequestBuilder.d.ts +25 -0
- package/dist/src/common/models/request/instruments/UpiIntentPayRequestBuilder.js +71 -0
- package/dist/src/common/models/request/instruments/UpiQrPaymentV2Instrument.d.ts +9 -0
- package/dist/src/common/models/request/instruments/UpiQrPaymentV2Instrument.js +36 -0
- package/dist/src/common/models/request/instruments/UpiQrRequestBuilder.d.ts +19 -0
- package/dist/src/common/models/request/instruments/UpiQrRequestBuilder.js +55 -0
- package/dist/src/common/models/request/instruments/VpaCollectPaymentDetails.d.ts +12 -0
- package/dist/src/common/models/request/instruments/VpaCollectPaymentDetails.js +41 -0
- package/dist/src/common/models/request/instruments/index.d.ts +21 -0
- package/dist/src/common/models/request/instruments/index.js +52 -0
- package/dist/src/common/models/response/CallbackData.d.ts +17 -0
- package/dist/src/common/models/response/CallbackData.js +21 -0
- package/dist/src/common/models/response/CallbackResponse.d.ts +6 -0
- package/dist/src/common/models/response/CallbackResponse.js +21 -0
- package/dist/src/common/models/response/CallbackType.d.ts +11 -0
- package/dist/src/common/models/response/CallbackType.js +30 -0
- package/dist/src/common/models/response/InstrumentCombo.d.ts +15 -0
- package/dist/src/common/models/response/InstrumentCombo.js +21 -0
- package/dist/src/common/models/response/OrderStatusResponse.d.ts +16 -0
- package/dist/src/common/models/response/OrderStatusResponse.js +21 -0
- package/dist/src/common/models/response/PaymentDetail.d.ts +24 -0
- package/dist/src/common/models/response/PaymentDetail.js +21 -0
- package/dist/src/common/models/response/PaymentRefundDetail.d.ts +24 -0
- package/dist/src/common/models/response/PaymentRefundDetail.js +21 -0
- package/dist/src/common/models/response/RefundResponse.d.ts +5 -0
- package/dist/src/common/models/response/RefundResponse.js +21 -0
- package/dist/src/common/models/response/RefundStatusResponse.d.ts +9 -0
- package/dist/src/common/models/response/RefundStatusResponse.js +21 -0
- package/dist/src/common/models/response/index.d.ts +11 -0
- package/dist/src/common/models/response/index.js +42 -0
- package/dist/src/common/models/response/paymentinstruments/AccountInstrumentV2.d.ts +10 -0
- package/dist/src/common/models/response/paymentinstruments/AccountInstrumentV2.js +22 -0
- package/dist/src/common/models/response/paymentinstruments/CreditCardPaymentInstrumentV2.d.ts +7 -0
- package/dist/src/common/models/response/paymentinstruments/CreditCardPaymentInstrumentV2.js +22 -0
- package/dist/src/common/models/response/paymentinstruments/DebitCardPaymentInstrumentV2.d.ts +7 -0
- package/dist/src/common/models/response/paymentinstruments/DebitCardPaymentInstrumentV2.js +22 -0
- package/dist/src/common/models/response/paymentinstruments/EgvPaymentInstrumentV2.d.ts +5 -0
- package/dist/src/common/models/response/paymentinstruments/EgvPaymentInstrumentV2.js +22 -0
- package/dist/src/common/models/response/paymentinstruments/NetbankingPaymentInstrumentV2.d.ts +7 -0
- package/dist/src/common/models/response/paymentinstruments/NetbankingPaymentInstrumentV2.js +22 -0
- package/dist/src/common/models/response/paymentinstruments/PaymentInstrumentType.d.ts +8 -0
- package/dist/src/common/models/response/paymentinstruments/PaymentInstrumentType.js +27 -0
- package/dist/src/common/models/response/paymentinstruments/PaymentInstrumentV2.d.ts +4 -0
- package/dist/src/common/models/response/paymentinstruments/PaymentInstrumentV2.js +21 -0
- package/dist/src/common/models/response/paymentinstruments/WalletPaymentInstrumentV2.d.ts +4 -0
- package/dist/src/common/models/response/paymentinstruments/WalletPaymentInstrumentV2.js +22 -0
- package/dist/src/common/models/response/paymentinstruments/index.d.ts +8 -0
- package/dist/src/common/models/response/paymentinstruments/index.js +39 -0
- package/dist/src/common/models/response/rails/PaymentRail.d.ts +9 -0
- package/dist/src/common/models/response/rails/PaymentRail.js +28 -0
- package/dist/src/common/models/response/rails/PgPaymentRail.d.ts +6 -0
- package/dist/src/common/models/response/rails/PgPaymentRail.js +22 -0
- package/dist/src/common/models/response/rails/PpiEgvPaymentRail.d.ts +3 -0
- package/dist/src/common/models/response/rails/PpiEgvPaymentRail.js +22 -0
- package/dist/src/common/models/response/rails/PpiWalletPaymentRail.d.ts +3 -0
- package/dist/src/common/models/response/rails/PpiWalletPaymentRail.js +22 -0
- package/dist/src/common/models/response/rails/UpiPaymentRail.d.ts +6 -0
- package/dist/src/common/models/response/rails/UpiPaymentRail.js +22 -0
- package/dist/src/common/models/response/rails/index.d.ts +5 -0
- package/dist/src/common/models/response/rails/index.js +36 -0
- package/dist/src/common/tokenhandler/OAuthRequest.d.ts +6 -0
- package/dist/src/common/tokenhandler/OAuthRequest.js +17 -0
- package/dist/src/common/tokenhandler/OAuthResponse.d.ts +10 -0
- package/dist/src/common/tokenhandler/OAuthResponse.js +52 -0
- package/dist/src/common/tokenhandler/TokenConstants.d.ts +4 -0
- package/dist/src/common/tokenhandler/TokenConstants.js +23 -0
- package/dist/src/common/tokenhandler/TokenService.d.ts +22 -0
- package/dist/src/common/tokenhandler/TokenService.js +115 -0
- package/dist/src/common/tokenhandler/index.d.ts +2 -0
- package/dist/src/common/tokenhandler/index.js +33 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +35 -0
- package/dist/src/payments/v2/CustomCheckoutClient.d.ts +86 -0
- package/dist/src/payments/v2/CustomCheckoutClient.js +229 -0
- package/dist/src/payments/v2/StandardCheckoutClient.d.ts +86 -0
- package/dist/src/payments/v2/StandardCheckoutClient.js +227 -0
- package/dist/src/payments/v2/customcheckout/Constants.d.ts +9 -0
- package/dist/src/payments/v2/customcheckout/Constants.js +28 -0
- package/dist/src/payments/v2/index.d.ts +3 -0
- package/dist/src/payments/v2/index.js +34 -0
- package/dist/src/payments/v2/models/index.d.ts +2 -0
- package/dist/src/payments/v2/models/index.js +33 -0
- package/dist/src/payments/v2/models/request/CreateSdkOrderRequest.d.ts +63 -0
- package/dist/src/payments/v2/models/request/CreateSdkOrderRequest.js +130 -0
- package/dist/src/payments/v2/models/request/CustomCheckoutPayRequest.d.ts +37 -0
- package/dist/src/payments/v2/models/request/CustomCheckoutPayRequest.js +79 -0
- package/dist/src/payments/v2/models/request/MerchantUrls.d.ts +4 -0
- package/dist/src/payments/v2/models/request/MerchantUrls.js +24 -0
- package/dist/src/payments/v2/models/request/PgCheckoutPaymentFlow.d.ts +18 -0
- package/dist/src/payments/v2/models/request/PgCheckoutPaymentFlow.js +48 -0
- package/dist/src/payments/v2/models/request/PgPaymentFlow.d.ts +20 -0
- package/dist/src/payments/v2/models/request/PgPaymentFlow.js +50 -0
- package/dist/src/payments/v2/models/request/PrefillUserLoginDetails.d.ts +16 -0
- package/dist/src/payments/v2/models/request/PrefillUserLoginDetails.js +38 -0
- package/dist/src/payments/v2/models/request/StandardCheckoutPayRequest.d.ts +40 -0
- package/dist/src/payments/v2/models/request/StandardCheckoutPayRequest.js +82 -0
- package/dist/src/payments/v2/models/request/index.d.ts +7 -0
- package/dist/src/payments/v2/models/request/index.js +38 -0
- package/dist/src/payments/v2/models/response/CreateSdkOrderResponse.d.ts +6 -0
- package/dist/src/payments/v2/models/response/CreateSdkOrderResponse.js +21 -0
- package/dist/src/payments/v2/models/response/CustomCheckoutPayResponse.d.ts +8 -0
- package/dist/src/payments/v2/models/response/CustomCheckoutPayResponse.js +21 -0
- package/dist/src/payments/v2/models/response/StandardCheckoutPayResponse.d.ts +6 -0
- package/dist/src/payments/v2/models/response/StandardCheckoutPayResponse.js +21 -0
- package/dist/src/payments/v2/models/response/index.d.ts +3 -0
- package/dist/src/payments/v2/models/response/index.js +34 -0
- package/dist/src/payments/v2/standardcheckout/Constants.d.ts +9 -0
- package/dist/src/payments/v2/standardcheckout/Constants.js +28 -0
- package/package.json +58 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Original Author(s), PhonePe India Pvt. Ltd.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.CommonUtils = void 0;
|
|
19
|
+
const crypto_1 = require("crypto");
|
|
20
|
+
var SHA_ALGORITHM;
|
|
21
|
+
(function (SHA_ALGORITHM) {
|
|
22
|
+
SHA_ALGORITHM["SHA256"] = "SHA256";
|
|
23
|
+
})(SHA_ALGORITHM || (SHA_ALGORITHM = {}));
|
|
24
|
+
class CommonUtils {
|
|
25
|
+
static calculateSha256(args) {
|
|
26
|
+
const data = Object.values(args).join(':');
|
|
27
|
+
return CommonUtils.shaHex(data, SHA_ALGORITHM.SHA256);
|
|
28
|
+
}
|
|
29
|
+
static shaHex(data, algorithm) {
|
|
30
|
+
switch (algorithm) {
|
|
31
|
+
case SHA_ALGORITHM.SHA256: {
|
|
32
|
+
const hash = (0, crypto_1.createHash)('sha256');
|
|
33
|
+
hash.update(data);
|
|
34
|
+
return hash.digest('hex');
|
|
35
|
+
}
|
|
36
|
+
default:
|
|
37
|
+
return data;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
static isCallbackValid(username, password, authorization) {
|
|
41
|
+
const sha256 = this.calculateSha256({ username, password });
|
|
42
|
+
return sha256 == authorization;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.CommonUtils = CommonUtils;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare class CredentialConfig {
|
|
2
|
+
private _clientId;
|
|
3
|
+
private _clientSecret;
|
|
4
|
+
private _clientVersion;
|
|
5
|
+
constructor(clientId: string, clientSecret: string, clientVersion: number);
|
|
6
|
+
static builder(): CredentialConfigBuilder;
|
|
7
|
+
/**
|
|
8
|
+
* Getter Functions
|
|
9
|
+
*/
|
|
10
|
+
get clientId(): string;
|
|
11
|
+
get clientSecret(): string;
|
|
12
|
+
get clientVersion(): number;
|
|
13
|
+
}
|
|
14
|
+
export declare class CredentialConfigBuilder {
|
|
15
|
+
private _clientId;
|
|
16
|
+
private _clientSecret;
|
|
17
|
+
private _clientVersion;
|
|
18
|
+
/**
|
|
19
|
+
* Setters used for MerchantConfig builder
|
|
20
|
+
*/
|
|
21
|
+
clientId: (clientId: string) => CredentialConfigBuilder;
|
|
22
|
+
clientSecret: (clientSecret: string) => CredentialConfigBuilder;
|
|
23
|
+
clientVersion: (clientVersion: number) => CredentialConfigBuilder;
|
|
24
|
+
build: () => CredentialConfig;
|
|
25
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Original Author(s), PhonePe India Pvt. Ltd.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.CredentialConfigBuilder = exports.CredentialConfig = void 0;
|
|
19
|
+
class CredentialConfig {
|
|
20
|
+
constructor(clientId, clientSecret, clientVersion) {
|
|
21
|
+
this._clientId = clientId;
|
|
22
|
+
this._clientSecret = clientSecret;
|
|
23
|
+
this._clientVersion = clientVersion;
|
|
24
|
+
}
|
|
25
|
+
static builder() {
|
|
26
|
+
return new CredentialConfigBuilder();
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Getter Functions
|
|
30
|
+
*/
|
|
31
|
+
get clientId() {
|
|
32
|
+
return this._clientId;
|
|
33
|
+
}
|
|
34
|
+
get clientSecret() {
|
|
35
|
+
return this._clientSecret;
|
|
36
|
+
}
|
|
37
|
+
get clientVersion() {
|
|
38
|
+
return this._clientVersion;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.CredentialConfig = CredentialConfig;
|
|
42
|
+
class CredentialConfigBuilder {
|
|
43
|
+
constructor() {
|
|
44
|
+
/**
|
|
45
|
+
* Setters used for MerchantConfig builder
|
|
46
|
+
*/
|
|
47
|
+
this.clientId = (clientId) => {
|
|
48
|
+
this._clientId = clientId;
|
|
49
|
+
return this;
|
|
50
|
+
};
|
|
51
|
+
this.clientSecret = (clientSecret) => {
|
|
52
|
+
this._clientSecret = clientSecret;
|
|
53
|
+
return this;
|
|
54
|
+
};
|
|
55
|
+
this.clientVersion = (clientVersion) => {
|
|
56
|
+
this._clientVersion = clientVersion;
|
|
57
|
+
return this;
|
|
58
|
+
};
|
|
59
|
+
this.build = () => {
|
|
60
|
+
return new CredentialConfig(this._clientId, this._clientSecret, this._clientVersion);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.CredentialConfigBuilder = CredentialConfigBuilder;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CredentialConfig';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Original Author(s), PhonePe India Pvt. Ltd.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
29
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
__exportStar(require("./CredentialConfig"), exports);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Original Author(s), PhonePe India Pvt. Ltd.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.BaseUrl = void 0;
|
|
19
|
+
exports.BaseUrl = {
|
|
20
|
+
PRODUCTION: {
|
|
21
|
+
PG_HOST_URL: 'https://api.phonepe.com/apis/pg',
|
|
22
|
+
OAUTH_HOST_URL: 'https://api.phonepe.com/apis/identity-manager',
|
|
23
|
+
EVENTS_HOST_URL: 'https://api.phonepe.com/apis/pg-ingestion',
|
|
24
|
+
},
|
|
25
|
+
SANDBOX: {
|
|
26
|
+
PG_HOST_URL: 'https://api-preprod.phonepe.com/apis/pg-sandbox',
|
|
27
|
+
OAUTH_HOST_URL: 'https://api-preprod.phonepe.com/apis/pg-sandbox',
|
|
28
|
+
EVENTS_HOST_URL: 'http://localhost',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class Headers {
|
|
2
|
+
static readonly INTEGRATION: string;
|
|
3
|
+
static readonly API_VERSION: string;
|
|
4
|
+
static readonly SDK_VERSION: string;
|
|
5
|
+
static readonly SDK_TYPE: string;
|
|
6
|
+
static readonly SOURCE: string;
|
|
7
|
+
static readonly SOURCE_VERSION: string;
|
|
8
|
+
static readonly SOURCE_PLATFORM: string;
|
|
9
|
+
static readonly SOURCE_PLATFORM_VERSION: string;
|
|
10
|
+
static readonly OAUTH_AUTHORIZATION: string;
|
|
11
|
+
static readonly CONTENT_TYPE: string;
|
|
12
|
+
static readonly ACCEPT: string;
|
|
13
|
+
static readonly APPLICATION_JSON = "application/json";
|
|
14
|
+
static readonly APPLICATION_FORM_URLENCODED = "application/x-www-form-urlencoded";
|
|
15
|
+
static readonly X_DEVICE_OS: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Original Author(s), PhonePe India Pvt. Ltd.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.Headers = void 0;
|
|
19
|
+
const package_json_1 = require("../../../package.json");
|
|
20
|
+
class Headers {
|
|
21
|
+
}
|
|
22
|
+
exports.Headers = Headers;
|
|
23
|
+
Headers.INTEGRATION = 'API';
|
|
24
|
+
Headers.API_VERSION = 'V2';
|
|
25
|
+
Headers.SDK_VERSION = package_json_1.version;
|
|
26
|
+
Headers.SDK_TYPE = 'BACKEND_NODE_SDK';
|
|
27
|
+
Headers.SOURCE = 'x-source';
|
|
28
|
+
Headers.SOURCE_VERSION = 'x-source-version';
|
|
29
|
+
Headers.SOURCE_PLATFORM = 'x-source-platform';
|
|
30
|
+
Headers.SOURCE_PLATFORM_VERSION = 'x-source-platform-version';
|
|
31
|
+
Headers.OAUTH_AUTHORIZATION = 'Authorization';
|
|
32
|
+
Headers.CONTENT_TYPE = 'Content-Type';
|
|
33
|
+
Headers.ACCEPT = 'Accept';
|
|
34
|
+
Headers.APPLICATION_JSON = 'application/json';
|
|
35
|
+
Headers.APPLICATION_FORM_URLENCODED = 'application/x-www-form-urlencoded';
|
|
36
|
+
Headers.X_DEVICE_OS = 'x-device-os';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class Constants {
|
|
2
|
+
static readonly MAX_EVENTS_IN_BATCH = 10;
|
|
3
|
+
static readonly SOURCE = "BACKEND_SDK";
|
|
4
|
+
static readonly CLIENT_VERSION = "V2";
|
|
5
|
+
static readonly AUTHORIZATION = "Authorization";
|
|
6
|
+
static readonly EVENTS_ENDPOINT = "/client/v1/backend/events/batch";
|
|
7
|
+
static readonly QUEUE_MAX_SIZE = 20000;
|
|
8
|
+
static readonly INITIAL_DELAY = 1000;
|
|
9
|
+
static readonly DELAY = 1000;
|
|
10
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Original Author(s), PhonePe India Pvt. Ltd.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.Constants = void 0;
|
|
19
|
+
class Constants {
|
|
20
|
+
}
|
|
21
|
+
exports.Constants = Constants;
|
|
22
|
+
Constants.MAX_EVENTS_IN_BATCH = 10;
|
|
23
|
+
Constants.SOURCE = 'BACKEND_SDK';
|
|
24
|
+
Constants.CLIENT_VERSION = 'V2';
|
|
25
|
+
Constants.AUTHORIZATION = 'Authorization';
|
|
26
|
+
Constants.EVENTS_ENDPOINT = '/client/v1/backend/events/batch';
|
|
27
|
+
Constants.QUEUE_MAX_SIZE = 20000; // Should be greater than MAX_EVENTS_IN_BATCH
|
|
28
|
+
Constants.INITIAL_DELAY = 1000; //in ms
|
|
29
|
+
Constants.DELAY = 1000; //in ms
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseEvent } from './models/BaseEvent';
|
|
2
|
+
export declare class EventQueueHandler {
|
|
3
|
+
queue: BaseEvent[];
|
|
4
|
+
maxSize: number;
|
|
5
|
+
private mutex;
|
|
6
|
+
constructor(maxSize: number);
|
|
7
|
+
add: (event: BaseEvent) => Promise<void>;
|
|
8
|
+
isEmpty: () => boolean;
|
|
9
|
+
size: () => number;
|
|
10
|
+
poll: () => Promise<BaseEvent | undefined>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Original Author(s), PhonePe India Pvt. Ltd.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.EventQueueHandler = void 0;
|
|
28
|
+
const async_mutex_1 = require("async-mutex");
|
|
29
|
+
class EventQueueHandler {
|
|
30
|
+
constructor(maxSize) {
|
|
31
|
+
this.mutex = new async_mutex_1.Mutex();
|
|
32
|
+
this.add = (event) => __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
yield this.mutex.runExclusive(() => {
|
|
34
|
+
if (this.queue.length < this.maxSize && event != null) {
|
|
35
|
+
this.queue.push(event);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
console.warn('Reached queue max size, skipping event {}', event.eventName);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
this.isEmpty = () => {
|
|
43
|
+
return this.queue.length == 0;
|
|
44
|
+
};
|
|
45
|
+
this.size = () => {
|
|
46
|
+
return this.queue.length;
|
|
47
|
+
};
|
|
48
|
+
this.poll = () => __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
return yield this.mutex.runExclusive(() => {
|
|
50
|
+
return this.queue.shift();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
this.maxSize = maxSize;
|
|
54
|
+
this.queue = [];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.EventQueueHandler = EventQueueHandler;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseEvent } from '../models/BaseEvent';
|
|
2
|
+
import { EventType } from '../models/enums/EventType';
|
|
3
|
+
import { EventData } from '../models/EventData';
|
|
4
|
+
export declare class BaseEventBuilder {
|
|
5
|
+
private _merchantOrderId;
|
|
6
|
+
private _eventName;
|
|
7
|
+
private _eventTime;
|
|
8
|
+
private _data;
|
|
9
|
+
/**
|
|
10
|
+
* SETTERS
|
|
11
|
+
**/
|
|
12
|
+
setMerchantOrderId: (merchantOrderId: string) => this;
|
|
13
|
+
setEventName: (eventName: EventType) => this;
|
|
14
|
+
setEventTime: (eventTime: number) => this;
|
|
15
|
+
setData: (data: EventData) => this;
|
|
16
|
+
build: () => BaseEvent;
|
|
17
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Original Author(s), PhonePe India Pvt. Ltd.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.BaseEventBuilder = void 0;
|
|
19
|
+
const BaseEvent_1 = require("../models/BaseEvent");
|
|
20
|
+
class BaseEventBuilder {
|
|
21
|
+
constructor() {
|
|
22
|
+
/**
|
|
23
|
+
* SETTERS
|
|
24
|
+
**/
|
|
25
|
+
this.setMerchantOrderId = (merchantOrderId) => {
|
|
26
|
+
this._merchantOrderId = merchantOrderId;
|
|
27
|
+
return this;
|
|
28
|
+
};
|
|
29
|
+
this.setEventName = (eventName) => {
|
|
30
|
+
this._eventName = eventName;
|
|
31
|
+
return this;
|
|
32
|
+
};
|
|
33
|
+
this.setEventTime = (eventTime) => {
|
|
34
|
+
this._eventTime = eventTime;
|
|
35
|
+
return this;
|
|
36
|
+
};
|
|
37
|
+
this.setData = (data) => {
|
|
38
|
+
this._data = data;
|
|
39
|
+
return this;
|
|
40
|
+
};
|
|
41
|
+
this.build = () => {
|
|
42
|
+
return new BaseEvent_1.BaseEvent(this._merchantOrderId, this._eventName, this._eventTime, this._data);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.BaseEventBuilder = BaseEventBuilder;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CreateSdkOrderRequest, CustomCheckoutPayRequest, StandardCheckoutPayRequest } from '../../../payments/v2';
|
|
2
|
+
import { PaymentFlowType, RefundRequest } from '../../models';
|
|
3
|
+
import { BaseEvent } from '../models/BaseEvent';
|
|
4
|
+
import { EventState } from '../models/enums/EventState';
|
|
5
|
+
import { EventType } from '../models/enums/EventType';
|
|
6
|
+
export declare const buildInitClientEvent: (eventName: EventType, paymentFlow?: PaymentFlowType) => BaseEvent;
|
|
7
|
+
export declare const buildStandardCheckoutPayEvent: (eventState: EventState, eventName: EventType, standardCheckoutPayRequest: StandardCheckoutPayRequest, apiPath: string, exception?: unknown) => BaseEvent;
|
|
8
|
+
export declare const buildCustomCheckoutPayRequest: (eventState: EventState, eventName: EventType, request: CustomCheckoutPayRequest, apiPath: string, exception?: unknown) => BaseEvent;
|
|
9
|
+
export declare const buildOrderStatusEvent: (eventState: EventState, merchantOrderId: string, paymentFlow: PaymentFlowType, apiPath: string, eventName: EventType, exception?: unknown) => BaseEvent;
|
|
10
|
+
export declare const buildRefundEvent: (eventState: EventState, refundRequest: RefundRequest, apiPath: string, paymentFlow: PaymentFlowType, eventName: EventType, exception?: unknown) => BaseEvent;
|
|
11
|
+
export declare const buildRefundStatusEvent: (eventState: EventState, eventName: EventType, refundId: string, apiPath: string, paymentFlow: PaymentFlowType, exception?: unknown) => BaseEvent;
|
|
12
|
+
export declare const buildCreateSdkOrderEvent: (eventState: EventState, eventName: EventType, createSdkOrderRequest: CreateSdkOrderRequest, apiPath: string, paymentFlow: PaymentFlowType, exception?: unknown) => BaseEvent;
|
|
13
|
+
export declare const buildTransactionStatusEvent: (eventState: EventState, eventName: EventType, transactionId: string, apiPath: string, paymentFlow: PaymentFlowType, exception?: unknown) => BaseEvent;
|
|
14
|
+
export declare const buildOAuthEvent: (fetchAttemptTime: number, apiPath: string, eventName: EventType, exception: unknown, cachedTokenIssuedAt: number, cachedTokenExpiresAt: number) => BaseEvent;
|
|
15
|
+
export declare const buildCallbackSerializationFailedEvent: (eventState: EventState, paymentFlow: PaymentFlowType, eventName: EventType, exception?: unknown) => BaseEvent;
|
|
16
|
+
export declare const populateExceptionFields: (event: BaseEvent, exception: any) => BaseEvent;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Original Author(s), PhonePe India Pvt. Ltd.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.populateExceptionFields = exports.buildCallbackSerializationFailedEvent = exports.buildOAuthEvent = exports.buildTransactionStatusEvent = exports.buildCreateSdkOrderEvent = exports.buildRefundStatusEvent = exports.buildRefundEvent = exports.buildOrderStatusEvent = exports.buildCustomCheckoutPayRequest = exports.buildStandardCheckoutPayEvent = exports.buildInitClientEvent = void 0;
|
|
19
|
+
const models_1 = require("../../models");
|
|
20
|
+
const BaseEvent_1 = require("../models/BaseEvent");
|
|
21
|
+
const EventState_1 = require("../models/enums/EventState");
|
|
22
|
+
const FlowType_1 = require("../models/enums/FlowType");
|
|
23
|
+
const EventData_1 = require("../models/EventData");
|
|
24
|
+
const buildInitClientEvent = (eventName, paymentFlow) => {
|
|
25
|
+
return BaseEvent_1.BaseEvent.builder()
|
|
26
|
+
.setEventName(eventName)
|
|
27
|
+
.setEventTime(Math.floor(Date.now() / 1000))
|
|
28
|
+
.setData(EventData_1.EventData.builder()
|
|
29
|
+
.setEventState(EventState_1.EventState.INITIATED)
|
|
30
|
+
.setFlowType(FlowType_1.FlowType.B2B_PG)
|
|
31
|
+
.setPaymentFlow(paymentFlow)
|
|
32
|
+
.build())
|
|
33
|
+
.build();
|
|
34
|
+
};
|
|
35
|
+
exports.buildInitClientEvent = buildInitClientEvent;
|
|
36
|
+
const buildStandardCheckoutPayEvent = (eventState, eventName, standardCheckoutPayRequest, apiPath, exception = null) => {
|
|
37
|
+
const event = BaseEvent_1.BaseEvent.builder()
|
|
38
|
+
.setEventName(eventName)
|
|
39
|
+
.setEventTime(Math.floor(Date.now() / 1000))
|
|
40
|
+
.setMerchantOrderId(standardCheckoutPayRequest.merchantOrderId)
|
|
41
|
+
.setData(EventData_1.EventData.builder()
|
|
42
|
+
.setEventState(eventState)
|
|
43
|
+
.setAmount(standardCheckoutPayRequest.amount)
|
|
44
|
+
.setPaymentFlow(models_1.PaymentFlowType.PG_CHECKOUT)
|
|
45
|
+
.setApiPath(apiPath)
|
|
46
|
+
.setExpireAfter(standardCheckoutPayRequest.expireAfter)
|
|
47
|
+
.setFlowType(FlowType_1.FlowType.B2B_PG)
|
|
48
|
+
.build())
|
|
49
|
+
.build();
|
|
50
|
+
return (0, exports.populateExceptionFields)(event, exception);
|
|
51
|
+
};
|
|
52
|
+
exports.buildStandardCheckoutPayEvent = buildStandardCheckoutPayEvent;
|
|
53
|
+
const buildCustomCheckoutPayRequest = (eventState, eventName, request, apiPath, exception = null) => {
|
|
54
|
+
const pgPaymentFlow = request.paymentFlow;
|
|
55
|
+
const targetApp = pgPaymentFlow.paymentMode instanceof models_1.IntentPaymentV2Instrument
|
|
56
|
+
? pgPaymentFlow.paymentMode.targetApp
|
|
57
|
+
: undefined;
|
|
58
|
+
const event = BaseEvent_1.BaseEvent.builder()
|
|
59
|
+
.setEventName(eventName)
|
|
60
|
+
.setEventTime(Math.floor(Date.now() / 1000))
|
|
61
|
+
.setMerchantOrderId(request.merchantOrderId)
|
|
62
|
+
.setData(EventData_1.EventData.builder()
|
|
63
|
+
.setEventState(eventState)
|
|
64
|
+
.setAmount(request.amount)
|
|
65
|
+
.setPaymentFlow(models_1.PaymentFlowType.PG)
|
|
66
|
+
.setApiPath(apiPath)
|
|
67
|
+
.setExpireAfter(request.expireAfter)
|
|
68
|
+
.setFlowType(FlowType_1.FlowType.B2B_PG)
|
|
69
|
+
.setPaymentInstrument(pgPaymentFlow.paymentMode.type)
|
|
70
|
+
.setTargetApp(targetApp)
|
|
71
|
+
.setDeviceContext(request.deviceContext)
|
|
72
|
+
.build())
|
|
73
|
+
.build();
|
|
74
|
+
return (0, exports.populateExceptionFields)(event, exception);
|
|
75
|
+
};
|
|
76
|
+
exports.buildCustomCheckoutPayRequest = buildCustomCheckoutPayRequest;
|
|
77
|
+
const buildOrderStatusEvent = (eventState, merchantOrderId, paymentFlow, apiPath, eventName, exception = null) => {
|
|
78
|
+
const event = BaseEvent_1.BaseEvent.builder()
|
|
79
|
+
.setEventName(eventName)
|
|
80
|
+
.setMerchantOrderId(merchantOrderId)
|
|
81
|
+
.setEventTime(Math.floor(Date.now() / 1000))
|
|
82
|
+
.setData(EventData_1.EventData.builder()
|
|
83
|
+
.setEventState(eventState)
|
|
84
|
+
.setPaymentFlow(paymentFlow)
|
|
85
|
+
.setApiPath(apiPath)
|
|
86
|
+
.setFlowType(FlowType_1.FlowType.B2B_PG)
|
|
87
|
+
.build())
|
|
88
|
+
.build();
|
|
89
|
+
return (0, exports.populateExceptionFields)(event, exception);
|
|
90
|
+
};
|
|
91
|
+
exports.buildOrderStatusEvent = buildOrderStatusEvent;
|
|
92
|
+
const buildRefundEvent = (eventState, refundRequest, apiPath, paymentFlow, eventName, exception = null) => {
|
|
93
|
+
const event = BaseEvent_1.BaseEvent.builder()
|
|
94
|
+
.setEventName(eventName)
|
|
95
|
+
.setEventTime(Math.floor(Date.now() / 1000))
|
|
96
|
+
.setMerchantOrderId(refundRequest.originalMerchantOrderId)
|
|
97
|
+
.setData(EventData_1.EventData.builder()
|
|
98
|
+
.setMerchantRefundId(refundRequest.merchantRefundId)
|
|
99
|
+
.setEventState(eventState)
|
|
100
|
+
.setPaymentFlow(paymentFlow)
|
|
101
|
+
.setApiPath(apiPath)
|
|
102
|
+
.setAmount(refundRequest.amount)
|
|
103
|
+
.setOriginalMerchantOrderId(refundRequest.originalMerchantOrderId)
|
|
104
|
+
.setFlowType(FlowType_1.FlowType.B2B_PG)
|
|
105
|
+
.build())
|
|
106
|
+
.build();
|
|
107
|
+
return (0, exports.populateExceptionFields)(event, exception);
|
|
108
|
+
};
|
|
109
|
+
exports.buildRefundEvent = buildRefundEvent;
|
|
110
|
+
const buildRefundStatusEvent = (eventState, eventName, refundId, apiPath, paymentFlow, exception = null) => {
|
|
111
|
+
const event = BaseEvent_1.BaseEvent.builder()
|
|
112
|
+
.setEventName(eventName)
|
|
113
|
+
.setEventTime(Math.floor(Date.now() / 1000))
|
|
114
|
+
.setData(EventData_1.EventData.builder()
|
|
115
|
+
.setMerchantRefundId(refundId)
|
|
116
|
+
.setEventState(eventState)
|
|
117
|
+
.setApiPath(apiPath)
|
|
118
|
+
.setPaymentFlow(paymentFlow)
|
|
119
|
+
.setFlowType(FlowType_1.FlowType.B2B_PG)
|
|
120
|
+
.build())
|
|
121
|
+
.build();
|
|
122
|
+
return (0, exports.populateExceptionFields)(event, exception);
|
|
123
|
+
};
|
|
124
|
+
exports.buildRefundStatusEvent = buildRefundStatusEvent;
|
|
125
|
+
const buildCreateSdkOrderEvent = (eventState, eventName, createSdkOrderRequest, apiPath, paymentFlow, exception = null) => {
|
|
126
|
+
const event = BaseEvent_1.BaseEvent.builder()
|
|
127
|
+
.setMerchantOrderId(createSdkOrderRequest.merchantOrderId)
|
|
128
|
+
.setEventName(eventName)
|
|
129
|
+
.setEventTime(Math.floor(Date.now() / 1000))
|
|
130
|
+
.setData(EventData_1.EventData.builder()
|
|
131
|
+
.setAmount(createSdkOrderRequest.amount)
|
|
132
|
+
.setApiPath(apiPath)
|
|
133
|
+
.setEventState(eventState)
|
|
134
|
+
.setExpireAfter(createSdkOrderRequest.expireAfter)
|
|
135
|
+
.setPaymentFlow(paymentFlow)
|
|
136
|
+
.setFlowType(FlowType_1.FlowType.B2B_PG)
|
|
137
|
+
.build())
|
|
138
|
+
.build();
|
|
139
|
+
return (0, exports.populateExceptionFields)(event, exception);
|
|
140
|
+
};
|
|
141
|
+
exports.buildCreateSdkOrderEvent = buildCreateSdkOrderEvent;
|
|
142
|
+
const buildTransactionStatusEvent = (eventState, eventName, transactionId, apiPath, paymentFlow, exception = null) => {
|
|
143
|
+
const event = BaseEvent_1.BaseEvent.builder()
|
|
144
|
+
.setEventName(eventName)
|
|
145
|
+
.setEventTime(Math.floor(Date.now() / 1000))
|
|
146
|
+
.setData(EventData_1.EventData.builder()
|
|
147
|
+
.setEventState(eventState)
|
|
148
|
+
.setTransactionId(transactionId)
|
|
149
|
+
.setApiPath(apiPath)
|
|
150
|
+
.setFlowType(FlowType_1.FlowType.B2B_PG)
|
|
151
|
+
.setPaymentFlow(paymentFlow)
|
|
152
|
+
.build())
|
|
153
|
+
.build();
|
|
154
|
+
return (0, exports.populateExceptionFields)(event, exception);
|
|
155
|
+
};
|
|
156
|
+
exports.buildTransactionStatusEvent = buildTransactionStatusEvent;
|
|
157
|
+
const buildOAuthEvent = (fetchAttemptTime, apiPath, eventName, exception, cachedTokenIssuedAt, cachedTokenExpiresAt) => {
|
|
158
|
+
const event = BaseEvent_1.BaseEvent.builder()
|
|
159
|
+
.setEventName(eventName)
|
|
160
|
+
.setEventTime(Math.floor(Date.now() / 1000))
|
|
161
|
+
.setData(EventData_1.EventData.builder()
|
|
162
|
+
.setTokenFetchAttemptTimestamp(fetchAttemptTime)
|
|
163
|
+
.setApiPath(apiPath)
|
|
164
|
+
.setEventState(EventState_1.EventState.FAILED)
|
|
165
|
+
.setCachedTokenExpiresAt(cachedTokenExpiresAt)
|
|
166
|
+
.setCachedTokenIssuesAt(cachedTokenIssuedAt)
|
|
167
|
+
.build())
|
|
168
|
+
.build();
|
|
169
|
+
return (0, exports.populateExceptionFields)(event, exception);
|
|
170
|
+
};
|
|
171
|
+
exports.buildOAuthEvent = buildOAuthEvent;
|
|
172
|
+
const buildCallbackSerializationFailedEvent = (eventState, paymentFlow, eventName, exception = null) => {
|
|
173
|
+
const event = BaseEvent_1.BaseEvent.builder()
|
|
174
|
+
.setEventName(eventName)
|
|
175
|
+
.setEventTime(Math.floor(Date.now() / 1000))
|
|
176
|
+
.setData(EventData_1.EventData.builder()
|
|
177
|
+
.setEventState(eventState)
|
|
178
|
+
.setPaymentFlow(paymentFlow)
|
|
179
|
+
.build())
|
|
180
|
+
.build();
|
|
181
|
+
return (0, exports.populateExceptionFields)(event, exception);
|
|
182
|
+
};
|
|
183
|
+
exports.buildCallbackSerializationFailedEvent = buildCallbackSerializationFailedEvent;
|
|
184
|
+
const populateExceptionFields = (event, exception) => {
|
|
185
|
+
var _a, _b, _c, _d, _e;
|
|
186
|
+
if (exception == null)
|
|
187
|
+
return event;
|
|
188
|
+
event.data.exceptionClass = (_a = exception === null || exception === void 0 ? void 0 : exception.type) !== null && _a !== void 0 ? _a : null;
|
|
189
|
+
event.data.exceptionMessage = (_b = exception === null || exception === void 0 ? void 0 : exception.message) !== null && _b !== void 0 ? _b : null;
|
|
190
|
+
event.data.exceptionCode = (_c = exception === null || exception === void 0 ? void 0 : exception.code) !== null && _c !== void 0 ? _c : null;
|
|
191
|
+
event.data.exceptionHttpStatusCode = (_d = exception === null || exception === void 0 ? void 0 : exception.httpStatusCode) !== null && _d !== void 0 ? _d : null;
|
|
192
|
+
event.data.exceptionData = (_e = exception === null || exception === void 0 ? void 0 : exception.data) !== null && _e !== void 0 ? _e : null;
|
|
193
|
+
return event;
|
|
194
|
+
};
|
|
195
|
+
exports.populateExceptionFields = populateExceptionFields;
|