Example #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";
            }
        }
Example #2
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";
            }
        }
Example #3
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";
            }
        }