Esempio n. 1
0
        /// <summary>
        /// Creates the transaction.
        /// </summary>
        /// <param name="profile_id">The profile_id.</param>
        /// <param name="payment_profile_id">The payment_profile_id.</param>
        /// <param name="amount">The amount.</param>
        public static void CreateTransaction(long profile_id, long payment_profile_id, decimal amount)
        {
            try
            {
                AuthorizeNet.ProfileTransAuthCaptureType auth_capture = new AuthorizeNet.ProfileTransAuthCaptureType();
                auth_capture.customerProfileId        = profile_id;
                auth_capture.customerPaymentProfileId = payment_profile_id;
                auth_capture.amount = amount;
                auth_capture.order  = new AuthorizeNet.OrderExType();
                auth_capture.order.invoiceNumber = "invoice" + DateTime.Now.ToShortTimeString();
                AuthorizeNet.ProfileTransactionType trans = new AuthorizeNet.ProfileTransactionType();
                trans.Item = auth_capture;

                AuthorizeNet.CreateCustomerProfileTransactionResponseType response = ServiceSoapClient.CreateCustomerProfileTransaction(MerchantAuthentication, trans, null);

                if (response.resultCode == AuthorizeNet.MessageTypeEnum.Error)
                {
                    throw new KioskException(string.Format("Could not create transaction for profile id/ payment profile id: {0}/{1}.", profile_id, payment_profile_id));
                }
            }
            catch (KioskException kioskException)
            {
                AlertController.AuthorizeDotNetAlert(kioskException);
                throw kioskException;
            }
            catch (Exception ex)
            {
                KioskException kioskException = new KioskException(Constants.Messages.CouldNotConnectToAuthorize);
                kioskException.OriginalException = ex;

                AlertController.AuthorizeDotNetAlert(ex);
                throw kioskException;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the customer payment profile.
        /// </summary>
        /// <param name="profileId">The profile id.</param>
        /// <param name="paymentProfileId">The profile payment id.</param>
        /// <returns></returns>
        public static AuthorizeNet.CustomerPaymentProfileMaskedType GetCustomerPaymentProfile(long profileId, long paymentProfileId)
        {
            AuthorizeNet.CustomerPaymentProfileMaskedType paymentProfile = null;

            try
            {
                AuthorizeNet.GetCustomerPaymentProfileResponseType responseType = ServiceSoapClient.GetCustomerPaymentProfile(MerchantAuthentication, profileId, paymentProfileId);
                paymentProfile = responseType.paymentProfile;
                if (responseType.resultCode == AuthorizeNet.MessageTypeEnum.Error)
                {
                    throw new KioskException(string.Format("Could not get customer payment profile for profile id/ payment profile Id: {0}/{1}.", profileId, paymentProfileId));
                }
            }
            catch (KioskException kioskException)
            {
                AlertController.AuthorizeDotNetAlert(kioskException);
                throw kioskException;
            }
            catch (Exception ex)
            {
                KioskException kioskException = new KioskException(Constants.Messages.CouldNotConnectToAuthorize);
                kioskException.OriginalException = ex;

                AlertController.AuthorizeDotNetAlert(ex);
                throw kioskException;
            }

            return(paymentProfile);
        }
Esempio n. 3
0
        /// <summary>
        /// Creates the customer profile.
        /// </summary>
        /// <param name="emailAddress">The email address.</param>
        /// <returns></returns>
        public static long CreateCustomerProfile(string emailAddress)
        {
            long customerProfileId = 0;

            try
            {
                AuthorizeNet.CustomerProfileType m_new_cust = new AuthorizeNet.CustomerProfileType();
                m_new_cust.email       = emailAddress;
                m_new_cust.description = "Kiosk customer " + DateTime.Now.ToShortTimeString();
                AuthorizeNet.CreateCustomerProfileResponseType response = ServiceSoapClient.CreateCustomerProfile(MerchantAuthentication, m_new_cust, AuthorizeNet.ValidationModeEnum.none);

                customerProfileId = response.customerProfileId;

                if (response.resultCode == AuthorizeNet.MessageTypeEnum.Error)
                {
                    throw new KioskException(string.Format("Could not create customer profile for email: {0}.", emailAddress));
                }
            }
            catch (KioskException kioskException)
            {
                AlertController.AuthorizeDotNetAlert(kioskException);
                throw kioskException;
            }
            catch (Exception ex)
            {
                KioskException kioskException = new KioskException(Constants.Messages.CouldNotConnectToAuthorize);
                kioskException.OriginalException = ex;

                AlertController.AuthorizeDotNetAlert(ex);
                throw kioskException;
            }

            return(customerProfileId);
        }
Esempio n. 4
0
        /// <summary>
        /// Creates the customer payment profile.
        /// </summary>
        /// <param name="profile_id">The profile_id.</param>
        /// <param name="ccNumber">The cc number.</param>
        /// <param name="expire_date">The expire_date.</param>
        /// <returns></returns>
        public static long CreateCustomerPaymentProfile(long profile_id, string ccNumber, string expire_date, string firstName, string lastName, string zipCode)
        {
            long customerPaymentProfileId = 0;

            try
            {
                AuthorizeNet.CustomerPaymentProfileType new_payment_profile = new AuthorizeNet.CustomerPaymentProfileType();
                AuthorizeNet.PaymentType    new_payment = new AuthorizeNet.PaymentType();
                AuthorizeNet.CreditCardType new_card    = new AuthorizeNet.CreditCardType();
                new_card.cardNumber         = ccNumber;
                new_card.expirationDate     = expire_date;
                new_payment.Item            = new_card;
                new_payment_profile.payment = new_payment;
                new_payment_profile.billTo  = new AuthorizeNet.CustomerAddressType
                {
                    firstName = firstName,
                    lastName  = lastName,
                    zip       = zipCode
                };

                AuthorizeNet.CreateCustomerPaymentProfileResponseType response = ServiceSoapClient.CreateCustomerPaymentProfile(MerchantAuthentication, profile_id, new_payment_profile, AuthorizeNet.ValidationModeEnum.testMode);
                customerPaymentProfileId = response.customerPaymentProfileId;

                if (response.resultCode == AuthorizeNet.MessageTypeEnum.Error)
                {
                    throw new KioskException(string.Format("Could not create customer payment profile for profile id: {0}.", profile_id));
                }
            }
            catch (KioskException kioskException)
            {
                AlertController.AuthorizeDotNetAlert(kioskException);
                throw kioskException;
            }
            catch (Exception ex)
            {
                KioskException kioskException = new KioskException(Constants.Messages.CouldNotConnectToAuthorize);
                kioskException.OriginalException = ex;

                AlertController.AuthorizeDotNetAlert(ex);
                throw kioskException;
            }

            return(customerPaymentProfileId);
        }
Esempio n. 5
0
        /// <summary>
        /// Processes the CC.
        /// </summary>
        /// <param name="ccNumber">The cc number.</param>
        /// <param name="ccExpDate">The cc exp date.</param>
        /// <param name="chargeAmount">The charge amount.</param>
        /// <param name="orderNumber">The order number.</param>
        /// <param name="zipCode">The zip code.</param>
        /// <returns></returns>
        private static string ProcessCC(string ccNumber, string ccExpDate, decimal chargeAmount, string orderNumber, string zipCode, string name)
        {
            try
            {
                if (chargeAmount > 0)
                {
                    var request = new AuthorizationRequest(ccNumber, ccExpDate, chargeAmount, "Bettery Charge");
                    request.Zip = zipCode;

                    //  Store the Swap Station ID in the CustID field
                    request.CustId = ConfigurationManager.AppSettings[Constants.SettingKeys.StationId];

                    //  Add customer info if user is logged in.
                    //if (BaseController.CurrentTransaction.Email != null || BaseController.CurrentTransaction.Email != String.Empty)
                    //    request.Email = BaseController.CurrentTransaction.Email;

                    if (BaseController.LoggedOnUser != null)
                    {
                        request.AddCustomer(BaseController.LoggedOnUser.MemberId.ToString(), BaseController.LoggedOnUser.MemberFirstName, BaseController.LoggedOnUser.MemberLastName, "", "", BaseController.CurrentTransaction.ZipCode);
                    }
                    else
                    {
                        request.FirstName = name;
                        request.Zip       = BaseController.CurrentTransaction.ZipCode;
                    }


                    // Get Test Request setting from config file
                    request.TestRequest = ConfigurationManager.AppSettings["TestTransaction"].ToString();


                    // Set Test Request true for admins
                    if (BaseController.LoggedOnUser != null && (BaseController.LoggedOnUser.GroupID == Constants.Group.SuperUser || BaseController.LoggedOnUser.GroupID == Constants.Group.SwapStationAdmin || BaseController.LoggedOnUser.GroupID == Constants.Group.CompanyAccount))
                    {
                        request.TestRequest = "TRUE";
                    }

                    //order number
                    request.AddInvoice(orderNumber);

                    var gate = new CardPresentGateway(BaseController.ApiLogin, BaseController.TransactionKey, false);

                    //step 3 - make some money
                    var response = gate.Send(request);
                    if (!response.Approved)
                    {
                        BaseController.CurrentTransaction.ZipCode = null;
                        throw new KioskException(Constants.Messages.NonApprovedRequest);
                    }
                    BaseController.CurrentTransaction.TransactionID = response.TransactionID;
                    return(response.AuthorizationCode);
                }
                else
                {
                    return("");
                }
            }
            catch (KioskException kioskException)
            {
                AlertController.AuthorizeDotNetAlert(kioskException);
                throw kioskException;
            }
            catch (Exception ex)
            {
                KioskException kioskException = new KioskException(Constants.Messages.CouldNotConnectToAuthorize);
                kioskException.OriginalException = ex;

                AlertController.AuthorizeDotNetAlert(ex);
                Logger.Log(EventLogEntryType.Error, "Could Not Connect to Authorize.NET or other Authorize.NET failure", BaseController.StationId);
                throw kioskException;
            }
        }