コード例 #1
0
ファイル: AcquirerApi.cs プロジェクト: olavorn/desafios
        public async Task Process(ICardTransaction payment)
        {
            if (payment.CardDigits?.Length != 16)
            {
                throw new System.Exception("Acquirer Error: Card Invalid");
            }

            if (payment.CardSecurityNumber?.Length != 3)
            {
                throw new System.Exception("Acquirer Error: Security Number Incorrect");
            }

            if (payment.CardExpirationDate?.Length != 7)
            {
                throw new System.Exception("Acquirer Error: Card Expiration Date Invalid. Should be MM/YYYY");
            }

            payment.Result = Enums.PaymentResponse.Approved;

            await Task.CompletedTask;
        }
コード例 #2
0
        public async Task <bool> Process(ICardTransaction payment)
        {
            await _acquirerApi.Process(payment).ConfigureAwait(false);

            return(payment.Result == Enums.PaymentResponse.Approved);
        }