public void Demo(FormCollection form)
        {
            string firstName   = form["txtfirstname"].ToString();
            string amount      = form["txtamount"].ToString();
            string productInfo = form["txtprodinfo"].ToString();
            string email       = form["txtemail"].ToString();
            string phone       = form["txtphone"].ToString();
            string surl        = form["txtsurl"].ToString();
            string furl        = form["txtfurl"].ToString();


            RemotePost myremotepost = new RemotePost();
            string     key          = "JBZaLc";
            string     salt         = "GQs7yium";

            //posting all the parameters required for integration.

            myremotepost.Url = "https://test.payu.in/_payment";
            myremotepost.Add("key", "JBZaLc");
            string txnid = Generatetxnid();

            myremotepost.Add("txnid", txnid);
            myremotepost.Add("amount", amount);
            myremotepost.Add("productinfo", productInfo);
            myremotepost.Add("firstname", firstName);
            myremotepost.Add("phone", phone);
            myremotepost.Add("email", email);
            myremotepost.Add("surl", "http://*****:*****@gmail.com|||||||||||mE2RxRwx";
            string hash = Generatehash512(hashString);

            myremotepost.Add("hash", hash);

            myremotepost.Post();
        }
예제 #2
0
        public void Index(PayuRequest data)
        {
            try
            {
                RemotePost myremotepost = new RemotePost();
                string     key          = ConfigurationManager.AppSettings["MERCHANT_KEY"];
                string     salt         = ConfigurationManager.AppSettings["SALT"];
                string     surl         = ConfigurationManager.AppSettings["SUCC_URL"];
                string     furl         = ConfigurationManager.AppSettings["FAIL_URL"];

                //posting all the parameters required for integration.
                myremotepost.Url = ConfigurationManager.AppSettings["PAYU_BASE_URL"];
                myremotepost.Add("key", key);
                string txnid = Guid.NewGuid().ToString().Substring(12);
                myremotepost.Add("txnid", txnid);
                myremotepost.Add("amount", data.amount);
                myremotepost.Add("productinfo", data.productInfo);
                myremotepost.Add("firstName", data.firstName);
                myremotepost.Add("lastname", data.lastname);
                myremotepost.Add("email", data.email);
                myremotepost.Add("phone", data.phone);
                myremotepost.Add("address1", data.address1);
                myremotepost.Add("address2", data.address2);
                myremotepost.Add("city", data.city);
                myremotepost.Add("state", data.state);
                myremotepost.Add("zipcode", data.zipcode);
                myremotepost.Add("surl", surl);
                myremotepost.Add("furl", furl);
                string hashString = key + "|" + txnid + "|" + data.amount + "|" + data.productInfo + "|" + data.firstName + "|" + data.email + "|||||||||||" + salt;
                string hash       = Hashing.Generatehash512(hashString);
                myremotepost.Add("hash", hash);
                myremotepost.Post();
            }
            catch
            {
                throw;
            }
        }
예제 #3
0
        /// <summary>
        /// Post process payment (payment gateways that require redirecting)
        /// </summary>
        /// <param name="order">Order</param>
        /// <returns>The error status, or String.Empty if no errors</returns>
        public string PostProcessPayment(Order order)
        {
            Uri gatewayUrl = new Uri(SimplePaySettings.GatewayUrl);

            RemotePost post = new RemotePost();

            post.FormName = "SimplePay";
            //ERIC'S CODE
            string hash = code_to_hash(SourceCode_PlaceOrder);

            //construct path digest
            string path_digest = "Merchant[[" + hash + "()]]";

            post.Add("path_digest", path_digest);

            //post.Url = gatewayUrl.ToString();
            post.Url    = "http://protoagnostic.cloudapp.net:8001/Default.aspx";
            post.Method = "POST";

            post.Add("immediateReturn", "1");
            post.Add(AmazonHelper.SIGNATURE_VERSION_KEYNAME, AmazonHelper.SIGNATURE_VERSION_2);
            post.Add(AmazonHelper.SIGNATURE_METHOD_KEYNAME, AmazonHelper.HMAC_SHA256_ALGORITHM);
            post.Add("accessKey", SimplePaySettings.AccessKey);
            post.Add("amount", String.Format(CultureInfo.InvariantCulture, "USD {0:0.00}", order.OrderTotal));
            post.Add("description", string.Format("{0}, {1}", SettingManager.StoreName, order.OrderId));
            post.Add("amazonPaymentsAccountId", SimplePaySettings.AccountId);
            post.Add("returnUrl", String.Format("{0}AmazonSimplePayReturn.aspx", CommonHelper.GetStoreLocation(false)));
            post.Add("processImmediate", (SimplePaySettings.SettleImmediately ? "1" : "0"));
            post.Add("referenceId", order.OrderId.ToString());
            //the entire msg is signed using the pre-decided simplepay secret key
            post.Add(AmazonHelper.SIGNATURE_KEYNAME, AmazonHelper.SignParameters(post.Params, SimplePaySettings.SecretKey, post.Method, gatewayUrl.Host, gatewayUrl.AbsolutePath));

            string tmp = String.Format("{0}AmazonSimplePayReturn.aspx", CommonHelper.GetStoreLocation(false));

            post.Post();

            return(String.Empty);
        }
예제 #4
0
        /// <summary>
        /// Post process payment (payment gateways that require redirecting)
        /// </summary>
        /// <param name="order">Order</param>
        /// <returns>The error status, or String.Empty if no errors</returns>
        public string PostProcessPayment(Order order)
        {
            if (string.IsNullOrEmpty(vendorName))
            {
                throw new NopException("SagePay VendorDescription is not set");
            }
            if (string.IsNullOrEmpty(vendorDescription))
            {
                throw new NopException("SagePay VendorDescription is not set");
            }

            RemotePost remotePostHelper = new RemotePost();

            remotePostHelper.FormName = "SagePayForm";
            remotePostHelper.Url      = GetSagePayUrl();

            remotePostHelper.Add("VPSProtocol", protocolNumber);
            remotePostHelper.Add("TxType", transactionType);
            remotePostHelper.Add("Vendor", vendorName);
            remotePostHelper.Add("Crypt", GenerateCryptField(order));
            remotePostHelper.Post();
            return(string.Empty);
        }
예제 #5
0
        /// <summary>
        /// Post process payment (used by payment gateways that require redirecting to a third-party URL)
        /// </summary>
        /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param>
        public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {
            var orderGuid  = postProcessPaymentRequest.Order.OrderGuid;
            var orderTotal = postProcessPaymentRequest.Order.OrderTotal;
            var amount     = Math.Round(orderTotal * 100).ToString();
            var orderId    = orderGuid.ToString();
            var mid        = _fondyPaymentSettings.MerchantId;
            var secret     = _fondyPaymentSettings.SecretKey;

            if (_fondyPaymentSettings.TestingMode == true)
            {
                mid = "1396424";
            }
            //create and send post data
            var post = new RemotePost
            {
                FormName = "FondyPay",
                Url      = FONDY_URL
            };

            post.Add("merchant_id", mid);
            post.Add("order_id", orderId);
            post.Add("currency", _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode);
            post.Add("amount", amount);
            post.Add("order_desc", _fondyPaymentSettings.DescriptionTemplate.Replace("$orderId", postProcessPaymentRequest.Order.Id.ToString()));
            var siteUrl             = _webHelper.GetStoreLocation();
            var response_url        = $"{siteUrl}Plugins/Fondy/Success";
            var server_callback_url = $"{siteUrl}Plugins/Fondy/ConfirmPay";

            post.Add("response_url", response_url);
            post.Add("server_callback_url", server_callback_url);

            //code to identify the sender and check integrity of files
            post.Add("signature", GetSignature(post.Params));

            post.Post();
        }
예제 #6
0
        public async Task Pay(FormCollection form)
        {
            var firstName   = form["txtfirstname"];
            var amount      = form["txtamount"];
            var productInfo = form["txtprodinfo"];
            var email       = form["txtemail"];
            var phone       = form["txtphone"];
            //var key = ConfigurationManager.AppSettings["MERCHANT_KEY"];
            //var salt = ConfigurationManager.AppSettings["SALT"];
            var key  = "";
            var salt = "";

            //var myremotepost = new RemotePost { Url = ConfigurationManager.AppSettings["PAYU_BASE_URL"] + "/_payment" };
            var myremotepost = new RemotePost {
                Url = "/_payment"
            };

            myremotepost.Add("key", key);
            myremotepost.Add("txnid", Generatetxnid());
            myremotepost.Add("amount", amount);
            myremotepost.Add("productinfo", productInfo);
            myremotepost.Add("firstname", firstName);
            myremotepost.Add("phone", phone);
            myremotepost.Add("email", email);
            myremotepost.Add("surl", "http://*****:*****@gmail.com|||||||||||mE2RxRwx";
            string hash = Generatehash512(hashString);

            //var hashString = key + "|" + Generatetxnid() + "|" + amount + "|" + productInfo + "|" + firstName + "|" + email + "|||||||||||" + salt;
            //var hash = Generatehash512(hashString);
            myremotepost.Add("hash", hash);
            await myremotepost.Post(Response);
        }
        /// <summary>
        /// Post process payment (used by payment gateways that require redirecting to a third-party URL)
        /// </summary>
        /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param>
        public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {
            var langId   = _storeContext.CurrentStore.DefaultLanguageId;
            var itemName = Join(",", postProcessPaymentRequest.Order.OrderItems.Select(q => q.Product.GetLocalized(x => x.Name, langId)));

            if (itemName.Length > 200)
            {
                itemName = itemName.Substring(0, 200);
            }



            var post = new RemotePost {
                FormName = "AllPaysubmit"
            };

            post.Url = _allPayPaymentSettings.TestMode ? TestCheckoutUrl : CheckoutUrl;
            post.Add("MerchantID", _allPayPaymentSettings.MerchantId);
            post.Add("MerchantTradeNo", postProcessPaymentRequest.Order.Id.ToString());
            post.Add("MerchantTradeDate", DateTime.UtcNow.AddHours(8).ToString("yyyy/MM/dd HH:mm:ss"));
            post.Add("PaymentType", "aio");
            post.Add("TotalAmount", postProcessPaymentRequest.Order.OrderTotal.ToString("N0"));
            post.Add("TradeDesc", "寧尼可進口線上商城");
            post.Add("ItemName", itemName);
            post.Add("ReturnURL", ReturnUrl);
            post.Add("ChoosePayment", "ALL");
            post.Add("ClientBackURL", Path.Combine(_webHelper.GetStoreLocation(), "orderdetails/" + postProcessPaymentRequest.Order.Id));
            var checkMacValue = GetCheckValue(post.Params);

            post.Add("CheckMacValue", checkMacValue);

            //post.Url = Path.Combine(_webHelper.GetStoreHost(_webHelper.IsCurrentConnectionSecured()), "Plugins/PaymentAllPay/ProcessPayment");
            //post.Add("url", url);
            //post.Add("orderid", postProcessPaymentRequest.Order.Id.ToString(CultureInfo.InvariantCulture));
            //post.Add("total", postProcessPaymentRequest.Order.OrderTotal.ToString("0.00"));
            post.Post();
        }
예제 #8
0
        /// <summary>
        /// Post process payment (used by payment gateways that require redirecting to a third-party URL)
        /// </summary>
        /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param>
        public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {
            var customerId = postProcessPaymentRequest.Order.CustomerId;
            var orderGuid  = postProcessPaymentRequest.Order.OrderGuid;
            var orderTotal = postProcessPaymentRequest.Order.OrderTotal;

            var currencyCode             = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode;
            var payAnyWayPaymentSettings = _settingService.LoadSetting <PayAnyWayPaymentSettings>(_storeContext.CurrentStore.Id);

            var model = PayAnyWayPaymentRequest.CreatePayAnyWayPaymentRequest(payAnyWayPaymentSettings, customerId, orderGuid, orderTotal, currencyCode);

            //create and send post data
            var post = new RemotePost
            {
                FormName = "PayPoint",
                Url      = payAnyWayPaymentSettings.MntDemoArea ? DEMO_MONETA_URL : MONETA_URL
            };

            post.Add("MNT_ID", model.MntId);
            post.Add("MNT_TRANSACTION_ID", model.MntTransactionId);
            post.Add("MNT_CURRENCY_CODE", model.MntCurrencyCode);
            post.Add("MNT_AMOUNT", model.MntAmount);
            post.Add("MNT_TEST_MODE", model.MntTestMode.ToString());
            post.Add("MNT_SUBSCRIBER_ID", model.MntSubscriberId.ToString());
            post.Add("MNT_SIGNATURE", model.MntSignature);
            var siteUrl    = _storeContext.CurrentStore.Url.TrimEnd('/');
            var failUrl    = String.Format("{0}/{1}", siteUrl, "Plugins/PayAnyWay/CancelOrder");
            var successUrl = String.Format("{0}/{1}", siteUrl, "Plugins/PayAnyWay/Success");
            var returnUrl  = String.Format("{0}/{1}", siteUrl, "Plugins/PayAnyWay/Return");

            post.Add("MNT_FAIL_URL", failUrl);
            post.Add("MNT_SUCCESS_URL", successUrl);
            post.Add("MNT_RETURN_URL", returnUrl);

            post.Post();
        }
예제 #9
0
        /// <summary>
        /// Post process payment (used by payment gateways that require redirecting to a third-party URL)
        /// </summary>
        /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param>
        public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {
            #region Dummy test card numbers
            //card type
            //card number
            //number length
            //issue no length
            //Mastercard
            //5100080000000000
            //16
            //0
            //Visa Delta - UK
            //4406080400000000
            //16
            //0
            //Visa Delta - Non UK
            //4462030000000000
            //16
            //0
            //Visa
            //4911830000000
            //13
            //0
            //Visa
            //4917610000000000
            //16
            //0
            //American Express
            //370000200000000
            //15
            //0
            //Diners
            //36700102000000
            //14
            //0
            //JCB
            //3528000700000000
            //16
            //0
            //Visa Electron (UK only)
            //4917300800000000
            //16
            //0
            //Solo
            //6334580500000000
            //16
            //0
            //Solo
            //633473060000000000
            //18
            //1
            //Discover Card
            //6011000400000000
            //16
            //0
            //Laser
            //630495060000000000
            //18
            //0
            //Maestro (UK only)
            //6759649826438453
            //16
            //0
            //Visa Purchasing
            //4484070000000000
            //16
            //0
            #endregion


            string returnUrl = _webHelper.GetStoreLocation(false) + "Plugins/PaymentWorldPay/Return";

            var remotePostHelper = new RemotePost();
            remotePostHelper.FormName = "WorldpayForm";
            remotePostHelper.Url      = GetWorldpayUrl();

            remotePostHelper.Add("instId", _worldPayPaymentSettings.InstanceId);
            remotePostHelper.Add("cartId", postProcessPaymentRequest.Order.Id.ToString());

            if (!string.IsNullOrEmpty(_worldPayPaymentSettings.CreditCard))
            {
                remotePostHelper.Add("paymentType", _worldPayPaymentSettings.CreditCard);
            }

            if (!string.IsNullOrEmpty(_worldPayPaymentSettings.CssName))
            {
                remotePostHelper.Add("MC_WorldPayCSSName", _worldPayPaymentSettings.CssName);
            }

            remotePostHelper.Add("currency", _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode);
            remotePostHelper.Add("email", postProcessPaymentRequest.Order.BillingAddress.Email);
            remotePostHelper.Add("hideContact", "true");
            remotePostHelper.Add("noLanguageMenu", "true");
            remotePostHelper.Add("withDelivery", postProcessPaymentRequest.Order.ShippingStatus != ShippingStatus.ShippingNotRequired ? "true" : "false");
            remotePostHelper.Add("fixContact", "false");
            remotePostHelper.Add("amount", postProcessPaymentRequest.Order.OrderTotal.ToString(new CultureInfo("en-US", false).NumberFormat));
            remotePostHelper.Add("desc", _storeContext.CurrentStore.Name);
            remotePostHelper.Add("M_UserID", postProcessPaymentRequest.Order.CustomerId.ToString());
            remotePostHelper.Add("M_FirstName", postProcessPaymentRequest.Order.BillingAddress.FirstName);
            remotePostHelper.Add("M_LastName", postProcessPaymentRequest.Order.BillingAddress.LastName);
            remotePostHelper.Add("M_Addr1", postProcessPaymentRequest.Order.BillingAddress.Address1);
            remotePostHelper.Add("tel", postProcessPaymentRequest.Order.BillingAddress.PhoneNumber);
            remotePostHelper.Add("M_Addr2", postProcessPaymentRequest.Order.BillingAddress.Address2);
            remotePostHelper.Add("M_Business", postProcessPaymentRequest.Order.BillingAddress.Company);

            var cultureInfo = new CultureInfo(_workContext.WorkingLanguage.LanguageCulture);
            remotePostHelper.Add("lang", cultureInfo.TwoLetterISOLanguageName);

            var billingStateProvince = postProcessPaymentRequest.Order.BillingAddress.StateProvince;
            if (billingStateProvince != null)
            {
                remotePostHelper.Add("M_StateCounty", billingStateProvince.Abbreviation);
            }
            else
            {
                remotePostHelper.Add("M_StateCounty", "");
            }
            if (!_worldPayPaymentSettings.UseSandbox)
            {
                remotePostHelper.Add("testMode", "0");
            }
            else
            {
                remotePostHelper.Add("testMode", "100");
            }
            remotePostHelper.Add("postcode", postProcessPaymentRequest.Order.BillingAddress.ZipPostalCode);
            var billingCountry = postProcessPaymentRequest.Order.BillingAddress.Country;
            if (billingCountry != null)
            {
                remotePostHelper.Add("country", billingCountry.TwoLetterIsoCode);
            }
            else
            {
                remotePostHelper.Add("country", "");
            }

            remotePostHelper.Add("address", postProcessPaymentRequest.Order.BillingAddress.Address1 + "," + (billingCountry != null ? billingCountry.Name : ""));
            remotePostHelper.Add("MC_callback", returnUrl);
            remotePostHelper.Add("name", postProcessPaymentRequest.Order.BillingAddress.FirstName + " " + postProcessPaymentRequest.Order.BillingAddress.LastName);

            if (postProcessPaymentRequest.Order.ShippingStatus != ShippingStatus.ShippingNotRequired)
            {
                remotePostHelper.Add("delvName", postProcessPaymentRequest.Order.ShippingAddress.FirstName + " " + postProcessPaymentRequest.Order.ShippingAddress.LastName);
                string delvAddress = postProcessPaymentRequest.Order.ShippingAddress.Address1;
                delvAddress += (!string.IsNullOrEmpty(postProcessPaymentRequest.Order.ShippingAddress.Address2)) ? " " + postProcessPaymentRequest.Order.ShippingAddress.Address2 : string.Empty;
                remotePostHelper.Add("delvAddress", delvAddress);
                remotePostHelper.Add("delvPostcode", postProcessPaymentRequest.Order.ShippingAddress.ZipPostalCode);
                var shippingCountry = postProcessPaymentRequest.Order.ShippingAddress.Country;
                remotePostHelper.Add("delvCountry", shippingCountry.TwoLetterIsoCode);
            }

            remotePostHelper.Post();
        }
예제 #10
0
        /// <summary>
        /// Post process payment (used by payment gateways that require redirecting to a third-party URL)
        /// </summary>
        /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param>
        public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {
            var remotePostHelperData = new Dictionary <string, string>();
            var remotePostHelper     = new RemotePost
            {
                FormName = "CCAvenueForm",
                Url      = _ccAvenuePaymentSettings.PayUri
            };

            //use TLS 1.2
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            remotePostHelperData.Add("Merchant_Id", _ccAvenuePaymentSettings.MerchantId);
            remotePostHelperData.Add("Amount", postProcessPaymentRequest.Order.OrderTotal.ToString(new CultureInfo("en-US", false).NumberFormat));
            remotePostHelperData.Add("Currency", _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode);
            remotePostHelperData.Add("Order_Id", postProcessPaymentRequest.Order.Id.ToString());
            remotePostHelperData.Add("Redirect_Url", _webHelper.GetStoreLocation(false) + "Plugins/PaymentCCAvenue/Return");

            remotePostHelperData.Add("cancel_url", _webHelper.GetStoreLocation(false) + "Plugins/PaymentCCAvenue/Return");
            remotePostHelperData.Add("language", "EN");

            //var myUtility = new CCAvenueHelper();
            //remotePostHelperData.Add("Checksum", myUtility.getchecksum(_ccAvenuePaymentSettings.MerchantId.ToString(), postProcessPaymentRequest.Order.Id.ToString(), postProcessPaymentRequest.Order.OrderTotal.ToString(), _webHelper.GetStoreLocation(false) + "Plugins/PaymentCCAvenue/Return", _ccAvenuePaymentSettings.Key));

            //Billing details
            remotePostHelperData.Add("billing_name", postProcessPaymentRequest.Order.BillingAddress.FirstName);
            //remotePostHelperData.Add("billing_address", postProcessPaymentRequest.Order.BillingAddress.Address1 + " " + postProcessPaymentRequest.Order.BillingAddress.Address2);

            remotePostHelperData.Add("billing_address", postProcessPaymentRequest.Order.BillingAddress.Address1);
            remotePostHelperData.Add("billing_tel", postProcessPaymentRequest.Order.BillingAddress.PhoneNumber);
            remotePostHelperData.Add("billing_email", postProcessPaymentRequest.Order.BillingAddress.Email);

            remotePostHelperData.Add("billing_city", postProcessPaymentRequest.Order.BillingAddress.City);
            var billingStateProvince = postProcessPaymentRequest.Order.BillingAddress.StateProvince;

            remotePostHelperData.Add("billing_state", billingStateProvince != null ? billingStateProvince.Abbreviation : string.Empty);
            remotePostHelperData.Add("billing_zip", postProcessPaymentRequest.Order.BillingAddress.ZipPostalCode);
            var billingCountry = postProcessPaymentRequest.Order.BillingAddress.Country;

            remotePostHelperData.Add("billing_country", billingCountry != null ? billingCountry.Name : string.Empty);

            //Delivery details

            if (postProcessPaymentRequest.Order.ShippingStatus != ShippingStatus.ShippingNotRequired)
            {
                remotePostHelperData.Add("delivery_name", postProcessPaymentRequest.Order.ShippingAddress.FirstName);
                //remotePostHelperData.Add("delivery_address", postProcessPaymentRequest.Order.ShippingAddress.Address1 + " " + postProcessPaymentRequest.Order.ShippingAddress.Address2);
                remotePostHelperData.Add("delivery_address", postProcessPaymentRequest.Order.ShippingAddress.Address1);
                //   remotePostHelper.Add("delivery_cust_notes", string.Empty);
                remotePostHelperData.Add("delivery_tel", postProcessPaymentRequest.Order.ShippingAddress.PhoneNumber);
                remotePostHelperData.Add("delivery_city", postProcessPaymentRequest.Order.ShippingAddress.City);
                var deliveryStateProvince = postProcessPaymentRequest.Order.ShippingAddress.StateProvince;
                remotePostHelperData.Add("delivery_state", deliveryStateProvince != null ? deliveryStateProvince.Abbreviation : string.Empty);
                remotePostHelperData.Add("delivery_zip", postProcessPaymentRequest.Order.ShippingAddress.ZipPostalCode);
                var deliveryCountry = postProcessPaymentRequest.Order.ShippingAddress.Country;
                remotePostHelperData.Add("delivery_country", deliveryCountry != null ? deliveryCountry.Name : string.Empty);
            }

            remotePostHelperData.Add("Merchant_Param", _ccAvenuePaymentSettings.MerchantParam);

            var strPOSTData = string.Empty;

            foreach (var item in remotePostHelperData)
            {
                //strPOSTData = strPOSTData +  item.Key.ToLower() + "=" + item.Value.ToLower() + "&";
                strPOSTData = strPOSTData + item.Key.ToLower() + "=" + item.Value + "&";
            }

            try
            {
                var strEncPOSTData = _ccaCrypto.Encrypt(strPOSTData, _ccAvenuePaymentSettings.Key);
                remotePostHelper.Add("encRequest", strEncPOSTData);
                remotePostHelper.Add("access_code", _ccAvenuePaymentSettings.AccessCode);

                remotePostHelper.Post();
            }
            catch (Exception ep)
            {
                throw new Exception(ep.Message);
            }
        }
예제 #11
0
        /// <summary>
        /// Submits a payment request to the hosted payment page
        /// </summary>
        /// <param name="request">The request to submit</param>
        /// <param name="merchantPassword">The merchant password that corresponds to the gateway account the transaction will be run through.</param>
        /// <param name="preSharedKey">The merchant gateway account pre shared key</param>
        /// <param name="postUrl">The url of the hosted payment page</param>
        public void SubmitTransaction(HostedTransactionRequest request, string MD5secretKey)
        {
            if (CommonUtils.AreNullOrEmpty(MD5secretKey))
            {
                throw new ArgumentNullException();
            }

            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            var requestInputs = request.ToNameValueCollection();
            var postUrl       = "";

            if (request.testMode == 100)
            {
                postUrl = "https://secure-test.worldpay.com/wcc/purchase";
            }
            else
            {
                postUrl = "https://secure.worldpay.com/wcc/purchase";
            }

            // ready to post - just return the NameValue Collection
            var remotePost = new RemotePost(_context, postUrl, FormMethod.POST);

            var callbackhashInputs = new StringBuilder();

            callbackhashInputs.Append(MD5secretKey);
            callbackhashInputs.Append(":");
            callbackhashInputs.Append(request.currency);
            callbackhashInputs.Append(":");
            callbackhashInputs.Append(request.amount.ToString("#0.00"));
            callbackhashInputs.Append(":");
            callbackhashInputs.Append(request.testMode);
            callbackhashInputs.Append(":");
            callbackhashInputs.Append(request.instId);

            var signaturehashInputs = new StringBuilder();

            signaturehashInputs.Append(MD5secretKey);
            signaturehashInputs.Append(":");
            signaturehashInputs.Append(request.currency);
            signaturehashInputs.Append(":");
            signaturehashInputs.Append(request.amount);
            signaturehashInputs.Append(":");
            signaturehashInputs.Append(request.testMode);
            signaturehashInputs.Append(":");
            signaturehashInputs.Append(request.instId);

            byte[] callbackhashDigest = new MD5CryptoServiceProvider().ComputeHash(StringToByteArray(callbackhashInputs.ToString()));

            byte[] signaturehashDigest = new MD5CryptoServiceProvider().ComputeHash(StringToByteArray(signaturehashInputs.ToString()));

            remotePost.AddInput("signature", ByteArrayToHexString(signaturehashDigest));
            remotePost.AddInput("MC_callbacksignature", ByteArrayToHexString(callbackhashDigest));

            // add the rest of the form variables
            foreach (var k in requestInputs.AllKeys)
            {
                remotePost.AddInput(k, requestInputs.GetValues(k)[0]);
            }

            remotePost.Post("CardsavePaymentForm");
        }
        /// <summary>
        /// Post process payment (used by payment gateways that require redirecting to a third-party URL)
        /// </summary>
        /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param>
        public async Task PostProcessPaymentAsync(PostProcessPaymentRequest postProcessPaymentRequest)
        {
            //choosing correct order address
            var orderAddress = await _addressService.GetAddressByIdAsync(
                (postProcessPaymentRequest.Order.PickupInStore ? postProcessPaymentRequest.Order.PickupAddressId : postProcessPaymentRequest.Order.ShippingAddressId) ?? 0);

            var orderShippingAddress = await _addressService.GetAddressByIdAsync((int)postProcessPaymentRequest.Order.ShippingAddressId);

            var myUtility = new PayuHelper();
            var orderId   = postProcessPaymentRequest.Order.Id;

            var remotePostHelper = new RemotePost();

            remotePostHelper.FormName = "PayuForm";
            remotePostHelper.Url      = _PayuPaymentSettings.PayUri;
            remotePostHelper.Add("key", _PayuPaymentSettings.MerchantId.ToString());
            remotePostHelper.Add("amount", postProcessPaymentRequest.Order.OrderTotal.ToString(new CultureInfo("en-US", false).NumberFormat));
            remotePostHelper.Add("productinfo", "productinfo");
            remotePostHelper.Add("Currency", (await _currencyService.GetCurrencyByIdAsync(_currencySettings.PrimaryStoreCurrencyId)).CurrencyCode);
            remotePostHelper.Add("Order_Id", orderId.ToString());
            remotePostHelper.Add("txnid", orderId.ToString());
            remotePostHelper.Add("service_provider", "payu_paisa");
            remotePostHelper.Add("surl", _webHelper.GetStoreLocation(false) + "Plugins/PaymentPayu/Return");
            remotePostHelper.Add("furl", _webHelper.GetStoreLocation(false) + "Plugins/PaymentPayu/Return");
            remotePostHelper.Add("hash", myUtility.getchecksum(_PayuPaymentSettings.MerchantId.ToString(),
                                                               postProcessPaymentRequest.Order.Id.ToString(), postProcessPaymentRequest.Order.OrderTotal.ToString(new CultureInfo("en-US", false).NumberFormat),
                                                               "productinfo", orderAddress?.FirstName,
                                                               orderAddress?.Email.ToString(), _PayuPaymentSettings.Key));


            //Billing details
            remotePostHelper.Add("firstname", orderAddress?.FirstName.ToString());
            remotePostHelper.Add("billing_cust_address", orderAddress?.Address1);
            remotePostHelper.Add("phone", orderAddress?.PhoneNumber);
            remotePostHelper.Add("email", orderAddress?.Email.ToString());
            remotePostHelper.Add("billing_cust_city", orderAddress?.City);
            var billingStateProvince = (await _stateProvinceService.GetStateProvinceByAddressAsync(orderAddress))?.Abbreviation;

            if (billingStateProvince != null)
            {
                remotePostHelper.Add("billing_cust_state", (await _stateProvinceService.GetStateProvinceByAddressAsync(orderAddress))?.Abbreviation);
            }
            else
            {
                remotePostHelper.Add("billing_cust_state", "");
            }
            remotePostHelper.Add("billing_zip_code", orderAddress?.ZipPostalCode);
            var billingCountry = (await _countryService.GetCountryByAddressAsync(orderAddress))?.TwoLetterIsoCode;

            if (billingCountry != null)
            {
                remotePostHelper.Add("billing_cust_country", (await _countryService.GetCountryByAddressAsync(orderAddress))?.TwoLetterIsoCode);
            }
            else
            {
                remotePostHelper.Add("billing_cust_country", "");
            }

            //Delivery details

            if (postProcessPaymentRequest.Order.ShippingStatus != ShippingStatus.ShippingNotRequired)
            {
                remotePostHelper.Add("delivery_cust_name", orderShippingAddress.FirstName);
                remotePostHelper.Add("delivery_cust_address", orderShippingAddress.Address1);
                remotePostHelper.Add("delivery_cust_notes", string.Empty);
                remotePostHelper.Add("delivery_cust_tel", orderShippingAddress.PhoneNumber);
                remotePostHelper.Add("delivery_cust_city", orderShippingAddress.City);
                var deliveryStateProvince = await _stateProvinceService.GetStateProvinceByAddressAsync(orderShippingAddress);

                if (deliveryStateProvince != null)
                {
                    remotePostHelper.Add("delivery_cust_state", deliveryStateProvince.Abbreviation);
                }
                else
                {
                    remotePostHelper.Add("delivery_cust_state", "");
                }
                remotePostHelper.Add("delivery_zip_code", orderShippingAddress.ZipPostalCode);
                var deliveryCountry = await _countryService.GetCountryByAddressAsync(orderShippingAddress); // postProcessPaymentRequest.Order.ShippingAddress.Country;

                if (deliveryCountry != null)
                {
                    remotePostHelper.Add("delivery_cust_country", deliveryCountry.ThreeLetterIsoCode);
                }
                else
                {
                    remotePostHelper.Add("delivery_cust_country", "");
                }
            }

            //  remotePostHelper.Add("Merchant_Param", _PayuPaymentSettings.MerchantParam);
            remotePostHelper.Post();
        }
예제 #13
0
        /// <summary>
        /// Post process payment (used by payment gateways that require redirecting to a third-party URL)
        /// </summary>
        /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param>
        public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {
            var service   = "create_forex_trade";
            var partner   = _aliPayPaymentSettings.Partner;
            var notifyUrl = _webHelper.GetStoreLocation(false) + "Plugins/PaymentAliPay/Notify";
            var returnUrl = _webHelper.GetStoreLocation(false) + "Plugins/PaymentAliPay/Return";


            var subject      = _storeContext.CurrentStore.Name;
            var inputCharset = @"UTF-8";
            var body         = _storeContext.CurrentStore.Name;
            var outTradeNo   = postProcessPaymentRequest.Order.Id.ToString();
            var rmbFee       = postProcessPaymentRequest.Order.OrderTotal.ToString("0.00", CultureInfo.InvariantCulture);

            //string sellerEmail = _aliPayPaymentSettings.SellerEmail;

            var key = _aliPayPaymentSettings.Key;


            string[] param =
            {
                "service=" + service,
                "partner=" + partner,
                "notify_url=" + notifyUrl,
                "return_url=" + returnUrl,
                "subject=" + subject,
                "_input_charset=" + inputCharset,
                "body=" + body,
                "out_trade_no=" + outTradeNo,
                "rmb_fee=" + rmbFee,
                "currency=AUD"
            };

            var sortedParam = BubbleSort(param);
            var sign        = GetSign(sortedParam, inputCharset, key);
            var signType    = "MD5";

            var finalParamList = sortedParam.ToList();

            finalParamList.Add("sign=" + sign);
            finalParamList.Add("sign_type=" + signType);


            var post = new RemotePost {
                FormName = "alipaysubmit"
            };
            var url   = @"https://mapi.alipay.com/gateway.do";
            var count = 0;

            foreach (var paramItem in finalParamList)
            {
                if (count > 0)
                {
                    url += @"&";
                }
                else
                {
                    url += @"?";
                }

                url += paramItem;
                count++;
            }

            post.Url = url;
            //post.Url = Path.Combine(_webHelper.GetStoreHost(_webHelper.IsCurrentConnectionSecured()), "Plugins/PaymentAlipay/ProcessPayment");
            //post.Add("url", url);
            //post.Add("orderid", postProcessPaymentRequest.Order.Id.ToString(CultureInfo.InvariantCulture));
            //post.Add("total", postProcessPaymentRequest.Order.OrderTotal.ToString("0.00"));
            post.Post();
        }
예제 #14
0
        /// <summary>
        /// Post process payment (used by payment gateways that require redirecting to a third-party URL)
        /// </summary>
        /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param>
        public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {
            RemotePost post = new RemotePost();

            post.FormName = "chinabanksubmit";
            post.Url      = "https://pay3.chinabank.com.cn/PayGate";
            post.Method   = "POST";

            //必要的交易信息
            string v_amount;       // 订单金额
            string v_moneytype;    // 币种
            string v_md5info;      // 对拼凑串MD5私钥加密后的值
            string v_mid;          // 商户号
            string v_url;          // 返回页地址
            string v_oid;          // 推荐订单号构成格式为 年月日-商户号-小时分钟秒
            //收货信息
            string v_rcvname;      // 收货人
            string v_rcvaddr;      // 收货地址
            string v_rcvtel;       // 收货人电话
            string v_rcvpost;      // 收货人邮编
            string v_rcvemail;     // 收货人邮件
            string v_rcvmobile;    // 收货人手机号
            //订货人信息
            string v_ordername;    // 订货人姓名
            string v_orderaddr;    // 订货人地址
            string v_ordertel;     // 订货人电话
            string v_orderpost;    // 订货人邮编
            string v_orderemail;   // 订货人邮件
            string v_ordermobile;  // 订货人手机号

            //两个备注
            string remark1;
            string remark2;

            v_mid = _chinabankPayPaymentSettings.Vmid;
            v_url = _webHelper.GetStoreLocation(false) + "Plugins/PaymentChinabank/Notify";
            string key = _chinabankPayPaymentSettings.Key;

            v_oid = postProcessPaymentRequest.Order.Id.ToString();

            if (v_oid == null || v_oid.Equals(""))
            {
                DateTime dt      = DateTime.Now;
                string   v_ymd   = dt.ToString("yyyyMMdd"); // yyyyMMdd
                string   timeStr = dt.ToString("HHmmss");   // HHmmss
                v_oid = v_ymd + v_mid + timeStr;
            }

            v_amount    = postProcessPaymentRequest.Order.OrderTotal.ToString("0.00", CultureInfo.InvariantCulture);
            v_moneytype = "CNY";
            string text = v_amount + v_moneytype + v_oid + v_mid + v_url + key; // 拼凑加密串

            v_md5info = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(text, "md5").ToUpper();

            //收货信息
            v_rcvname   = String.Empty;
            v_rcvaddr   = postProcessPaymentRequest.Order.BillingAddress.Address1;
            v_rcvtel    = postProcessPaymentRequest.Order.BillingAddress.PhoneNumber;
            v_rcvpost   = postProcessPaymentRequest.Order.BillingAddress.ZipPostalCode;
            v_rcvemail  = postProcessPaymentRequest.Order.BillingAddress.Email;
            v_rcvmobile = postProcessPaymentRequest.Order.BillingAddress.PhoneNumber;
            //订货人信息
            v_ordername   = String.Empty;
            v_orderaddr   = postProcessPaymentRequest.Order.ShippingAddress.Address1;
            v_ordertel    = postProcessPaymentRequest.Order.ShippingAddress.PhoneNumber;
            v_orderpost   = postProcessPaymentRequest.Order.ShippingAddress.ZipPostalCode;
            v_orderemail  = postProcessPaymentRequest.Order.ShippingAddress.Email;
            v_ordermobile = postProcessPaymentRequest.Order.ShippingAddress.PhoneNumber;
            //附加信息
            remark1 = "";
            remark2 = "";

            post.Add("v_md5info", v_md5info);
            post.Add("v_mid", v_mid);
            post.Add("v_oid", v_oid);
            post.Add("v_amount", v_amount);
            post.Add("v_moneytype", v_moneytype);
            post.Add("v_url", v_url);
            post.Add("v_rcvname", v_rcvname);
            post.Add("v_rcvaddr", v_rcvaddr);
            post.Add("v_rcvtel", v_rcvtel);
            post.Add("v_rcvpost", v_rcvpost);
            post.Add("v_rcvemail", v_rcvemail);
            post.Add("v_rcvmobile", v_rcvmobile);
            post.Add("v_ordername", v_ordername);
            post.Add("v_orderaddr", v_orderaddr);
            post.Add("v_ordertel", v_ordertel);
            post.Add("v_orderpost", v_orderpost);
            post.Add("v_orderemail", v_orderemail);
            post.Add("v_ordermobile", v_ordermobile);
            post.Add("remark1", remark1);
            post.Add("remark2", remark2);

            post.Post();
        }
        /// <summary>
        /// Post process payment (used by payment gateways that require redirecting to a third-party URL)
        /// </summary>
        /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param>
        public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {
            //string gateway = "https://www.alipay.com/cooperate/gateway.do?";
            string service = "create_direct_pay_by_user";

            string seller_email  = _aliPayPaymentSettings.SellerEmail;
            string sign_type     = "MD5";
            string key           = _aliPayPaymentSettings.Key;
            string partner       = _aliPayPaymentSettings.Partner;
            string input_charset = "utf-8";

            string show_url = "http://www.alipay.com/";

            string out_trade_no = postProcessPaymentRequest.Order.Id.ToString();
            string subject      = _storeContext.CurrentStore.Name;
            string body         = "Order from " + _storeContext.CurrentStore.Name;
            string total_fee    = postProcessPaymentRequest.Order.OrderTotal.ToString("0.00", CultureInfo.InvariantCulture);

            string notify_url = _webHelper.GetStoreLocation(false) + "Plugins/PaymentAliPay/Notify";
            string return_url = _webHelper.GetStoreLocation(false) + "Plugins/PaymentAliPay/Return";

            string[] para =
            {
                "service=" + service,
                "partner=" + partner,
                "seller_email=" + seller_email,
                "out_trade_no=" + out_trade_no,
                "subject=" + subject,
                "body=" + body,
                "total_fee=" + total_fee,
                "show_url=" + show_url,
                "payment_type=1",
                "notify_url=" + notify_url,
                "return_url=" + return_url,
                "_input_charset=" + input_charset
            };

            string aliay_url = CreatUrl(
                para,
                input_charset,
                key
                );
            var post = new RemotePost();

            post.FormName = "alipaysubmit";
            post.Url      = "https://www.alipay.com/cooperate/gateway.do?_input_charset=utf-8";
            post.Method   = "POST";

            post.Add("service", service);
            post.Add("partner", partner);
            post.Add("seller_email", seller_email);
            post.Add("out_trade_no", out_trade_no);
            post.Add("subject", subject);
            post.Add("body", body);
            post.Add("total_fee", total_fee);
            post.Add("show_url", show_url);
            post.Add("return_url", return_url);
            post.Add("notify_url", notify_url);
            post.Add("payment_type", "1");
            post.Add("sign", aliay_url);
            post.Add("sign_type", sign_type);

            post.Post();
        }
예제 #16
0
        /// <summary>
        /// Post process payment (payment gateways that require redirecting)
        /// </summary>
        /// <param name="order">Order</param>
        /// <returns>The error status, or String.Empty if no errors</returns>
        public string PostProcessPayment(Order order)
        {
            string returnURL = CommonHelper.GetStoreLocation(false) + "WorldpayReturn.aspx";

            RemotePost remotePostHelper = new RemotePost();

            remotePostHelper.FormName = "WorldpayForm";
            remotePostHelper.Url      = GetWorldpayUrl();

            remotePostHelper.Add("instId", instanceID);
            remotePostHelper.Add("cartId", order.OrderId.ToString());

            if (!string.IsNullOrEmpty(SettingManager.GetSettingValue(WorldpayConstants.SETTING_CREDITCARD_CODE_PROPERTY)))
            {
                remotePostHelper.Add("paymentType", SettingManager.GetSettingValue(WorldpayConstants.SETTING_CREDITCARD_CODE_PROPERTY));
            }

            if (!string.IsNullOrEmpty(SettingManager.GetSettingValue(WorldpayConstants.SETTING_WorldPayCSSName)))
            {
                remotePostHelper.Add("MC_WorldPayCSSName", SettingManager.GetSettingValue(WorldpayConstants.SETTING_WorldPayCSSName));
            }

            remotePostHelper.Add("currency", CurrencyManager.PrimaryStoreCurrency.CurrencyCode);
            remotePostHelper.Add("email", order.BillingEmail);
            remotePostHelper.Add("hideContact", "true");
            remotePostHelper.Add("noLanguageMenu", "true");
            remotePostHelper.Add("withDelivery", "true");
            remotePostHelper.Add("fixContact", "false");
            remotePostHelper.Add("amount", order.OrderTotal.ToString(new CultureInfo("en-US", false).NumberFormat));
            remotePostHelper.Add("desc", SettingManager.StoreName);
            remotePostHelper.Add("M_UserID", order.CustomerId.ToString());
            remotePostHelper.Add("M_FirstName", order.BillingFirstName);
            remotePostHelper.Add("M_LastName", order.BillingLastName);
            remotePostHelper.Add("M_Addr1", order.BillingAddress1);
            remotePostHelper.Add("tel", order.BillingPhoneNumber);
            remotePostHelper.Add("M_Addr2", order.BillingAddress2);
            remotePostHelper.Add("M_Business", order.BillingCompany);

            CultureInfo cultureInfo = new CultureInfo(NopContext.Current.WorkingLanguage.LanguageCulture);

            remotePostHelper.Add("lang", cultureInfo.TwoLetterISOLanguageName);

            StateProvince billingStateProvince = StateProvinceManager.GetStateProvinceById(order.BillingStateProvinceId);

            if (billingStateProvince != null)
            {
                remotePostHelper.Add("M_StateCounty", billingStateProvince.Abbreviation);
            }
            else
            {
                remotePostHelper.Add("M_StateCounty", order.BillingStateProvince);
            }
            if (!useSandBox)
            {
                remotePostHelper.Add("testMode", "0");
            }
            else
            {
                remotePostHelper.Add("testMode", "100");
            }
            remotePostHelper.Add("postcode", order.BillingZipPostalCode);
            Country billingCountry = CountryManager.GetCountryById(order.BillingCountryId);

            if (billingCountry != null)
            {
                remotePostHelper.Add("country", billingCountry.TwoLetterIsoCode);
            }
            else
            {
                remotePostHelper.Add("country", order.BillingCountry);
            }

            remotePostHelper.Add("address", order.BillingAddress1 + "," + order.BillingCountry);
            remotePostHelper.Add("MC_callback", returnURL);
            remotePostHelper.Add("name", order.BillingFirstName + " " + order.BillingLastName);

            if (order.ShippingStatus != ShippingStatusEnum.ShippingNotRequired)
            {
                remotePostHelper.Add("delvName", order.ShippingFullName);
                string delvAddress = order.ShippingAddress1;
                delvAddress += (!string.IsNullOrEmpty(order.ShippingAddress2)) ? " " + order.ShippingAddress2 : string.Empty;
                remotePostHelper.Add("delvAddress", delvAddress);
                remotePostHelper.Add("delvPostcode", order.ShippingZipPostalCode);
                Country shippingCountry = CountryManager.GetCountryById(order.ShippingCountryId);
                remotePostHelper.Add("delvCountry", shippingCountry.TwoLetterIsoCode);
            }

            remotePostHelper.Post();
            return(string.Empty);
        }
예제 #17
0
        /// <summary>
        /// Post process payment (payment gateways that require redirecting)
        /// </summary>
        /// <param name="order">Order</param>
        /// <returns>The error status, or String.Empty if no errors</returns>
        public string PostProcessPayment(Order order)
        {
            //string gateway = "https://www.alipay.com/cooperate/gateway.do?";
            string service = "create_direct_pay_by_user";

            string seller_email  = IoC.Resolve <ISettingManager>().GetSettingValue("PaymentMethod.Alipay.SellerEmail");
            string sign_type     = "MD5";
            string key           = IoC.Resolve <ISettingManager>().GetSettingValue("PaymentMethod.Alipay.Key");
            string partner       = IoC.Resolve <ISettingManager>().GetSettingValue("PaymentMethod.Alipay.Partner");
            string input_charset = "utf-8";

            string show_url = "http://www.alipay.com/";

            string out_trade_no = order.OrderId.ToString();
            string subject      = IoC.Resolve <ISettingManager>().StoreName;
            string body         = "Order from " + IoC.Resolve <ISettingManager>().StoreName;
            string total_fee    = order.OrderTotal.ToString("0.00", CultureInfo.InvariantCulture);

            string notify_url = CommonHelper.GetStoreLocation() + "Alipay_Notify.aspx";
            string return_url = CommonHelper.GetStoreLocation() + "Alipay_Return.aspx";

            string[] para =
            {
                "service=" + service,
                "partner=" + partner,
                "seller_email=" + seller_email,
                "out_trade_no=" + out_trade_no,
                "subject=" + subject,
                "body=" + body,
                "total_fee=" + total_fee,
                "show_url=" + show_url,
                "payment_type=1",
                "notify_url=" + notify_url,
                "return_url=" + return_url,
                "_input_charset=" + input_charset
            };

            string aliay_url = CreatUrl(
                para,
                input_charset,
                key
                );
            RemotePost post = new RemotePost();

            post.FormName = "alipaysubmit";
            post.Url      = "https://www.alipay.com/cooperate/gateway.do?_input_charset=utf-8";
            post.Method   = "POST";

            post.Add("service", service);
            post.Add("partner", partner);
            post.Add("seller_email", seller_email);
            post.Add("out_trade_no", out_trade_no);
            post.Add("subject", subject);
            post.Add("body", body);
            post.Add("total_fee", total_fee);
            post.Add("show_url", show_url);
            post.Add("return_url", return_url);
            post.Add("notify_url", notify_url);
            post.Add("payment_type", "1");
            post.Add("sign", aliay_url);
            post.Add("sign_type", sign_type);

            post.Post();

            return(String.Empty);
        }
        public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {
            try
            {
                var storeUrl   = _webHelper.GetStoreLocation(false);
                var order      = postProcessPaymentRequest.Order;
                var orderTotal = Math.Round(order.OrderTotal, 2);
                ///var orderDescription = GetOrderDescription(order);

                var post = new RemotePost {
                    Url = "https://secure.nochex.com"
                };

                // Merchant Id
                post.Add("merchant_id", _NochexPaymentSettings.MerchantID);
                string orderDesc     = "";
                string xmlCollection = "<items>";

                foreach (var item in postProcessPaymentRequest.Order.OrderItems)
                {
                    orderDesc     += "" + item.Product.Name + " - " + item.Quantity.ToString() + " x " + item.PriceInclTax.ToString();
                    xmlCollection += "<item><id></id><name>" + item.Product.Name + "</name><description>" + item.Product.ShortDescription + "</description><quantity>" + item.Quantity.ToString() + "</quantity><price>" + item.PriceInclTax.ToString() + "</price></item>";
                }
                xmlCollection += "</items>";

                // Urls
                post.Add("cancel_url", storeUrl + CANCEL_URL);
                post.Add("success_url", storeUrl + SUCCESS_ORDER_URL);
                post.Add("test_success_url", storeUrl + SUCCESS_ORDER_URL);
                post.Add("callback_url", storeUrl + CALLBACK_URL);

                // Order Details
                post.Add("order_id", order.CustomOrderNumber);
                post.Add("optional_1", order.OrderGuid.ToString());
                post.Add("amount", orderTotal.ToString("0.00"));

                // Billing Address
                var billingAddress = order.BillingAddress;
                post.Add("billing_fullname", billingAddress.FirstName + ", " + billingAddress.LastName);
                post.Add("billing_address", billingAddress.Address1 + ", " + billingAddress.Address2);
                post.Add("billing_city", billingAddress.City);
                post.Add("billing_postcode", billingAddress.ZipPostalCode);
                post.Add("email_address", billingAddress.Email);
                post.Add("customer_phone_number", billingAddress.PhoneNumber);

                // Shipping Address

                var shippingAddress = order.ShippingAddress;
                post.Add("delivery_fullname", shippingAddress.FirstName + ", " + shippingAddress.LastName);
                post.Add("delivery_address", shippingAddress.Address1 + ", " + shippingAddress.Address2);
                post.Add("delivery_city", billingAddress.City);
                post.Add("delivery_postcode", shippingAddress.ZipPostalCode);

                if (_NochexPaymentSettings.ProdInfoMode)
                {
                    post.Add("xml_item_collection", xmlCollection);
                    post.Add("description", "Order for:" + order.CustomOrderNumber);
                }
                else
                {
                    post.Add("description", orderDesc);
                }
                if (_NochexPaymentSettings.TransactMode)
                {
                    post.Add("test_transaction", "100");
                }

                if (_NochexPaymentSettings.HideBillingDetails)
                {
                    post.Add("hide_billing_details", "true");
                }

                post.Post();

                // _httpContextAccessor.HttpContext.Response.Redirect(post);
            }

            catch (Exception ex)
            {
                _logger.InsertLog(LogLevel.Error, ex.Message, fullMessage: ex.ToString());
            }
        }
예제 #19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Code that runs when a new session is started

            //get the incoming request
            var         context = HttpContext.Current;
            HttpRequest req     = context.Request;

            RemotePost post = new RemotePost();

            post.FormName = "SimplePay";
            post.Url      = "https://authorize.payments-sandbox.amazon.com/pba/paypipeline";
            post.Method   = "POST";

            //get info from nopcommerce submission form
            NameValueCollection form = Request.Form;
            var items = form.AllKeys.SelectMany(form.GetValues, (k, v) => new { key = k, value = v });

            foreach (var item in items)
            {
                if (item.key == "returnUrl" && form["path_digest"] == null)
                {
                    post.Add(item.key, "http://localhost:38623/pay.aspx");
                }
                else if (item.key == "returnUrl" && form["path_digest"] != null)
                {
                    post.Add(item.key, "http://localhost:38623/pay.aspx?path_digest=" + form["path_digest"]);
                }
                else if (item.key == "signature")
                {
                    post.Add(item.key, AmazonHelper.SignParameters(post.Params,
                                                                   "[secret key]", //simplePay secret key
                                                                   post.Method,
                                                                   "authorize.payments-sandbox.amazon.com",
                                                                   "/pba/paypipeline"));
                }
                else if (item.key == "path_digest")
                {
                    continue;
                }
                else
                {
                    post.Add(item.key, item.value);
                }
            }

            /*
             * post.Add("immediateReturn", "1");
             * post.Add("signatureVersion", "2");
             * post.Add("signatureMethod", "HmacSHA256");
             * post.Add("accessKey", "[AWS access key]");
             * post.Add("amount", "USD 35.12");
             * post.Add("description", "Your store name, 9");
             * post.Add("amazonPaymentsAccountId", "IGFCUTPWGXVM311K1E6QTXIQ1RPEIUG5PTIMUZ");
             * post.Add("returnUrl", "http://localhost:8242/AmazonSimplePayReturn.aspx");
             * post.Add("processImmediate", "0");
             * post.Add("referenceId", "9");
             * post.Add("signature", "e6nHOQqZCC3BMXZ1veEVIzWfu5SQxUIJ7O6v2wjdpQw=");
             */

            post.Post();
        }
예제 #20
0
        /// <summary>
        /// Post process payment (used by payment gateways that require redirecting to a third-party URL)
        /// </summary>
        /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param>
        public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {
            var myUtility      = new PayuHelper();
            var orderId        = postProcessPaymentRequest.Order.Id;
            var billingAddress = _addressService.GetAddressById(postProcessPaymentRequest.Order.BillingAddressId);
            var countryName    = string.Empty;
            var stateName      = string.Empty;

            if (billingAddress != null)
            {
                var country = _countryService.GetCountryById((int)billingAddress.CountryId);
                if (country != null)
                {
                    countryName = country.ThreeLetterIsoCode;
                }

                if (billingAddress.StateProvinceId != null)
                {
                    var state = _stateProvinceService.GetStateProvinceById((int)billingAddress.StateProvinceId);
                    if (state != null)
                    {
                        stateName = state.Abbreviation;
                    }
                }
            }

            var threeletter     = string.Empty;
            var abbreviation    = string.Empty;
            var shippingaddress = _addressService.GetAddressById((int)postProcessPaymentRequest.Order.ShippingAddressId);

            if (shippingaddress != null)
            {
                var country = _countryService.GetCountryById((int)shippingaddress.CountryId);
                if (country != null)
                {
                    threeletter = country.ThreeLetterIsoCode;
                }

                if (shippingaddress.StateProvinceId != null)
                {
                    var state = _stateProvinceService.GetStateProvinceById((int)shippingaddress.StateProvinceId);
                    if (state != null)
                    {
                        abbreviation = state.Abbreviation;
                    }
                }
            }


            var remotePostHelper = new RemotePost();

            remotePostHelper.FormName = "PayuForm";
            remotePostHelper.Url      = _PayuPaymentSettings.PayUri;
            remotePostHelper.Add("key", _PayuPaymentSettings.MerchantId.ToString());
            remotePostHelper.Add("amount", postProcessPaymentRequest.Order.OrderTotal.ToString(new CultureInfo("en-US", false).NumberFormat));
            remotePostHelper.Add("productinfo", "productinfo");
            remotePostHelper.Add("Currency", _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode);
            remotePostHelper.Add("Order_Id", orderId.ToString());
            remotePostHelper.Add("txnid", orderId.ToString());
            remotePostHelper.Add("service_provider", "payu_paisa");
            remotePostHelper.Add("surl", _webHelper.GetStoreLocation(false) + "Plugins/PaymentPayu/Return");
            remotePostHelper.Add("furl", _webHelper.GetStoreLocation(false) + "Plugins/PaymentPayu/Return");
            remotePostHelper.Add("hash", myUtility.getchecksum(_PayuPaymentSettings.MerchantId.ToString(),
                                                               postProcessPaymentRequest.Order.Id.ToString(), postProcessPaymentRequest.Order.OrderTotal.ToString(new CultureInfo("en-US", false).NumberFormat),
                                                               "productinfo", billingAddress?.FirstName.ToString(),
                                                               billingAddress?.Email.ToString(), _PayuPaymentSettings.Key));


            //Billing details
            remotePostHelper.Add("firstname", billingAddress?.FirstName.ToString());
            remotePostHelper.Add("billing_cust_address", billingAddress?.Address1);
            remotePostHelper.Add("phone", billingAddress?.PhoneNumber);
            remotePostHelper.Add("email", billingAddress?.Email.ToString());
            remotePostHelper.Add("billing_cust_city", billingAddress?.City);

            remotePostHelper.Add("billing_cust_state", stateName);

            remotePostHelper.Add("billing_zip_code", billingAddress?.ZipPostalCode);

            remotePostHelper.Add("billing_cust_country", countryName);


            //Delivery details

            if (postProcessPaymentRequest.Order.ShippingStatus != ShippingStatus.ShippingNotRequired)
            {
                remotePostHelper.Add("delivery_cust_name", shippingaddress.FirstName);
                remotePostHelper.Add("delivery_cust_address", shippingaddress.Address1);
                remotePostHelper.Add("delivery_cust_notes", string.Empty);
                remotePostHelper.Add("delivery_cust_tel", shippingaddress.PhoneNumber);
                remotePostHelper.Add("delivery_cust_city", shippingaddress.City);

                remotePostHelper.Add("delivery_cust_state", abbreviation);

                remotePostHelper.Add("delivery_zip_code", shippingaddress?.ZipPostalCode);


                remotePostHelper.Add("delivery_cust_country", threeletter);
            }

            //  remotePostHelper.Add("Merchant_Param", _PayuPaymentSettings.MerchantParam);
            remotePostHelper.Post();
        }
예제 #21
0
        /// <summary>
        /// Post process payment (payment gateways that require redirecting)
        /// </summary>
        /// <param name="order">Order</param>
        /// <returns>The error status, or String.Empty if no errors</returns>
        public string PostProcessPayment(Order order)
        {
            RemotePost post = new RemotePost();

            post.FormName = "CyberSource";
            post.Url      = HostedPaymentSettings.GatewayUrl;
            post.Method   = "POST";

            post.Add("merchantID", HostedPaymentSettings.MerchantId);
            post.Add("orderPage_timestamp", HostedPaymentHelper.OrderPageTimestamp);
            post.Add("orderPage_transactionType", "authorization");
            post.Add("orderPage_version", "4");
            post.Add("orderPage_serialNumber", HostedPaymentSettings.SerialNumber);

            post.Add("amount", String.Format(CultureInfo.InvariantCulture, "{0:0.00}", order.OrderTotal));
            post.Add("currency", order.CustomerCurrencyCode);
            post.Add("orderNumber", order.OrderId.ToString());

            post.Add("billTo_firstName", order.BillingFirstName);
            post.Add("billTo_lastName", order.BillingLastName);
            post.Add("billTo_street1", order.BillingAddress1);
            Country billCountry = IoC.Resolve <ICountryService>().GetCountryById(order.BillingCountryId);

            if (billCountry != null)
            {
                post.Add("billTo_country", billCountry.TwoLetterIsoCode);
            }
            StateProvince billState = IoC.Resolve <IStateProvinceService>().GetStateProvinceById(order.BillingStateProvinceId);

            if (billState != null)
            {
                post.Add("billTo_state", billState.Abbreviation);
            }
            post.Add("billTo_city", order.BillingCity);
            post.Add("billTo_postalCode", order.BillingZipPostalCode);
            post.Add("billTo_phoneNumber", order.BillingPhoneNumber);
            post.Add("billTo_email", order.BillingEmail);

            if (order.ShippingStatus != ShippingStatusEnum.ShippingNotRequired)
            {
                post.Add("shipTo_firstName", order.ShippingFirstName);
                post.Add("shipTo_lastName", order.ShippingLastName);
                post.Add("shipTo_street1", order.ShippingAddress1);
                Country shipCountry = IoC.Resolve <ICountryService>().GetCountryById(order.ShippingCountryId);
                if (shipCountry != null)
                {
                    post.Add("shipTo_country", shipCountry.TwoLetterIsoCode);
                }
                StateProvince shipState = IoC.Resolve <IStateProvinceService>().GetStateProvinceById(order.ShippingStateProvinceId);
                if (shipState != null)
                {
                    post.Add("shipTo_state", shipState.Abbreviation);
                }
                post.Add("shipTo_city", order.ShippingCity);
                post.Add("shipTo_postalCode", order.ShippingZipPostalCode);
            }

            post.Add("orderPage_receiptResponseURL", String.Format("{0}CheckoutCompleted.aspx", CommonHelper.GetStoreLocation(false)));
            post.Add("orderPage_receiptLinkText", "Return");

            post.Add("orderPage_signaturePublic", HostedPaymentHelper.CalcRequestSign(post.Params));

            post.Post();

            return(String.Empty);
        }
예제 #22
0
        public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {
            var orderTotal = postProcessPaymentRequest.Order.OrderTotal;
            var amount     = String.Format(CultureInfo.InvariantCulture, "{0:0.00}", orderTotal);
            var orderId    = postProcessPaymentRequest.Order.Id;
            //TODO: Uncomment next time
            //var orderItems = postProcessPaymentRequest.Order.OrderItems.ToList();
            var currency   = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId);
            var enumerator = 1;
            var storeUrl   = _webHelper.GetStoreLocation();

            var form = new RemotePost
            {
                FormName = "PayPoint",
                Url      = Constants.OK_PAYMENT_URL
            };

            //TODO: After finish tests, remove this IF DEBUG block
#if DEBUG
            var ipnUrl = "https://www.nopcommerce.com/RecordQueryTest.aspx";
#else
            // URL`s
            var ipnUrl = String.Concat(storeUrl, "plugins/okpay/ipnhandler");
#endif
            var successUrl = String.Concat(storeUrl, "plugins/okpay/success");
            var failUrl    = String.Concat(storeUrl, "plugins/okpay/fail");
            form.Add(Constants.OK_IPN_URL_KEY, ipnUrl);
            form.Add(Constants.OK_RETURN_SUCCESS_URL_KEY, successUrl);
            form.Add(Constants.OK_RETURN_FAIL_URL_KEY, failUrl);

            form.Add(Constants.OK_RECEIVER_KEY, _okPayPaymentSettings.WalletId);

            /*
             * Currently OkPay does not support a separate parameter discounts and gift cards.
             * Therefore, the code commented out. OkPay developers promise to include support for gift cards in the near future.
             *
             * TODO: Uncomment next time
             */

            //if (_okPayPaymentSettings.PassProductNamesAndTotals)
            //{
            //    decimal cartTotal = decimal.Zero;
            //    // Send to OkPay order details information, include Product Name, Quantity, Price and SKU
            //    foreach (var item in orderItems)
            //    {
            //        form.Add(String.Format(Constants.OK_ITEM_NAME_FORMATED_KEY, enumerator), item.Product.Name);
            //        form.Add(String.Format(Constants.OK_ITEM_QTY_FORMATED_KEY, enumerator), item.Quantity.ToString());
            //        form.Add(String.Format(Constants.OK_ITEM_TYPE_FORMATED_KEY, enumerator),
            //            item.Product.IsDownload ? "digital" : "shipment");
            //        if (!string.IsNullOrEmpty(item.Product.Sku))
            //            form.Add(String.Format(Constants.OK_ITEM_ARTICLE_FORMATED_KEY, enumerator), item.Product.Sku);
            //        form.Add(String.Format(Constants.OK_ITEM_PRICE_FORMATED_KEY, enumerator),
            //            String.Format(CultureInfo.InvariantCulture, "{0:0.00}", Math.Round(item.UnitPriceExclTax, 2)));
            //        cartTotal += item.PriceExclTax;
            //        enumerator++;
            //    }
            //    // attributes
            //    var attributeValues =
            //        _checkoutAttributeParser.ParseCheckoutAttributeValues(
            //            postProcessPaymentRequest.Order.CheckoutAttributesXml);
            //    foreach (var val in attributeValues)
            //    {
            //        var attPrice = _taxService.GetCheckoutAttributePrice(val, false,
            //            postProcessPaymentRequest.Order.Customer);
            //        //round
            //        var attPriceRounded = Math.Round(attPrice, 2);
            //        if (attPrice > decimal.Zero) //if it has a price
            //        {
            //            var attribute = val.CheckoutAttribute;
            //            if (attribute != null)
            //            {
            //                var attName = attribute.Name; //set the name
            //                form.Add(String.Format(Constants.OK_ITEM_NAME_FORMATED_KEY, enumerator), attName);
            //                form.Add(String.Format(Constants.OK_ITEM_QTY_FORMATED_KEY, enumerator), "1");
            //                form.Add(String.Format(Constants.OK_ITEM_PRICE_FORMATED_KEY, enumerator),
            //                    attPriceRounded.ToString("0.00", CultureInfo.InvariantCulture));
            //                enumerator++;
            //                cartTotal += attPrice;
            //            }
            //        }
            //    }
            //    //shipping
            //    var orderShippingExclTax = postProcessPaymentRequest.Order.OrderShippingExclTax;
            //    var orderShippingExclTaxRounded = Math.Round(orderShippingExclTax, 2);
            //    if (orderShippingExclTax > decimal.Zero)
            //    {
            //        form.Add(String.Format(Constants.OK_ITEM_NAME_FORMATED_KEY, enumerator), "Shipping fee");
            //        form.Add(String.Format(Constants.OK_ITEM_QTY_FORMATED_KEY, enumerator), "1");
            //        form.Add(String.Format(Constants.OK_ITEM_PRICE_FORMATED_KEY, enumerator),
            //            orderShippingExclTaxRounded.ToString("0.00", CultureInfo.InvariantCulture));
            //        enumerator++;
            //        cartTotal += orderShippingExclTax;
            //    }

            //    //payment method additional fee
            //    var paymentMethodAdditionalFeeExclTax =
            //        postProcessPaymentRequest.Order.PaymentMethodAdditionalFeeExclTax;
            //    var paymentMethodAdditionalFeeExclTaxRounded = Math.Round(paymentMethodAdditionalFeeExclTax, 2);
            //    if (paymentMethodAdditionalFeeExclTax > decimal.Zero)
            //    {
            //        form.Add(String.Format(Constants.OK_ITEM_NAME_FORMATED_KEY, enumerator), "Payment method fee");
            //        form.Add(String.Format(Constants.OK_ITEM_QTY_FORMATED_KEY, enumerator), "1");
            //        form.Add(String.Format(Constants.OK_ITEM_PRICE_FORMATED_KEY, enumerator),
            //            paymentMethodAdditionalFeeExclTaxRounded.ToString("0.00", CultureInfo.InvariantCulture));
            //        enumerator++;
            //        cartTotal += paymentMethodAdditionalFeeExclTax;
            //    }

            //    // tax
            //    var orderTax = postProcessPaymentRequest.Order.OrderTax;
            //    var orderTaxRounded = Math.Round(orderTax, 2);
            //    if (orderTax > decimal.Zero)
            //    {
            //        //add tax as item
            //        form.Add(String.Format(Constants.OK_ITEM_NAME_FORMATED_KEY, enumerator), "Sales Tax");
            //        form.Add(String.Format(Constants.OK_ITEM_QTY_FORMATED_KEY, enumerator), "1");
            //        form.Add(String.Format(Constants.OK_ITEM_PRICE_FORMATED_KEY, enumerator),
            //            orderTaxRounded.ToString("0.00", CultureInfo.InvariantCulture));
            //        cartTotal += orderTax;
            //    }

            //    if (cartTotal > postProcessPaymentRequest.Order.OrderTotal)
            //    {
            //        decimal discountTotal = cartTotal - postProcessPaymentRequest.Order.OrderTotal;
            //        discountTotal = Math.Round(discountTotal, 2);
            //    }
            //}
            //else
            //{
            form.Add(String.Format(Constants.OK_ITEM_NAME_FORMATED_KEY, enumerator), string.Format(_okPayPaymentSettings.OrderDescription, orderId));
            form.Add(String.Format(Constants.OK_ITEM_QTY_FORMATED_KEY, enumerator), "1");
            form.Add(String.Format(Constants.OK_ITEM_PRICE_FORMATED_KEY, enumerator), amount);
            //}

            form.Add(Constants.OK_KIND_KEY, "payment");
            form.Add(Constants.OK_INVOICE_KEY, orderId.ToString());
            form.Add(Constants.OK_CURRENCY_KEY, currency.CurrencyCode);
            form.Add(Constants.OK_FEES_KEY, _okPayPaymentSettings.Fees.ToString());
            //General info
            // if you want to send the personal data of the customer, you can uncomment the following code

            //var billingInfo = postProcessPaymentRequest.Order.BillingAddress;
            //form.Add(Constants.OK_PAYER_FIRST_NAME_KEY, billingInfo.FirstName.ToTransliterate());
            //form.Add(Constants.OK_PAYER_LAST_NAME_KEY, billingInfo.LastName.ToTransliterate());
            //if (!string.IsNullOrEmpty(billingInfo.Company))
            //    form.Add(Constants.OK_PAYER_COMPANY_NAME_KEY, billingInfo.Company.ToTransliterate());
            //form.Add(Constants.OK_PAYER_EMAIL_KEY, billingInfo.Email.ToTransliterate());
            //form.Add(Constants.OK_PAYER_PHONE_KEY, billingInfo.PhoneNumber.ToTransliterate());
            //form.Add(Constants.OK_PAYER_COUNTRY_CODE_KEY, billingInfo.Country.TwoLetterIsoCode.ToTransliterate());
            //form.Add(Constants.OK_PAYER_COUNTRY_KEY, billingInfo.Country.Name.ToTransliterate());
            //form.Add(Constants.OK_PAYER_CITY_KEY, billingInfo.City.ToTransliterate());
            //form.Add(Constants.OK_PAYER_STATE_KEY, billingInfo.StateProvince.Name);
            //form.Add(Constants.OK_PAYER_STREET_KEY, billingInfo.Address1);
            //form.Add(Constants.OK_PAYER_ZIP_KEY, billingInfo.ZipPostalCode);

            form.Post();
        }
예제 #23
0
        /// <summary>
        /// Post process payment (used by payment gateways that require redirecting to a third-party URL)
        /// </summary>
        /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param>
        public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {
            var nfi        = new CultureInfo("en-US", false).NumberFormat;
            var url        = GetPaymentUrl();
            var gatewayUrl = new Uri(url);
            var post       = new RemotePost {
                Url = gatewayUrl.ToString(), Method = "POST"
            };

            var order = postProcessPaymentRequest.Order;

            //required details
            post.Add("ps_store_id", _monerisPaymentSettings.PsStoreId);
            post.Add("hpp_key", _monerisPaymentSettings.HppKey);
            post.Add("charge_total", order.OrderTotal.ToString(nfi));

            ////other transaction details
            post.Add("cust_id", order.CustomerId.ToString());
            if (!_monerisPaymentSettings.UseSandbox)
            {
                post.Add("order_id", order.Id.ToString());
            }
            post.Add("email", order.BillingAddress.Email);
            post.Add("rvar_order_id", order.Id.ToString());

            //shipping details
            if (order.ShippingAddress != null)
            {
                post.Add("ship_first_name", order.ShippingAddress.FirstName);
                post.Add("ship_last_name", order.ShippingAddress.LastName);
                post.Add("ship_company_name", order.ShippingAddress.Company);
                post.Add("ship_city", order.ShippingAddress.City);
                post.Add("ship_phone", order.ShippingAddress.PhoneNumber);
                post.Add("ship_fax", order.ShippingAddress.FaxNumber);
                post.Add("ship_postal_code", order.ShippingAddress.ZipPostalCode);
                post.Add("ship_address_one",
                         "1: " + order.ShippingAddress.Address1 +
                         " 2: " + order.ShippingAddress.Address2);
                post.Add("ship_state_or_province",
                         order.ShippingAddress.StateProvince != null
                             ? order.ShippingAddress.StateProvince.Name
                             : string.Empty);
                post.Add("ship_country",
                         order.ShippingAddress.Country != null
                             ? order.ShippingAddress.Country.Name
                             : string.Empty);
            }

            //billing details
            if (order.BillingAddress != null)
            {
                post.Add("bill_first_name", order.BillingAddress.FirstName);
                post.Add("bill_last_name", order.BillingAddress.LastName);
                post.Add("bill_company_name", order.BillingAddress.Company);
                post.Add("bill_phone", order.BillingAddress.PhoneNumber);
                post.Add("bill_fax", order.BillingAddress.FaxNumber);
                post.Add("bill_postal_code", order.BillingAddress.ZipPostalCode);
                post.Add("bill_city", order.BillingAddress.City);
                post.Add("bill_address_one",
                         "1: " + order.BillingAddress.Address1 +
                         " 2: " + order.BillingAddress.Address2);
                post.Add("bill_state_or_province",
                         order.BillingAddress.StateProvince != null
                             ? order.BillingAddress.StateProvince.Name
                             : string.Empty);
                post.Add("bill_country",
                         order.BillingAddress.Country != null
                             ? order.BillingAddress.Country.Name
                             : string.Empty);
            }

            post.Post();
        }
예제 #24
0
        public void RedirectToPayumoney(BookingDetailsViewModel bookingDetailsViewModel)
        {
            var user = SessionManager.GetSessionUser();
            var searchCriteria = (SearchViewModel)Session["SearchCriteria"];
            if (user == null && user.Id == 0)
            {
                //user session time out
            }
            else if (searchCriteria == null && searchCriteria.BookingFromDate == null)
            {
                //search criteria is removed...redirect user for search again
            }
            else
            {
                string txnid = Generatetxnid();
                //transaction management
                if (transactionManagement.AddTransaction(bookingDetailsViewModel, txnid, user.Id, searchCriteria.BookingFromDate) > 1)
                {
                    string firstName = user.FirstName;
                    string amount = bookingDetailsViewModel.Price.ToString();
                    string productInfo = bookingDetailsViewModel.RoomID.ToString();
                    string email = user.Email;
                    string phone = user.PhoneNumber;
                    string surl = Url.Action("Payment", "Success");
                    string furl = Url.Action("Payment", "Success");

                    RemotePost myremotepost = new RemotePost();

                    string key = LYSConfig.PayUmoneyKey;
                    string salt = LYSConfig.PayUmoneySalt;

                    //posting all the parameters required for integration.
                    myremotepost.Url = LYSConfig.PayUmoneyRedirectURL;
                    myremotepost.Add("key", key);
                    myremotepost.Add("txnid", txnid);
                    myremotepost.Add("amount", bookingDetailsViewModel.Price.ToString());
                    myremotepost.Add("productinfo", productInfo);
                    myremotepost.Add("firstname", firstName);
                    myremotepost.Add("phone", phone);
                    myremotepost.Add("email", email);
                    myremotepost.Add("surl", surl);//Change the success url here depending upon the port number of your local system.
                    myremotepost.Add("furl", furl);//Change the failure url here depending upon the port number of your local system.
                    myremotepost.Add("service_provider", "payu_paisa");
                    string hashString = key + "|" + txnid + "|" + amount + "|" + productInfo + "|" + firstName + "|" + email + "|||||||||||" + salt;
                    //string hashString = "3Q5c3q|2590640|3053.00|OnlineBooking|vimallad|[email protected]|||||||||||mE2RxRwx";
                    string hash = Generatehash512(hashString);
                    myremotepost.Add("hash", hash);

                    myremotepost.Post();
                }
                else
                {
                    //bed not available
                }
            }
        }
        /// <summary>
        /// Post process payment (used by payment gateways that require redirecting to a third-party URL)
        /// </summary>
        /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param>
        public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {
            string lang = EPayHelper.GetLangauge(Thread.CurrentThread.CurrentCulture).ToString();

            decimal orderTotal  = Math.Round(postProcessPaymentRequest.Order.OrderTotal, 2);
            string  amount      = (orderTotal * 100).ToString("0", CultureInfo.InvariantCulture);
            string  currency    = EPayHelper.GetIsoCode(postProcessPaymentRequest.Order.CustomerCurrencyCode);
            string  itemurl     = this.webHelper.GetStoreLocation(false);
            string  continueurl = itemurl + "Plugins/PaymentePay/PDTHandler";
            string  cancelurl   = itemurl + "Plugins/PaymentePay/CancelOrder";
            string  merchant    = ePayPaymentSettings.MerchantId;

            var orderHasRecurringItems = false;

            foreach (var item in postProcessPaymentRequest.Order.OrderItems)
            {
                orderHasRecurringItems = orderHasRecurringItems || (item.Product != null && item.Product.IsRecurring);
            }

            string ordernumber = postProcessPaymentRequest.Order.Id.ToString("D2");

            // ordernumber 1-9 must be with 0 in front, e.g. 01
            if (ordernumber.Length == 1)
            {
                ordernumber = "0" + ordernumber;
            }

            var remotePostHelper = new RemotePost
            {
                FormName = "ePay",
                Url      = itemurl + "Plugins/PaymentePay/Open"
            };

            remotePostHelper.Add("merchantnumber", merchant);
            remotePostHelper.Add("orderid", ordernumber);
            remotePostHelper.Add("amount", amount);
            remotePostHelper.Add("windowstate", ePayPaymentSettings.FullScreen ? "3" : "1");
            remotePostHelper.Add("language", lang);
            remotePostHelper.Add("currency", currency);
            remotePostHelper.Add("accepturl", continueurl);
            remotePostHelper.Add("callbackurl", continueurl);
            remotePostHelper.Add("declineurl", cancelurl);
            remotePostHelper.Add("authmail", ePayPaymentSettings.AuthMail);
            remotePostHelper.Add("authsms", ePayPaymentSettings.AuthSms);
            remotePostHelper.Add("group", ePayPaymentSettings.Group);
            remotePostHelper.Add("instantcapture", Convert.ToByte(ePayPaymentSettings.Instantcapture).ToString());
            remotePostHelper.Add("ownreceipt", Convert.ToByte(ePayPaymentSettings.OwnReceipt).ToString());
            remotePostHelper.Add("cms", "nopcommerce");
            remotePostHelper.Add("subscription", (orderHasRecurringItems) ? "1" : "0");

            string stringToMd5 = "";

            foreach (string key in remotePostHelper.Params)
            {
                stringToMd5 += "" + remotePostHelper.Params[key];
            }

            string md5Check = GetMd5(stringToMd5 + ePayPaymentSettings.Md5Secret);

            remotePostHelper.Add("md5key", md5Check);

            remotePostHelper.Post();
        }
예제 #26
0
        /// <summary>
        /// Post process payment (used by payment gateways that require redirecting to a third-party URL)
        /// </summary>
        /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param>
        public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {
            var myUtility        = new PayuHelper();
            var orderId          = postProcessPaymentRequest.Order.Id;
            var remotePostHelper = new RemotePost();

            remotePostHelper.FormName = "PayuForm";
            remotePostHelper.Url      = _PayuPaymentSettings.PayUri;
            remotePostHelper.Add("key", _PayuPaymentSettings.MerchantId.ToString());
            remotePostHelper.Add("amount", postProcessPaymentRequest.Order.TotalTransactionAmount.ToString(new CultureInfo("en-US", false).NumberFormat));
            remotePostHelper.Add("productinfo", "productinfo");
            remotePostHelper.Add("Currency", _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode);
            remotePostHelper.Add("Order_Id", orderId.ToString());
            remotePostHelper.Add("txnid", postProcessPaymentRequest.Order.OrderGuid.ToString());

            remotePostHelper.Add("surl", _webHelper.GetStoreLocation(true) + "PaymentPayu/Return");
            remotePostHelper.Add("furl", _webHelper.GetStoreLocation(true) + "PaymentPayu/Return");
            remotePostHelper.Add("hash", myUtility.getchecksum(_PayuPaymentSettings.MerchantId.ToString(),
                                                               postProcessPaymentRequest.Order.OrderGuid.ToString(), postProcessPaymentRequest.Order.TotalTransactionAmount.ToString(new CultureInfo("en-US", false).NumberFormat),
                                                               "productinfo", postProcessPaymentRequest.Order.BillingAddress.FirstName.ToString(),
                                                               postProcessPaymentRequest.Order.BillingAddress.Email.ToString(), _PayuPaymentSettings.Key));


            //Billing details
            remotePostHelper.Add("firstname", postProcessPaymentRequest.Order.BillingAddress.FirstName.ToString());
            remotePostHelper.Add("billing_cust_address", postProcessPaymentRequest.Order.BillingAddress.Address1);
            remotePostHelper.Add("phone", postProcessPaymentRequest.Order.BillingAddress.PhoneNumber);
            remotePostHelper.Add("email", postProcessPaymentRequest.Order.BillingAddress.Email.ToString());
            remotePostHelper.Add("billing_cust_city", postProcessPaymentRequest.Order.BillingAddress.City);
            var billingStateProvince = postProcessPaymentRequest.Order.BillingAddress.StateProvince;

            if (billingStateProvince != null)
            {
                remotePostHelper.Add("billing_cust_state", billingStateProvince.Abbreviation);
            }
            else
            {
                remotePostHelper.Add("billing_cust_state", "");
            }
            remotePostHelper.Add("billing_zip_code", postProcessPaymentRequest.Order.BillingAddress.ZipPostalCode);
            var billingCountry = postProcessPaymentRequest.Order.BillingAddress.Country;

            if (billingCountry != null)
            {
                remotePostHelper.Add("billing_cust_country", billingCountry.ThreeLetterIsoCode);
            }
            else
            {
                remotePostHelper.Add("billing_cust_country", "");
            }

            //Delivery details

            if (postProcessPaymentRequest.Order.ShippingStatus != ShippingStatus.ShippingNotRequired)
            {
                remotePostHelper.Add("delivery_cust_name", postProcessPaymentRequest.Order.ShippingAddress.FirstName);
                remotePostHelper.Add("delivery_cust_address", postProcessPaymentRequest.Order.ShippingAddress.Address1);
                remotePostHelper.Add("delivery_cust_notes", string.Empty);
                remotePostHelper.Add("delivery_cust_tel", postProcessPaymentRequest.Order.ShippingAddress.PhoneNumber);
                remotePostHelper.Add("delivery_cust_city", postProcessPaymentRequest.Order.ShippingAddress.City);
                var deliveryStateProvince = postProcessPaymentRequest.Order.ShippingAddress.StateProvince;
                if (deliveryStateProvince != null)
                {
                    remotePostHelper.Add("delivery_cust_state", deliveryStateProvince.Abbreviation);
                }
                else
                {
                    remotePostHelper.Add("delivery_cust_state", "");
                }
                remotePostHelper.Add("delivery_zip_code", postProcessPaymentRequest.Order.ShippingAddress.ZipPostalCode);
                var deliveryCountry = postProcessPaymentRequest.Order.ShippingAddress.Country;
                if (deliveryCountry != null)
                {
                    remotePostHelper.Add("delivery_cust_country", deliveryCountry.ThreeLetterIsoCode);
                }
                else
                {
                    remotePostHelper.Add("delivery_cust_country", "");
                }
            }

            //  remotePostHelper.Add("Merchant_Param", _PayuPaymentSettings.MerchantParam);
            remotePostHelper.Post();
        }
        /// <summary>
        /// Post process payment (payment gateways that require redirecting)
        /// </summary>
        /// <param name="order">Order</param>
        /// <returns>The error status, or String.Empty if no errors</returns>
        public string PostProcessPayment(Order order)
        {
            //Notificación On-Line
            string strDs_Merchant_MerchantURL = Common.Utils.CommonHelper.GetStoreLocation(false) + "SermepaReturn.aspx";

            //URL OK
            string strDs_Merchant_UrlOK = Common.Utils.CommonHelper.GetStoreLocation(false) + "CheckoutCompleted.aspx";

            //URL KO
            string strDs_Merchant_UrlKO = Common.Utils.CommonHelper.GetStoreLocation(false) + "SermepaError.aspx";

            //Numero de pedido
            string strDs_Merchant_Order = order.OrderId.ToString();

            //Nombre del comercio
            string strDs_Merchant_MerchantName = SettingManager.GetSettingValue("PaymentMethod.Sermepa.NombreComercio");

            //Importe
            string amount = ((int)Convert.ToInt64(order.OrderTotal * 100)).ToString();
            string strDs_Merchant_Amount = amount;

            //Código de comercio
            string strDs_Merchant_MerchantCode = SettingManager.GetSettingValue("PaymentMethod.Sermepa.FUC");

            //Moneda
            string strDs_Merchant_Currency = SettingManager.GetSettingValue("PaymentMethod.Sermepa.Moneda");

            //Terminal
            string strDs_Merchant_Terminal = SettingManager.GetSettingValue("PaymentMethod.Sermepa.Terminal");

            //Tipo de transaccion (0 - Autorización)
            string strDs_Merchant_TransactionType = "0";

            //Clave
            string clave = "";

            if (pruebas)
            {
                clave = SettingManager.GetSettingValue("PaymentMethod.Sermepa.ClavePruebas");
            }
            else
            {
                clave = SettingManager.GetSettingValue("PaymentMethod.Sermepa.ClaveReal");
            };

            //Calculo de la firma
            string SHA = string.Format("{0}{1}{2}{3}{4}{5}{6}",
                                       strDs_Merchant_Amount,
                                       strDs_Merchant_Order,
                                       strDs_Merchant_MerchantCode,
                                       strDs_Merchant_Currency,
                                       strDs_Merchant_TransactionType,
                                       strDs_Merchant_MerchantURL,
                                       clave);

            byte[] SHAresult;
            SHA1   shaM = new SHA1Managed();

            SHAresult = shaM.ComputeHash(System.Text.Encoding.Default.GetBytes(SHA));
            string SHAresultStr = BitConverter.ToString(SHAresult).Replace("-", "");

            //Creamos el POST
            RemotePost remotePostHelper = new RemotePost();

            remotePostHelper.FormName = "form1";
            remotePostHelper.Url      = GetSermepaUrl();

            remotePostHelper.Add("Ds_Merchant_Amount", strDs_Merchant_Amount);
            remotePostHelper.Add("Ds_Merchant_Currency", strDs_Merchant_Currency);
            remotePostHelper.Add("Ds_Merchant_Order", strDs_Merchant_Order);
            remotePostHelper.Add("Ds_Merchant_MerchantCode", strDs_Merchant_MerchantCode);
            remotePostHelper.Add("Ds_Merchant_TransactionType", strDs_Merchant_TransactionType);
            remotePostHelper.Add("Ds_Merchant_MerchantURL", strDs_Merchant_MerchantURL);
            remotePostHelper.Add("Ds_Merchant_MerchantSignature", SHAresultStr);
            remotePostHelper.Add("Ds_Merchant_Terminal", strDs_Merchant_Terminal);
            remotePostHelper.Add("Ds_Merchant_MerchantName", strDs_Merchant_MerchantName);
            remotePostHelper.Add("Ds_Merchant_UrlOK", strDs_Merchant_UrlOK);
            remotePostHelper.Add("Ds_Merchant_UrlKO", strDs_Merchant_UrlKO);

            remotePostHelper.Post();

            return(string.Empty);
        }
예제 #28
0
        /// <summary>
        /// Post process payment (payment gateways that require redirecting)
        /// </summary>
        /// <param name="order">Order</param>
        /// <returns>The error status, or String.Empty if no errors</returns>
        public string PostProcessPayment(Order order)
        {
            InitSettings();

            RemotePost remotePostHelper = new RemotePost();

            remotePostHelper.FormName = "CCAvenueForm";
            remotePostHelper.Url      = _payURI;
            remotePostHelper.Add("Merchant_Id", _merchantID.ToString());
            remotePostHelper.Add("Amount", order.OrderTotal.ToString(new CultureInfo("en-US", false).NumberFormat));
            remotePostHelper.Add("Currency", IoC.Resolve <ICurrencyService>().PrimaryStoreCurrency.CurrencyCode);
            remotePostHelper.Add("Order_Id", order.OrderId.ToString());
            remotePostHelper.Add("Redirect_Url", CommonHelper.GetStoreLocation(false) + "CCAvenueReturn.aspx");
            remotePostHelper.Add("Checksum", _myUtility.getchecksum(_merchantID.ToString(), order.OrderId.ToString(), order.OrderTotal.ToString(), CommonHelper.GetStoreLocation(false) + "CCAvenueReturn.aspx", _key));


            //Billing details
            remotePostHelper.Add("billing_cust_name", order.BillingFirstName);
            remotePostHelper.Add("billing_cust_address", order.BillingAddress1);
            remotePostHelper.Add("billing_cust_tel", order.BillingPhoneNumber);
            remotePostHelper.Add("billing_cust_email", order.BillingEmail);
            remotePostHelper.Add("billing_cust_city", order.BillingCity);
            StateProvince billingStateProvince = IoC.Resolve <IStateProvinceService>().GetStateProvinceById(order.BillingStateProvinceId);

            if (billingStateProvince != null)
            {
                remotePostHelper.Add("billing_cust_state", billingStateProvince.Abbreviation);
            }
            else
            {
                remotePostHelper.Add("billing_cust_state", order.BillingStateProvince);
            }
            remotePostHelper.Add("billing_zip_code", order.BillingZipPostalCode);
            Country billingCountry = IoC.Resolve <ICountryService>().GetCountryById(order.BillingCountryId);

            if (billingCountry != null)
            {
                remotePostHelper.Add("billing_cust_country", billingCountry.ThreeLetterIsoCode);
            }
            else
            {
                remotePostHelper.Add("billing_cust_country", order.BillingCountry);
            }

            //Delivery details

            if (order.ShippingStatus != ShippingStatusEnum.ShippingNotRequired)
            {
                remotePostHelper.Add("delivery_cust_name", order.ShippingFirstName);
                remotePostHelper.Add("delivery_cust_address", order.ShippingAddress1);
                remotePostHelper.Add("delivery_cust_notes", string.Empty);
                remotePostHelper.Add("delivery_cust_tel", order.ShippingPhoneNumber);
                remotePostHelper.Add("delivery_cust_city", order.ShippingCity);
                StateProvince deliveryStateProvince = IoC.Resolve <IStateProvinceService>().GetStateProvinceById(order.ShippingStateProvinceId);
                if (deliveryStateProvince != null)
                {
                    remotePostHelper.Add("delivery_cust_state", deliveryStateProvince.Abbreviation);
                }
                else
                {
                    remotePostHelper.Add("delivery_cust_state", order.ShippingStateProvince);
                }
                remotePostHelper.Add("delivery_zip_code", order.ShippingZipPostalCode);
                Country deliveryCountry = IoC.Resolve <ICountryService>().GetCountryById(order.ShippingCountryId);
                if (deliveryCountry != null)
                {
                    remotePostHelper.Add("delivery_cust_country", deliveryCountry.ThreeLetterIsoCode);
                }
                else
                {
                    remotePostHelper.Add("delivery_cust_country", order.ShippingCountry);
                }
            }

            remotePostHelper.Add("Merchant_Param", _merchantParam);
            remotePostHelper.Post();
            return(string.Empty);
        }
예제 #29
0
        /// <summary>
        /// Post process payment (payment gateways that require redirecting)
        /// </summary>
        /// <param name="order">Order</param>
        /// <returns>The error status, or String.Empty if no errors</returns>
        public string PostProcessPayment(Order order)
        {
            string     validUntil       = DateTime.UtcNow.ToString("o", new CultureInfo("en-us"));
            RemotePost remotePostHelper = new RemotePost
            {
                FormName = "IdealCheckoutForm",
                Url      = iDealBasicPaymentSettings.Url
            };

            remotePostHelper.Add("urlCancel", CommonHelper.GetStoreLocation(false) + "idealreturn.aspx?s=1&o=" + order.OrderId);
            remotePostHelper.Add("urlSuccess", CommonHelper.GetStoreLocation(false) + "checkoutcompleted.aspx");
            remotePostHelper.Add("urlError", CommonHelper.GetStoreLocation(false) + "idealreturn.aspx?s=2&o=" + order.OrderId);

            remotePostHelper.Add("merchantID", iDealBasicPaymentSettings.MerchantId);
            remotePostHelper.Add("subID", iDealBasicPaymentSettings.SubId);
            remotePostHelper.Add("description", "Order " + order.OrderId);

            remotePostHelper.Add("language", "nl");
            remotePostHelper.Add("currency", IoC.Resolve <ICurrencyService>().PrimaryStoreCurrency.CurrencyCode);
            remotePostHelper.Add("paymentType", "ideal");

            remotePostHelper.Add("purchaseID", order.OrderId.ToString());
            remotePostHelper.Add("amount", ((int)(order.OrderTotal * 100)).ToString());
            remotePostHelper.Add("validUntil", validUntil);

            StringBuilder hasString = new StringBuilder(iDealBasicPaymentSettings.HashKey);

            hasString.Append(iDealBasicPaymentSettings.MerchantId);
            hasString.Append(iDealBasicPaymentSettings.SubId);
            hasString.Append(((int)(order.OrderTotal * 100)).ToString());
            hasString.Append(order.OrderId.ToString());
            hasString.Append("ideal");
            hasString.Append(validUntil);
            ulong aantal = 0;
            int   price  = 0;
            int   i      = 1;

            foreach (OrderProductVariant product in order.OrderProductVariants)
            {
                hasString.Append(product.ProductVariantId.ToString());
                remotePostHelper.Add("itemNumber" + i, product.ProductVariantId.ToString());

                if (!string.IsNullOrEmpty(product.ProductVariant.Product.LocalizedShortDescription))
                {
                    string shortDescription = HttpUtility.UrlEncode(product.ProductVariant.Product.LocalizedShortDescription);
                    remotePostHelper.Add("itemDescription" + i, shortDescription);
                    hasString.Append(shortDescription);
                }
                else
                {
                    string fullProductName = HttpUtility.UrlEncode(product.ProductVariant.LocalizedFullProductName);
                    remotePostHelper.Add("itemDescription" + i, fullProductName);
                    hasString.Append(fullProductName);
                }
                int itemPrice = ((int)(product.PriceExclTax * 100)) / product.Quantity;
                remotePostHelper.Add("itemQuantity" + i, product.Quantity.ToString());
                remotePostHelper.Add("itemPrice" + i, itemPrice.ToString());

                hasString.Append(product.Quantity.ToString());
                hasString.Append(itemPrice.ToString());

                aantal += (ulong)product.Quantity;
                price  += (int)(product.PriceExclTax * 100);
                i++;
            }

            decimal orderShippingPrice = order.OrderShippingExclTax;

            if (orderShippingPrice > 0)
            {
                price += (int)(orderShippingPrice * 100);

                remotePostHelper.Add("itemNumber" + i, "zending");
                remotePostHelper.Add("itemDescription" + i, "Verzend kosten");
                remotePostHelper.Add("itemQuantity" + i, "1");
                remotePostHelper.Add("itemPrice" + i, ((int)(orderShippingPrice * 100)).ToString());

                hasString.Append("zending");
                hasString.Append("Verzend kosten");
                hasString.Append(1);
                hasString.Append(((int)(orderShippingPrice * 100)).ToString());
                aantal++;
                i++;
            }

            // Add additional handling fee
            if (order.PaymentMethodAdditionalFeeExclTax > 0)
            {
                price += (int)(order.PaymentMethodAdditionalFeeExclTax * 100);

                remotePostHelper.Add("itemNumber" + i, "administratiekosten");
                remotePostHelper.Add("itemDescription" + i, "Administratiekosten");
                remotePostHelper.Add("itemQuantity" + i, "1");
                remotePostHelper.Add("itemPrice" + i, ((int)(order.PaymentMethodAdditionalFeeExclTax * 100)).ToString());

                hasString.Append("administratiekosten");
                hasString.Append("Administratiekosten");
                hasString.Append(1);
                hasString.Append(((int)(order.PaymentMethodAdditionalFeeExclTax * 100)).ToString());
                aantal++;
                i++;
            }

            // Add Taxes
            if (order.OrderTax > 0)
            {
                price += (int)(order.OrderTax * 100);

                remotePostHelper.Add("itemNumber" + i, "belasting");
                remotePostHelper.Add("itemDescription" + i, "Belasting");
                remotePostHelper.Add("itemQuantity" + i, "1");
                remotePostHelper.Add("itemPrice" + i, ((int)(order.OrderTax * 100)).ToString());

                hasString.Append("belasting");
                hasString.Append("Belasting");
                hasString.Append(1);
                hasString.Append(((int)(order.OrderTax * 100)).ToString());
                aantal++;
                i++;
            }

            if ((int)(order.OrderTotal * 100) != price)
            {
                int currencyconversion = (int)(order.OrderTotal * 100) - price;

                remotePostHelper.Add("itemNumber" + i, "currencyconversion");
                remotePostHelper.Add("itemDescription" + i, "currencyConversion");
                remotePostHelper.Add("itemQuantity" + i, "1");
                remotePostHelper.Add("itemPrice" + i, currencyconversion.ToString());

                hasString.Append("currencyconversion");
                hasString.Append("currencyConversion");
                hasString.Append(1);
                hasString.Append(currencyconversion.ToString());
                aantal++;
            }

            // Generate Sha1
            hasString = hasString.Replace(" ", string.Empty).Replace("\t", string.Empty).Replace("\n", string.Empty);
            string hashString = BitConverter.ToString(SHA1.Create().ComputeHash(Encoding.ASCII.GetBytes(hasString.ToString())));

            hashString = hashString.Replace("-", string.Empty).ToLower();
            remotePostHelper.Add("hash", hashString);

            // Do post if needed
            if (aantal != 0 && price != 0)
            {
                remotePostHelper.Post();
            }

            return(string.Empty);
        }
예제 #30
0
        /// <summary>
        /// Post process payment (used by payment gateways that require redirecting to a third-party URL)
        /// </summary>
        /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param>
        public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {
            var post = new RemotePost
            {
                FormName = "CyberSource",
                Url      = _cyberSourcePaymentSettings.GatewayUrl,
                Method   = "POST"
            };

            post.Add("merchantID", _cyberSourcePaymentSettings.MerchantId);
            post.Add("orderPage_timestamp", HostedPaymentHelper.OrderPageTimestamp);
            post.Add("orderPage_transactionType", "authorization");
            post.Add("orderPage_version", "4");
            post.Add("orderPage_serialNumber", _cyberSourcePaymentSettings.SerialNumber);

            post.Add("amount", string.Format(CultureInfo.InvariantCulture, "{0:0.00}", postProcessPaymentRequest.Order.OrderTotal));
            post.Add("currency", _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode);
            post.Add("orderNumber", postProcessPaymentRequest.Order.Id.ToString());

            post.Add("billTo_firstName", postProcessPaymentRequest.Order.BillingAddress.FirstName);
            post.Add("billTo_lastName", postProcessPaymentRequest.Order.BillingAddress.LastName);
            post.Add("billTo_street1", postProcessPaymentRequest.Order.BillingAddress.Address1);
            var billCountry = postProcessPaymentRequest.Order.BillingAddress.Country;

            if (billCountry != null)
            {
                post.Add("billTo_country", billCountry.TwoLetterIsoCode);
            }
            var billState = postProcessPaymentRequest.Order.BillingAddress.StateProvince;

            if (billState != null)
            {
                post.Add("billTo_state", billState.Abbreviation);
            }
            post.Add("billTo_city", postProcessPaymentRequest.Order.BillingAddress.City);
            post.Add("billTo_postalCode", postProcessPaymentRequest.Order.BillingAddress.ZipPostalCode);
            post.Add("billTo_phoneNumber", postProcessPaymentRequest.Order.BillingAddress.PhoneNumber);
            post.Add("billTo_email", postProcessPaymentRequest.Order.BillingAddress.Email);

            if (postProcessPaymentRequest.Order.ShippingStatus != ShippingStatus.ShippingNotRequired)
            {
                post.Add("shipTo_firstName", postProcessPaymentRequest.Order.ShippingAddress.FirstName);
                post.Add("shipTo_lastName", postProcessPaymentRequest.Order.ShippingAddress.LastName);
                post.Add("shipTo_street1", postProcessPaymentRequest.Order.ShippingAddress.Address1);
                var shipCountry = postProcessPaymentRequest.Order.ShippingAddress.Country;
                if (shipCountry != null)
                {
                    post.Add("shipTo_country", shipCountry.TwoLetterIsoCode);
                }
                var shipState = postProcessPaymentRequest.Order.ShippingAddress.StateProvince;
                if (shipState != null)
                {
                    post.Add("shipTo_state", shipState.Abbreviation);
                }
                post.Add("shipTo_city", postProcessPaymentRequest.Order.ShippingAddress.City);
                post.Add("shipTo_postalCode", postProcessPaymentRequest.Order.ShippingAddress.ZipPostalCode);
            }

            post.Add("orderPage_receiptResponseURL", String.Format("{0}checkout/completed", _webHelper.GetStoreLocation(false)));
            post.Add("orderPage_receiptLinkText", "Return");

            post.Add("orderPage_signaturePublic", HostedPaymentHelper.CalcRequestSign(post.Params, _cyberSourcePaymentSettings.PublicKey));

            post.Post();
        }
        /// <summary>
        /// Post process payment (used by payment gateways that require redirecting to a third-party URL)
        /// </summary>
        /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param>
        public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {
            string service = "create_direct_pay_by_user";

            string seller_email  = _aliPayPaymentSettings.SellerEmail;
            string sign_type     = "MD5";
            string key           = _aliPayPaymentSettings.Key;
            string partner       = _aliPayPaymentSettings.Partner;
            string input_charset = "utf-8";

            string show_url = _webHelper.GetStoreLocation(false);

            string out_trade_no = postProcessPaymentRequest.Order.OrderGuid.ToString();
            string subject      = string.IsNullOrEmpty(_aliPayPaymentSettings.InvoiceSubject) ? _storeContext.CurrentStore.Name : _aliPayPaymentSettings.InvoiceSubject;
            //string body = _aliPayPaymentSettings.InvoiceBody;
            string body = "";

            foreach (var item in postProcessPaymentRequest.Order.OrderItems)
            {
                if (item.Product.Name.Length > 100)
                {
                    body += item.Product.Name.Substring(0, 100) + "...,";
                }
                else
                {
                    body += item.Product.Name + ",";
                }
            }
            body = body.Substring(0, body.Length - 1);
            if (body.Length > 999)
            {
                body = body.Substring(0, 996) + "...";
            }

            string total_fee = postProcessPaymentRequest.Order.OrderTotal.ToString("0.00", CultureInfo.InvariantCulture);

            string notify_url = _webHelper.GetStoreLocation(false) + "Plugins/PaymentAliPay/Notify";
            string return_url = _webHelper.GetStoreLocation(false) + "Plugins/PaymentAliPay/Return";

            var paymethod   = "directPay"; //bankPay:银联支付; directPay:支付宝即时到账
            var defaultBank = "";

            var customInfo = postProcessPaymentRequest.Order.DeserializeCustomValues();

            if (customInfo != null && customInfo.Count > 0)
            {
                if (customInfo.ContainsKey(AliPayPaymentSystemNames.SelectedAlipayPayMethod))
                {
                    paymethod = customInfo[AliPayPaymentSystemNames.SelectedAlipayPayMethod].ToString();
                    if (!string.IsNullOrEmpty(paymethod) && paymethod != AliPayPaymentSystemNames.DirectPay)
                    {
                        //默认网银
                        defaultBank = paymethod;//如果传递的paymethod不等于directPay,则表示使用银联支付,paymethod表示银行编码

                        //默认支付方式
                        paymethod = AliPayPaymentSystemNames.BankPay;
                    }
                }
            }

            IList <string> paraList = new List <string>();

            paraList.Add("service=" + service);
            paraList.Add("partner=" + partner);
            paraList.Add("seller_email=" + seller_email);
            paraList.Add("out_trade_no=" + out_trade_no);
            paraList.Add("subject=" + subject);
            paraList.Add("body=" + body);
            paraList.Add("total_fee=" + total_fee);
            paraList.Add("show_url=" + show_url);
            paraList.Add("return_url=" + return_url);
            paraList.Add("notify_url=" + notify_url);
            paraList.Add("payment_type=1");
            paraList.Add("paymethod=" + paymethod);
            if (!string.IsNullOrEmpty(defaultBank))
            {
                paraList.Add("defaultbank=" + defaultBank);
            }
            paraList.Add("_input_charset=" + input_charset);

            string aliay_url = CreatUrl(
                paraList.ToArray(),
                input_charset,
                key
                );
            var post = new RemotePost();

            post.FormName = "alipaysubmit";
            post.Url      = "https://mapi.alipay.com/gateway.do?_input_charset=utf-8";
            post.Method   = "POST";

            post.Add("service", service);
            post.Add("partner", partner);
            post.Add("seller_email", seller_email);
            post.Add("out_trade_no", out_trade_no);
            post.Add("subject", subject);
            post.Add("body", body);
            post.Add("total_fee", total_fee);
            post.Add("show_url", show_url);
            post.Add("return_url", return_url);
            post.Add("notify_url", notify_url);
            post.Add("payment_type", "1");
            post.Add("paymethod", paymethod);
            if (!string.IsNullOrEmpty(defaultBank))
            {
                post.Add("defaultbank", defaultBank);
            }
            post.Add("sign", aliay_url);
            post.Add("sign_type", sign_type);

            post.Post();
        }
    private void SepeteUrunEkleSayfayaGit()
    {
        RemotePost urlPost = new RemotePost();
        urlPost.Url = ResolveUrl( string.Format("{0}/Market/Sepet.aspx?user=ok", ConfigurationManager.AppSettings["sslSitePath"]));
        urlPost.Add("urunId", ViewState["urunId"]);
        urlPost.Add("sagAdet", ViewState["sagAdet"]);
        urlPost.Add("solAdet", ViewState["solAdet"]);
        urlPost.Add("sagBilgi", ViewState["sagBilgi"]);
        urlPost.Add("solBilgi", ViewState["solBilgi"]);
        urlPost.Add("hediyeId", ViewState["hediyeId"]);
        urlPost.Add("hediyeBilgi", ViewState["hediyeBilgi"]);

        urlPost.Post();
    }