UNPKG

@atomixdesign/nodepay-paystream

Version:

Nodepay strategy for the Paystream payment gateway.

64 lines (63 loc) 3.27 kB
"use strict"; 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 moment_1 = __importDefault(require("moment")); var log = debug_1.default('nodepay:paystream'); /** @internal */ var CreditCardDTO = /** @class */ (function () { function CreditCardDTO(creditCard) { log("building " + this.constructor.name); log({ creditCard: creditCard }); this.card_number = creditCard.cardNumber; this.card_holder = creditCard.cardHolderName; this.cvv = creditCard.CCV; this.card_expiry = creditCard.expiryDateMonth + "/" + moment_1.default(creditCard.expiryDateYear, 'YYYY').year(); } __decorate([ class_validator_1.IsNotEmpty({ message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotEmpty, 'card_number'), }), class_validator_1.IsCreditCard({ message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotACreditCard, 'card_number'), }), __metadata("design:type", String) ], CreditCardDTO.prototype, "card_number", void 0); __decorate([ class_validator_1.IsNotEmpty({ message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotEmpty, 'card_holder'), }), __metadata("design:type", String) ], CreditCardDTO.prototype, "card_holder", void 0); __decorate([ class_validator_1.Length(3, 4, { message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.LengthOutOfBounds, 'cvv'), }), class_validator_1.IsNumberString(undefined, { message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.NotANumber, 'cvv'), }), __metadata("design:type", String) ], CreditCardDTO.prototype, "cvv", void 0); __decorate([ class_validator_1.Length(7, 7, { message: validation_1.ErrorFactory.getErrorMessage(validation_1.ErrorType.LengthOutOfBounds, 'card_expiry'), }), __metadata("design:type", String) ], CreditCardDTO.prototype, "card_expiry", void 0); return CreditCardDTO; }()); exports.CreditCardDTO = CreditCardDTO;