@prakashacharya/vendure-plugin-nepal-payments 0.1.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/NOTICE.md +9 -0
- package/README.md +223 -0
- package/dist/api/api-extensions.d.ts +1 -0
- package/dist/api/api-extensions.js +36 -0
- package/dist/api/api-extensions.js.map +1 -0
- package/dist/api/payment-callback.controller.d.ts +9 -0
- package/dist/api/payment-callback.controller.js +83 -0
- package/dist/api/payment-callback.controller.js.map +1 -0
- package/dist/api/shop.resolver.d.ts +9 -0
- package/dist/api/shop.resolver.js +41 -0
- package/dist/api/shop.resolver.js.map +1 -0
- package/dist/config.d.ts +56 -0
- package/dist/config.js +52 -0
- package/dist/config.js.map +1 -0
- package/dist/entities/payment-attempt.entity.d.ts +29 -0
- package/dist/entities/payment-attempt.entity.js +102 -0
- package/dist/entities/payment-attempt.entity.js.map +1 -0
- package/dist/handlers/payment-handlers.d.ts +3 -0
- package/dist/handlers/payment-handlers.js +85 -0
- package/dist/handlers/payment-handlers.js.map +1 -0
- package/dist/handlers/payment-metadata.d.ts +7 -0
- package/dist/handlers/payment-metadata.js +13 -0
- package/dist/handlers/payment-metadata.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/nepal-payments.plugin.d.ts +29 -0
- package/dist/nepal-payments.plugin.js +91 -0
- package/dist/nepal-payments.plugin.js.map +1 -0
- package/dist/providers/amount.d.ts +2 -0
- package/dist/providers/amount.js +22 -0
- package/dist/providers/amount.js.map +1 -0
- package/dist/providers/esewa.provider.d.ts +15 -0
- package/dist/providers/esewa.provider.js +117 -0
- package/dist/providers/esewa.provider.js.map +1 -0
- package/dist/providers/http-client.d.ts +3 -0
- package/dist/providers/http-client.js +46 -0
- package/dist/providers/http-client.js.map +1 -0
- package/dist/providers/khalti.provider.d.ts +15 -0
- package/dist/providers/khalti.provider.js +91 -0
- package/dist/providers/khalti.provider.js.map +1 -0
- package/dist/providers/provider-error.d.ts +5 -0
- package/dist/providers/provider-error.js +13 -0
- package/dist/providers/provider-error.js.map +1 -0
- package/dist/providers/provider.factory.d.ts +2 -0
- package/dist/providers/provider.factory.js +18 -0
- package/dist/providers/provider.factory.js.map +1 -0
- package/dist/providers/sanitize-provider-data.d.ts +4 -0
- package/dist/providers/sanitize-provider-data.js +35 -0
- package/dist/providers/sanitize-provider-data.js.map +1 -0
- package/dist/providers/signing.d.ts +9 -0
- package/dist/providers/signing.js +18 -0
- package/dist/providers/signing.js.map +1 -0
- package/dist/services/payment-orchestrator.service.d.ts +18 -0
- package/dist/services/payment-orchestrator.service.js +188 -0
- package/dist/services/payment-orchestrator.service.js.map +1 -0
- package/dist/services/reconciliation.service.d.ts +11 -0
- package/dist/services/reconciliation.service.js +55 -0
- package/dist/services/reconciliation.service.js.map +1 -0
- package/dist/services/reconciliation.task.d.ts +2 -0
- package/dist/services/reconciliation.task.js +14 -0
- package/dist/services/reconciliation.task.js.map +1 -0
- package/dist/types.d.ts +76 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/docs/ADDING_A_PROVIDER.md +74 -0
- package/docs/ARCHITECTURE.md +75 -0
- package/docs/CONFIGURATION.md +49 -0
- package/docs/DATA_HANDLING.md +46 -0
- package/docs/INSTALLATION.md +132 -0
- package/docs/LICENSING.md +29 -0
- package/docs/PRODUCTION.md +50 -0
- package/docs/PROVIDERS.md +57 -0
- package/docs/README.md +15 -0
- package/docs/RELEASING.md +74 -0
- package/docs/STOREFRONT.md +111 -0
- package/docs/TROUBLESHOOTING.md +71 -0
- package/package.json +79 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.NepalPaymentAttempt = void 0;
|
|
13
|
+
const core_1 = require("@vendure/core");
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
/**
|
|
16
|
+
* Stores the asynchronous provider-side lifecycle before a verified Vendure
|
|
17
|
+
* {@link Payment} is created. Applications should treat these records as
|
|
18
|
+
* operational data and must not manually mark them settled.
|
|
19
|
+
*
|
|
20
|
+
* @category Entity
|
|
21
|
+
*/
|
|
22
|
+
let NepalPaymentAttempt = class NepalPaymentAttempt extends core_1.VendureEntity {
|
|
23
|
+
constructor(input) {
|
|
24
|
+
super(input);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.NepalPaymentAttempt = NepalPaymentAttempt;
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, typeorm_1.Column)('varchar'),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], NepalPaymentAttempt.prototype, "orderId", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, typeorm_1.Column)('varchar'),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], NepalPaymentAttempt.prototype, "orderCode", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, typeorm_1.Column)('varchar'),
|
|
38
|
+
__metadata("design:type", String)
|
|
39
|
+
], NepalPaymentAttempt.prototype, "channelId", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, typeorm_1.Column)('varchar'),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], NepalPaymentAttempt.prototype, "channelToken", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, typeorm_1.Column)('varchar'),
|
|
46
|
+
__metadata("design:type", String)
|
|
47
|
+
], NepalPaymentAttempt.prototype, "provider", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, typeorm_1.Column)('varchar'),
|
|
50
|
+
__metadata("design:type", String)
|
|
51
|
+
], NepalPaymentAttempt.prototype, "paymentMethodCode", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, typeorm_1.Column)('varchar'),
|
|
54
|
+
__metadata("design:type", String)
|
|
55
|
+
], NepalPaymentAttempt.prototype, "merchantReference", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, typeorm_1.Column)('varchar', { nullable: true }),
|
|
58
|
+
__metadata("design:type", Object)
|
|
59
|
+
], NepalPaymentAttempt.prototype, "providerReference", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
(0, core_1.Money)(),
|
|
62
|
+
__metadata("design:type", Number)
|
|
63
|
+
], NepalPaymentAttempt.prototype, "amount", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, typeorm_1.Column)('varchar', { length: 3 }),
|
|
66
|
+
__metadata("design:type", String)
|
|
67
|
+
], NepalPaymentAttempt.prototype, "currencyCode", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
(0, typeorm_1.Column)('varchar'),
|
|
70
|
+
__metadata("design:type", String)
|
|
71
|
+
], NepalPaymentAttempt.prototype, "status", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, typeorm_1.Column)('varchar', { unique: true }),
|
|
74
|
+
__metadata("design:type", String)
|
|
75
|
+
], NepalPaymentAttempt.prototype, "idempotencyKey", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
78
|
+
__metadata("design:type", Date)
|
|
79
|
+
], NepalPaymentAttempt.prototype, "expiresAt", void 0);
|
|
80
|
+
__decorate([
|
|
81
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
82
|
+
__metadata("design:type", Date)
|
|
83
|
+
], NepalPaymentAttempt.prototype, "verifiedAt", void 0);
|
|
84
|
+
__decorate([
|
|
85
|
+
(0, typeorm_1.Column)('varchar', { nullable: true }),
|
|
86
|
+
__metadata("design:type", Object)
|
|
87
|
+
], NepalPaymentAttempt.prototype, "providerTransactionId", void 0);
|
|
88
|
+
__decorate([
|
|
89
|
+
(0, typeorm_1.Column)('varchar', { nullable: true }),
|
|
90
|
+
__metadata("design:type", Object)
|
|
91
|
+
], NepalPaymentAttempt.prototype, "vendurePaymentId", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
(0, typeorm_1.Column)('simple-json', { nullable: true }),
|
|
94
|
+
__metadata("design:type", Object)
|
|
95
|
+
], NepalPaymentAttempt.prototype, "providerResponse", void 0);
|
|
96
|
+
exports.NepalPaymentAttempt = NepalPaymentAttempt = __decorate([
|
|
97
|
+
(0, typeorm_1.Entity)(),
|
|
98
|
+
(0, typeorm_1.Index)(['provider', 'merchantReference'], { unique: true }),
|
|
99
|
+
(0, typeorm_1.Index)(['provider', 'providerReference'], { unique: true }),
|
|
100
|
+
__metadata("design:paramtypes", [Object])
|
|
101
|
+
], NepalPaymentAttempt);
|
|
102
|
+
//# sourceMappingURL=payment-attempt.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-attempt.entity.js","sourceRoot":"","sources":["../../src/entities/payment-attempt.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAkE;AAClE,qCAAgD;AAGhD;;;;;;GAMG;AAII,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,oBAAa;IACpD,YAAY,KAAwC;QAClD,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;CAoDF,CAAA;A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CAAC,UAAU,EAAE,mBAAmB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC1D,IAAA,eAAK,EAAC,CAAC,UAAU,EAAE,mBAAmB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;GAC9C,mBAAmB,CAuD/B"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.esewaPaymentHandler = exports.khaltiPaymentHandler = void 0;
|
|
4
|
+
const core_1 = require("@vendure/core");
|
|
5
|
+
const config_1 = require("../config");
|
|
6
|
+
const provider_factory_1 = require("../providers/provider.factory");
|
|
7
|
+
const signing_1 = require("../providers/signing");
|
|
8
|
+
const payment_metadata_1 = require("./payment-metadata");
|
|
9
|
+
function createHandler(providerCode, displayName, withRefund) {
|
|
10
|
+
return new core_1.PaymentMethodHandler({
|
|
11
|
+
code: `nepal-${providerCode}`,
|
|
12
|
+
description: [{ languageCode: core_1.LanguageCode.en, value: displayName }],
|
|
13
|
+
args: {},
|
|
14
|
+
createPayment: async (ctx, order, amount, _args, metadata) => {
|
|
15
|
+
try {
|
|
16
|
+
const input = (0, payment_metadata_1.readSettlementMetadata)(metadata);
|
|
17
|
+
const expectedProof = (0, signing_1.signSettlementProof)({
|
|
18
|
+
provider: providerCode,
|
|
19
|
+
attemptId: input.attemptId,
|
|
20
|
+
orderId: String(order.id),
|
|
21
|
+
amount,
|
|
22
|
+
providerReference: input.providerReference,
|
|
23
|
+
}, (0, config_1.getPluginOptions)().internalSigningSecret);
|
|
24
|
+
if (!(0, signing_1.secureStringEqual)(input.proof, expectedProof)) {
|
|
25
|
+
throw new Error('Invalid settlement proof');
|
|
26
|
+
}
|
|
27
|
+
const verified = await (0, provider_factory_1.createProvider)(providerCode).verify({
|
|
28
|
+
merchantReference: input.attemptId,
|
|
29
|
+
providerReference: input.providerReference,
|
|
30
|
+
amount,
|
|
31
|
+
});
|
|
32
|
+
if (verified.status !== 'settled') {
|
|
33
|
+
throw new Error(`${displayName} payment is ${verified.status}, not settled`);
|
|
34
|
+
}
|
|
35
|
+
if (verified.amount !== amount) {
|
|
36
|
+
throw new Error(`${displayName} verified amount does not match the order`);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
amount,
|
|
40
|
+
state: 'Settled',
|
|
41
|
+
transactionId: verified.transactionId ?? verified.providerReference ?? input.providerReference,
|
|
42
|
+
metadata: {
|
|
43
|
+
provider: providerCode,
|
|
44
|
+
providerReference: input.providerReference,
|
|
45
|
+
public: { attemptId: input.attemptId, provider: providerCode },
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
return {
|
|
51
|
+
amount,
|
|
52
|
+
state: 'Declined',
|
|
53
|
+
errorMessage: error instanceof Error ? error.message : 'Payment verification failed',
|
|
54
|
+
metadata: { provider: providerCode },
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
settlePayment: async () => ({ success: true }),
|
|
59
|
+
...(withRefund ? {
|
|
60
|
+
createRefund: async (_ctx, _input, amount, _order, payment) => {
|
|
61
|
+
try {
|
|
62
|
+
const result = await (0, provider_factory_1.createProvider)(providerCode).refund?.({
|
|
63
|
+
transactionId: payment.transactionId,
|
|
64
|
+
amount: amount < payment.amount ? amount : undefined,
|
|
65
|
+
});
|
|
66
|
+
if (!result || result.status === 'failed')
|
|
67
|
+
return { state: 'Failed' };
|
|
68
|
+
return {
|
|
69
|
+
state: result.status === 'settled' ? 'Settled' : 'Pending',
|
|
70
|
+
transactionId: result.transactionId,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
return {
|
|
75
|
+
state: 'Failed',
|
|
76
|
+
metadata: { errorMessage: error instanceof Error ? error.message : 'Refund failed' },
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
} : {}),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
exports.khaltiPaymentHandler = createHandler('khalti', 'Khalti by IME', true);
|
|
84
|
+
exports.esewaPaymentHandler = createHandler('esewa', 'eSewa', false);
|
|
85
|
+
//# sourceMappingURL=payment-handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-handlers.js","sourceRoot":"","sources":["../../src/handlers/payment-handlers.ts"],"names":[],"mappings":";;;AAAA,wCAAmE;AACnE,sCAA6C;AAE7C,oEAA+D;AAC/D,kDAA8E;AAC9E,yDAA4D;AAE5D,SAAS,aAAa,CAAC,YAAsC,EAAE,WAAmB,EAAE,UAAmB;IACrG,OAAO,IAAI,2BAAoB,CAAC;QAC9B,IAAI,EAAE,SAAS,YAAY,EAAE;QAC7B,WAAW,EAAE,CAAC,EAAE,YAAY,EAAE,mBAAY,CAAC,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;QACpE,IAAI,EAAE,EAAE;QACR,aAAa,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;YAC3D,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,IAAA,yCAAsB,EAAC,QAAQ,CAAC,CAAC;gBAC/C,MAAM,aAAa,GAAG,IAAA,6BAAmB,EAAC;oBACxC,QAAQ,EAAE,YAAY;oBACtB,SAAS,EAAE,KAAK,CAAC,SAAS;oBAC1B,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;oBACzB,MAAM;oBACN,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;iBAC3C,EAAE,IAAA,yBAAgB,GAAE,CAAC,qBAAqB,CAAC,CAAC;gBAC7C,IAAI,CAAC,IAAA,2BAAiB,EAAC,KAAK,CAAC,KAAK,EAAE,aAAa,CAAC,EAAE,CAAC;oBACnD,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;gBAC9C,CAAC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|
|
4
|
+
providerReference: string;
|
|
5
|
+
proof: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function readSettlementMetadata(metadata: PaymentMetadata): NepalSettlementMetadata;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readSettlementMetadata = readSettlementMetadata;
|
|
4
|
+
function readSettlementMetadata(metadata) {
|
|
5
|
+
const input = metadata;
|
|
6
|
+
if (typeof input.attemptId !== 'string' ||
|
|
7
|
+
typeof input.providerReference !== 'string' ||
|
|
8
|
+
typeof input.proof !== 'string') {
|
|
9
|
+
throw new Error('Missing authenticated Nepal payment settlement metadata');
|
|
10
|
+
}
|
|
11
|
+
return input;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=payment-metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-metadata.js","sourceRoot":"","sources":["../../src/handlers/payment-metadata.ts"],"names":[],"mappings":";;AAQA,wDAUC;AAVD,SAAgB,sBAAsB,CAAC,QAAyB;IAC9D,MAAM,KAAK,GAAG,QAA4C,CAAC;IAC3D,IACE,OAAO,KAAK,CAAC,SAAS,KAAK,QAAQ;QACnC,OAAO,KAAK,CAAC,iBAAiB,KAAK,QAAQ;QAC3C,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,EAC/B,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,KAAgC,CAAC;AAC1C,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { EsewaPluginOptions, FonepayPluginOptions, KhaltiPluginOptions, NepalPaymentsPluginOptions, } from './config';
|
|
2
|
+
export { NepalPaymentAttempt } from './entities/payment-attempt.entity';
|
|
3
|
+
export { NepalPaymentsPlugin } from './nepal-payments.plugin';
|
|
4
|
+
export { NEPAL_PAYMENT_PROVIDERS, PAYMENT_ATTEMPT_STATUSES, } from './types';
|
|
5
|
+
export type { CustomerDetails, InitiatePaymentInput, NepalPaymentProvider, NepalPaymentProviderCode, PaymentAttemptStatus, PaymentInitiation, RefundPaymentInput, RefundResult, VerifiedPayment, VerifyPaymentInput, } from './types';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PAYMENT_ATTEMPT_STATUSES = exports.NEPAL_PAYMENT_PROVIDERS = exports.NepalPaymentsPlugin = exports.NepalPaymentAttempt = void 0;
|
|
4
|
+
var payment_attempt_entity_1 = require("./entities/payment-attempt.entity");
|
|
5
|
+
Object.defineProperty(exports, "NepalPaymentAttempt", { enumerable: true, get: function () { return payment_attempt_entity_1.NepalPaymentAttempt; } });
|
|
6
|
+
var nepal_payments_plugin_1 = require("./nepal-payments.plugin");
|
|
7
|
+
Object.defineProperty(exports, "NepalPaymentsPlugin", { enumerable: true, get: function () { return nepal_payments_plugin_1.NepalPaymentsPlugin; } });
|
|
8
|
+
var types_1 = require("./types");
|
|
9
|
+
Object.defineProperty(exports, "NEPAL_PAYMENT_PROVIDERS", { enumerable: true, get: function () { return types_1.NEPAL_PAYMENT_PROVIDERS; } });
|
|
10
|
+
Object.defineProperty(exports, "PAYMENT_ATTEMPT_STATUSES", { enumerable: true, get: function () { return types_1.PAYMENT_ATTEMPT_STATUSES; } });
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAMA,4EAAwE;AAA/D,6HAAA,mBAAmB,OAAA;AAC5B,iEAA8D;AAArD,4HAAA,mBAAmB,OAAA;AAC5B,iCAGiB;AAFf,gHAAA,uBAAuB,OAAA;AACvB,iHAAA,wBAAwB,OAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Type } from '@vendure/core';
|
|
2
|
+
import { NepalPaymentsPluginOptions } from './config';
|
|
3
|
+
/**
|
|
4
|
+
* Adds Khalti by IME and eSewa payment integrations to Vendure.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* NepalPaymentsPlugin.init({
|
|
9
|
+
* publicServerUrl: process.env.PUBLIC_SERVER_URL!,
|
|
10
|
+
* storefrontResultUrl: process.env.STOREFRONT_PAYMENT_RESULT_URL!,
|
|
11
|
+
* internalSigningSecret: process.env.NEPAL_PAYMENTS_INTERNAL_SECRET!,
|
|
12
|
+
* khalti: {
|
|
13
|
+
* secretKey: process.env.KHALTI_SECRET_KEY!,
|
|
14
|
+
* websiteUrl: process.env.KHALTI_WEBSITE_URL!,
|
|
15
|
+
* },
|
|
16
|
+
* })
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @category Plugin
|
|
20
|
+
*/
|
|
21
|
+
export declare class NepalPaymentsPlugin {
|
|
22
|
+
/** @internal */
|
|
23
|
+
static options: NepalPaymentsPluginOptions;
|
|
24
|
+
/**
|
|
25
|
+
* Configures the enabled providers, public callback origin, storefront
|
|
26
|
+
* result URL, and reconciliation behavior.
|
|
27
|
+
*/
|
|
28
|
+
static init(options: NepalPaymentsPluginOptions): Type<NepalPaymentsPlugin>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var NepalPaymentsPlugin_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.NepalPaymentsPlugin = void 0;
|
|
11
|
+
const core_1 = require("@vendure/core");
|
|
12
|
+
const shop_resolver_1 = require("./api/shop.resolver");
|
|
13
|
+
const api_extensions_1 = require("./api/api-extensions");
|
|
14
|
+
const payment_callback_controller_1 = require("./api/payment-callback.controller");
|
|
15
|
+
const config_1 = require("./config");
|
|
16
|
+
const payment_attempt_entity_1 = require("./entities/payment-attempt.entity");
|
|
17
|
+
const payment_handlers_1 = require("./handlers/payment-handlers");
|
|
18
|
+
const http_client_1 = require("./providers/http-client");
|
|
19
|
+
const payment_orchestrator_service_1 = require("./services/payment-orchestrator.service");
|
|
20
|
+
const reconciliation_service_1 = require("./services/reconciliation.service");
|
|
21
|
+
const reconciliation_task_1 = require("./services/reconciliation.task");
|
|
22
|
+
/**
|
|
23
|
+
* Adds Khalti by IME and eSewa payment integrations to Vendure.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* NepalPaymentsPlugin.init({
|
|
28
|
+
* publicServerUrl: process.env.PUBLIC_SERVER_URL!,
|
|
29
|
+
* storefrontResultUrl: process.env.STOREFRONT_PAYMENT_RESULT_URL!,
|
|
30
|
+
* internalSigningSecret: process.env.NEPAL_PAYMENTS_INTERNAL_SECRET!,
|
|
31
|
+
* khalti: {
|
|
32
|
+
* secretKey: process.env.KHALTI_SECRET_KEY!,
|
|
33
|
+
* websiteUrl: process.env.KHALTI_WEBSITE_URL!,
|
|
34
|
+
* },
|
|
35
|
+
* })
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @category Plugin
|
|
39
|
+
*/
|
|
40
|
+
let NepalPaymentsPlugin = class NepalPaymentsPlugin {
|
|
41
|
+
static { NepalPaymentsPlugin_1 = this; }
|
|
42
|
+
/**
|
|
43
|
+
* Configures the enabled providers, public callback origin, storefront
|
|
44
|
+
* result URL, and reconciliation behavior.
|
|
45
|
+
*/
|
|
46
|
+
static init(options) {
|
|
47
|
+
(0, config_1.setPluginOptions)(options);
|
|
48
|
+
this.options = options;
|
|
49
|
+
return NepalPaymentsPlugin_1;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
exports.NepalPaymentsPlugin = NepalPaymentsPlugin;
|
|
53
|
+
exports.NepalPaymentsPlugin = NepalPaymentsPlugin = NepalPaymentsPlugin_1 = __decorate([
|
|
54
|
+
(0, core_1.VendurePlugin)({
|
|
55
|
+
imports: [core_1.PluginCommonModule],
|
|
56
|
+
entities: [payment_attempt_entity_1.NepalPaymentAttempt],
|
|
57
|
+
providers: [http_client_1.PaymentHttpClient, payment_orchestrator_service_1.PaymentOrchestratorService, reconciliation_service_1.ReconciliationService],
|
|
58
|
+
controllers: [payment_callback_controller_1.PaymentCallbackController],
|
|
59
|
+
shopApiExtensions: {
|
|
60
|
+
schema: api_extensions_1.shopApiExtensions,
|
|
61
|
+
resolvers: [shop_resolver_1.NepalPaymentsShopResolver],
|
|
62
|
+
},
|
|
63
|
+
configuration: config => {
|
|
64
|
+
const handlers = config.paymentOptions.paymentMethodHandlers ?? [];
|
|
65
|
+
const codes = new Set(handlers.map(handler => handler.code));
|
|
66
|
+
const options = getInitializedOptions();
|
|
67
|
+
if (options.khalti && !codes.has(payment_handlers_1.khaltiPaymentHandler.code))
|
|
68
|
+
handlers.push(payment_handlers_1.khaltiPaymentHandler);
|
|
69
|
+
if (options.esewa && !codes.has(payment_handlers_1.esewaPaymentHandler.code))
|
|
70
|
+
handlers.push(payment_handlers_1.esewaPaymentHandler);
|
|
71
|
+
config.paymentOptions.paymentMethodHandlers = handlers;
|
|
72
|
+
if (options.reconciliationSchedule !== false) {
|
|
73
|
+
reconciliation_task_1.reconcileNepalPaymentsTask.configure({
|
|
74
|
+
schedule: options.reconciliationSchedule ?? '*/5 * * * *',
|
|
75
|
+
});
|
|
76
|
+
config.schedulerOptions.tasks = [
|
|
77
|
+
...(config.schedulerOptions.tasks ?? []).filter(task => task.id !== reconciliation_task_1.reconcileNepalPaymentsTask.id),
|
|
78
|
+
reconciliation_task_1.reconcileNepalPaymentsTask,
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
return config;
|
|
82
|
+
},
|
|
83
|
+
compatibility: '^3.7.0',
|
|
84
|
+
})
|
|
85
|
+
], NepalPaymentsPlugin);
|
|
86
|
+
function getInitializedOptions() {
|
|
87
|
+
if (!NepalPaymentsPlugin.options)
|
|
88
|
+
throw new Error('NepalPaymentsPlugin.init() was not called');
|
|
89
|
+
return NepalPaymentsPlugin.options;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=nepal-payments.plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nepal-payments.plugin.js","sourceRoot":"","sources":["../src/nepal-payments.plugin.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,wCAAwE;AACxE,uDAAgE;AAChE,yDAAyD;AACzD,mFAA8E;AAC9E,qCAAwE;AACxE,8EAAwE;AACxE,kEAAwF;AACxF,yDAA4D;AAC5D,0FAAqF;AACrF,8EAA0E;AAC1E,wEAA4E;AAE5E;;;;;;;;;;;;;;;;;GAiBG;AA8BI,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;;IAI9B;;;OAGG;IACH,MAAM,CAAC,IAAI,CAAC,OAAmC;QAC7C,IAAA,yBAAgB,EAAC,OAAO,CAAC,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO,qBAAmB,CAAC;IAC7B,CAAC;CACF,CAAA;AAbY,kDAAmB;8BAAnB,mBAAmB;IA7B/B,IAAA,oBAAa,EAAC;QACb,OAAO,EAAE,CAAC,yBAAkB,CAAC;QAC7B,QAAQ,EAAE,CAAC,4CAAmB,CAAC;QAC/B,SAAS,EAAE,CAAC,+BAAiB,EAAE,yDAA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CAAC;QACD,aAAa,EAAE,QAAQ;KACxB,CAAC;GACW,mBAAmB,CAa/B;AAED,SAAS,qBAAqB;IAC5B,IAAI,CAAC,mBAAmB,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/F,OAAO,mBAAmB,CAAC,OAAO,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.minorUnitsToDecimal = minorUnitsToDecimal;
|
|
4
|
+
exports.decimalToMinorUnits = decimalToMinorUnits;
|
|
5
|
+
function minorUnitsToDecimal(amount) {
|
|
6
|
+
if (!Number.isSafeInteger(amount) || amount < 0) {
|
|
7
|
+
throw new Error('Payment amount must be a non-negative safe integer');
|
|
8
|
+
}
|
|
9
|
+
return `${Math.floor(amount / 100)}.${String(amount % 100).padStart(2, '0')}`;
|
|
10
|
+
}
|
|
11
|
+
function decimalToMinorUnits(value) {
|
|
12
|
+
const normalized = String(value).replace(/,/g, '').trim();
|
|
13
|
+
if (!/^\d+(?:\.\d{1,2})?$/.test(normalized)) {
|
|
14
|
+
throw new Error(`Invalid decimal amount: ${normalized}`);
|
|
15
|
+
}
|
|
16
|
+
const [major, fraction = ''] = normalized.split('.');
|
|
17
|
+
const amount = Number(major) * 100 + Number(fraction.padEnd(2, '0'));
|
|
18
|
+
if (!Number.isSafeInteger(amount))
|
|
19
|
+
throw new Error('Amount exceeds safe integer range');
|
|
20
|
+
return amount;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=amount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amount.js","sourceRoot":"","sources":["../../src/providers/amount.ts"],"names":[],"mappings":";;AAAA,kDAKC;AAED,kDASC;AAhBD,SAAgB,mBAAmB,CAAC,MAAc;IAChD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AAChF,CAAC;AAED,SAAgB,mBAAmB,CAAC,KAAsB;IACxD,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1D,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,2BAA2B,UAAU,EAAE,CAAC,CAAC;IAC3D,CAAC;IACD,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,EAAE,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IACrE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACxF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { EsewaPluginOptions } from '../config';
|
|
2
|
+
import type { InitiatePaymentInput, NepalPaymentProvider, PaymentInitiation, VerifiedPayment, VerifyPaymentInput } from '../types';
|
|
3
|
+
import { PaymentHttpClient } from './http-client';
|
|
4
|
+
export declare class EsewaProvider implements NepalPaymentProvider {
|
|
5
|
+
private readonly options;
|
|
6
|
+
private readonly http;
|
|
7
|
+
readonly code: "esewa";
|
|
8
|
+
private readonly formUrl;
|
|
9
|
+
private readonly statusUrl;
|
|
10
|
+
constructor(options: EsewaPluginOptions, http?: PaymentHttpClient);
|
|
11
|
+
initiate(input: InitiatePaymentInput): Promise<PaymentInitiation>;
|
|
12
|
+
verify(input: VerifyPaymentInput): Promise<VerifiedPayment>;
|
|
13
|
+
verifyCallbackData(data: string, merchantReference: string, expectedAmount: number): Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export declare function mapEsewaStatus(status: string): "pending" | "settled" | "failed" | "cancelled" | "partially-refunded" | "refunded" | "unknown";
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EsewaProvider = void 0;
|
|
4
|
+
exports.mapEsewaStatus = mapEsewaStatus;
|
|
5
|
+
const amount_1 = require("./amount");
|
|
6
|
+
const http_client_1 = require("./http-client");
|
|
7
|
+
const signing_1 = require("./signing");
|
|
8
|
+
class EsewaProvider {
|
|
9
|
+
constructor(options, http = new http_client_1.PaymentHttpClient()) {
|
|
10
|
+
this.options = options;
|
|
11
|
+
this.http = http;
|
|
12
|
+
this.code = 'esewa';
|
|
13
|
+
const production = options.environment === 'production';
|
|
14
|
+
this.formUrl = production
|
|
15
|
+
? 'https://epay.esewa.com.np/api/epay/main/v2/form'
|
|
16
|
+
: 'https://rc-epay.esewa.com.np/api/epay/main/v2/form';
|
|
17
|
+
this.statusUrl = production
|
|
18
|
+
? 'https://esewa.com.np/api/epay/transaction/status/'
|
|
19
|
+
: 'https://rc.esewa.com.np/api/epay/transaction/status/';
|
|
20
|
+
}
|
|
21
|
+
async initiate(input) {
|
|
22
|
+
const totalAmount = (0, amount_1.minorUnitsToDecimal)(input.amount);
|
|
23
|
+
const signedFieldNames = 'total_amount,transaction_uuid,product_code';
|
|
24
|
+
const message = `total_amount=${totalAmount},transaction_uuid=${input.attemptId},product_code=${this.options.productCode}`;
|
|
25
|
+
const fields = {
|
|
26
|
+
amount: totalAmount,
|
|
27
|
+
tax_amount: '0.00',
|
|
28
|
+
total_amount: totalAmount,
|
|
29
|
+
transaction_uuid: input.attemptId,
|
|
30
|
+
product_code: this.options.productCode,
|
|
31
|
+
product_service_charge: '0.00',
|
|
32
|
+
product_delivery_charge: '0.00',
|
|
33
|
+
success_url: `${input.returnUrl}?outcome=success`,
|
|
34
|
+
failure_url: `${input.returnUrl}?outcome=failure`,
|
|
35
|
+
signed_field_names: signedFieldNames,
|
|
36
|
+
signature: (0, signing_1.hmacSha256Base64)(message, this.options.secretKey),
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
providerReference: input.attemptId,
|
|
40
|
+
form: {
|
|
41
|
+
action: this.formUrl,
|
|
42
|
+
fields: Object.entries(fields).map(([name, value]) => ({ name, value })),
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
async verify(input) {
|
|
47
|
+
if (input.callbackPayload?.data) {
|
|
48
|
+
this.verifyCallbackData(String(input.callbackPayload.data), input.merchantReference, input.amount);
|
|
49
|
+
}
|
|
50
|
+
const params = new URLSearchParams({
|
|
51
|
+
product_code: this.options.productCode,
|
|
52
|
+
total_amount: (0, amount_1.minorUnitsToDecimal)(input.amount),
|
|
53
|
+
transaction_uuid: input.merchantReference,
|
|
54
|
+
});
|
|
55
|
+
const response = await this.http.request(`${this.statusUrl}?${params}`, {
|
|
56
|
+
method: 'GET',
|
|
57
|
+
headers: { Accept: 'application/json' },
|
|
58
|
+
});
|
|
59
|
+
if (response.product_code !== this.options.productCode) {
|
|
60
|
+
throw new Error('eSewa status product code does not match the merchant');
|
|
61
|
+
}
|
|
62
|
+
if (response.transaction_uuid !== input.merchantReference) {
|
|
63
|
+
throw new Error('eSewa status transaction does not match the payment attempt');
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
providerReference: response.transaction_uuid,
|
|
67
|
+
transactionId: response.ref_id ?? undefined,
|
|
68
|
+
amount: (0, amount_1.decimalToMinorUnits)(response.total_amount),
|
|
69
|
+
status: mapEsewaStatus(response.status),
|
|
70
|
+
raw: response,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
verifyCallbackData(data, merchantReference, expectedAmount) {
|
|
74
|
+
let payload;
|
|
75
|
+
try {
|
|
76
|
+
payload = JSON.parse(Buffer.from(data, 'base64').toString('utf8'));
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
throw new Error('Invalid eSewa callback data');
|
|
80
|
+
}
|
|
81
|
+
const fieldNames = String(payload.signed_field_names ?? '').split(',').filter(Boolean);
|
|
82
|
+
if (fieldNames.length === 0 || !fieldNames.every(name => Object.hasOwn(payload, name))) {
|
|
83
|
+
throw new Error('Invalid eSewa signed fields');
|
|
84
|
+
}
|
|
85
|
+
const message = fieldNames.map(name => `${name}=${String(payload[name])}`).join(',');
|
|
86
|
+
const expectedSignature = (0, signing_1.hmacSha256Base64)(message, this.options.secretKey);
|
|
87
|
+
if (!(0, signing_1.secureStringEqual)(String(payload.signature ?? ''), expectedSignature)) {
|
|
88
|
+
throw new Error('Invalid eSewa callback signature');
|
|
89
|
+
}
|
|
90
|
+
if (String(payload.transaction_uuid) !== merchantReference) {
|
|
91
|
+
throw new Error('eSewa callback transaction does not match the payment attempt');
|
|
92
|
+
}
|
|
93
|
+
if ((0, amount_1.decimalToMinorUnits)(String(payload.total_amount)) !== expectedAmount) {
|
|
94
|
+
throw new Error('eSewa callback amount does not match the order');
|
|
95
|
+
}
|
|
96
|
+
return payload;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.EsewaProvider = EsewaProvider;
|
|
100
|
+
function mapEsewaStatus(status) {
|
|
101
|
+
switch (status.trim().toUpperCase()) {
|
|
102
|
+
case 'COMPLETE':
|
|
103
|
+
case 'SUCCESS': return 'settled';
|
|
104
|
+
case 'PENDING':
|
|
105
|
+
case 'BOOKED':
|
|
106
|
+
case 'AMBIGUOUS': return 'pending';
|
|
107
|
+
case 'FULL_REFUND':
|
|
108
|
+
case 'REVERTED': return 'refunded';
|
|
109
|
+
case 'PARTIAL_REFUND': return 'partially-refunded';
|
|
110
|
+
case 'CANCELED':
|
|
111
|
+
case 'CANCELLED': return 'cancelled';
|
|
112
|
+
case 'NOT_FOUND':
|
|
113
|
+
case 'FAILED': return 'failed';
|
|
114
|
+
default: return 'unknown';
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=esewa.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esewa.provider.js","sourceRoot":"","sources":["../../src/providers/esewa.provider.ts"],"names":[],"mappings":";;;AAsHA,wCAgBC;AA9HD,qCAAoE;AACpE,+CAAkD;AAClD,uCAAgE;AAUhE,MAAa,aAAa;IAKxB,YACmB,OAA2B,EAC3B,OAAO,IAAI,+BAAiB,EAAE;QAD9B,YAAO,GAAP,OAAO,CAAoB;QAC3B,SAAI,GAAJ,IAAI,CAA0B;QANxC,SAAI,GAAG,OAAgB,CAAC;QAQ/B,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,KAAK,YAAY,CAAC;QACxD,IAAI,CAAC,OAAO,GAAG,UAAU;YACvB,CAAC,CAAC,iDAAiD;YACnD,CAAC,CAAC,oDAAoD,CAAC;QACzD,IAAI,CAAC,SAAS,GAAG,UAAU;YACzB,CAAC,CAAC,mDAAmD;YACrD,CAAC,CAAC,sDAAsD,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,KAA2B;QACxC,MAAM,WAAW,GAAG,IAAA,4BAAmB,EAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACtD,MAAM,gBAAgB,GAAG,4CAA4C,CAAC;QACtE,MAAM,OAAO,GAAG,gBAAgB,WAAW,qBAAqB,KAAK,CAAC,SAAS,iBAAiB,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QAC3H,MAAM,MAAM,GAAG;YACb,MAAM,EAAE,WAAW;YACnB,UA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OAAO,SAAkB,CAAC;QAC5C,KAAK,aAAa,CAAC;QACnB,KAAK,UAAU,CAAC,CAAC,OAAO,UAAmB,CAAC;QAC5C,KAAK,gBAAgB,CAAC,CAAC,OAAO,oBAA6B,CAAC;QAC5D,KAAK,UAAU,CAAC;QAChB,KAAK,WAAW,CAAC,CAAC,OAAO,WAAoB,CAAC;QAC9C,KAAK,WAAW,CAAC;QACjB,KAAK,QAAQ,CAAC,CAAC,OAAO,QAAiB,CAAC;QACxC,OAAO,CAAC,CAAC,OAAO,SAAkB,CAAC;IACrC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.PaymentHttpClient = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const provider_error_1 = require("./provider-error");
|
|
12
|
+
let PaymentHttpClient = class PaymentHttpClient {
|
|
13
|
+
async request(url, init, timeoutMs = 10_000) {
|
|
14
|
+
const controller = new AbortController();
|
|
15
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
16
|
+
try {
|
|
17
|
+
const response = await fetch(url, { ...init, redirect: 'error', signal: controller.signal });
|
|
18
|
+
const text = await response.text();
|
|
19
|
+
let body;
|
|
20
|
+
try {
|
|
21
|
+
body = text ? JSON.parse(text) : {};
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
body = { detail: text.slice(0, 500) };
|
|
25
|
+
}
|
|
26
|
+
if (!response.ok) {
|
|
27
|
+
throw new provider_error_1.PaymentProviderError(`Provider returned HTTP ${response.status}`, response.status, body);
|
|
28
|
+
}
|
|
29
|
+
return body;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
if (error instanceof provider_error_1.PaymentProviderError)
|
|
33
|
+
throw error;
|
|
34
|
+
const message = error instanceof Error ? error.message : 'Unknown provider network error';
|
|
35
|
+
throw new provider_error_1.PaymentProviderError(`Provider request failed: ${message}`);
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
clearTimeout(timeout);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
exports.PaymentHttpClient = PaymentHttpClient;
|
|
43
|
+
exports.PaymentHttpClient = PaymentHttpClient = __decorate([
|
|
44
|
+
(0, common_1.Injectable)()
|
|
45
|
+
], PaymentHttpClient);
|
|
46
|
+
//# sourceMappingURL=http-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-client.js","sourceRoot":"","sources":["../../src/providers/http-client.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,qDAAwD;AAGjD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC5B,KAAK,CAAC,OAAO,CAAI,GAAW,EAAE,IAAiB,EAAE,SAAS,GAAG,MAAM;QACjE,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,SAAS,CAAC,CAAC;QAChE,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;YAC7F,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,IAAI,IAAa,CAAC;YAClB,IAAI,CAAC;gBACH,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACtC,CAAC;YAAC,MAAM,CAAC;gBACP,IAAI,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;YACxC,CAAC;YACD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,MAAM,IAAI,qCAAoB,CAAC,0BAA0B,QAAQ,CAAC,MAAM,EAAE,EAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACrG,CAAC;YACD,OAAO,IAAS,CAAC;QACnB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,qCAAoB;gBAAE,MAAM,KAAK,CAAC;YACvD,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,gCAAgC,CAAC;YAC1F,MAAM,IAAI,qCAAoB,CAAC,4BAA4B,OAAO,EAAE,CAAC,CAAC;QACxE,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;CACF,CAAA;AAzBY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CAyB7B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { KhaltiPluginOptions } from '../config';
|
|
2
|
+
import type { InitiatePaymentInput, NepalPaymentProvider, PaymentInitiation, RefundPaymentInput, RefundResult, VerifiedPayment, VerifyPaymentInput } from '../types';
|
|
3
|
+
import { PaymentHttpClient } from './http-client';
|
|
4
|
+
export declare class KhaltiProvider implements NepalPaymentProvider {
|
|
5
|
+
private readonly options;
|
|
6
|
+
private readonly http;
|
|
7
|
+
readonly code: "khalti";
|
|
8
|
+
private readonly baseUrl;
|
|
9
|
+
constructor(options: KhaltiPluginOptions, http?: PaymentHttpClient);
|
|
10
|
+
initiate(input: InitiatePaymentInput): Promise<PaymentInitiation>;
|
|
11
|
+
verify(input: VerifyPaymentInput): Promise<VerifiedPayment>;
|
|
12
|
+
refund(input: RefundPaymentInput): Promise<RefundResult>;
|
|
13
|
+
private headers;
|
|
14
|
+
}
|
|
15
|
+
export declare function mapKhaltiStatus(status: string): "pending" | "settled" | "failed" | "cancelled" | "expired" | "partially-refunded" | "refunded" | "unknown";
|