Ejemplo n.º 1
0
        public void Void(Order order, ref CancelPaymentResult cancelPaymentResult)
        {
            var usaepay = new USAePayAPI.USAePay();

            usaepay.SourceKey = sourceKey;
            usaepay.Pin       = pin;

            try
            {
                usaepay.Void(order.AuthorizationTransactionId);

                switch (usaepay.ResultCode)
                {
                case "A":
                    cancelPaymentResult.PaymentStatus = PaymentStatusEnum.Voided;
                    //cancelPaymentResult.AuthorizationTransactionId = usaepay.RefNum;
                    break;

                case "D":
                    cancelPaymentResult.Error     = "Void Declined: " + usaepay.ErrorMesg;
                    cancelPaymentResult.FullError = "Void Declined : " + usaepay.ErrorMesg;
                    break;

                default:
                    cancelPaymentResult.Error     = "Error during void";
                    cancelPaymentResult.FullError = "Error during void: " + usaepay.ErrorMesg;
                    break;
                }
            }
            catch
            {
                cancelPaymentResult.Error     = "Error during void";
                cancelPaymentResult.FullError = "Error during void";
            }
        }
Ejemplo n.º 2
0
        private Response ParseResponse(USAePayAPI.USAePay usaepay)
        {
            Response response = new Response();

            response.AuthCode           = usaepay.AuthCode;
            response.TransactionID      = usaepay.ResultRefNum;
            response.ReasonText         = usaepay.ErrorCode + "" + usaepay.ErrorMesg;
            response.GatewayResponseRaw = usaepay.RawResult;
            if (usaepay.ResultCode == "A")
            {
                response.ResponseType = TransactionResponseType.Approved;
            }
            else if (usaepay.ResultCode == "D")
            {
                response.ResponseType = TransactionResponseType.Denied;
            }
            else
            {
                response.ResponseType = TransactionResponseType.Error;
            }

            return(response);
        }
Ejemplo n.º 3
0
        public void Capture(Order order, ref ProcessPaymentResult processPaymentResult)
        {
            var usaepay = new USAePayAPI.USAePay();

            usaepay.SourceKey = sourceKey;
            usaepay.Pin       = pin;

            try
            {
                usaepay.Capture(order.AuthorizationTransactionId);

                switch (usaepay.ResultCode)
                {
                case "A":
                    processPaymentResult.PaymentStatus = PaymentStatusEnum.Paid;
                    processPaymentResult.AVSResult     = usaepay.AvsResult;
                    processPaymentResult.AuthorizationTransactionCode = usaepay.AuthCode;
                    processPaymentResult.AuthorizationTransactionId   = usaepay.RefNum;
                    break;

                case "D":
                    processPaymentResult.Error     = "Declined: " + usaepay.ErrorMesg;
                    processPaymentResult.FullError = "Declined : " + usaepay.ErrorMesg;
                    break;

                default:
                    processPaymentResult.Error     = "Error during checkout";
                    processPaymentResult.FullError = "Error during checkout: " + usaepay.ErrorMesg;
                    break;
                }
            }
            catch
            {
                processPaymentResult.Error     = "Error during capture";
                processPaymentResult.FullError = "Error during capture";
            }
        }
Ejemplo n.º 4
0
        protected USAePayAPI.USAePay BuildRequestPost(Request request)
        {
            USAePayAPI.USAePay usaepay = new USAePayAPI.USAePay();

            //Create parameters from objProvider settings

            //Init object with our source key and pin from usaepay.com
            usaepay.SourceKey  = gatewaySettings.SourceKey;
            usaepay.Pin        = gatewaySettings.Pin;
            usaepay.GatewayURL = gatewaySettings.TransactionURL;

            //Create parameters from request

            usaepay.BillingFirstName = request.FirstName;
            usaepay.BillingLastName  = request.LastName;
            usaepay.BillingStreet    = request.Address1;
            usaepay.BillingStreet2   = request.Address2;
            usaepay.BillingZip       = request.ZipCode;
            usaepay.BillingState     = request.State;
            usaepay.BillingCountry   = request.CompanyName;
            usaepay.BillingPhone     = request.Phone;

            usaepay.ShippingFirstName = request.ShipToFirstName;
            usaepay.ShippingLastName  = request.ShipToLastName;
            usaepay.ShippingStreet    = request.ShipToAddress;
            usaepay.ShippingZip       = request.ShipToZipCode;
            usaepay.ShippingState     = request.ShipToState;
            usaepay.ShippingCountry   = request.ShipToCountry;


            usaepay.Amount      = Convert.ToDecimal(request.Amount);
            usaepay.Description = request.TransactionDescription;
            usaepay.CardHolder  = request.FirstName + " " + request.LastName;
            usaepay.CardNumber  = request.CardNumber;
            usaepay.Cavv        = request.CardCvv;
            usaepay.CardExp     = request.ExpireDate.ToString("MMyy"); // Format specify. Make sure its 4 digit
            usaepay.CustID      = request.CustomerID;
            usaepay.OrderID     = request.InvoiceNumber;

            try
            {
                if (gatewaySettings.RequestType.ToLower().Equals("preauth"))
                {
                    usaepay.AuthOnly(); //PreAuth Transaction
                }
                else if (gatewaySettings.RequestType.ToLower().Equals("sale"))
                {
                    usaepay.Sale(); //Posting Transaction
                }
                else if (gatewaySettings.RequestType.ToLower().Equals("capture"))
                {
                    usaepay.Capture();//Posting Transaction
                }
                else
                {
                    usaepay.Sale();// By default we will consider sale. //Posting Transaction
                }
            }
            catch (Exception ex)
            {
                throw new PaymentProviderException(string.Format("An exception occured while creating the post parameters: {0}", ex.Message), ex);
            }

            return(usaepay);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Process payment
        /// </summary>
        /// <param name="paymentInfo">Payment info required for an order processing</param>
        /// <param name="customer">Customer</param>
        /// <param name="OrderGuid">Unique order identifier</param>
        /// <param name="processPaymentResult">Process payment result</param>
        public void ProcessPayment(PaymentInfo paymentInfo, Customer customer, Guid OrderGuid, ref ProcessPaymentResult processPaymentResult)
        {
            TransactMode transactionMode = GetCurrentTransactionMode();

            var usaepay = new USAePayAPI.USAePay();

            usaepay.SourceKey = sourceKey;
            usaepay.Pin       = pin;

            usaepay.OrderID        = OrderGuid.ToString();
            usaepay.Amount         = paymentInfo.OrderTotal;
            usaepay.CardNumber     = paymentInfo.CreditCardNumber;
            usaepay.CardHolder     = paymentInfo.CreditCardName;
            usaepay.CardExp        = GetCardExp(paymentInfo.CreditCardExpireMonth, paymentInfo.CreditCardExpireYear);
            usaepay.BillingStreet  = paymentInfo.BillingAddress.Address1;
            usaepay.BillingStreet2 = paymentInfo.BillingAddress.Address2;
            usaepay.BillingCity    = paymentInfo.BillingAddress.City;
            if (paymentInfo.BillingAddress.StateProvince != null)
            {
                usaepay.BillingState = paymentInfo.BillingAddress.StateProvince.Abbreviation;
            }
            usaepay.BillingZip       = paymentInfo.BillingAddress.ZipPostalCode;
            usaepay.BillingFirstName = paymentInfo.BillingAddress.FirstName;
            usaepay.BillingLastName  = paymentInfo.BillingAddress.LastName;
            usaepay.BillingCompany   = paymentInfo.BillingAddress.Company;

            if (paymentInfo.ShippingAddress != null)
            {
                usaepay.ShippingFirstName = paymentInfo.ShippingAddress.FirstName;
                usaepay.ShippingLastName  = paymentInfo.ShippingAddress.LastName;
                usaepay.ShippingStreet    = paymentInfo.ShippingAddress.Address1;
                usaepay.ShippingStreet2   = paymentInfo.ShippingAddress.Address2;
                usaepay.ShippingCity      = paymentInfo.ShippingAddress.City;
                if (paymentInfo.ShippingAddress.StateProvince != null)
                {
                    usaepay.ShippingState = paymentInfo.ShippingAddress.StateProvince.Abbreviation;
                }
                usaepay.ShippingZip     = paymentInfo.ShippingAddress.ZipPostalCode;
                usaepay.ShippingCompany = paymentInfo.ShippingAddress.Company;
            }

            try
            {
                if (transactionMode == TransactMode.Authorize)
                {
                    usaepay.AuthOnly();
                }
                else
                {
                    usaepay.Sale();
                }


                switch (usaepay.ResultCode)
                {
                case "A":
                    processPaymentResult.PaymentStatus = transactionMode == TransactMode.Authorize ? PaymentStatusEnum.Authorized : PaymentStatusEnum.Paid;
                    processPaymentResult.AVSResult     = usaepay.AvsResult;
                    processPaymentResult.AuthorizationTransactionCode = usaepay.AuthCode;
                    processPaymentResult.AuthorizationTransactionId   = usaepay.RefNum;
                    break;

                case "D":
                    processPaymentResult.Error     = "Declined: " + usaepay.ErrorMesg;
                    processPaymentResult.FullError = "Declined : " + usaepay.ErrorMesg;
                    break;

                default:
                    processPaymentResult.Error     = "Error during checkout";
                    processPaymentResult.FullError = "Error during checkout: " + usaepay.ErrorMesg;
                    break;
                }
            }
            catch (Exception)
            {
                processPaymentResult.Error     = "Error during checkout";
                processPaymentResult.FullError = "Error during checkout";
            }
        }
        public void Void(Order order, ref CancelPaymentResult cancelPaymentResult)
        {
            var usaepay = new USAePayAPI.USAePay();
            usaepay.SourceKey = sourceKey;
            usaepay.Pin = pin;

            try
            {
                usaepay.Void(order.AuthorizationTransactionId);

                switch (usaepay.ResultCode)
                {
                    case "A":
                        cancelPaymentResult.PaymentStatus = PaymentStatusEnum.Voided;
                        //cancelPaymentResult.AuthorizationTransactionId = usaepay.RefNum;
                        break;
                    case "D":
                        cancelPaymentResult.Error = "Void Declined: " + usaepay.ErrorMesg;
                        cancelPaymentResult.FullError = "Void Declined : " + usaepay.ErrorMesg;
                        break;
                    default:
                        cancelPaymentResult.Error = "Error during void";
                        cancelPaymentResult.FullError = "Error during void: " + usaepay.ErrorMesg;
                        break;
                }
            }
            catch
            {
                cancelPaymentResult.Error = "Error during void";
                cancelPaymentResult.FullError = "Error during void";
            }
        }
        /// <summary>
        /// Process payment
        /// </summary>
        /// <param name="paymentInfo">Payment info required for an order processing</param>
        /// <param name="customer">Customer</param>
        /// <param name="OrderGuid">Unique order identifier</param>
        /// <param name="processPaymentResult">Process payment result</param>
        public void ProcessPayment(PaymentInfo paymentInfo, Customer customer, Guid OrderGuid, ref ProcessPaymentResult processPaymentResult)
        {
            TransactMode transactionMode = GetCurrentTransactionMode();

            var usaepay = new USAePayAPI.USAePay();
            usaepay.SourceKey = sourceKey;
            usaepay.Pin = pin;

            usaepay.OrderID = OrderGuid.ToString();
            usaepay.Amount = paymentInfo.OrderTotal;
            usaepay.CardNumber = paymentInfo.CreditCardNumber;
            usaepay.CardHolder = paymentInfo.CreditCardName;
            usaepay.CardExp = GetCardExp(paymentInfo.CreditCardExpireMonth, paymentInfo.CreditCardExpireYear);
            usaepay.BillingStreet = paymentInfo.BillingAddress.Address1;
            usaepay.BillingStreet2 = paymentInfo.BillingAddress.Address2;
            usaepay.BillingCity = paymentInfo.BillingAddress.City;
            if (paymentInfo.BillingAddress.StateProvince != null) usaepay.BillingState = paymentInfo.BillingAddress.StateProvince.Abbreviation;
            usaepay.BillingZip = paymentInfo.BillingAddress.ZipPostalCode;
            usaepay.BillingFirstName = paymentInfo.BillingAddress.FirstName;
            usaepay.BillingLastName = paymentInfo.BillingAddress.LastName;
            usaepay.BillingCompany = paymentInfo.BillingAddress.Company;

            if (paymentInfo.ShippingAddress != null)
            {
                usaepay.ShippingFirstName = paymentInfo.ShippingAddress.FirstName;
                usaepay.ShippingLastName = paymentInfo.ShippingAddress.LastName;
                usaepay.ShippingStreet = paymentInfo.ShippingAddress.Address1;
                usaepay.ShippingStreet2 = paymentInfo.ShippingAddress.Address2;
                usaepay.ShippingCity = paymentInfo.ShippingAddress.City;
                if (paymentInfo.ShippingAddress.StateProvince != null)  usaepay.ShippingState = paymentInfo.ShippingAddress.StateProvince.Abbreviation;
                usaepay.ShippingZip = paymentInfo.ShippingAddress.ZipPostalCode;
                usaepay.ShippingCompany = paymentInfo.ShippingAddress.Company;
            }

            try
            {
                if (transactionMode == TransactMode.Authorize)
                {
                    usaepay.AuthOnly();
                }
                else
                {
                    usaepay.Sale();
                }

                switch (usaepay.ResultCode)
                {
                    case "A":
                        processPaymentResult.PaymentStatus = transactionMode == TransactMode.Authorize ? PaymentStatusEnum.Authorized : PaymentStatusEnum.Paid;
                        processPaymentResult.AVSResult = usaepay.AvsResult;
                        processPaymentResult.AuthorizationTransactionCode = usaepay.AuthCode;
                        processPaymentResult.AuthorizationTransactionId = usaepay.RefNum;
                        break;
                    case "D":
                        processPaymentResult.Error = "Declined: " + usaepay.ErrorMesg;
                        processPaymentResult.FullError = "Declined : " + usaepay.ErrorMesg;
                        break;
                    default:
                        processPaymentResult.Error = "Error during checkout";
                        processPaymentResult.FullError = "Error during checkout: " + usaepay.ErrorMesg;
                        break;
                }
            }
            catch (Exception)
            {
                processPaymentResult.Error = "Error during checkout";
                processPaymentResult.FullError = "Error during checkout";
            }
        }
        public void Capture(Order order, ref ProcessPaymentResult processPaymentResult)
        {
            var usaepay = new USAePayAPI.USAePay();
            usaepay.SourceKey = sourceKey;
            usaepay.Pin = pin;

            try
            {
                usaepay.Capture(order.AuthorizationTransactionId);

                switch (usaepay.ResultCode)
                {
                    case "A":
                        processPaymentResult.PaymentStatus = PaymentStatusEnum.Paid;
                        processPaymentResult.AVSResult = usaepay.AvsResult;
                        processPaymentResult.AuthorizationTransactionCode = usaepay.AuthCode;
                        processPaymentResult.AuthorizationTransactionId = usaepay.RefNum;
                        break;
                    case "D":
                        processPaymentResult.Error = "Declined: " + usaepay.ErrorMesg;
                        processPaymentResult.FullError = "Declined : " + usaepay.ErrorMesg;
                        break;
                    default:
                        processPaymentResult.Error = "Error during checkout";
                        processPaymentResult.FullError = "Error during checkout: " + usaepay.ErrorMesg;
                        break;
                }
            }
            catch
            {
                processPaymentResult.Error = "Error during capture";
                processPaymentResult.FullError = "Error during capture";
            }
        }