vendure-plugin-nowpayments
Version:
A cryptocurrency payment gateway plugin for Vendure that integrates with NOWPayments.io, enabling your store to accept payments in Bitcoin, Ethereum, and 100+ other cryptocurrencies.
65 lines (64 loc) • 2.81 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "NOWPaymentsController", {
enumerable: true,
get: function() {
return NOWPaymentsController;
}
});
const _ts_decorate = require("@swc/helpers/_/_ts_decorate");
const _ts_metadata = require("@swc/helpers/_/_ts_metadata");
const _ts_param = require("@swc/helpers/_/_ts_param");
const _common = require("@nestjs/common");
const _express = require("express");
const _core = require("@vendure/core");
const _nowpaymentsservice = require("./nowpayments.service");
const _types = require("./types");
const _constants = require("./constants");
let NOWPaymentsController = class NOWPaymentsController {
async handleIpn(body, signature, res) {
try {
// Create a proper RequestContext for the IPN processing
const ctx = await this.requestContextService.create({
apiType: 'admin'
});
const success = await this.nowPaymentsService.processIpn(ctx, body, signature);
if (success) {
res.status(_common.HttpStatus.OK).send('IPN processed successfully');
} else {
res.status(_common.HttpStatus.BAD_REQUEST).send('IPN processing failed');
}
} catch (error) {
_core.Logger.error('IPN processing error', _constants.loggerCtx, error instanceof Error ? error.message : String(error));
res.status(_common.HttpStatus.INTERNAL_SERVER_ERROR).send('Internal server error');
}
}
constructor(nowPaymentsService, requestContextService){
this.nowPaymentsService = nowPaymentsService;
this.requestContextService = requestContextService;
}
};
_ts_decorate._([
(0, _common.Post)('ipn'),
_ts_param._(0, (0, _common.Body)()),
_ts_param._(1, (0, _common.Headers)('x-nowpayments-sig')),
_ts_param._(2, (0, _common.Res)()),
_ts_metadata._("design:type", Function),
_ts_metadata._("design:paramtypes", [
typeof _types.NOWPaymentsIPNData === "undefined" ? Object : _types.NOWPaymentsIPNData,
String,
typeof _express.Response === "undefined" ? Object : _express.Response
]),
_ts_metadata._("design:returntype", Promise)
], NOWPaymentsController.prototype, "handleIpn", null);
NOWPaymentsController = _ts_decorate._([
(0, _common.Controller)('nowpayments'),
_ts_metadata._("design:type", Function),
_ts_metadata._("design:paramtypes", [
typeof _nowpaymentsservice.NOWPaymentsService === "undefined" ? Object : _nowpaymentsservice.NOWPaymentsService,
typeof _core.RequestContextService === "undefined" ? Object : _core.RequestContextService
])
], NOWPaymentsController);
//# sourceMappingURL=nowpayments.controller.js.map