Пример #1
0
        public void SendTest_Credit_Approved()
        {
            // Test setup.
            const string transId = "????";               // A settled eCheck transaction id
            const decimal creditAmount = (decimal) 1.50; // Amount to request credit for; less than the settled amount minus refund amount.
            const string accountType = "eCheck";         // The account type used in the transaction, such as eCheck
            const string accountLast4Digits = "????";    // The last 4 digitals of the account number used in the transaction, such as 3456

            //check ApiLoginid / TransactionKey
            var sError = CheckApiLoginTransactionKey();
            Assert.IsTrue(sError == "", sError);

            var responseString = "1|1|1|This transaction has been approved.||P|2207741772||Credit transaction approved testing|"+creditAmount+"|CC|credit||||||||||||[email protected]||||||||||||||574B2D5282D8A2914AEB7272AECD4B71|||||||||||||XXXX"+accountLast4Digits+"|"+accountType+"||||||||||||||||";
            LocalRequestObject.ResponseString = responseString;
            IGatewayResponse expected = new GatewayResponse(responseString.Split('|'));

            var target = new Gateway(ApiLogin, TransactionKey, true);

            IGatewayRequest request = new EcheckCreditRequest(transId, creditAmount, accountLast4Digits);
            const string description = "Credit transaction approved testing";

            var actual = target.Send(request, description);

            Assert.AreEqual(expected.Amount, actual.Amount);
            Assert.AreEqual(expected.Approved, actual.Approved);
            Assert.AreEqual(expected.CardNumber, actual.CardNumber);
            Assert.AreEqual(expected.Message, actual.Message);
            Assert.AreEqual(expected.ResponseCode, actual.ResponseCode);

            Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
            Assert.Greater(long.Parse(actual.TransactionID),  0);
        }
Пример #2
0
        public TransactionResponse RefundCheck(string reference, decimal amt, string lastDigits = "")
        {
            if (string.IsNullOrWhiteSpace(lastDigits))
                throw new ArgumentException("Last four of bank account number are required for refunds against Authorize.net", "lastDigits");

            var req = new EcheckCreditRequest(reference, amt, lastDigits);
            var response = Gateway.Send(req);

            return new TransactionResponse
            {
                Approved = response.Approved,
                AuthCode = response.AuthorizationCode,
                Message = response.Message,
                TransactionId = response.TransactionID
            };
        }