@hachther/mesomb
Version:
JS client for browser to perform mobile payment operation with MeSomb
80 lines (79 loc) • 2.62 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ATransaction = void 0;
var Location_1 = require("./Location");
/**
* Abstract class for transaction
*
* @abstract
*
* @property {string} pk - Primary key of the transaction
* @property {string} status - Status of the transaction
* @property {string} type - Type of the transaction
* @property {number} amount - Amount of the transaction
* @property {number} fees - Fees of the transaction
* @property {string} bParty - B party of the transaction
* @property {string} message - Message of the transaction
* @property {string} service - Service of the transaction
* @property {string} reference - Reference of the transaction
* @property {Date} date - Date of the transaction
* @property {string} country - Country of the transaction
* @property {string} currency - Currency of the transaction
* @property {string} finTrxId - Financial transaction ID of the transaction
* @property {number} trxamount - Total transaction amount
* @property {Location} location - Location of the transaction
*/
var ATransaction = /** @class */ (function () {
function ATransaction(data) {
this.data = data;
this.pk = data.pk;
this.status = data.status;
this.type = data.type;
this.amount = data.amount;
this.fees = data.fees;
this.bParty = data.b_party;
this.message = data.message;
this.service = data.service;
this.reference = data.reference;
this.date = new Date(data.ts);
this.country = data.country;
this.currency = data.currency;
this.finTrxId = data.fin_trx_id;
this.trxamount = data.trxamount;
if (data.location) {
this.location = new Location_1.default(data.location);
}
}
/**
* Check if transaction is success
*
* @return {boolean}
*/
ATransaction.prototype.isSuccess = function () {
return this.status === 'SUCCESS';
};
/**
* Check if transaction is pending
*
* @return {boolean}
*/
ATransaction.prototype.isPending = function () {
return this.status === 'PENDING';
};
/**
* Check if transaction is failed
*
* @return {boolean}
*/
ATransaction.prototype.isFailed = function () {
return this.status === 'FAILED';
};
/**
* @return {Record<string, any>} - data go from the server
*/
ATransaction.prototype.getData = function () {
return this.data;
};
return ATransaction;
}());
exports.ATransaction = ATransaction;