コード例 #1
0
        public static string CreateHashString(ApiPaymentRequest apiPaymentRequest, string secretKey)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary.Add("MERCHANT", apiPaymentRequest.Config.MERCHANT);
            dictionary.Add("ORDER_REF", apiPaymentRequest.Order.Get_ORDER_REF());
            dictionary.Add("ORDER_DATE", apiPaymentRequest.Order.Get_ORDER_DATE());
            dictionary.Add("ORDER_SHIPPING", apiPaymentRequest.Order.Get_ORDER_SHIPPING());
            dictionary.Add("LU_ENABLE_TOKEN", apiPaymentRequest.Config.LU_ENABLE_TOKEN);
            int i = 0;

            foreach (var item in apiPaymentRequest.Order.OrderItems)
            {
                dictionary.Add("ORDER_PNAME[" + i.ToString() + "]", item.Get_ORDER_PNAME());
                dictionary.Add("ORDER_PCODE[" + i.ToString() + "]", item.Get_ORDER_PCODE());
                dictionary.Add("ORDER_PINFO[" + i.ToString() + "]", item.Get_ORDER_PINFO());
                dictionary.Add("ORDER_PRICE[" + i.ToString() + "]", item.Get_ORDER_PRICE());
                dictionary.Add("ORDER_QTY[" + i.ToString() + "]", item.Get_ORDER_QTY());
                dictionary.Add("ORDER_VAT[" + i.ToString() + "]", item.Get_ORDER_VAT());
                dictionary.Add("ORDER_PRICE_TYPE[" + i.ToString() + "]", item.Get_ORDER_PRICE_TYPE());
                i++;
            }
            dictionary.Add("PRICES_CURRENCY", apiPaymentRequest.Config.PRICES_CURRENCY);
            dictionary.Add("PAY_METHOD", apiPaymentRequest.Config.PAY_METHOD);
            dictionary.Add("CC_NUMBER", apiPaymentRequest.CreditCard.Get_CC_NUMBER());
            dictionary.Add("EXP_MONTH", apiPaymentRequest.CreditCard.Get_EXP_MONTH());
            dictionary.Add("EXP_YEAR", apiPaymentRequest.CreditCard.Get_EXP_YEAR());
            dictionary.Add("CC_CVV", apiPaymentRequest.CreditCard.Get_CC_CVV());
            dictionary.Add("CC_OWNER", apiPaymentRequest.CreditCard.Get_CC_OWNER());
            dictionary.Add("CC_TOKEN", apiPaymentRequest.CreditCard.CC_TOKEN);
            dictionary.Add("BACK_REF", apiPaymentRequest.Config.BACK_REF);
            dictionary.Add("CLIENT_IP", apiPaymentRequest.Customer.CLIENT_IP);
            dictionary.Add("CLIENT_TIME", apiPaymentRequest.Customer.CLIENT_TIME);
            if (!string.IsNullOrEmpty(apiPaymentRequest.CreditCard.Get_SELECTED_INSTALLMENTS_NUMBER()))
            {
                dictionary.Add("SELECTED_INSTALLMENTS_NUMBER", apiPaymentRequest.CreditCard.Get_SELECTED_INSTALLMENTS_NUMBER());
            }
            dictionary.Add("BILL_LNAME", apiPaymentRequest.Customer.BILL_LNAME);
            dictionary.Add("BILL_FNAME", apiPaymentRequest.Customer.BILL_FNAME);
            dictionary.Add("BILL_EMAIL", apiPaymentRequest.Customer.BILL_EMAIL);
            dictionary.Add("BILL_PHONE", apiPaymentRequest.Customer.BILL_PHONE);
            dictionary.Add("BILL_FAX", apiPaymentRequest.Customer.BILL_FAX);
            dictionary.Add("BILL_ADDRESS", apiPaymentRequest.Customer.BILL_ADDRESS);
            dictionary.Add("BILL_ADDRESS2", apiPaymentRequest.Customer.BILL_ADDRESS2);
            dictionary.Add("BILL_ZIPCODE", apiPaymentRequest.Customer.BILL_ZIPCODE);
            dictionary.Add("BILL_CITY", apiPaymentRequest.Customer.BILL_CITY);
            dictionary.Add("BILL_COUNTRYCODE", apiPaymentRequest.Customer.BILL_COUNTRYCODE);
            dictionary.Add("BILL_STATE", apiPaymentRequest.Customer.BILL_STATE);
            dictionary.Add("DELIVERY_FNAME", apiPaymentRequest.Delivery.DELIVERY_FNAME);
            dictionary.Add("DELIVERY_LNAME", apiPaymentRequest.Delivery.DELIVERY_LNAME);
            dictionary.Add("DELIVERY_EMAIL", apiPaymentRequest.Delivery.DELIVERY_EMAIL);
            dictionary.Add("DELIVERY_PHONE", apiPaymentRequest.Delivery.DELIVERY_PHONE);
            dictionary.Add("DELIVERY_COMPANY", apiPaymentRequest.Delivery.DELIVERY_COMPANY);
            dictionary.Add("DELIVERY_ADDRESS", apiPaymentRequest.Delivery.DELIVERY_ADDRESS);
            dictionary.Add("DELIVERY_ADDRESS2", apiPaymentRequest.Delivery.DELIVERY_ADDRESS2);
            dictionary.Add("DELIVERY_ZIPCODE", apiPaymentRequest.Delivery.DELIVERY_ZIPCODE);
            dictionary.Add("DELIVERY_CITY", apiPaymentRequest.Delivery.DELIVERY_CITY);
            dictionary.Add("DELIVERY_STATE", apiPaymentRequest.Delivery.DELIVERY_STATE);
            dictionary.Add("DELIVERY_COUNTRYCODE", apiPaymentRequest.Delivery.DELIVERY_COUNTRYCODE);
            var    ordered = dictionary.OrderBy(x => x.Key);
            string hash    = string.Empty;

            foreach (var item in ordered)
            {
                hash += "&" + item.Key + "=" + item.Value;
            }
            hash  = hash.Substring(1);
            hash += "&ORDER_HASH=" + CreateMD5Hash(secretKey, dictionary);

            return(hash);
        }
コード例 #2
0
        public static ApiPayment3DResponse ThreeDSecurePayment(ApiPaymentRequest request, Options options)
        {
            var hashString = CreateHashString(request, options.SecretKey);

            return(HttpCaller.Create().PostData <ApiPayment3DResponse>(options.Url, hashString));
        }