コード例 #1
0
        private void SetCreditCardData(CreditCardRequest request, Payment payment, AccountDataDictionary accountData)
        {
            //set credit card data
            string accountNumber   = accountData.GetValue("AccountNumber");
            string expirationMonth = accountData.GetValue("ExpirationMonth");

            if (expirationMonth.Length == 1)
            {
                expirationMonth.Insert(0, "0");
            }
            string expirationYear = accountData.GetValue("ExpirationYear");

            if (string.IsNullOrEmpty(accountNumber))
            {
                //credit card data missing. can't do much
                return;
            }
            request.setCreditCardNumber(accountNumber);
            request.setExpireMonth(expirationMonth);
            request.setExpireYear(expirationYear);

            string securityCode = accountData.GetValue("SecurityCode");

            if (!string.IsNullOrEmpty(securityCode))
            {
                request.setCreditCardVerificationNumber(securityCode);
            }
        }
コード例 #2
0
        private void SetupCreditCardData(XmlDocument xmlRequest, Payment payment, AccountDataDictionary accountData, Dictionary <string, string> sensitiveData)
        {
            //set credit card data
            string accountNumber   = accountData.GetValue("AccountNumber");
            string expirationMonth = accountData.GetValue("ExpirationMonth");

            if (expirationMonth.Length == 1)
            {
                expirationMonth.Insert(0, "0");
            }
            string expirationYear = accountData.GetValue("ExpirationYear");

            XmlUtility.SetElementValue(xmlRequest.DocumentElement, "xxxCard_Number", accountNumber);
            if (this.UseDebugMode)
            {
                sensitiveData[accountNumber] = MakeReferenceNumber(accountNumber);
            }
            XmlUtility.SetElementValue(xmlRequest.DocumentElement, "xxxCCMonth", expirationMonth);
            XmlUtility.SetElementValue(xmlRequest.DocumentElement, "xxxCCYear", expirationYear);

            string securityCode = accountData.GetValue("SecurityCode");

            if (!string.IsNullOrEmpty(securityCode))
            {
                XmlUtility.SetElementValue(xmlRequest.DocumentElement, "CVV2Indicator", "0");
                XmlUtility.SetElementValue(xmlRequest.DocumentElement, "CVV2", securityCode);
                if (this.UseDebugMode)
                {
                    sensitiveData["CVV2%3E" + securityCode] = "CVV2%3E" + (new string('x', securityCode.Length));
                    sensitiveData["CVV2%3e" + securityCode] = "CVV2%3e" + (new string('x', securityCode.Length));
                }
            }
        }
コード例 #3
0
        private void SetRequestForCreditCard(RefundTransactionRequest refundRequest)
        {
            if (HasValue(_AccountData, "AccountNumber"))
            {
                refundRequest.CardNumber = _AccountData["AccountNumber"];
            }
            else
            {
                refundRequest.CardNumber = CreditCardNumber.Text;
            }
            if (HasValue(_AccountData, "ExpirationMonth") && HasValue(_AccountData, "ExpirationYear"))
            {
                refundRequest.ExpirationMonth = AlwaysConvert.ToInt(_AccountData["ExpirationMonth"]);
                refundRequest.ExpirationYear  = AlwaysConvert.ToInt(_AccountData["ExpirationYear"]);
            }
            else
            {
                refundRequest.ExpirationMonth = AlwaysConvert.ToInt(CreditCardExpirationMonth.SelectedValue);
                refundRequest.ExpirationYear  = AlwaysConvert.ToInt(CreditCardExpirationYear.SelectedValue);
            }

            // SET ADDITIONAL FIELDS FOR INTERNATIONAL DEBIT
            if (DebitCardFields.Visible)
            {
                if (HasValue(_AccountData, "IssueNumber"))
                {
                    refundRequest.ExtendedProperties["IssueNumber"] = _AccountData.GetValue("IssueNumber");
                }
                else if (DebitCardIssueNumber.Text.Length > 0)
                {
                    refundRequest.ExtendedProperties["IssueNumber"] = DebitCardIssueNumber.Text;
                }
                if (HasValue(_AccountData, "StartDateMonth") || HasValue(_AccountData, "StartDateYear"))
                {
                    refundRequest.ExtendedProperties["StartDateMonth"] = _AccountData.GetValue("StartDateMonth");
                    refundRequest.ExtendedProperties["StartDateYear"]  = _AccountData.GetValue("StartDateYear");
                }
                else if (DebitCardStartMonth.SelectedIndex > 0 && DebitCardStartYear.SelectedIndex > 0)
                {
                    refundRequest.ExtendedProperties["StartDateMonth"] = DebitCardStartMonth.SelectedValue;
                    refundRequest.ExtendedProperties["StartDateYear"]  = DebitCardStartYear.SelectedValue;
                }
            }
        }
コード例 #4
0
        private RecurringRequest InitializeAuthRecurringRequest(AuthorizeRecurringTransactionRequest authRequest, int payPeriod)
        {
            VerifyPaymentInstrument(authRequest.Payment);
            RecurringRequest request = new RecurringRequest();

            Payment payment = authRequest.Payment;
            Order   order   = payment.Order;
            User    user    = payment.Order.User;
            //Address address = user.PrimaryAddress;

            //credit card data
            AccountDataDictionary accountData = new AccountDataDictionary(payment.AccountData);
            string accountNumber   = accountData.GetValue("AccountNumber");
            string expirationMonth = accountData.GetValue("ExpirationMonth");

            if (expirationMonth.Length == 1)
            {
                expirationMonth.Insert(0, "0");
            }
            string expirationYear = accountData.GetValue("ExpirationYear");

            request.setCommand(RecurringRequest.COMMAND_ADD_CUSTOMER_ACCOUNT_AND_RECURRENCE);
            request.setAccountType(RecurringRequest.ACCOUNT_TYPE_CREDIT_CARD);
            request.setCreditCardNumber(accountNumber);
            request.setExpireMonth(expirationMonth);
            request.setExpireYear(expirationYear);

            request.setBillingAddress(order.BillToAddress1 + ", " + order.BillToAddress2 + "," + order.BillToCity);
            request.setZipOrPostalCode(order.BillToPostalCode);
            request.setCountryCode(order.BillToCountryCode);

            LSDecimal amount = authRequest.RecurringChargeSpecified ? authRequest.RecurringCharge : authRequest.Amount;

            request.setChargeTotal((double)amount);

            request.setCustomerId(user.UserId.ToString());
            if (accountData.ContainsKey("AccountName") && !string.IsNullOrEmpty(accountData["AccountName"]))
            {
                request.setCustomerName(accountData["AccountName"]);
            }
            else
            {
                request.setCustomerName(order.BillToFirstName + " " + order.BillToLastName);
            }
            request.setDescription(authRequest.SubscriptionName);

            string strEmail = string.IsNullOrEmpty(order.BillToEmail) ? user.Email : order.BillToEmail;

            request.setEmailAddress(user.Email);

            request.setNotifyCustomer(true);
            request.setNumberOfRetries(3);
            request.setRecurrenceId(authRequest.Payment.OrderId.ToString());
            request.setPeriod(payPeriod);

            DateTime startDt = LocaleHelper.LocalNow;

            if (authRequest.RecurringChargeSpecified)
            {
                startDt = GetNextPaymentDate(payPeriod);
            }
            request.setStartDay(startDt.Day);
            request.setStartMonth(startDt.Month);
            request.setStartYear(startDt.Year);

            DateTime endDt = GetEndDate(startDt, payPeriod, authRequest.NumberOfPayments);

            request.setEndDay(endDt.Day);
            request.setEndMonth(endDt.Month);
            request.setEndYear(endDt.Year);

            return(request);
        }
コード例 #5
0
        private string InitializeAuthRecurringRequest(AuthorizeRecurringTransactionRequest authRequest, Dictionary <string, string> sensitiveData)
        {
            Payment payment = authRequest.Payment;
            User    user    = payment.Order.User;
            Order   order   = payment.Order;

            VerifyPaymentInstrument(payment);
            AccountDataDictionary accountData = new AccountDataDictionary(payment.AccountData);
            string accountNumber   = accountData.GetValue("AccountNumber");
            string expirationMonth = accountData.GetValue("ExpirationMonth");
            string expirationYear  = accountData.GetValue("ExpirationYear");

            if (expirationMonth.Length == 1)
            {
                expirationMonth = "0" + expirationMonth;
            }
            if (expirationYear.Length > 2)
            {
                expirationYear = expirationYear.Substring(expirationYear.Length - 2);
            }
            string expireDate   = expirationMonth + expirationYear;
            string amount       = String.Format("{0:F2}", authRequest.RecurringChargeSpecified? authRequest.RecurringCharge : authRequest.Amount);
            string securityCode = accountData.GetValue("SecurityCode");

            //authentication data
            string data = "dc_logon=" + HttpUtility.UrlEncode(this.LoginName, System.Text.Encoding.UTF8);

            data += Encode("dc_password", this.Password);
            if (this.UseDebugMode)
            {
                sensitiveData[this.Password] = "xxxxxxxx";
            }

            //address data
            data += Encode("dc_address", order.BillToAddress1 + " " + order.BillToAddress2);
            data += Encode("dc_city", order.BillToCity);
            data += Encode("dc_zip", order.BillToPostalCode);
            data += Encode("dc_country", order.BillToCountryCode);

            //transaction data
            data += Encode("dc_transaction_type", "AUTHORIZATION_CAPTURE");
            data += Encode("dc_transaction_amount", amount);
            data += Encode("dc_version", "1.2");

            //cc data
            string fullName;

            if (accountData.ContainsKey("AccountName") && !string.IsNullOrEmpty(accountData["AccountName"]))
            {
                fullName = accountData["AccountName"];
            }
            else
            {
                fullName = order.BillToFirstName + " " + order.BillToLastName;
            }
            data += Encode("dc_name", fullName);
            data += Encode("dc_number", accountNumber);
            if (this.UseDebugMode)
            {
                sensitiveData[accountNumber] = MakeReferenceNumber(accountNumber);
            }
            data += Encode("dc_expiration_month", expirationMonth);
            data += Encode("dc_expiration_year", expirationYear);

            if (!string.IsNullOrEmpty(securityCode))
            {
                data += Encode("dc_verification_number", securityCode);
                if (this.UseDebugMode)
                {
                    sensitiveData["dc_verification_number=" + securityCode] = "dc_verification_number=" + (new string('x', securityCode.Length));
                }
            }

            //schedule data
            data += Encode("dc_schedule_create", "true");
            int remainingPayments = authRequest.NumberOfPayments;

            if (authRequest.RecurringChargeSpecified)
            {
                remainingPayments -= 1;
            }
            data += Encode("dc_schedule_limit", remainingPayments.ToString());
            if (authRequest.PaymentFrequencyUnit == CommerceBuilder.Products.PaymentFrequencyUnit.Day)
            {
                data += Encode("dc_schedule_periodic_type", "day");
            }
            else
            {
                data += Encode("dc_schedule_periodic_type", "month");
            }
            data += Encode("dc_schedule_periodic_number", authRequest.PaymentFrequency.ToString());

            DateTime startDt = GetNextPaymentDate(authRequest);

            data += Encode("dc_schedule_start", startDt.ToString("yyyy-MM-dd"));

            return(data);
        }
コード例 #6
0
        private string InitializeRefundRequest(Payment payment, RefundTransactionRequest refundRequest, Transaction authorizeTransaction, LSDecimal dAmount, Dictionary <string, string> sensitiveData)
        {
            Order order = payment.Order;
            AccountDataDictionary accountData = new AccountDataDictionary(payment.AccountData);
            string accountNumber   = refundRequest.CardNumber;
            string expirationMonth = refundRequest.ExpirationMonth.ToString();
            string expirationYear  = refundRequest.ExpirationYear.ToString();

            if (expirationMonth.Length == 1)
            {
                expirationMonth = "0" + expirationMonth;
            }
            if (expirationYear.Length > 2)
            {
                expirationYear = expirationYear.Substring(expirationYear.Length - 2);
            }
            string expireDate   = expirationMonth + expirationYear;
            string amount       = String.Format("{0:F2}", dAmount);
            string securityCode = accountData.GetValue("SecurityCode");

            string fullName;

            if (accountData.ContainsKey("AccountName") && !string.IsNullOrEmpty(accountData["AccountName"]))
            {
                fullName = accountData["AccountName"];
            }
            else
            {
                fullName = order.BillToFirstName + " " + order.BillToLastName;
            }

            string data = "dc_logon=" + HttpUtility.UrlEncode(this.LoginName, System.Text.Encoding.UTF8);

            data += Encode("dc_password", this.Password);
            if (this.UseDebugMode)
            {
                sensitiveData[this.Password] = "xxxxxxxx";
            }
            data += Encode("dc_transaction_type", "CREDIT");
            data += Encode("dc_version", "1.2");
            data += Encode("dc_transaction_id", authorizeTransaction.ProviderTransactionId);
            data += Encode("dc_address", order.BillToAddress1 + " " + order.BillToAddress2);
            data += Encode("dc_city", order.BillToCity);
            data += Encode("dc_zip", order.BillToPostalCode);
            data += Encode("dc_transaction_amount", amount);
            data += Encode("dc_name", fullName);
            data += Encode("dc_number", accountNumber);
            if (this.UseDebugMode)
            {
                sensitiveData[accountNumber] = MakeReferenceNumber(accountNumber);
            }
            data += Encode("dc_expiration_month", expirationMonth);
            data += Encode("dc_expiration_year", expirationYear);
            if (!string.IsNullOrEmpty(securityCode))
            {
                data += Encode("dc_verification_number", securityCode);
                if (this.UseDebugMode)
                {
                    sensitiveData["dc_verification_number=" + securityCode] = "dc_verification_number=" + (new string('x', securityCode.Length));
                }
            }

            return(data);
        }
コード例 #7
0
        private string InitializeAuthRequest(Payment payment, Order order, User user, Dictionary <string, string> sensitiveData, bool capture)
        {
            VerifyPaymentInstrument(payment);
            //Address address = user.PrimaryAddress;
            AccountDataDictionary accountData = new AccountDataDictionary(payment.AccountData);
            string accountNumber   = accountData.GetValue("AccountNumber");
            string expirationMonth = accountData.GetValue("ExpirationMonth");
            string expirationYear  = accountData.GetValue("ExpirationYear");

            if (expirationMonth.Length == 1)
            {
                expirationMonth = "0" + expirationMonth;
            }
            if (expirationYear.Length > 2)
            {
                expirationYear = expirationYear.Substring(expirationYear.Length - 2);
            }
            string expireDate   = expirationMonth + expirationYear;
            string amount       = String.Format("{0:F2}", payment.Amount);
            string securityCode = accountData.GetValue("SecurityCode");

            string data = "dc_logon=" + HttpUtility.UrlEncode(this.LoginName, System.Text.Encoding.UTF8);

            data += Encode("dc_password", this.Password);
            if (this.UseDebugMode)
            {
                sensitiveData[this.Password] = "xxxxxxxx";
            }
            if (capture)
            {
                data += Encode("dc_transaction_type", "AUTHORIZATION_CAPTURE");
            }
            else
            {
                data += Encode("dc_transaction_type", "AUTHORIZATION");
            }

            string fullName;

            if (accountData.ContainsKey("AccountName") && !string.IsNullOrEmpty(accountData["AccountName"]))
            {
                fullName = accountData["AccountName"];
            }
            else
            {
                fullName = order.BillToFirstName + " " + order.BillToLastName;
            }

            data += Encode("dc_version", "1.2");
            data += Encode("dc_address", order.BillToAddress1 + " " + order.BillToAddress2);
            data += Encode("dc_city", order.BillToCity);
            data += Encode("dc_zip", order.BillToPostalCode);
            data += Encode("dc_country", order.BillToCountryCode);
            data += Encode("dc_transaction_amount", amount);
            data += Encode("dc_name", fullName);
            data += Encode("dc_number", accountNumber);
            if (this.UseDebugMode)
            {
                sensitiveData[accountNumber] = MakeReferenceNumber(accountNumber);
            }
            data += Encode("dc_expiration_month", expirationMonth);
            data += Encode("dc_expiration_year", expirationYear);

            if (!string.IsNullOrEmpty(securityCode))
            {
                data += Encode("dc_verification_number", securityCode);
                if (this.UseDebugMode)
                {
                    sensitiveData["dc_verification_number=" + securityCode] = "dc_verification_number=" + (new string('x', securityCode.Length));
                }
            }

            return(data);
        }