private IEnumerable <IGatewayResponse> SendGetTransactionsRequest(AuthorizeDotNetRequest request)
        {
            var result = string.Empty;
            //IGatewayResponse gatewayResponse;
            var transactions = new List <Model.Gateway.Payment>();

            var authentication = new MerchantAuthenticationType();

            authentication.name           = request.KeyValues[AuthorizeDotNetApi.ApiLogin];
            authentication.transactionKey = request.KeyValues[AuthorizeDotNetApi.TransactionKey];

            string id = request.KeyValues[AuthorizeDotNetApi.BatchId];

            using (var webService = new RevStack.AuthorizeDotNet.net.authorize.api.Service())
            {
                webService.Url = request.PostUrl;
                GetTransactionListRequestType listType = new GetTransactionListRequestType();
                listType.batchId = id;
                GetTransactionListResponseType response = webService.GetTransactionList(authentication, listType, null);
                char del = request.KeyValues[AuthorizeDotNetApi.DelimitCharacter].ToCharArray()[0];

                if (response == null)
                {
                    return(transactions);
                }

                foreach (var transaction in response.transactions)
                {
                    var gatewayResponse = new Model.Gateway.Payment(transaction);
                    transactions.Add(gatewayResponse);
                }
            }

            return(transactions);
        }
Ejemplo n.º 2
0
        public T Charge <T>(ICharge charge) where T : IPayment
        {
            var url = _context.Url + "/quickbooks/v4/payments/charges";

            var payment = new Model.Gateway.Payment();

            payment.Amount   = charge.Amount;
            payment.Currency = _context.Currency;

            var address = new Model.Gateway.Address();

            address.City          = charge.Customer.City;
            address.Country       = charge.Customer.Country;
            address.PostalCode    = charge.Customer.Zipcode;
            address.Region        = charge.Customer.StateOrProvince;
            address.StreetAddress = charge.Customer.Address;

            var creditCard = new Model.Gateway.CreditCard();

            creditCard.Name     = charge.Customer.FirstName + " " + charge.Customer.LastName;
            creditCard.Address  = address;
            creditCard.Number   = charge.CreditCard.CardNumber;
            creditCard.ExpMonth = charge.CreditCard.ExpirationMonth;
            creditCard.ExpYear  = charge.CreditCard.ExpirationYear;
            creditCard.CVC      = charge.CreditCard.CVV;
            payment.Card        = creditCard;

            var body     = JsonConvert.SerializeObject(payment);
            var response = _context.SendRequest(url, "POST", body, new Dictionary <string, string>(), null);

            return(JsonConvert.DeserializeObject <T>(response.Body.ToString()));
        }
        private IGatewayResponse SendGetTransactionDetailsRequest(AuthorizeDotNetRequest request)
        {
            var result = string.Empty;
            IGatewayResponse gatewayResponse;

            var authentication = new MerchantAuthenticationType();

            authentication.name           = request.KeyValues[AuthorizeDotNetApi.ApiLogin];
            authentication.transactionKey = request.KeyValues[AuthorizeDotNetApi.TransactionKey];

            string id = request.KeyValues[AuthorizeDotNetApi.TransactionId];

            using (var webService = new RevStack.AuthorizeDotNet.net.authorize.api.Service())
            {
                webService.Url = request.PostUrl;
                GetTransactionDetailsResponseType response = webService.GetTransactionDetails(authentication, id, null);
                char del = request.KeyValues[AuthorizeDotNetApi.DelimitCharacter].ToCharArray()[0];
                gatewayResponse = new Model.Gateway.Payment(response.transaction);
            }

            return(gatewayResponse);
        }