@atomixdesign/nodepay-ezidebit
Version:
Nodepay strategy for the Ezidebit payment gateway.
108 lines (107 loc) • 5.68 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.OnceOffChargeDTO = void 0;
var class_validator_1 = require("class-validator");
var validation_1 = require("@atomixdesign/nodepay-core/build/validation");
var debug_1 = __importDefault(require("debug"));
var log = debug_1.default('nodepay:ezidebit');
/** @internal */
var OnceOffChargeDTO = /** @class */ (function () {
function OnceOffChargeDTO(charge) {
// * CustomerName
this.CustomerName = '';
log("building " + this.constructor.name);
log({ charge: charge });
this.CreditCardNumber = charge.CreditCardNumber;
this.CreditCardExpiryMonth = charge.CreditCardExpiryMonth;
this.CreditCardExpiryYear = charge.CreditCardExpiryYear;
this.CreditCardCCV = charge.CreditCardCCV;
this.NameOnCreditCard = charge.NameOnCreditCard;
this.PaymentAmountInCents = charge.PaymentAmountInCents;
this.CustomerName = charge.CustomerName;
this.PaymentReference = charge.PaymentReference;
}
__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)
], OnceOffChargeDTO.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)
], OnceOffChargeDTO.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)
], OnceOffChargeDTO.prototype, "CreditCardExpiryYear", void 0);
__decorate([
class_validator_1.Length(3, 4, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.LengthOutOfBounds, 'CreditCardCCV'),
}),
class_validator_1.IsNumberString(undefined, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotANumber, 'CreditCardCCV'),
}),
__metadata("design:type", String)
], OnceOffChargeDTO.prototype, "CreditCardCCV", 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)
], OnceOffChargeDTO.prototype, "NameOnCreditCard", void 0);
__decorate([
class_validator_1.IsNumber(undefined, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotANumber, 'PaymentAmountInCents'),
}),
__metadata("design:type", Number)
], OnceOffChargeDTO.prototype, "PaymentAmountInCents", void 0);
__decorate([
class_validator_1.MaxLength(255, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.FieldTooLong, 'CustomerName'),
}),
__metadata("design:type", Object)
], OnceOffChargeDTO.prototype, "CustomerName", void 0);
__decorate([
class_validator_1.IsNotEmpty({
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotEmpty, 'PaymentReference'),
}),
class_validator_1.MaxLength(50, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.FieldTooLong, 'PaymentReference'),
}),
__metadata("design:type", String)
], OnceOffChargeDTO.prototype, "PaymentReference", void 0);
return OnceOffChargeDTO;
}());
exports.OnceOffChargeDTO = OnceOffChargeDTO;