Ejemplo n.º 1
0
        public string Make3DPaymentApprove(VPosTransactionResponseContract model)
        {
            try
            {
                //return _paymentStrategy.SendApprove3DPayment(model);

                return("");
            }
            catch (System.Exception ex)
            {
                throw;
            }
        }
        /// <summary>
        /// DeSerialize Xml object to VPosTransactionResponseContract object
        /// </summary>
        /// <param name="response">Xml objext</param>
        /// <returns>VPosTransactionResponseContract object</returns>
        public VPosTransactionResponseContract GetVPosTransactionResponseContract(string response)
        {
            var resp  = System.Web.HttpUtility.UrlDecode(response);
            var x     = new XmlSerializer(typeof(VPosTransactionResponseContract));
            var model = new VPosTransactionResponseContract();

            using (var ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(resp)))
            {
                model = x.Deserialize(ms) as VPosTransactionResponseContract;
            }

            return(model);
        }
Ejemplo n.º 3
0
        public ServiceResponse <string> ThreeDPaymentFail()
        {
            try
            {
                string response1 = Request.Form["AuthenticationResponse"];
                string resp      = System.Web.HttpUtility.UrlDecode(response1);
                var    x         = new XmlSerializer(typeof(VPosTransactionResponseContract));
                var    model     = new VPosTransactionResponseContract();
                using (var ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(resp)))
                {
                    var xmlreader = XmlReader.Create(ms);
                    model = x.Deserialize(xmlreader) as VPosTransactionResponseContract;
                    xmlreader.Dispose();
                }

                var response = _paymentBusiness.Make3DPaymentApprove(model);

                return(new ServiceResponse <string>(response, true, 100, ""));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 4
0
        public async Task <VerifyGatewayResult> VerifyGateway(VerifyGatewayRequest request, PaymentGatewayRequest gatewayRequest, IFormCollection form)
        {
            if (form == null)
            {
                return(VerifyGatewayResult.Failed("Form verisi alınamadı."));
            }

            var authenticationResponse = form["AuthenticationResponse"].ToString();

            if (string.IsNullOrEmpty(authenticationResponse))
            {
                return(VerifyGatewayResult.Failed("Form verisi alınamadı."));
            }

            authenticationResponse = HttpUtility.UrlDecode(authenticationResponse);
            var serializer = new XmlSerializer(typeof(VPosTransactionResponseContract));

            var model = new VPosTransactionResponseContract();

            using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(authenticationResponse)))
            {
                model = serializer.Deserialize(ms) as VPosTransactionResponseContract;
            }

            if (model.ResponseCode != "00")
            {
                return(VerifyGatewayResult.Failed(model.ResponseMessage, model.ResponseCode));
            }

            var merchantOrderId = model.MerchantOrderId;
            var amount          = model.VPosMessage.Amount;
            var mD         = model.MD;
            var merchantId = request.BankParameters["merchantId"];
            var customerId = request.BankParameters["customerNumber"];
            var userName   = request.BankParameters["userName"];
            var password   = request.BankParameters["password"];

            //Hash some data in one string result
            var cryptoServiceProvider = new SHA1CryptoServiceProvider();
            var hashedPassword        = Convert.ToBase64String(cryptoServiceProvider.ComputeHash(Encoding.UTF8.GetBytes(password)));

            //merchantId, merchantOrderId, amount, userName, hashedPassword
            var hashstr    = $"{merchantId}{merchantOrderId}{amount}{userName}{hashedPassword}";
            var hashbytes  = Encoding.GetEncoding("ISO-8859-9").GetBytes(hashstr);
            var inputbytes = cryptoServiceProvider.ComputeHash(hashbytes);
            var hashData   = Convert.ToBase64String(inputbytes);

            var requestXml = $@"<KuveytTurkVPosMessage
                    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
                    xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
                        <APIVersion>1.0.0</APIVersion>
                        <HashData>{hashData}</HashData>
                        <MerchantId>{merchantId}</MerchantId>
                        <CustomerId>{customerId}</CustomerId>
                        <UserName>{userName}</UserName>
                        <CurrencyCode>0949</CurrencyCode>
                        <TransactionType>Sale</TransactionType>
                        <InstallmentCount>0</InstallmentCount>
                        <Amount>{amount}</Amount>
                        <MerchantOrderId>{merchantOrderId}</MerchantOrderId>
                        <TransactionSecurity>3</TransactionSecurity>
                        <KuveytTurkVPosAdditionalData>
                        <AdditionalData>
                        <Key>MD</Key>
                        <Data>{mD}</Data>
                        </AdditionalData>
                        </KuveytTurkVPosAdditionalData>
                        </KuveytTurkVPosMessage>";

            //send request
            var response = await client.PostAsync(request.BankParameters["verifyUrl"], new StringContent(requestXml, Encoding.UTF8, "text/xml"));

            string responseContent = await response.Content.ReadAsStringAsync();

            responseContent = HttpUtility.UrlDecode(responseContent);

            using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(responseContent)))
            {
                model = serializer.Deserialize(ms) as VPosTransactionResponseContract;
            }

            if (model.ResponseCode == "00")
            {
                return(VerifyGatewayResult.Successed(model.OrderId.ToString(), model.OrderId.ToString(),
                                                     0, 0, model.ResponseMessage,
                                                     model.ResponseCode));
            }

            return(VerifyGatewayResult.Failed(model.ResponseMessage, model.ResponseCode));
        }