transbank-sdk
Version:
Transbank SDK for Node.js
88 lines (87 loc) • 4.34 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var base_transaction_1 = __importDefault(require("../common/base_transaction"));
var options_1 = __importDefault(require("../common/options"));
var requests_1 = require("./requests");
var request_service_1 = __importDefault(require("../common/request_service"));
var environment_1 = __importDefault(require("./common/environment"));
var Inscription = /** @class */ (function (_super) {
__extends(Inscription, _super);
/**
* Constructor class Inscription PatpassComercio.
* @param options You can pass options to use a custom configuration.
*/
function Inscription(options) {
return _super.call(this, options) || this;
}
/**
* Creates and returns an instance of `Inscription` configured for the integration environment.
*
* @param commerceCode The commerce code.
* @param apiKey The API key used for authentication.
* @return A new instance of `Inscription` configured for the test environment (Environment.Integration).
*/
Inscription.buildForIntegration = function (commerceCode, apiKey) {
return new Inscription(new options_1.default(commerceCode, apiKey, environment_1.default.Integration));
};
/**
* Creates and returns an instance of `Inscription` configured for the production environment.
*
* @param commerceCode The commerce code.
* @param apiKey The API key used for authentication.
* @return A new instance of `Inscription` configured for the production environment (Environment.Production).
*/
Inscription.buildForProduction = function (commerceCode, apiKey) {
return new Inscription(new options_1.default(commerceCode, apiKey, environment_1.default.Production));
};
/**
* Starts a card inscription process
* @param url URL to which Transbank will redirect after cardholder finish enrolling their card
* @param name Client's name
* @param lastName Client's lastName
* @param secondLastName Client's second lastName
* @param rut Commerce's Rut
* @param serviceId Service Id
* @param finalUrl URL to which Transbank will redirect after showing the receipt
* @param maxAmount Max amount
* @param phone Contact's phone
* @param cellPhone Contact's cellphone
* @param patpassName Patpass name
* @param personEmail Contact's email
* @param commerceEmail Commerce's email
* @param address Contact's city
* @param city Contact's city
*/
Inscription.prototype.start = function (url, name, lastName, secondLastName, rut, serviceId, finalUrl, maxAmount, phone, cellPhone, patpassName, personEmail, commerceEmail, address, city) {
var startRequest = new requests_1.StartRequest(url, name, lastName, secondLastName, rut, serviceId, finalUrl, this.options.commerceCode, maxAmount, phone, cellPhone, patpassName, personEmail, commerceEmail, address, city);
return request_service_1.default.performPatpass(startRequest, this.options);
};
/**
* This finalizes the card enrolling process
* @param token Unique inscription identifier
*/
Inscription.prototype.status = function (token) {
return request_service_1.default.performPatpass(new requests_1.StatusRequest(token), this.options);
};
return Inscription;
}(base_transaction_1.default));
;
exports.default = Inscription;