Пример #1
0
        public override ApiInfo RefundPayment(Order order, IDictionary <string, string> settings)
        {
            ApiInfo apiInfo = null;

            try {
                order.MustNotBeNull("order");
                settings.MustNotBeNull("settings");
                settings.MustContainKey("Vendor", "settings");
                settings.MustContainKey("Description", "settings");

                Dictionary <string, string> inputFields = new Dictionary <string, string>();

                Guid vendorTxCode = Guid.NewGuid();

                inputFields["VPSProtocol"]  = "2.23";
                inputFields["TxType"]       = "REFUND";
                inputFields["Vendor"]       = settings["Vendor"];
                inputFields["VendorTxCode"] = vendorTxCode.ToString();
                inputFields["Amount"]       = order.TransactionInformation.AmountAuthorized.Value.ToString("0.00", CultureInfo.InvariantCulture);
                //Check that the Iso code exists
                Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);
                if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
                {
                    throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
                }
                inputFields["Currency"]            = currency.IsoCode;
                inputFields["Description"]         = settings["Description"].Truncate(100);
                inputFields["RelatedVPSTxId"]      = order.TransactionInformation.TransactionId;
                inputFields["RelatedVendorTxCode"] = order.Properties["vendorTxCode"];
                inputFields["RelatedSecurityKey"]  = order.Properties["securityKey"];
                inputFields["RelatedTxAuthNo"]     = order.Properties["txAuthNo"];
                inputFields["ApplyAVSCV2"]         = "0";

                IDictionary <string, string> responseFields = GetFields(MakePostRequest(GetMethodUrl("REFUND", settings), inputFields));

                if (responseFields["Status"] == "OK")
                {
                    order.Properties.AddOrUpdate(new CustomProperty("vendorTxCode", vendorTxCode.ToString())
                    {
                        ServerSideOnly = true
                    });
                    order.Properties.AddOrUpdate(new CustomProperty("txAuthNo", responseFields["TxAuthNo"])
                    {
                        ServerSideOnly = true
                    });
                    order.Save();

                    apiInfo = new ApiInfo(responseFields["VPSTxId"], PaymentState.Refunded);
                }
                else
                {
                    LoggingService.Instance.Warn <SagePay>("Sage pay(" + order.OrderNumber + ") - Error making API request: " + responseFields["StatusDetail"]);
                }
            } catch (Exception exp) {
                LoggingService.Instance.Error <SagePay>("Sage pay(" + order.OrderNumber + ") - Refund payment", exp);
            }

            return(apiInfo);
        }
Пример #2
0
        public override ApiInfo RefundPayment(Order order, IDictionary <string, string> settings)
        {
            ApiInfo apiInfo = null;

            try
            {
                order.MustNotBeNull("order");
                settings.MustNotBeNull("settings");
                settings.MustContainKey("brq_websitekey", "settings");
                settings.MustContainKey("secret_key", "settings");
                settings.MustContainKey("test_mode", "settings");

                //Check that the Iso code exists
                Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);
                if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
                {
                    throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
                }

                // request via the NVP gateway
                Dictionary <string, string> inputFields = new Dictionary <string, string>();
                inputFields["brq_websitekey"] = settings["brq_websitekey"];

                inputFields["brq_invoicenumber"]       = order.CartNumber;
                inputFields["brq_currency"]            = currency.IsoCode;
                inputFields["brq_culture"]             = currency.CultureName;
                inputFields["brq_amount_credit"]       = order.TotalPrice.Value.WithVat.ToString("0.00", CultureInfo.InvariantCulture);
                inputFields["brq_originaltransaction"] = order.TransactionInformation.TransactionId;

                Dictionary <string, string> response = MakeNVPGatewayRequest("TransactionRequest", inputFields, settings);
                if (response.ContainsKey("BRQ_STATUSCODE") && response.ContainsKey("BRQ_TRANSACTIONS"))
                {
                    // set the transaction id to the transaction that contains the refund (important)
                    // just return 'Refunded' (if you use 'PendingExternalSystem' the status 'Refunded' will not be shown in TeaCommerce)
                    apiInfo = new ApiInfo(response["BRQ_TRANSACTIONS"], PaymentState.Refunded);
                }

                LoggingService.Instance.Info <BuckarooPayments>(String.Concat("Buckaroo-Payments (", order.OrderNumber, ") - Refunded Order from back-end"));
                return(apiInfo);
            }
            catch (Exception exp)
            {
                LoggingService.Instance.Error <BuckarooPayments>(String.Concat("Buckaroo-Payments (", order.OrderNumber, ")"), exp);
            }
            return(apiInfo);
        }
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("SHAINPASSPHRASE", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm
            {
                Action = GetMethodUrl("GENERATEFORM", settings)
            };

            string[] settingsToExclude = new[] { "SHAINPASSPHRASE", "SHAOUTPASSPHRASE", "APIUSERID", "APIPASSWORD", "TESTMODE" };
            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key) && !string.IsNullOrEmpty(i.Value)).ToDictionary(i => i.Key.ToUpperInvariant(), i => i.Value);

            htmlForm.InputFields["ORDERID"] = order.CartNumber;
            htmlForm.InputFields["AMOUNT"]  = (order.TotalPrice.Value.WithVat * 100M).ToString("0", CultureInfo.InvariantCulture);

            //Check that the Iso code exists
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            htmlForm.InputFields["CURRENCY"] = currency.IsoCode;

            htmlForm.InputFields["CN"]           = order.PaymentInformation.FirstName + " " + order.PaymentInformation.LastName;
            htmlForm.InputFields["EMAIL"]        = order.PaymentInformation.Email;
            htmlForm.InputFields["ACCEPTURL"]    = teaCommerceContinueUrl;
            htmlForm.InputFields["DECLINEURL"]   = teaCommerceCancelUrl;
            htmlForm.InputFields["EXCEPTIONURL"] = teaCommerceCancelUrl;
            htmlForm.InputFields["CANCELURL"]    = teaCommerceCancelUrl;

            //Ogone dont support to show order line information to the shopper

            string strToHash = string.Join("", htmlForm.InputFields.OrderBy(i => i.Key).Select(i => i.Key + "=" + i.Value + settings["SHAINPASSPHRASE"]));

            htmlForm.InputFields["SHASIGN"] = new SHA512Managed().ComputeHash(Encoding.UTF8.GetBytes(strToHash)).ToHex();

            return(htmlForm);
        }
Пример #4
0
        public override ApiInfo CapturePayment(Order order, IDictionary <string, string> settings)
        {
            ApiInfo apiInfo = null;

            try
            {
                order.MustNotBeNull("order");
                settings.MustNotBeNull("settings");

                IDictionary <string, string> inputFields = PrepareApiPostRequest("DoCapture", settings);

                inputFields.Add("AUTHORIZATIONID", order.TransactionInformation.TransactionId);
                inputFields.Add("AMT", order.TransactionInformation.AmountAuthorized.Value.ToString("0.00", CultureInfo.InvariantCulture));
                Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);
                if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
                {
                    throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
                }
                inputFields.Add("CURRENCYCODE", currency.IsoCode);
                inputFields.Add("COMPLETETYPE", "Complete");

                ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
                IDictionary <string, string> responseKvp = GetApiResponseKvp(MakePostRequest(settings.ContainsKey("isSandbox") && settings["isSandbox"] == "1" ? "https://api-3t.sandbox.paypal.com/nvp" : "https://api-3t.paypal.com/nvp", inputFields));
                if (responseKvp["ACK"] == "Success" || responseKvp["ACK"] == "SuccessWithWarning")
                {
                    apiInfo = InternalGetStatus(order.OrderNumber, responseKvp["TRANSACTIONID"], settings);
                }
                else
                {
                    LoggingService.Instance.Warn <PayPal>("PayPal(" + order.OrderNumber + ") - Error making API request - error code: " + responseKvp["L_ERRORCODE0"]);
                }
            }
            catch (Exception exp)
            {
                LoggingService.Instance.Error <PayPal>("PayPal(" + order.OrderNumber + ") - Refund payment", exp);
            }

            return(apiInfo);
        }
Пример #5
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm {
                Action = settings.ContainsKey("isSandbox") && settings["isSandbox"] == "1" ? "https://www.sandbox.paypal.com/cgi-bin/webscr" : "https://www.paypal.com/cgi-bin/webscr"
            };

            string[] settingsToExclude = new[] { "USER", "PWD", "SIGNATURE", "isSandbox" };
            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            htmlForm.InputFields["cmd"]    = "_cart";
            htmlForm.InputFields["upload"] = "1";

            //Check that the Iso code exists
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            htmlForm.InputFields["currency_code"] = currency.IsoCode;

            htmlForm.InputFields["invoice"] = order.CartNumber;

            htmlForm.InputFields["return"]        = teaCommerceContinueUrl;
            htmlForm.InputFields["rm"]            = "2";
            htmlForm.InputFields["cancel_return"] = teaCommerceCancelUrl;
            htmlForm.InputFields["notify_url"]    = teaCommerceCallBackUrl;

            htmlForm.InputFields["item_name_1"]   = settings.ContainsKey("totalName") ? settings["totalName"] : "Total";
            htmlForm.InputFields["item_number_1"] = settings.ContainsKey("totalSku") ? settings["totalSku"] : "0001";
            htmlForm.InputFields["amount_1"]      = order.TotalPrice.Value.WithVat.ToString("0.00", CultureInfo.InvariantCulture);
            htmlForm.InputFields["quantity_1"]    = 1M.ToString("0", CultureInfo.InvariantCulture);

            return(htmlForm);
        }
Пример #6
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("shopid", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm {
                Action     = "https://betaling.wannafind.dk/paymentwindow.php",
                Attributes = { { "id", "wannafind" }, { "name", "wannafind" }, { "target", "_self" } }
            };

            string[] settingsToExclude = new[] { "md5AuthSecret", "md5CallbackSecret", "apiUser", "apiPassword", "testmode" };
            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            //orderid
            string orderId = order.CartNumber.Replace(StoreService.Instance.Get(order.StoreId).OrderSettings.CartNumberPrefix, "");

            htmlForm.InputFields["orderid"] = orderId;

            //currency
            //Check that the Iso code exists
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            string currencyStr = Iso4217CurrencyCodes[currency.IsoCode];

            htmlForm.InputFields["currency"] = currencyStr;

            //amount
            string amount = (order.TotalPrice.Value.WithVat * 100M).ToString("0", CultureInfo.InvariantCulture);

            htmlForm.InputFields["amount"] = amount;

            htmlForm.InputFields["accepturl"]   = teaCommerceContinueUrl;
            htmlForm.InputFields["declineurl"]  = teaCommerceCancelUrl;
            htmlForm.InputFields["callbackurl"] = teaCommerceCallBackUrl;

            //authtype
            htmlForm.InputFields["authtype"] = "auth";

            //paytype - legacy
            if (!settings.ContainsKey("paytype"))
            {
                htmlForm.InputFields["paytype"] = "creditcard";
            }

            //cardtype
            string cardType = string.Empty;

            if (htmlForm.InputFields.ContainsKey("cardtype"))
            {
                cardType = htmlForm.InputFields["cardtype"];
                if (string.IsNullOrEmpty(cardType))
                {
                    htmlForm.InputFields.Remove("cardtype");
                }
            }

            //uniqueorderid
            htmlForm.InputFields["uniqueorderid"] = "true";

            //cardnomask
            htmlForm.InputFields["cardnomask"] = "true";

            //md5securitykey
            if (settings.ContainsKey("md5AuthSecret") && !string.IsNullOrEmpty(settings["md5AuthSecret"]))
            {
                htmlForm.InputFields["checkmd5"] = GenerateMD5Hash(currencyStr + orderId + amount + cardType + settings["md5AuthSecret"]);
            }

            //wannafind dont support to show order line information to the shopper

            return(htmlForm);
        }
Пример #7
0
        public override string ProcessRequest(Order order, HttpRequest request, IDictionary <string, string> settings)
        {
            string response = "";

            try
            {
                order.MustNotBeNull("order");
                request.MustNotBeNull("request");
                settings.MustNotBeNull("settings");
                settings.MustContainKey("profile_id", "settings");
                settings.MustContainKey("access_key", "settings");
                settings.MustContainKey("locale", "settings");
                settings.MustContainKey("transaction_type", "settings");
                settings.MustContainKey("phonePropertyAlias", "settings");
                settings.MustContainKey("streetAddressPropertyAlias", "settings");
                settings.MustContainKey("cityPropertyAlias", "settings");
                order.Properties[settings["phonePropertyAlias"]].MustNotBeNullOrEmpty("phone");
                order.Properties[settings["streetAddressPropertyAlias"]].MustNotBeNullOrEmpty("street address");
                order.Properties[settings["cityPropertyAlias"]].MustNotBeNullOrEmpty("city");
                order.PaymentInformation.FirstName.MustNotBeNull("first name");
                order.PaymentInformation.LastName.MustNotBeNull("last name");
                order.PaymentInformation.Email.MustNotBeNull("email");

                // If in test mode, write out the form data to a text file
                if (settings.ContainsKey("mode") && settings["mode"] == "test")
                {
                    LogRequest <CyberSource>(request, logPostData: true);
                }

                //Generate input fields for the JavaScript post of the inline form
                IDictionary <string, string> inputFields = new Dictionary <string, string>();
                inputFields["profile_id"] = settings["profile_id"];
                inputFields["access_key"] = settings["access_key"];
                inputFields["override_custom_receipt_page"] = order.Properties["teaCommerceCallBackUrl"];
                inputFields["locale"]         = settings["locale"];
                inputFields["payment_method"] = "card";

                inputFields["reference_number"] = order.CartNumber;
                inputFields["signed_date_time"] = DateTime.UtcNow.ToString("yyyy-MM-dd'T'HH:mm:ss'Z'");
                inputFields["transaction_type"] = settings["transaction_type"];
                inputFields["transaction_uuid"] = Guid.NewGuid().ToString();
                inputFields["amount"]           = order.TotalPrice.Value.WithVat.ToString("0.00", CultureInfo.InvariantCulture);
                Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);
                if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
                {
                    throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
                }
                inputFields["currency"] = currency.IsoCode;

                inputFields["bill_to_forename"] = order.PaymentInformation.FirstName;
                inputFields["bill_to_surname"]  = order.PaymentInformation.LastName;
                inputFields["bill_to_email"]    = order.PaymentInformation.Email;
                inputFields["bill_to_phone"]    = order.Properties[settings["phonePropertyAlias"]];

                inputFields["bill_to_address_line1"] = order.Properties[settings["streetAddressPropertyAlias"]];
                inputFields["bill_to_address_city"]  = order.Properties[settings["cityPropertyAlias"]];
                if (settings.ContainsKey("zipCodePropertyAlias"))
                {
                    inputFields["bill_to_address_postal_code"] = order.Properties[settings["zipCodePropertyAlias"]];
                }
                Country country = CountryService.Instance.Get(order.StoreId, order.PaymentInformation.CountryId);
                if (!Iso3166CountryCodes.ContainsKey(country.RegionCode))
                {
                    throw new Exception("You must specify an ISO 3166 country code for the " + country.Name + " country");
                }
                inputFields["bill_to_address_country"] = country.RegionCode;
                inputFields["bill_to_address_state"]   = order.PaymentInformation.CountryRegionId != null?CountryRegionService.Instance.Get(order.StoreId, order.PaymentInformation.CountryRegionId.Value).RegionCode : "";

                inputFields["card_type"]        = request.Form["card_type"];
                inputFields["card_expiry_date"] = request.Form["card_expiry_date"];
                inputFields["card_cvn"]         = request.Form["card_cvn"];
                inputFields["card_number"]      = request.Form["card_number"];

                inputFields["unsigned_field_names"] = "";
                inputFields["signed_field_names"]   = string.Join(",", inputFields.Select(kvp => kvp.Key)) + ",signed_field_names";

                //Signature and card number should not be signed
                inputFields["signature"] = CreateSignature(inputFields, settings);

                foreach (KeyValuePair <string, string> kvp in inputFields)
                {
                    if (request.Form[kvp.Key] != "")
                    {
                        response += "<input type=\"hidden\" name=\"" + kvp.Key + "\" value=\"" + kvp.Value + "\" />";
                    }
                }
            }
            catch (Exception exp)
            {
                LoggingService.Instance.Error <CyberSource>("CyberSource(" + order.CartNumber + ") - ProcessRequest", exp);
            }

            return(response);
        }
Пример #8
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("merchant", "settings");
            settings.MustContainKey("language", "settings");
            settings.MustContainKey("md5secret", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm {
                Action = "https://secure.quickpay.dk/form/"
            };

            string[] settingsToExclude = new[] { "md5secret" };
            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            htmlForm.InputFields["protocol"] = "7";
            htmlForm.InputFields["msgtype"]  = "authorize";

            //Order name must be between 4 or 20 chars
            string orderName = order.CartNumber;

            while (orderName.Length < 4)
            {
                orderName = "0" + orderName;
            }
            if (orderName.Length > 20)
            {
                throw new Exception("Cart number of the order can not exceed 20 characters.");
            }
            htmlForm.InputFields["ordernumber"] = orderName;
            htmlForm.InputFields["amount"]      = (order.TotalPrice.Value.WithVat * 100M).ToString("0", CultureInfo.InvariantCulture);

            //Check that the Iso code exists
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            htmlForm.InputFields["currency"] = currency.IsoCode;

            htmlForm.InputFields["continueurl"] = teaCommerceContinueUrl;
            htmlForm.InputFields["cancelurl"]   = teaCommerceCancelUrl;
            htmlForm.InputFields["callbackurl"] = teaCommerceCallBackUrl;

            //Quickpay dont support to show order line information to the shopper

            //Md5 check sum
            string[] md5CheckSumKeys = { "protocol", "msgtype", "merchant", "language", "ordernumber", "amount", "currency", "continueurl", "cancelurl", "callbackurl", "autocapture", "autofee", "cardtypelock", "description", "group", "testmode", "splitpayment", "forcemobile", "deadline", "cardhash" };
            string   md5CheckValue   = "";

            foreach (string key in md5CheckSumKeys)
            {
                if (htmlForm.InputFields.ContainsKey(key))
                {
                    md5CheckValue += htmlForm.InputFields[key];
                }
            }
            md5CheckValue += settings["md5secret"];

            htmlForm.InputFields["md5check"] = GenerateMD5Hash(md5CheckValue);

            return(htmlForm);
        }
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("SECURITY.SENDER", "settings");
            settings.MustContainKey("USER.LOGIN", "settings");
            settings.MustContainKey("USER.PWD", "settings");
            settings.MustContainKey("TRANSACTION.CHANNEL", "settings");
            settings.MustContainKey("PAYMENT.CODE", "settings");
            settings.MustContainKey("streetAddressPropertyAlias", "settings");
            settings.MustContainKey("cityPropertyAlias", "settings");
            settings.MustContainKey("zipCodePropertyAlias", "settings");
            settings.MustContainKey("TRANSACTION.MODE", "settings");
            settings.MustContainKey("SYSTEM", "settings");
            order.Properties[settings["streetAddressPropertyAlias"]].MustNotBeNullOrEmpty("street address");
            order.Properties[settings["cityPropertyAlias"]].MustNotBeNullOrEmpty("city");
            order.Properties[settings["zipCodePropertyAlias"]].MustNotBeNullOrEmpty("zip code");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm();

            string[] settingsToExclude = new[] { "FRONTEND.RESPONSE_URL", "FRONTEND.CANCEL_URL", "streetAddressPropertyAlias", "cityPropertyAlias", "zipCodePropertyAlias", "SYSTEM" };
            Dictionary <string, string> inputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            inputFields["REQUEST.VERSION"]  = "1.0";
            inputFields["FRONTEND.ENABLED"] = "true";
            inputFields["FRONTEND.POPUP"]   = "false";

            inputFields["IDENTIFICATION.TRANSACTIONID"] = order.CartNumber;

            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            inputFields["PRESENTATION.CURRENCY"] = currency.IsoCode;
            inputFields["PRESENTATION.AMOUNT"]   = (order.TotalPrice.Value.WithVat).ToString("0.00", CultureInfo.InvariantCulture);

            inputFields["FRONTEND.RESPONSE_URL"] = teaCommerceCallBackUrl;

            inputFields["NAME.GIVEN"]  = order.PaymentInformation.FirstName;
            inputFields["NAME.FAMILY"] = order.PaymentInformation.LastName;

            inputFields["CONTACT.EMAIL"] = order.PaymentInformation.Email;
            inputFields["CONTACT.IP"]    = HttpContext.Current.Request.UserHostAddress;

            inputFields["ADDRESS.STREET"] = order.Properties[settings["streetAddressPropertyAlias"]];
            inputFields["ADDRESS.CITY"]   = order.Properties[settings["cityPropertyAlias"]];
            inputFields["ADDRESS.ZIP"]    = order.Properties[settings["zipCodePropertyAlias"]];

            inputFields["ADDRESS.COUNTRY"] = CountryService.Instance.Get(order.StoreId, order.PaymentInformation.CountryId).RegionCode;
            if (order.PaymentInformation.CountryRegionId != null)
            {
                inputFields["ADDRESS.STATE"] = CountryRegionService.Instance.Get(order.StoreId, order.PaymentInformation.CountryRegionId.Value).RegionCode;
            }

            IDictionary <string, string> responseKvps = MakePostRequest(settings, inputFields);

            if (responseKvps["POST.VALIDATION"].Equals("ACK"))
            {
                htmlForm.Action = HttpContext.Current.Server.UrlDecode(responseKvps["FRONTEND.REDIRECT_URL"]);
            }
            else
            {
                throw new Exception("Generate html failed - error code: " + responseKvps["POST.VALIDATION"]);
            }

            return(htmlForm);
        }
Пример #10
0
        public override ApiInfo RefundPayment(Order order, IDictionary <string, string> settings)
        {
            ApiInfo apiInfo = null;

            try {
                order.MustNotBeNull("order");
                settings.MustNotBeNull("settings");
                settings.MustContainKey("merchant", "settings");
                settings.MustContainKey("md5k1", "settings");
                settings.MustContainKey("md5k2", "settings");
                settings.MustContainKey("apiusername", "settings");
                settings.MustContainKey("apipassword", "settings");

                Dictionary <string, string> inputFields = new Dictionary <string, string>();

                string merchant = settings["merchant"];
                inputFields["merchant"] = merchant;

                string strAmount = (order.TransactionInformation.AmountAuthorized.Value * 100M).ToString("0");
                inputFields["amount"] = strAmount;

                inputFields["orderid"]   = order.CartNumber;
                inputFields["transact"]  = order.TransactionInformation.TransactionId;
                inputFields["textreply"] = "yes";

                Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);
                if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
                {
                    throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
                }
                inputFields["currency"] = Iso4217CurrencyCodes[currency.IsoCode];

                //MD5(key2 + MD5(key1 + “merchant=<merchant>&orderid=<orderid> &transact=<transact>&amount=<amount>"))
                string md5CheckValue = string.Empty;
                md5CheckValue += settings["md5k1"];
                md5CheckValue += "merchant=" + merchant;
                md5CheckValue += "&orderid=" + order.CartNumber;
                md5CheckValue += "&transact=" + order.TransactionInformation.TransactionId;
                md5CheckValue += "&amount=" + strAmount;

                inputFields["md5key"] = GenerateMD5Hash(settings["md5k2"] + GenerateMD5Hash(md5CheckValue));

                try {
                    string response = MakePostRequest("https://payment.architrade.com/cgi-adm/refund.cgi", inputFields, new NetworkCredential(settings["apiusername"], settings["apipassword"]));

                    Regex  reg    = new Regex(@"result=(\d*)");
                    string result = reg.Match(response).Groups[1].Value;

                    if (result == "0")
                    {
                        apiInfo = new ApiInfo(order.TransactionInformation.TransactionId, PaymentState.Refunded);
                    }
                    else
                    {
                        LoggingService.Instance.Warn <Dibs>("DIBS(" + order.OrderNumber + ") - Error making API request - error message: " + result);
                    }
                } catch (WebException) {
                    LoggingService.Instance.Warn <Dibs>("DIBS(" + order.OrderNumber + ") - Error making API request - wrong credentials");
                }
            } catch (Exception exp) {
                LoggingService.Instance.Error <Dibs>("DIBS(" + order.OrderNumber + ") - Refund payment", exp);
            }

            return(apiInfo);
        }
Пример #11
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("MerchantID", "settings");
            settings.MustContainKey("TransactionType", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm {
                Action = "https://mms.paymentsensegateway.com/Pages/PublicPages/PaymentForm.aspx"
            };

            string[] settingsToExclude = new[] { "CancelURL", "streetAddressPropertyAlias", "cityPropertyAlias", "zipCodePropertyAlias", "PreSharedKey", "Password", "Testing" };
            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            if (order.CartNumber.Length > 50)
            {
                throw new Exception("Cart number of the order can not exceed 50 characters.");
            }
            htmlForm.InputFields["OrderID"] = order.CartNumber;

            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            htmlForm.InputFields["CurrencyCode"] = Iso4217CurrencyCodes[currency.IsoCode];
            htmlForm.InputFields["Amount"]       = (order.TotalPrice.Value.WithVat * 100M).ToString("0", CultureInfo.InvariantCulture);

            htmlForm.InputFields["CustomerName"] = order.PaymentInformation.FirstName + " " + order.PaymentInformation.LastName;

            if (settings.ContainsKey("streetAddressPropertyAlias"))
            {
                htmlForm.InputFields["Address1"] = order.Properties[settings["streetAddressPropertyAlias"]];
            }

            if (settings.ContainsKey("cityPropertyAlias"))
            {
                htmlForm.InputFields["City"] = order.Properties[settings["cityPropertyAlias"]];
            }

            if (order.PaymentInformation.CountryRegionId != null)
            {
                htmlForm.InputFields["State"] = CountryRegionService.Instance.Get(order.StoreId, order.PaymentInformation.CountryRegionId.Value).Name;
            }

            if (settings.ContainsKey("zipCodePropertyAlias"))
            {
                htmlForm.InputFields["PostCode"] = order.Properties[settings["zipCodePropertyAlias"]];
            }

            Country country = CountryService.Instance.Get(order.StoreId, order.PaymentInformation.CountryId);

            if (!Iso3166CountryCodes.ContainsKey(country.RegionCode))
            {
                throw new Exception("You must specify an ISO 3166 country code for the " + country.Name + " country");
            }
            htmlForm.InputFields["CountryCode"] = Iso3166CountryCodes[country.RegionCode];

            htmlForm.InputFields["EmailAddress"] = order.PaymentInformation.Email;

            htmlForm.InputFields["CallbackURL"]     = teaCommerceCallBackUrl;
            htmlForm.InputFields["ServerResultURL"] = teaCommerceCallBackUrl;

            htmlForm.InputFields["ResultDeliveryMethod"]      = "SERVER";
            htmlForm.InputFields["PaymentFormDisplaysResult"] = bool.FalseString;
            htmlForm.InputFields["TransactionDateTime"]       = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss zzz");

            List <string> keysToHash = new List <string>();

            keysToHash.Add("PreSharedKey");
            keysToHash.Add("MerchantID");
            keysToHash.Add("Password");
            keysToHash.Add("Amount");
            keysToHash.Add("CurrencyCode");
            if (htmlForm.InputFields.ContainsKey("EchoAVSCheckResult"))
            {
                keysToHash.Add("EchoAVSCheckResult");
            }
            if (htmlForm.InputFields.ContainsKey("EchoCV2CheckResult"))
            {
                keysToHash.Add("EchoCV2CheckResult");
            }
            if (htmlForm.InputFields.ContainsKey("EchoThreeDSecureAuthenticationCheckResult"))
            {
                keysToHash.Add("EchoThreeDSecureAuthenticationCheckResult");
            }
            if (htmlForm.InputFields.ContainsKey("EchoCardType"))
            {
                keysToHash.Add("EchoCardType");
            }
            if (htmlForm.InputFields.ContainsKey("AVSOverridePolicy"))
            {
                keysToHash.Add("AVSOverridePolicy");
            }
            if (htmlForm.InputFields.ContainsKey("CV2OverridePolicy"))
            {
                keysToHash.Add("CV2OverridePolicy");
            }
            if (htmlForm.InputFields.ContainsKey("ThreeDSecureOverridePolicy"))
            {
                keysToHash.Add("ThreeDSecureOverridePolicy");
            }
            keysToHash.Add("OrderID");
            keysToHash.Add("TransactionType");
            keysToHash.Add("TransactionDateTime");
            keysToHash.Add("CallbackURL");
            keysToHash.Add("OrderDescription");
            keysToHash.Add("CustomerName");
            keysToHash.Add("Address1");
            keysToHash.Add("Address2");
            keysToHash.Add("Address3");
            keysToHash.Add("Address4");
            keysToHash.Add("City");
            keysToHash.Add("State");
            keysToHash.Add("PostCode");
            keysToHash.Add("CountryCode");
            if (htmlForm.InputFields.ContainsKey("EmailAddress"))
            {
                keysToHash.Add("EmailAddress");
            }
            if (htmlForm.InputFields.ContainsKey("PhoneNumber"))
            {
                keysToHash.Add("PhoneNumber");
            }
            if (htmlForm.InputFields.ContainsKey("EmailAddressEditable"))
            {
                keysToHash.Add("EmailAddressEditable");
            }
            if (htmlForm.InputFields.ContainsKey("PhoneNumberEditable"))
            {
                keysToHash.Add("PhoneNumberEditable");
            }
            if (htmlForm.InputFields.ContainsKey("CV2Mandatory"))
            {
                keysToHash.Add("CV2Mandatory");
            }
            if (htmlForm.InputFields.ContainsKey("Address1Mandatory"))
            {
                keysToHash.Add("Address1Mandatory");
            }
            if (htmlForm.InputFields.ContainsKey("CityMandatory"))
            {
                keysToHash.Add("CityMandatory");
            }
            if (htmlForm.InputFields.ContainsKey("PostCodeMandatory"))
            {
                keysToHash.Add("PostCodeMandatory");
            }
            if (htmlForm.InputFields.ContainsKey("StateMandatory"))
            {
                keysToHash.Add("StateMandatory");
            }
            if (htmlForm.InputFields.ContainsKey("CountryMandatory"))
            {
                keysToHash.Add("CountryMandatory");
            }
            keysToHash.Add("ResultDeliveryMethod");
            if (htmlForm.InputFields.ContainsKey("ServerResultURL"))
            {
                keysToHash.Add("ServerResultURL");
            }
            if (htmlForm.InputFields.ContainsKey("PaymentFormDisplaysResult"))
            {
                keysToHash.Add("PaymentFormDisplaysResult");
            }
            if (htmlForm.InputFields.ContainsKey("ServerResultURLCookieVariables"))
            {
                keysToHash.Add("ServerResultURLCookieVariables");
            }
            if (htmlForm.InputFields.ContainsKey("ServerResultURLFormVariables"))
            {
                keysToHash.Add("ServerResultURLFormVariables");
            }
            if (htmlForm.InputFields.ContainsKey("ServerResultURLQueryStringVariables"))
            {
                keysToHash.Add("ServerResultURLQueryStringVariables");
            }

            htmlForm.InputFields["HashDigest"] = CreateHashDigest(keysToHash, settings, htmlForm.InputFields);

            return(htmlForm);
        }
Пример #12
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("merchant_id", "settings");
            settings.MustContainKey("agreement_id", "settings");
            settings.MustContainKey("autocapture", "settings");
            settings.MustContainKey("language", "settings");
            settings.MustContainKey("windowApiKey", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm {
                Action = "https://payment.quickpay.net"
            };

            htmlForm.InputFields["version"]         = "v10";
            htmlForm.InputFields["merchant_id"]     = settings["merchant_id"];
            htmlForm.InputFields["agreement_id"]    = settings["agreement_id"];
            htmlForm.InputFields["autocapture"]     = settings["autocapture"];
            htmlForm.InputFields["payment_methods"] = settings["payment_methods"];

            //Order name must be between 4 or 20 chars
            string orderName = order.CartNumber;

            while (orderName.Length < 4)
            {
                orderName = "0" + orderName;
            }
            if (orderName.Length > 20)
            {
                throw new Exception("Cart number of the order can not exceed 20 characters.");
            }
            htmlForm.InputFields["order_id"] = orderName;

            htmlForm.InputFields["amount"] = (order.TotalPrice.Value.WithVat * 100M).ToString("0", CultureInfo.InvariantCulture);

            //Check that the Iso code exists
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            htmlForm.InputFields["currency"] = currency.IsoCode;

            htmlForm.InputFields["continueurl"] = teaCommerceContinueUrl;
            htmlForm.InputFields["cancelurl"]   = teaCommerceCancelUrl;
            htmlForm.InputFields["callbackurl"] = teaCommerceCallBackUrl;

            htmlForm.InputFields["language"] = settings["language"];

            if (settings.ContainsKey("branding_id"))
            {
                htmlForm.InputFields["branding_id"] = settings["branding_id"];
            }

            if (settings.ContainsKey("google_analytics_tracking_id"))
            {
                htmlForm.InputFields["google_analytics_tracking_id"] = settings["google_analytics_tracking_id"];
            }

            if (settings.ContainsKey("google_analytics_client_id"))
            {
                htmlForm.InputFields["google_analytics_client_id"] = settings["google_analytics_client_id"];
            }

            htmlForm.InputFields["checksum"] = GetChecksum(htmlForm.InputFields, settings["windowApiKey"]);

            return(htmlForm);
        }
Пример #13
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("merchantId", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm();

            string[] settingsToExclude = new[] { "accepturl", "cancelurl", "instantcapture", "testMode" };
            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            //orderNumber
            htmlForm.InputFields["orderNumber"] = order.CartNumber;

            //currencyCode
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            htmlForm.InputFields["currencyCode"] = currency.IsoCode;

            //amount
            htmlForm.InputFields["amount"] = (order.TotalPrice.Value.WithVat * 100M).ToString("0", CultureInfo.InvariantCulture);

            //redirectUrl
            htmlForm.InputFields["redirectUrl"] = teaCommerceCallBackUrl;

            //redirectOnError
            htmlForm.InputFields["redirectOnError"] = "false";

            //paymentMethodList
            if (htmlForm.InputFields.ContainsKey("paymentMethodList") && string.IsNullOrEmpty(htmlForm.InputFields["paymentMethodList"]))
            {
                htmlForm.InputFields.Remove("paymentMethodList");
            }

            XDocument xmlResponse = XDocument.Parse(MakePostRequest(settings.ContainsKey("testMode") && settings["testMode"] == "1" ? "https://epayment-test.bbs.no/Netaxept/Register.aspx" : "https://epayment.bbs.no/Netaxept/Register.aspx", htmlForm.InputFields), LoadOptions.PreserveWhitespace);

            if (xmlResponse.XPathSelectElement("//RegisterResponse") != null)
            {
                //Save the Tea Commerce continue and cancel url so we have access to them in the "Callback"
                order.Properties.AddOrUpdate(new CustomProperty("teaCommerceContinueUrl", teaCommerceContinueUrl)
                {
                    ServerSideOnly = true
                });
                order.Properties.AddOrUpdate(new CustomProperty("teaCommerceCancelUrl", teaCommerceCancelUrl)
                {
                    ServerSideOnly = true
                });
                order.Save();

                htmlForm.Action = (settings.ContainsKey("testMode") && settings["testMode"] == "1" ? "https://epayment-test.bbs.no/Terminal/default.aspx" : "https://epayment.bbs.no/Terminal/default.aspx") + "?merchantId=" + settings["merchantId"] + "&transactionId=" + xmlResponse.XPathSelectElement("//TransactionId").Value;
            }
            else
            {
                throw new Exception("Generate html failed - error message: " + xmlResponse.XPathSelectElement("//Error/Message").Value);
            }

            return(htmlForm);
        }
Пример #14
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            string action    = string.Empty;
            string encrypted = string.Empty;

            try {
                int bvCount = 0;

                IDictionary <string, string> inputFields = PrepareApiPostRequest("BMCreateButton", settings);

                inputFields.Add("BUTTONCODE", "ENCRYPTED");
                inputFields.Add("BUTTONTYPE", "BUYNOW");
                inputFields.Add("BUTTONSUBTYPE", "PRODUCTS");

                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "business=" + (settings.ContainsKey("business") ? settings["business"] : string.Empty).Trim());
                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "lc=" + (settings.ContainsKey("lc") ? settings["lc"] : string.Empty).Trim());
                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "button_subtype=PRODUCTS");

                // Check that the Iso code exists
                Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);
                if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
                {
                    throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
                }

                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "currency_code=" + currency.IsoCode);

                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "invoice=" + order.CartNumber);
                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "item_name=" + (settings.ContainsKey("totalName") ? settings["totalName"] : "Total").Trim());
                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "item_number=" + (settings.ContainsKey("totalSku") ? settings["totalSku"] : "0001").Trim());
                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "amount=" + order.TotalPrice.Value.WithVat.ToString("0.00", CultureInfo.InvariantCulture));
                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "quantity=" + 1M.ToString("0", CultureInfo.InvariantCulture));

                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "return=" + teaCommerceContinueUrl);
                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "rm=2");
                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "cancel_return=" + teaCommerceCancelUrl);
                bvCount++;
                inputFields.Add($"L_BUTTONVAR{bvCount}", "notify_url=" + teaCommerceCallBackUrl);

                ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
                string response = MakePostRequest(settings.ContainsKey("isSandbox") && settings["isSandbox"] == "1" ? "https://api-3t.sandbox.paypal.com/nvp" : "https://api-3t.paypal.com/nvp", inputFields);
                IDictionary <string, string> responseKvp = GetApiResponseKvp(response);
                if (responseKvp["ACK"] == "Success" || responseKvp["ACK"] == "SuccessWithWarning")
                {
                    string input = responseKvp["WEBSITECODE"];
                    using (XmlReader reader = XmlReader.Create(new StringReader(input))) {
                        reader.ReadToFollowing("form");
                        reader.MoveToAttribute("action");
                        action = reader.Value.Trim();

                        while (reader.ReadToFollowing("input"))
                        {
                            reader.MoveToAttribute("name");
                            string name = reader.Value.Trim();
                            if (name != "encrypted")
                            {
                                continue;
                            }

                            reader.MoveToAttribute("value");
                            encrypted = reader.Value.Trim();
                            break;
                        }
                    }
                }
                else
                {
                    LoggingService.Instance.Warn <PayPal>("PayPal(" + order.OrderNumber + ") - Error making API request - error code: " + responseKvp["L_ERRORCODE0"]);
                }
            }
            catch (Exception exp) {
                LoggingService.Instance.Error <PayPal>("PayPal(" + order.OrderNumber + ") - GenerateHtmlForm payment", exp);
            }

            PaymentHtmlForm htmlForm = new PaymentHtmlForm {
                Action      = action,
                InputFields = new Dictionary <string, string> {
                    { "cmd", "_s-xclick" },
                    { "encrypted", encrypted }
                }
            };

            return(htmlForm);
        }
Пример #15
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("md5Secret", "settings");
            settings.MustContainKey("instId", "settings");
            settings.MustContainKey("streetAddressPropertyAlias", "settings");
            settings.MustContainKey("cityPropertyAlias", "settings");
            settings.MustContainKey("zipCodePropertyAlias", "settings");
            order.Properties[settings["streetAddressPropertyAlias"]].MustNotBeNullOrEmpty("street address");
            order.Properties[settings["cityPropertyAlias"]].MustNotBeNullOrEmpty("city");
            order.Properties[settings["zipCodePropertyAlias"]].MustNotBeNullOrEmpty("zip code");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm {
                Action = settings.ContainsKey("testMode") && settings["testMode"] == "100" ? "https://secure-test.worldpay.com/wcc/purchase" : "https://secure.worldpay.com/wcc/purchase"
            };

            string[] settingsToExclude = new[] { "md5Secret", "callbackPW", "streetAddressPropertyAlias", "cityPropertyAlias", "zipCodePropertyAlias" };
            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            //cartId
            htmlForm.InputFields["cartId"] = order.CartNumber;

            //currency
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            htmlForm.InputFields["currency"] = currency.IsoCode;

            //amount
            string amount = order.TotalPrice.Value.WithVat.ToString("0.00", CultureInfo.InvariantCulture);

            htmlForm.InputFields["amount"] = amount;

            htmlForm.InputFields["successURL"] = teaCommerceContinueUrl;
            htmlForm.InputFields["cancelURL"]  = teaCommerceCancelUrl;

            //name
            htmlForm.InputFields["name"] = order.PaymentInformation.FirstName + " " + order.PaymentInformation.LastName;

            //email
            htmlForm.InputFields["email"] = order.PaymentInformation.Email;

            //country
            Country country = CountryService.Instance.Get(order.StoreId, order.PaymentInformation.CountryId);

            htmlForm.InputFields["country"] = country.RegionCode;

            //country region
            if (order.PaymentInformation.CountryRegionId != null)
            {
                CountryRegion countryRegion = CountryRegionService.Instance.Get(order.StoreId, order.PaymentInformation.CountryRegionId.Value);
                htmlForm.InputFields["region"] = countryRegion.RegionCode;
            }

            //address1
            htmlForm.InputFields["address1"] = order.Properties[settings["streetAddressPropertyAlias"]];

            //town
            htmlForm.InputFields["town"] = order.Properties[settings["cityPropertyAlias"]];

            //postcode
            htmlForm.InputFields["postcode"] = order.Properties[settings["zipCodePropertyAlias"]];

            //UI settings
            htmlForm.InputFields["noLanguageMenu"] = string.Empty;
            htmlForm.InputFields["hideCurrency"]   = string.Empty;
            htmlForm.InputFields["fixContact"]     = string.Empty;
            htmlForm.InputFields["hideContact"]    = string.Empty;

            htmlForm.InputFields["signatureFields"] = "amount:currency:instId:cartId";
            htmlForm.InputFields["signature"]       = GenerateMD5Hash(settings["md5Secret"] + ":" + amount + ":" + currency.IsoCode + ":" + settings["instId"] + ":" + order.CartNumber);

            //WorldPay dont support to show order line information to the shopper

            return(htmlForm);
        }
Пример #16
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("merchantnumber", "settings");
            settings.MustContainKey("language", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm {
                Action = "https://ssl.ditonlinebetalingssystem.dk/integration/ewindow/Default.aspx"
            };

            string[] settingsToExclude = new[] { "iframeelement", "md5securitykey", "webservicepassword", "testMode" };
            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            //orderid
            htmlForm.InputFields["orderid"] = order.CartNumber;

            //currency
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }

            htmlForm.InputFields["currency"] = Iso4217CurrencyCodes[currency.IsoCode];

            //amount
            htmlForm.InputFields["amount"] = (order.TotalPrice.Value.WithVat * 100M).ToString("0", CultureInfo.InvariantCulture);

            htmlForm.InputFields["accepturl"]   = teaCommerceContinueUrl;
            htmlForm.InputFields["cancelurl"]   = teaCommerceCancelUrl;
            htmlForm.InputFields["callbackurl"] = teaCommerceCallBackUrl;

            //instantcallback
            htmlForm.InputFields["instantcallback"] = "1";

            //instantcapture
            if (htmlForm.InputFields.ContainsKey("instantcapture") && string.IsNullOrEmpty(htmlForm.InputFields["instantcapture"]))
            {
                htmlForm.InputFields.Remove("instantcapture");
            }

            //cardtype
            if (htmlForm.InputFields.ContainsKey("paymenttype") && string.IsNullOrEmpty(htmlForm.InputFields["paymenttype"]))
            {
                htmlForm.InputFields.Remove("paymenttype");
            }

            //windowstate
            if (htmlForm.InputFields.ContainsKey("windowstate") && string.IsNullOrEmpty(htmlForm.InputFields["windowstate"]))
            {
                htmlForm.InputFields.Remove("windowstate");
            }

            htmlForm.InputFields["ownreceipt"] = "1";

            //ePay dont support to show order line information to the shopper

            //md5securitykey
            if (settings.ContainsKey("md5securitykey") && !string.IsNullOrEmpty(settings["md5securitykey"]))
            {
                htmlForm.InputFields["hash"] = GenerateMD5Hash(string.Join("", htmlForm.InputFields.Values) + settings["md5securitykey"]);
            }

            htmlForm.JavaScriptFunction = SubmitJavascriptFunction(htmlForm.InputFields, settings);

            return(htmlForm);
        }
Пример #17
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("customerLanguageCode", "settings");
            settings.MustContainKey("testMode", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm();

            IPaynovaClient client = GetClient(settings);

            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            try
            {
                //Create order request
                CreateOrderRequest createOrderRequest = new CreateOrderRequest(order.CartNumber, currency.IsoCode, order.TotalPrice.Value.WithVat)
                {
                    Customer = new Customer(),
                    BillTo   = new NameAndAddress(),
                    ShipTo   = new NameAndAddress()
                };

                #region Customer information

                createOrderRequest.Customer.EmailAddress     = order.PaymentInformation.Email;
                createOrderRequest.Customer.Name.CompanyName = createOrderRequest.BillTo.Name.CompanyName = order.Properties[settings.ContainsKey("companyPropertyAlias") && !string.IsNullOrEmpty(settings["companyPropertyAlias"]) ? settings["companyPropertyAlias"] : "company"];
                createOrderRequest.Customer.Name.Title       = createOrderRequest.BillTo.Name.Title = order.Properties[settings.ContainsKey("titlePropertyAlias") && !string.IsNullOrEmpty(settings["titlePropertyAlias"]) ? settings["titlePropertyAlias"] : "title"];
                createOrderRequest.Customer.Name.FirstName   = createOrderRequest.BillTo.Name.FirstName = order.PaymentInformation.FirstName;
                createOrderRequest.Customer.Name.MiddleNames = createOrderRequest.BillTo.Name.MiddleNames = order.Properties[settings.ContainsKey("middleNamesPropertyAlias") && !string.IsNullOrEmpty(settings["middleNamesPropertyAlias"]) ? settings["middleNamesPropertyAlias"] : "middleNames"];
                createOrderRequest.Customer.Name.LastName    = createOrderRequest.BillTo.Name.LastName = order.PaymentInformation.LastName;
                createOrderRequest.Customer.Name.Suffix      = createOrderRequest.BillTo.Name.Suffix = order.Properties[settings.ContainsKey("suffixPropertyAlias") && !string.IsNullOrEmpty(settings["suffixPropertyAlias"]) ? settings["suffixPropertyAlias"] : "suffix"];
                createOrderRequest.Customer.HomeTelephone    = order.Properties[settings.ContainsKey("homeTelephonePropertyAlias") && !string.IsNullOrEmpty(settings["homeTelephonePropertyAlias"]) ? settings["homeTelephonePropertyAlias"] : "phone"];
                createOrderRequest.Customer.WorkTelephone    = order.Properties[settings.ContainsKey("workTelephonePropertyAlias") && !string.IsNullOrEmpty(settings["workTelephonePropertyAlias"]) ? settings["workTelephonePropertyAlias"] : "workPhone"];
                createOrderRequest.Customer.MobileTelephone  = order.Properties[settings.ContainsKey("mobileTelephonePropertyAlias") && !string.IsNullOrEmpty(settings["mobileTelephonePropertyAlias"]) ? settings["mobileTelephonePropertyAlias"] : "mobile"];
                createOrderRequest.BillTo.Address.Street1    = order.Properties[settings.ContainsKey("street1PropertyAlias") && !string.IsNullOrEmpty(settings["street1PropertyAlias"]) ? settings["street1PropertyAlias"] : "streetAddress"];
                createOrderRequest.BillTo.Address.Street2    = order.Properties[settings.ContainsKey("street2PropertyAlias") && !string.IsNullOrEmpty(settings["street2PropertyAlias"]) ? settings["street2PropertyAlias"] : "streetAddress2"];
                createOrderRequest.BillTo.Address.Street3    = order.Properties[settings.ContainsKey("street3PropertyAlias") && !string.IsNullOrEmpty(settings["street3PropertyAlias"]) ? settings["street3PropertyAlias"] : "streetAddress3"];
                createOrderRequest.BillTo.Address.Street4    = order.Properties[settings.ContainsKey("street4PropertyAlias") && !string.IsNullOrEmpty(settings["street4PropertyAlias"]) ? settings["street4PropertyAlias"] : "streetAddress4"];
                createOrderRequest.BillTo.Address.City       = order.Properties[settings.ContainsKey("cityPropertyAlias") && !string.IsNullOrEmpty(settings["cityPropertyAlias"]) ? settings["cityPropertyAlias"] : "city"];
                createOrderRequest.BillTo.Address.PostalCode = order.Properties[settings.ContainsKey("postalCodePropertyAlias") && !string.IsNullOrEmpty(settings["postalCodePropertyAlias"]) ? settings["postalCodePropertyAlias"] : "zipCode"];
                if (order.PaymentInformation.CountryRegionId != null)
                {
                    createOrderRequest.BillTo.Address.RegionCode = CountryRegionService.Instance.Get(order.StoreId, order.PaymentInformation.CountryRegionId.Value).RegionCode;
                }
                createOrderRequest.BillTo.Address.CountryCode = CountryService.Instance.Get(order.StoreId, order.PaymentInformation.CountryId).RegionCode;

                createOrderRequest.ShipTo.Name.CompanyName   = order.Properties[settings.ContainsKey("shipping_companyPropertyAlias") && !string.IsNullOrEmpty(settings["shipping_companyPropertyAlias"]) ? settings["shipping_companyPropertyAlias"] : "shipping_company"];
                createOrderRequest.ShipTo.Name.Title         = order.Properties[settings.ContainsKey("shipping_titlePropertyAlias") && !string.IsNullOrEmpty(settings["shipping_titlePropertyAlias"]) ? settings["shipping_titlePropertyAlias"] : "shipping_title"];
                createOrderRequest.ShipTo.Name.FirstName     = order.Properties[settings.ContainsKey("shipping_firstNamePropertyAlias") && !string.IsNullOrEmpty(settings["shipping_firstNamePropertyAlias"]) ? settings["shipping_firstNamePropertyAlias"] : "shipping_firstName"];
                createOrderRequest.ShipTo.Name.MiddleNames   = order.Properties[settings.ContainsKey("shipping_middleNamesPropertyAlias") && !string.IsNullOrEmpty(settings["shipping_middleNamesPropertyAlias"]) ? settings["shipping_middleNamesPropertyAlias"] : "shipping_middleNames"];
                createOrderRequest.ShipTo.Name.LastName      = order.Properties[settings.ContainsKey("shipping_lastNamePropertyAlias") && !string.IsNullOrEmpty(settings["shipping_lastNamePropertyAlias"]) ? settings["shipping_lastNamePropertyAlias"] : "shipping_lastName"];
                createOrderRequest.ShipTo.Name.Suffix        = order.Properties[settings.ContainsKey("shipping_suffixPropertyAlias") && !string.IsNullOrEmpty(settings["shipping_suffixPropertyAlias"]) ? settings["shipping_suffixPropertyAlias"] : "shipping_suffix"];
                createOrderRequest.ShipTo.Address.Street1    = order.Properties[settings.ContainsKey("shipping_street1PropertyAlias") && !string.IsNullOrEmpty(settings["shipping_street1PropertyAlias"]) ? settings["shipping_street1PropertyAlias"] : "shipping_streetAddress"];
                createOrderRequest.ShipTo.Address.Street2    = order.Properties[settings.ContainsKey("shipping_street2PropertyAlias") && !string.IsNullOrEmpty(settings["shipping_street2PropertyAlias"]) ? settings["shipping_street2PropertyAlias"] : "shipping_streetAddress2"];
                createOrderRequest.ShipTo.Address.Street3    = order.Properties[settings.ContainsKey("shipping_street3PropertyAlias") && !string.IsNullOrEmpty(settings["shipping_street3PropertyAlias"]) ? settings["shipping_street3PropertyAlias"] : "shipping_streetAddress3"];
                createOrderRequest.ShipTo.Address.Street4    = order.Properties[settings.ContainsKey("shipping_street4PropertyAlias") && !string.IsNullOrEmpty(settings["shipping_street4PropertyAlias"]) ? settings["shipping_street4PropertyAlias"] : "shipping_streetAddress4"];
                createOrderRequest.ShipTo.Address.City       = order.Properties[settings.ContainsKey("shipping_cityPropertyAlias") && !string.IsNullOrEmpty(settings["shipping_cityPropertyAlias"]) ? settings["shipping_cityPropertyAlias"] : "shipping_city"];
                createOrderRequest.ShipTo.Address.PostalCode = order.Properties[settings.ContainsKey("shipping_postalCodePropertyAlias") && !string.IsNullOrEmpty(settings["shipping_postalCodePropertyAlias"]) ? settings["shipping_postalCodePropertyAlias"] : "shipping_zipCode"];
                if (order.ShipmentInformation.CountryRegionId != null)
                {
                    createOrderRequest.ShipTo.Address.RegionCode = CountryRegionService.Instance.Get(order.StoreId, order.ShipmentInformation.CountryRegionId.Value).RegionCode;
                }
                if (order.ShipmentInformation.CountryId != null)
                {
                    createOrderRequest.ShipTo.Address.CountryCode = CountryService.Instance.Get(order.StoreId, order.ShipmentInformation.CountryId.Value).RegionCode;
                }

                #endregion

                CreateOrderResponse createOrderResponse = client.CreateOrder(createOrderRequest);

                //Initialize payment request
                InterfaceOptions         interfaceOptions         = new InterfaceOptions(InterfaceId.Aero, settings["customerLanguageCode"], new Uri(teaCommerceContinueUrl), new Uri(teaCommerceCancelUrl), new Uri(teaCommerceContinueUrl));
                InitializePaymentRequest initializePaymentRequest = new InitializePaymentRequest(createOrderResponse.OrderId, order.TotalPrice.Value.WithVat, PaymentChannelId.Web, interfaceOptions);

                if (settings.ContainsKey("paymentMethods") && !string.IsNullOrEmpty(settings["paymentMethods"]))
                {
                    initializePaymentRequest.WithPaymentMethods(settings["paymentMethods"].Split(',').Select(i => PaynovaPaymentMethod.Custom(int.Parse(i))));
                }


                InitializePaymentResponse initializePaymentResponse = client.InitializePayment(initializePaymentRequest);
                htmlForm.Action = initializePaymentResponse.Url;
            }
            catch (Exception e)
            {
            }

            return(htmlForm);
        }
Пример #18
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("merchant", "settings");
            settings.MustContainKey("md5k1", "settings");
            settings.MustContainKey("md5k2", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm {
                Action = "https://payment.architrade.com/paymentweb/start.action"
            };

            string[] settingsToExclude = new[] { "md5k1", "md5k2", "apiusername", "apipassword" };
            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            htmlForm.InputFields["orderid"] = order.CartNumber;

            string strAmount = (order.TotalPrice.Value.WithVat * 100M).ToString("0", CultureInfo.InvariantCulture);

            htmlForm.InputFields["amount"] = strAmount;

            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            string currencyStr = Iso4217CurrencyCodes[currency.IsoCode];

            htmlForm.InputFields["currency"] = currencyStr;

            htmlForm.InputFields["accepturl"]   = teaCommerceContinueUrl;
            htmlForm.InputFields["cancelurl"]   = teaCommerceCancelUrl;
            htmlForm.InputFields["callbackurl"] = teaCommerceCallBackUrl;

            if (htmlForm.InputFields.ContainsKey("capturenow") && htmlForm.InputFields["capturenow"] != "1")
            {
                htmlForm.InputFields.Remove("capturenow");
            }

            if (htmlForm.InputFields.ContainsKey("calcfee") && htmlForm.InputFields["calcfee"] != "1")
            {
                htmlForm.InputFields.Remove("calcfee");
            }

            htmlForm.InputFields["uniqueoid"] = string.Empty;

            if (htmlForm.InputFields.ContainsKey("test") && htmlForm.InputFields["test"] != "1")
            {
                htmlForm.InputFields.Remove("test");
            }

            //DIBS dont support to show order line information to the shopper

            //MD5(key2 + MD5(key1 + “merchant=<merchant>&orderid=<orderid> &currency=<cur>&amount=<amount>))
            string md5CheckValue = string.Empty;

            md5CheckValue += settings["md5k1"];
            md5CheckValue += "merchant=" + settings["merchant"];
            md5CheckValue += "&orderid=" + order.CartNumber;
            md5CheckValue += "&currency=" + currencyStr;
            md5CheckValue += "&amount=" + strAmount;

            htmlForm.InputFields["md5key"] = GenerateMD5Hash(settings["md5k2"] + GenerateMD5Hash(md5CheckValue));

            return(htmlForm);
        }
Пример #19
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("accountNumber", "settings");
            settings.MustContainKey("purchaseOperation", "settings");
            settings.MustContainKey("encryptionKey", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm();

            long   accountNumber     = long.Parse(settings["accountNumber"]);
            string purchaseOperation = settings["purchaseOperation"];
            int    price             = (int)Math.Round(order.TotalPrice.Value.WithVat * 100M, 0);
            string priceArgList      = string.Empty;

            //Check that the Iso code exists
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }

            int          vat              = (int)Math.Round(order.VatRate * 100M * 100M, 0);
            string       orderId          = order.CartNumber;
            string       productNumber    = string.Join(",", order.OrderLines.Select(ol => ol.Sku));
            string       description      = string.Join(",", order.OrderLines.Select(ol => ol.Name));
            string       clientIpAddress  = HttpContext.Current.Request.UserHostAddress;
            string       clientIdentifier = string.Empty;
            string       additionalValues = string.Empty;
            string       externalId       = string.Empty;
            string       returnUrl        = teaCommerceContinueUrl;
            const string view             = "CREDITCARD";
            string       agreementRef     = string.Empty;
            string       cancelUrl        = teaCommerceCancelUrl;
            string       clientLanguage   = string.Empty;

            string md5Hash = GenerateMD5Hash(accountNumber.ToString(CultureInfo.InvariantCulture) + purchaseOperation + price.ToString(CultureInfo.InvariantCulture) + priceArgList + currency.IsoCode + vat.ToString(CultureInfo.InvariantCulture) + orderId + productNumber + description + clientIpAddress + clientIdentifier + additionalValues + externalId + returnUrl + view + agreementRef + cancelUrl + clientLanguage + settings["encryptionKey"]);

            ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
            string xmlReturn = GetPayExServiceClient(settings).Initialize7(accountNumber, purchaseOperation, price, priceArgList, currency.IsoCode, vat, orderId, productNumber, description, clientIpAddress, clientIdentifier, additionalValues, externalId, returnUrl, view, agreementRef, cancelUrl, clientLanguage, md5Hash);

            XDocument xmlDoc    = XDocument.Parse(xmlReturn, LoadOptions.PreserveWhitespace);
            string    errorCode = xmlDoc.XPathSelectElement("//status/errorCode").Value;

            if (errorCode.Equals("OK"))
            {
                order.Properties.AddOrUpdate(new CustomProperty("orderRef", xmlDoc.XPathSelectElement("//orderRef").Value)
                {
                    ServerSideOnly = true
                });
                order.Save();
                htmlForm.Action = xmlDoc.XPathSelectElement("//redirectUrl").Value;
            }
            else
            {
                htmlForm.Action = teaCommerceCancelUrl;
                LoggingService.Instance.Warn <PayEx>("PayEx(" + order.CartNumber + ") - Generate html form error - error code: " + xmlDoc.XPathSelectElement("//status/description").Value);
            }

            return(htmlForm);
        }
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("streetAddressPropertyAlias", "settings");
            settings.MustContainKey("cityPropertyAlias", "settings");
            settings.MustContainKey("zipCodePropertyAlias", "settings");
            settings.MustContainKey("Description", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm();

            string[] settingsToExclude = new[] { "streetAddressPropertyAlias", "cityPropertyAlias", "zipCodePropertyAlias", "phonePropertyAlias", "shipping_firstNamePropertyAlias", "shipping_lastNamePropertyAlias", "shipping_streetAddressPropertyAlias", "shipping_cityPropertyAlias", "shipping_zipCodePropertyAlias", "shipping_phonePropertyAlias", "testMode" };
            Dictionary <string, string> inputFields = settings.Where(i => !settingsToExclude.Contains(i.Key)).ToDictionary(i => i.Key, i => i.Value);

            inputFields["VPSProtocol"] = "2.23";

            #region Address properties

            string streetAddress = order.Properties[settings["streetAddressPropertyAlias"]];
            string city          = order.Properties[settings["cityPropertyAlias"]];
            string zipCode       = order.Properties[settings["zipCodePropertyAlias"]];

            streetAddress.MustNotBeNullOrEmpty("streetAddress");
            city.MustNotBeNullOrEmpty("city");
            zipCode.MustNotBeNullOrEmpty("zipCode");

            string shippingFirstName = settings.ContainsKey("shipping_firstNamePropertyAlias") ? order.Properties[settings["shipping_firstNamePropertyAlias"]] : "";
            if (string.IsNullOrEmpty(shippingFirstName))
            {
                shippingFirstName = order.PaymentInformation.FirstName;
            }

            string shippingLastName = settings.ContainsKey("shipping_lastNamePropertyAlias") ? order.Properties[settings["shipping_lastNamePropertyAlias"]] : "";
            if (string.IsNullOrEmpty(shippingLastName))
            {
                shippingLastName = order.PaymentInformation.LastName;
            }

            string shippingStreetAddress = settings.ContainsKey("shipping_streetAddressPropertyAlias") ? order.Properties[settings["shipping_streetAddressPropertyAlias"]] : "";
            if (string.IsNullOrEmpty(shippingStreetAddress))
            {
                shippingStreetAddress = streetAddress;
            }

            string shippingCity = settings.ContainsKey("shipping_cityPropertyAlias") ? order.Properties[settings["shipping_cityPropertyAlias"]] : "";
            if (string.IsNullOrEmpty(shippingCity))
            {
                shippingCity = city;
            }

            string shippingZipCode = settings.ContainsKey("shipping_zipCodePropertyAlias") ? order.Properties[settings["shipping_zipCodePropertyAlias"]] : "";
            if (string.IsNullOrEmpty(shippingZipCode))
            {
                shippingZipCode = zipCode;
            }

            #endregion

            if (order.CartNumber.Length > 40)
            {
                throw new Exception("Cart number of the order can not exceed 40 characters.");
            }
            inputFields["VendorTxCode"] = order.CartNumber;
            inputFields["Amount"]       = order.TotalPrice.Value.WithVat.ToString("0.00", CultureInfo.InvariantCulture);

            //Check that the Iso code exists
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);
            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            inputFields["Currency"]          = currency.IsoCode;
            inputFields["Description"]       = inputFields["Description"].Truncate(100);
            inputFields["SuccessURL"]        = teaCommerceContinueUrl;
            inputFields["FailureURL"]        = teaCommerceCancelUrl;
            inputFields["NotificationURL"]   = teaCommerceCallBackUrl;
            inputFields["BillingSurname"]    = order.PaymentInformation.LastName.Truncate(20);
            inputFields["BillingFirstnames"] = order.PaymentInformation.FirstName.Truncate(20);
            inputFields["BillingAddress1"]   = streetAddress.Truncate(100);
            inputFields["BillingCity"]       = city.Truncate(40);
            inputFields["BillingPostCode"]   = zipCode.Truncate(10);

            Country country = CountryService.Instance.Get(order.StoreId, order.PaymentInformation.CountryId);
            inputFields["BillingCountry"] = country.RegionCode;
            if (country.RegionCode.ToUpperInvariant() == "US" && order.PaymentInformation.CountryRegionId != null)
            {
                CountryRegion countryRegion = CountryRegionService.Instance.Get(order.StoreId, order.PaymentInformation.CountryRegionId.Value);
                inputFields["BillingState"] = countryRegion.RegionCode.Truncate(2);
            }
            if (settings.ContainsKey("phonePropertyAlias"))
            {
                inputFields["BillingPhone"] = order.Properties[settings["phonePropertyAlias"]].Truncate(20);
            }

            inputFields["DeliverySurname"]    = shippingLastName.Truncate(20);
            inputFields["DeliveryFirstnames"] = shippingFirstName.Truncate(20);
            inputFields["DeliveryAddress1"]   = shippingStreetAddress.Truncate(100);
            inputFields["DeliveryCity"]       = shippingCity.Truncate(40);
            inputFields["DeliveryPostCode"]   = shippingZipCode.Truncate(10);

            country = CountryService.Instance.Get(order.StoreId, order.ShipmentInformation.CountryId ?? order.PaymentInformation.CountryId);
            inputFields["DeliveryCountry"] = country.RegionCode;

            long?shippingCountryRegionId = order.ShipmentInformation.CountryId != null ? order.ShipmentInformation.CountryRegionId : order.PaymentInformation.CountryRegionId;
            if (country.RegionCode.ToUpperInvariant() == "US" && shippingCountryRegionId != null)
            {
                CountryRegion countryRegion = CountryRegionService.Instance.Get(order.StoreId, shippingCountryRegionId.Value);
                inputFields["DeliveryState"] = countryRegion.RegionCode.Truncate(2);
            }
            if (settings.ContainsKey("shipping_phonePropertyAlias"))
            {
                inputFields["DeliveryPhone"] = order.Properties[settings["shipping_phonePropertyAlias"]].Truncate(20);
            }

            if (!settings.ContainsKey("Apply3DSecure"))
            {
                inputFields["Apply3DSecure"] = "2";
            }

            IDictionary <string, string> responseFields = GetFields(MakePostRequest(GetMethodUrl("PURCHASE", settings), inputFields));
            string status = responseFields["Status"];

            if (status == "OK" || status == "OK REPEATED")
            {
                order.Properties.AddOrUpdate(new CustomProperty("securityKey", responseFields["SecurityKey"])
                {
                    ServerSideOnly = true
                });
                order.Properties.AddOrUpdate(new CustomProperty("teaCommerceContinueUrl", teaCommerceContinueUrl)
                {
                    ServerSideOnly = true
                });
                order.Properties.AddOrUpdate(new CustomProperty("teaCommerceCancelUrl", teaCommerceCancelUrl)
                {
                    ServerSideOnly = true
                });
                order.Save();
                htmlForm.Action = responseFields["NextURL"];
            }
            else
            {
                htmlForm.Action = teaCommerceCancelUrl;
                LoggingService.Instance.Warn <SagePay>("Sage Pay(" + order.CartNumber + ") - Generate html form error - status: " + status + " | status details: " + responseFields["StatusDetail"]);
            }

            return(htmlForm);
        }
Пример #21
0
        public override string ProcessRequest(Order order, HttpRequest request, IDictionary <string, string> settings)
        {
            string response = "";

            try {
                order.MustNotBeNull("order");
                settings.MustNotBeNull("settings");
                settings.MustContainKey("sharedSecret", "settings");

                string communicationType = request["communicationType"];

                KlarnaOrder klarnaOrder = null;
                IConnector  connector   = Connector.Create(settings["sharedSecret"]);

                if (communicationType == "checkout")
                {
                    settings.MustContainKey("merchant.id", "settings");
                    settings.MustContainKey("merchant.terms_uri", "settings");
                    settings.MustContainKey("locale", "settings");

                    //Cart information
                    List <Dictionary <string, object> > cartItems = new List <Dictionary <string, object> > {
                        new Dictionary <string, object> {
                            { "reference", settings.ContainsKey("totalSku") ? settings["totalSku"] : "0001" },
                            { "name", settings.ContainsKey("totalName") ? settings["totalName"] : "Total" },
                            { "quantity", 1 },
                            { "unit_price", (int)(order.TotalPrice.Value.WithVat * 100M) },
                            { "tax_rate", 0 }
                        }
                    };

                    Dictionary <string, object> data = new Dictionary <string, object> {
                        { "cart", new Dictionary <string, object> {
                              { "items", cartItems }
                          } }
                    };
                    string klarnaLocation   = order.Properties["klarnaLocation"];
                    string merchantTermsUri = settings["merchant.terms_uri"];

                    if (!merchantTermsUri.StartsWith("http"))
                    {
                        Uri baseUrl = new UriBuilder(HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port).Uri;
                        merchantTermsUri = new Uri(baseUrl, merchantTermsUri).AbsoluteUri;
                    }

                    //Merchant information
                    data["merchant"] = new Dictionary <string, object> {
                        { "id", settings["merchant.id"] },
                        { "terms_uri", merchantTermsUri },
                        { "checkout_uri", request.UrlReferrer.ToString() },
                        { "confirmation_uri", order.Properties["teaCommerceContinueUrl"] },
                        { "push_uri", order.Properties["teaCommerceCallbackUrl"] }
                    };

                    data["merchant_reference"] = new Dictionary <string, object>()
                    {
                        { "orderid1", order.CartNumber }
                    };

                    //Combined data
                    Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

                    //If the currency is not a valid iso4217 currency then throw an error
                    if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
                    {
                        throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
                    }

                    data["purchase_country"]  = CountryService.Instance.Get(order.StoreId, order.PaymentInformation.CountryId).RegionCode;
                    data["purchase_currency"] = currency.IsoCode;
                    data["locale"]            = settings["locale"];

                    //Check if the order has a Klarna location URI property - then we try and update the order
                    if (!string.IsNullOrEmpty(klarnaLocation))
                    {
                        try {
                            klarnaOrder = new KlarnaOrder(connector, new Uri(klarnaLocation))
                            {
                                ContentType = KlarnaApiRequestContentType
                            };
                            klarnaOrder.Fetch();
                            klarnaOrder.Update(data);
                        } catch (Exception) {
                            //Klarna cart session has expired and we make sure to remove the Klarna location URI property
                            klarnaOrder = null;
                        }
                    }

                    //If no Klarna order was found to update or the session expired - then create new Klarna order
                    if (klarnaOrder == null)
                    {
                        klarnaOrder = new KlarnaOrder(connector)
                        {
                            BaseUri     = settings.ContainsKey("testMode") && settings["testMode"] == "1" ? new Uri("https://checkout.testdrive.klarna.com/checkout/orders") : new Uri("https://checkout.klarna.com/checkout/orders"),
                            ContentType = KlarnaApiRequestContentType
                        };

                        //Create new order
                        klarnaOrder.Create(data);
                        klarnaOrder.Fetch();
                        order.Properties.AddOrUpdate(new CustomProperty("klarnaLocation", klarnaOrder.Location.ToString())
                        {
                            ServerSideOnly = true
                        });
                        order.Save();
                    }
                }
                else if (communicationType == "confirmation")
                {
                    //get confirmation response
                    string klarnaLocation = order.Properties["klarnaLocation"];

                    if (!string.IsNullOrEmpty(klarnaLocation))
                    {
                        //Fetch and show confirmation page if status is not checkout_incomplete
                        klarnaOrder = new KlarnaOrder(connector, new Uri(klarnaLocation))
                        {
                            ContentType = KlarnaApiRequestContentType
                        };
                        klarnaOrder.Fetch();

                        if ((string)klarnaOrder.GetValue("status") == "checkout_incomplete")
                        {
                            throw new Exception("Confirmation page reached without a Klarna order that is finished");
                        }
                    }
                }

                //Get the JavaScript snippet from the Klarna order
                if (klarnaOrder != null)
                {
                    JObject guiElement = klarnaOrder.GetValue("gui") as JObject;
                    if (guiElement != null)
                    {
                        response = guiElement["snippet"].ToString();
                    }
                }
            } catch (Exception exp) {
                LoggingService.Instance.Error <Klarna>("Klarna(" + order.CartNumber + ") - ProcessRequest", exp);
            }

            return(response);
        }
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("payer_agentid", "settings");
            settings.MustContainKey("language", "settings");
            settings.MustContainKey("payment_methods", "settings");
            settings.MustContainKey("md5Key1", "settings");
            settings.MustContainKey("md5Key2", "settings");

            HttpServerUtility server = HttpContext.Current.Server;

            PaymentHtmlForm htmlForm = new PaymentHtmlForm
            {
                Action = "https://secure.pay-read.se/PostAPI_V1/InitPayFlow"
            };

            //Shop id
            htmlForm.InputFields["payer_agentid"] = server.HtmlEncode(settings["payer_agentid"]);

            //API version
            htmlForm.InputFields["payer_xml_writer"] = "payread_php_0_2_v08";

            XNamespace ns        = "http://www.w3.org/2001/XMLSchema-instance";
            XElement   payerData = new XElement("payread_post_api_0_2",
                                                new XAttribute(XNamespace.Xmlns + "xsi", "http://www.w3.org/2001/XMLSchema-instance"),
                                                new XAttribute(ns + "noNamespaceSchemaLocation", "payread_post_api_0_2.xsd")
                                                );

            //Seller details
            payerData.Add(new XElement("seller_details",
                                       new XElement("agent_id", server.HtmlEncode(settings["payer_agentid"]))
                                       ));

            //Buyer details
            payerData.Add(new XElement("buyer_details",
                                       new XElement("first_name", server.HtmlEncode(order.PaymentInformation.FirstName)),
                                       new XElement("last_name", server.HtmlEncode(order.PaymentInformation.LastName)),
                                       new XElement("address_line_1", server.HtmlEncode(string.Empty)),
                                       new XElement("address_line_2", server.HtmlEncode(string.Empty)),
                                       new XElement("postal_code", server.HtmlEncode(string.Empty)),
                                       new XElement("city", server.HtmlEncode(string.Empty)),
                                       new XElement("country_code", server.HtmlEncode(string.Empty)),
                                       new XElement("phone_home", server.HtmlEncode(string.Empty)),
                                       new XElement("phone_work", server.HtmlEncode(string.Empty)),
                                       new XElement("phone_mobile", server.HtmlEncode(string.Empty)),
                                       new XElement("email", server.HtmlEncode(order.PaymentInformation.Email)),
                                       new XElement("organisation", server.HtmlEncode(string.Empty)),
                                       new XElement("orgnr", server.HtmlEncode(string.Empty)),
                                       new XElement("customer_id", server.HtmlEncode(string.Empty))
                                       //new XElement( "your_reference", server.HtmlEncode( string.Empty ) )
                                       //new XElement( "options", server.HtmlEncode( string.Empty ) )
                                       ));

            //Purchase
            XElement purchaseList = new XElement("purchase_list");

            purchaseList.Add(new XElement("freeform_purchase",
                                          new XElement("line_number", 1),
                                          new XElement("description", server.HtmlEncode(settings.ContainsKey("totalName") ? settings["totalName"] : "Total")),
                                          new XElement("item_number", server.HtmlEncode(settings.ContainsKey("totalSku") ? settings["totalSku"] : "0001")),
                                          new XElement("price_including_vat", server.HtmlEncode(order.TotalPrice.Value.WithVat.ToString(CultureInfo.InvariantCulture))),
                                          new XElement("vat_percentage", server.HtmlEncode(0M.ToString(CultureInfo.InvariantCulture))),
                                          new XElement("quantity", server.HtmlEncode(1M.ToString(CultureInfo.InvariantCulture)))
                                          ));

            //Check that the Iso code exists
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            payerData.Add(new XElement("purchase",
                                       new XElement("currency", server.HtmlEncode(currency.IsoCode)),
                                       new XElement("reference_id", server.HtmlEncode(order.CartNumber)),
                                       purchaseList
                                       ));

            //Processing control
            payerData.Add(new XElement("processing_control",
                                       new XElement("success_redirect_url", server.HtmlEncode(teaCommerceContinueUrl)),
                                       new XElement("authorize_notification_url", server.HtmlEncode(teaCommerceCallBackUrl)),
                                       new XElement("settle_notification_url", server.HtmlEncode(teaCommerceCallBackUrl)),
                                       new XElement("redirect_back_to_shop_url", server.HtmlEncode(teaCommerceCancelUrl))
                                       ));

            //Database overrides
            payerData.Add(new XElement("database_overrides",
                                       new XElement("accepted_payment_methods",
                                                    settings["payment_methods"].Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(i =>
                                                                                                                                                   new XElement("payment_method", server.HtmlEncode(i))
                                                                                                                                                   )
                                                    ),
                                       new XElement("debug_mode", server.HtmlEncode(settings.ContainsKey("settings") && settings["test_mode"] == "true" ? "verbose" : "silent")),
                                       new XElement("test_mode", server.HtmlEncode(settings.ContainsKey("settings") ? settings["test_mode"] : "false")),
                                       new XElement("language", server.HtmlEncode(settings["language"]))
                                       ));

            //Add all data to the xml document
            XDocument xmlDocument = new XDocument(
                new XDeclaration("1.0", "ISO-8859-1", "yes"),
                payerData
                );

            htmlForm.InputFields["payer_data"]     = xmlDocument.ToString().ToBase64();
            htmlForm.InputFields["payer_checksum"] = GenerateMD5Hash(settings["md5Key1"] + htmlForm.InputFields["payer_data"] + settings["md5Key2"]);

            return(htmlForm);
        }
Пример #23
0
        public override PaymentHtmlForm GenerateHtmlForm(Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary <string, string> settings)
        {
            order.MustNotBeNull("order");
            settings.MustNotBeNull("settings");
            settings.MustContainKey("return_url", "settings");

            PaymentHtmlForm htmlForm = new PaymentHtmlForm
            {
                Action = GetHtmlMethodUrl(settings)
            };

            string[] settingsToExclude = new[] { "secret_key", "return_url", "return_cancel_url", "payment_description", "test_mode", "awaiting_transfer_statusid", "awaiting_transfer_update",
                                                 "streetPropertyAlias", "houseNumberPropertyAlias", "postalCodePropertyAlias", "cityPropertyAlias", "shippingStreetPropertyAlias",
                                                 "shippingHouseNumberPropertyAlias", "shippingPostalCodePropertyAlias", "shippingCityPropertyAlias", "sexeAlias", "birthdateAlias", "ibanAlias", "phoneNumberAlias" };



            htmlForm.InputFields = settings.Where(i => !settingsToExclude.Contains(i.Key) && !string.IsNullOrEmpty(i.Value)).ToDictionary(i => i.Key, i => i.Value);

            // Amount
            Currency currency = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId);

            if (!Iso4217CurrencyCodes.ContainsKey(currency.IsoCode))
            {
                throw new Exception("You must specify an ISO 4217 currency code for the " + currency.Name + " currency");
            }
            htmlForm.InputFields["brq_currency"] = currency.IsoCode;
            htmlForm.InputFields["brq_amount"]   = order.TotalPrice.Value.WithVat.ToString("0.00", CultureInfo.InvariantCulture);

            // Reference to order
            htmlForm.InputFields["brq_invoicenumber"] = order.CartNumber;
            htmlForm.InputFields["add_cartnumber"]    = order.CartNumber;

            //Show a nice description when customer arrives in Buckaroo
            if (settings.ContainsKey("payment_description") && settings["payment_description"] != "")
            {
                string paymentDescription = settings["payment_description"];
                if (order.Properties[paymentDescription] != null)
                {
                    htmlForm.InputFields["brq_description"] = order.Properties[paymentDescription];
                }
            }

            // WARN: this gets the URL of the current path as a base path. So you can use relative URL's to the language node of the site.
            string path    = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority);
            string baseUrl = path + String.Concat(HttpContext.Current.Request.Url.Segments.Take(2));

            teaCommerceContinueUrl = GetAbsoluteUrl(baseUrl, settings["return_url"]);
            teaCommerceCancelUrl   = GetAbsoluteUrl(baseUrl, settings["return_cancel_url"]);

            // Interactions
            htmlForm.InputFields["brq_return"]       = teaCommerceContinueUrl;
            htmlForm.InputFields["brq_returncancel"] = teaCommerceCancelUrl;
            htmlForm.InputFields["brq_returnerror"]  = teaCommerceCancelUrl;
            htmlForm.InputFields["brq_returnreject"] = teaCommerceCancelUrl;
            htmlForm.InputFields["brq_push"]         = teaCommerceCallBackUrl;
            htmlForm.InputFields["brq_pushfailure"]  = teaCommerceCallBackUrl;

            // Module info for Buckaroo
            htmlForm.InputFields["brq_module_name"]      = "Tea Commerce Payment Provider for Buckaroo Payments";
            htmlForm.InputFields["brq_module_supplier"]  = "Kresco";
            htmlForm.InputFields["brq_module_version"]   = "1";
            htmlForm.InputFields["brq_platform_name"]    = "Umbraco CMS";
            htmlForm.InputFields["brq_platform_version"] = "6";

            if (settings["brq_payment_method"].Equals("ideal", StringComparison.InvariantCultureIgnoreCase))
            {
                string idealIssuer = order.Properties["ideal_issuer"];
                htmlForm.InputFields["brq_service_ideal_issuer"] = idealIssuer;
            }

            if (settings["brq_requestedservices"].Contains("paymentguarantee"))
            {
                // Information for AfterPay
                htmlForm.InputFields["brq_culture"] = currency.CultureName;
                htmlForm.InputFields["brq_service_paymentguarantee_action"] = "PaymentInvitation"; // Default
                string customerId = order.CustomerId.ToString();
                // Generate random guid for anonymous customers
                if (String.IsNullOrWhiteSpace(customerId))
                {
                    customerId = Guid.NewGuid().ToString();
                }

                htmlForm.InputFields["brq_service_paymentguarantee_CustomerCode"]      = customerId;
                htmlForm.InputFields["brq_service_paymentguarantee_CustomerGender"]    = order.Properties[settings["sexeAlias"]]; // Value, 1 = Male, 2 = Female
                htmlForm.InputFields["brq_service_paymentguarantee_CustomerFirstName"] = order.PaymentInformation.FirstName;
                htmlForm.InputFields["brq_service_paymentguarantee_CustomerBirthDate"] = order.Properties[settings["birthdateAlias"]];
                htmlForm.InputFields["brq_service_paymentguarantee_CustomerLastName"]  = order.PaymentInformation.LastName;
                htmlForm.InputFields["brq_service_paymentguarantee_AmountVat"]         = order.TotalPrice.Value.Vat.ToString("0.00", CultureInfo.InvariantCulture);
                htmlForm.InputFields["brq_service_paymentguarantee_CustomerInitials"]  = order.PaymentInformation.FirstName.Substring(0, 1);
                htmlForm.InputFields["brq_service_paymentguarantee_DateDue"]           = string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(14));
                htmlForm.InputFields["brq_service_paymentguarantee_CustomerIban"]      = order.Properties[settings["ibanAlias"]];
                htmlForm.InputFields["brq_service_paymentguarantee_CustomerEmail"]     = order.Properties["email"];


                // Determine type
                var phonenumber = order.Properties[settings["phoneNumberAlias"]];
                if (phonenumber.StartsWith("06"))
                {
                    htmlForm.InputFields["brq_service_paymentguarantee_MobilePhoneNumber"] = phonenumber;
                }
                else
                {
                    htmlForm.InputFields["brq_service_paymentguarantee_PhoneNumber"] = phonenumber;
                }


                htmlForm.InputFields["brq_service_paymentguarantee_address_AddressType_1"] = "INVOICE";
                htmlForm.InputFields["brq_service_paymentguarantee_address_Street_1"]      = order.Properties[settings["streetPropertyAlias"]];
                htmlForm.InputFields["brq_service_paymentguarantee_address_HouseNumber_1"] = order.Properties[settings["houseNumberPropertyAlias"]];
                // Suffix?
                htmlForm.InputFields["brq_service_paymentguarantee_address_HouseNumberSuffix_1"] = string.Empty;
                htmlForm.InputFields["brq_service_paymentguarantee_address_ZipCode_1"]           = order.Properties[settings["postalCodePropertyAlias"]];
                htmlForm.InputFields["brq_service_paymentguarantee_address_City_1"] = order.Properties[settings["cityPropertyAlias"]];

                Country currentPaymentCountry = CountryService.Instance.Get(order.StoreId, order.PaymentInformation.CountryId);
                htmlForm.InputFields["brq_service_paymentguarantee_address_Country_1"] = currentPaymentCountry.RegionCode;

                htmlForm.InputFields["brq_service_paymentguarantee_address_AddressType_2"] = "SHIPPING";
                if (!String.IsNullOrWhiteSpace(order.Properties[settings["shippingStreetPropertyAlias"]]))
                {
                    htmlForm.InputFields["brq_service_paymentguarantee_address_Street_2"]      = order.Properties[settings["shippingStreetPropertyAlias"]];
                    htmlForm.InputFields["brq_service_paymentguarantee_address_HouseNumber_2"] = order.Properties[settings["shippingHouseNumberPropertyAlias"]];
                    // Suffix?
                    htmlForm.InputFields["brq_service_paymentguarantee_address_HouseNumberSuffix_2"] = string.Empty;
                    htmlForm.InputFields["brq_service_paymentguarantee_address_ZipCode_2"]           = order.Properties[settings["shippingPostalCodePropertyAlias"]];
                    htmlForm.InputFields["brq_service_paymentguarantee_address_City_2"] = order.Properties[settings["shippingCityPropertyAlias"]];

                    Country currentShippingCountry = CountryService.Instance.Get(order.StoreId, order.ShipmentInformation.CountryId.Value);
                    htmlForm.InputFields["brq_service_paymentguarantee_address_Country_2"] = currentShippingCountry.RegionCode;
                }
                else
                {
                    htmlForm.InputFields["brq_service_paymentguarantee_address_Street_2"]      = order.Properties[settings["streetPropertyAlias"]];
                    htmlForm.InputFields["brq_service_paymentguarantee_address_HouseNumber_2"] = order.Properties[settings["houseNumberPropertyAlias"]];
                    // Suffix?
                    htmlForm.InputFields["brq_service_paymentguarantee_address_ZipCode_2"] = order.Properties[settings["postalCodePropertyAlias"]];
                    htmlForm.InputFields["brq_service_paymentguarantee_address_City_2"]    = order.Properties[settings["cityPropertyAlias"]];
                    htmlForm.InputFields["brq_service_paymentguarantee_address_Country_2"] = currentPaymentCountry.RegionCode;
                }
            }

            // Finally generate signature
            htmlForm.InputFields["brq_signature"] = GenerateBuckarooSignature(htmlForm.InputFields, settings);

            return(htmlForm);
        }