@atomixdesign/nodepay-ezidebit
Version:
Nodepay strategy for the Ezidebit payment gateway.
118 lines (117 loc) • 6.2 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CreditCardDTO = void 0;
var class_validator_1 = require("class-validator");
var IsOptionalIfEmpty_1 = require("./IsOptionalIfEmpty");
var validation_1 = require("@atomixdesign/nodepay-core/build/validation");
var moment_1 = __importDefault(require("moment"));
var debug_1 = __importDefault(require("debug"));
var log = debug_1.default('nodepay:ezidebit');
/** @internal */
var CreditCardDTO = /** @class */ (function () {
function CreditCardDTO(creditCard) {
var _a, _b;
// * EziDebitCustomerID
this.EziDebitCustomerID = '';
// * YourSystemReference
this.YourSystemReference = '';
// * Username
this.Username = '';
log("building " + this.constructor.name);
log({ creditCard: creditCard });
if (!creditCard.YourSystemReference)
this.EziDebitCustomerID = creditCard.EziDebitCustomerID;
if (!creditCard.EziDebitCustomerID)
this.YourSystemReference = creditCard.YourSystemReference;
this.CreditCardNumber = creditCard.CreditCardNumber;
this.CreditCardExpiryMonth = creditCard.CreditCardExpiryMonth;
this.CreditCardExpiryYear = moment_1.default(creditCard.CreditCardExpiryYear, 'YYYY').year().toString();
this.NameOnCreditCard = creditCard.NameOnCreditCard;
this.Reactivate = (_a = creditCard.Reactivate) !== null && _a !== void 0 ? _a : 'YES';
this.Username = (_b = creditCard.Username) !== null && _b !== void 0 ? _b : '';
}
__decorate([
IsOptionalIfEmpty_1.IsOptionalIfEmpty(),
class_validator_1.IsNumberString(undefined, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotANumber, 'EziDebitCustomerID'),
}),
class_validator_1.MaxLength(50, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.FieldTooLong, 'EziDebitCustomerID'),
}),
__metadata("design:type", Object)
], CreditCardDTO.prototype, "EziDebitCustomerID", void 0);
__decorate([
class_validator_1.IsNotEmpty({
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotEmpty, 'CreditCardNumber'),
}),
class_validator_1.IsCreditCard({
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotACreditCard, 'CreditCardNumber'),
}),
class_validator_1.MaxLength(16, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.FieldTooLong, 'CreditCardNumber'),
}),
__metadata("design:type", String)
], CreditCardDTO.prototype, "CreditCardNumber", void 0);
__decorate([
class_validator_1.Length(2, 2, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.LengthOutOfBounds, 'CreditCardExpiryMonth'),
}),
class_validator_1.IsNumberString(undefined, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotANumber, 'CreditCardExpiryMonth'),
}),
__metadata("design:type", String)
], CreditCardDTO.prototype, "CreditCardExpiryMonth", void 0);
__decorate([
class_validator_1.Length(4, 4, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.LengthOutOfBounds, 'CreditCardExpiryYear'),
}),
class_validator_1.IsNumberString(undefined, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotANumber, 'CreditCardExpiryYear'),
}),
__metadata("design:type", String)
], CreditCardDTO.prototype, "CreditCardExpiryYear", void 0);
__decorate([
class_validator_1.IsNotEmpty({
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotEmpty, 'NameOnCreditCard'),
}),
class_validator_1.MaxLength(100, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.FieldTooLong, 'NameOnCreditCard'),
}),
__metadata("design:type", String)
], CreditCardDTO.prototype, "NameOnCreditCard", void 0);
__decorate([
class_validator_1.IsNotEmpty({
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotEmpty, 'Reactivate'),
}),
class_validator_1.IsIn(['YES', 'NO'], {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotInAllowedSet, 'Reactivate'),
}),
__metadata("design:type", String)
], CreditCardDTO.prototype, "Reactivate", void 0);
__decorate([
class_validator_1.MaxLength(50, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.FieldTooLong, 'YourSystemReference'),
}),
__metadata("design:type", Object)
], CreditCardDTO.prototype, "YourSystemReference", void 0);
__decorate([
class_validator_1.MaxLength(50, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.FieldTooLong, 'Username'),
}),
__metadata("design:type", Object)
], CreditCardDTO.prototype, "Username", void 0);
return CreditCardDTO;
}());
exports.CreditCardDTO = CreditCardDTO;