@atomixdesign/nodepay-pay-way
Version:
Nodepay strategy for the WestPac PayWay payment gateway.
77 lines (76 loc) • 3.94 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 validation_1 = require("@atomixdesign/nodepay-core/build/validation");
var debug_1 = __importDefault(require("debug"));
var log = debug_1.default('nodepay:pay-way');
/** @internal */
var CreditCardDTO = /** @class */ (function () {
function CreditCardDTO(creditCard) {
log("building " + this.constructor.name);
log({ creditCard: creditCard });
this.paymentMethod = 'creditCard';
this.cardNumber = creditCard.cardNumber;
this.cardholderName = creditCard.cardHolderName;
this.cvn = creditCard.CCV;
this.expiryDateMonth = creditCard.expiryDateMonth;
this.expiryDateYear = creditCard.expiryDateYear.slice(-2);
}
__decorate([
class_validator_1.IsNotEmpty({
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotEmpty, 'cardNumber'),
}),
class_validator_1.IsCreditCard({
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotACreditCard, 'cardNumber'),
}),
__metadata("design:type", String)
], CreditCardDTO.prototype, "cardNumber", void 0);
__decorate([
class_validator_1.IsNotEmpty({
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotEmpty, 'cardholderName'),
}),
__metadata("design:type", String)
], CreditCardDTO.prototype, "cardholderName", void 0);
__decorate([
class_validator_1.Length(3, 4, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.LengthOutOfBounds, 'cvn'),
}),
class_validator_1.IsNumberString(undefined, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotANumber, 'cvn'),
}),
__metadata("design:type", String)
], CreditCardDTO.prototype, "cvn", void 0);
__decorate([
class_validator_1.Length(2, 2, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.LengthOutOfBounds, 'expiryDateMonth'),
}),
class_validator_1.IsNumberString(undefined, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotANumber, 'expiryDateMonth'),
}),
__metadata("design:type", String)
], CreditCardDTO.prototype, "expiryDateMonth", void 0);
__decorate([
class_validator_1.Length(2, 2, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.LengthOutOfBounds, 'expiryDateYear'),
}),
class_validator_1.IsNumberString(undefined, {
message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotANumber, 'expiryDateYear'),
}),
__metadata("design:type", String)
], CreditCardDTO.prototype, "expiryDateYear", void 0);
return CreditCardDTO;
}());
exports.CreditCardDTO = CreditCardDTO;