PayU Ödemde Sistemi
<%
Dim tmpOrder As TempOrder = Session("TempOrder")
Dim b_FName, b_LName, b_Phone, b_Country, b_District, b_City As String
Dim b_FAddress As String = turkce(tmpOrder.BillingInfo.Address)
Dim s_Faddress As String = turkce(tmpOrder.ShippingInfo.Address)
Dim mail As String = turkce(tmpOrder.ShippingInfo.Mail)
b_Country = "TR"
If mail = "" Then
mail="admin@siteniz.com"
End If
'urun1adi (Urun1Kodu) , urun2adi (Urun2Kodu), urun3adi(Urun2Kodu)…
Dim productinfo As String = ""
If tmpOrder.OrderItems.Count > 0 Then
For m As Integer = 0 To tmpOrder.OrderItems.Count - 1
productinfo &= DirectCast(tmpOrder.OrderItems(m), ASPNetPortal.OrderItem).Name & "(" & DirectCast(tmpOrder.OrderItems(m), ASPNetPortal.OrderItem).Id & "),"
Next
Else
productinfo = "-"
End If
If productinfo.Length > 155 Then
productinfo = productinfo.Substring(0, 154)
End If
If tmpOrder.BillingInfo.CompanyName <> "" Then
If tmpOrder.BillingInfo.CompanyName.Contains(" ") Then
b_FName = turkce(tmpOrder.BillingInfo.CompanyName.Split(" ")(0))
b_LName = turkce(tmpOrder.BillingInfo.CompanyName.Split(" ")(1))
Else
b_FName = turkce(tmpOrder.BillingInfo.CompanyName)
b_LName = turkce(tmpOrder.BillingInfo.CompanyName)
End If
b_Phone = tmpOrder.BillingInfo.PhoneNo
b_District = turkce(tmpOrder.BillingInfo.DistrictName)
b_City = turkce(tmpOrder.BillingInfo.CityName)
Else
If tmpOrder.ShippingInfo.RecipientName.Contains(" ") Then
b_FName = turkce(tmpOrder.ShippingInfo.RecipientName.Split(" ")(0))
b_LName = turkce(tmpOrder.ShippingInfo.RecipientName.Split(" ")(1))
Else
b_FName = turkce(tmpOrder.ShippingInfo.RecipientName)
b_LName = turkce(tmpOrder.ShippingInfo.RecipientName)
End If
b_Phone = tmpOrder.ShippingInfo.PhoneNo
b_District = turkce(tmpOrder.BillingInfo.DistrictName)
b_City = turkce(tmpOrder.BillingInfo.CityName)
End If
Dim clientId As String = ""
If ChkNullBoolean(Session("Payu3D"), True) Then
clientId = Session("GetwayUserName")
Else
clientId = Session("PosNo")
End If
Dim oid As String = GetRandomOrderCode()
Dim odate As String = Date.UtcNow.ToString("yyyy-MM-dd HH:mm:ss")
Dim currency As String = "TRY"
'Dim amount As String = Format(Session("amount"), "0.00").Replace(",", ".")
Dim amount As String = Format(Session("PayuApiAmount"), "0.00").Replace(",", ".")
Dim back_url As String = BaseUrl & "/store/banks3d/3dodemepayuapi.aspx?oid=" & oid
If ConfigurationManager.AppSettings("UseSsl") = "True" Then
back_url = BaseUrl.Replace("http://", "https://") & "/store/banks3d/3dodemepayuapi.aspx?oid=" & oid
End If
Dim ip As String = HttpContext.Current.Request.UserHostAddress
Dim storekey As String = ""
If ChkNullBoolean(Session("Payu3D"), True) Then
storekey = Session("GetwayPassword")
Else
storekey = Session("Xcip")
End If
' = Session("GetwayPassword")
Dim hashstr As New StringBuilder()
'vars = 'MERCHANT,ORDER_REF,ORDER_DATE,ORDER_PNAME[],ORDER_PCODE[],ORDER_PINFO[],
'ORDER_PRICE[],ORDER_QTY[],ORDER_VAT[],ORDER_SHIPPING,PRICES_CURRENCY,
'DISCOUNT,DESTINATION_CITY,DESTINATION_STATE,DESTINATION_COUNTRY,PAY_METHOD,
'ORDER_PRICE_TYPE[],INSTALLMENT_OPTIONS';
'BACK_REF
hashstr.Append(Encoding.UTF8.GetByteCount(back_url) & back_url)
'BILL_ADDRESS
hashstr.Append(Encoding.UTF8.GetByteCount(b_FAddress) & b_FAddress)
'BILL_ADDRESS2
hashstr.Append(Encoding.UTF8.GetByteCount(s_Faddress) & s_Faddress)
'BILL_CITY
hashstr.Append(Encoding.UTF8.GetByteCount(b_District) & b_District)
'BILL_COUNTRYCODE
hashstr.Append(Encoding.UTF8.GetByteCount(b_Country) & b_Country)
'BILL_EMAIL
hashstr.Append(Encoding.UTF8.GetByteCount(mail) & mail)
'BILL_FAX
hashstr.Append(Encoding.UTF8.GetByteCount("-") & "-")
'BILL_FNAME
hashstr.Append(Encoding.UTF8.GetByteCount(b_FName) & b_FName)
'BILL_LNAME
hashstr.Append(Encoding.UTF8.GetByteCount(b_LName) & b_LName)
'BILL_PHONE
hashstr.Append(Encoding.UTF8.GetByteCount(b_Phone) & b_Phone)
'BILL_STATE
hashstr.Append(Encoding.UTF8.GetByteCount(b_City) & b_City)
'BILL_ZIPCODE
hashstr.Append(Encoding.UTF8.GetByteCount("-") & "-")
'CC_CVV
hashstr.Append(Encoding.UTF8.GetByteCount(Session("CvcNumber")) & Session("CvcNumber"))
'CC_NUMBER
hashstr.Append(Encoding.UTF8.GetByteCount(Session("CardNumber")) & Session("CardNumber"))
'CC_OWNER
hashstr.Append(Encoding.UTF8.GetByteCount(Session("CardHolderName")) & Session("CardHolderName"))
'CLIENT_IP
hashstr.Append(Encoding.UTF8.GetByteCount(ip) & ip)
'DELIVERY_ADDRESS
hashstr.Append(Encoding.UTF8.GetByteCount(b_FAddress) & b_FAddress)
'DELIVERY_ADDRESS2
hashstr.Append(Encoding.UTF8.GetByteCount(s_Faddress) & s_Faddress)
'DELIVERY_CITY
hashstr.Append(Encoding.UTF8.GetByteCount(b_District) & b_District)
'DELIVERY_COMPANY
hashstr.Append(Encoding.UTF8.GetByteCount("-") & "-")
'DELIVERY_COUNTRYCODE
hashstr.Append(Encoding.UTF8.GetByteCount(b_Country) & b_Country)
'DELIVERY_EMAIL
hashstr.Append(Encoding.UTF8.GetByteCount(mail) & mail)
'DELIVERY_FNAME
hashstr.Append(Encoding.UTF8.GetByteCount(b_FName) & b_FName)
'DELIVERY_LNAME
hashstr.Append(Encoding.UTF8.GetByteCount(b_LName) & b_LName)
'DELIVERY_PHONE
hashstr.Append(Encoding.UTF8.GetByteCount(b_Phone) & b_Phone)
'DELIVERY_STATE
hashstr.Append(Encoding.UTF8.GetByteCount(b_City) & b_City)
'DELIVERY_ZIPCODE
hashstr.Append(Encoding.UTF8.GetByteCount("-") & "-")
'EXP_MONTH
hashstr.Append(Encoding.UTF8.GetByteCount(Session("ExpMonthPayuApi")) & Session("ExpMonthPayuApi"))
'EXP_YEAR
hashstr.Append(Encoding.UTF8.GetByteCount(Session("ExpYearPayuApi")) & Session("ExpYearPayuApi"))
'MERCHANT
hashstr.Append(Encoding.UTF8.GetByteCount(clientId) & clientId)
'ORDER_DATE
hashstr.Append(Encoding.UTF8.GetByteCount(odate) & odate)
'ORDER_PCODE
hashstr.Append(Encoding.UTF8.GetByteCount(oid) & oid)
'ORDER_PINFO
hashstr.Append(Encoding.UTF8.GetByteCount(productinfo) & productinfo)
'ORDER_PNAME
hashstr.Append(Encoding.UTF8.GetByteCount("Siparis Kodu : " & oid) & "Siparis Kodu : " & oid)
'ORDER_PRICE
hashstr.Append(Encoding.UTF8.GetByteCount(amount) & amount)
'ORDER_QTY
hashstr.Append(Encoding.UTF8.GetByteCount("1") & "1") ' adet
'ORDER_REF
hashstr.Append(Encoding.UTF8.GetByteCount(oid) & oid)
'PAY_METHOD
hashstr.Append(Encoding.UTF8.GetByteCount("CCVISAMC") & "CCVISAMC")
'PRICES_CURRENCY
hashstr.Append(Encoding.UTF8.GetByteCount(currency) & currency)
'SELECTED_INSTALLMENTS_NUMBER
hashstr.Append(Encoding.UTF8.GetByteCount(Session("Taksit")) & Session("Taksit"))
Dim sb As New StringBuilder()
Dim data As Byte() = Encoding.UTF8.GetBytes(hashstr.ToString)
Dim secretkey As Byte() = Encoding.UTF8.GetBytes(storekey)
Dim hmacMD5 As New System.Security.Cryptography.HMACMD5(secretkey)
Dim macSender As Byte() = hmacMD5.ComputeHash(data)
For i As Integer = 0 To macSender.Length - 1
sb.Append(macSender(i).ToString("x2"))
Next
hmacMD5.Clear()
Dim hash As String = BitConverter.ToString(macSender).Replace("-", String.Empty).ToLowerInvariant()
Dim istest As String = "0"
If ConfigurationManager.AppSettings("PayUIsTest") = "True" Then
istest = "1"
End If
Dim address As String = "https://secure.payu.com.tr/order/alu.php"
Dim webClient As New WebClient()
Dim param As New Specialized.NameValueCollection
param.Add("BACK_REF", back_url)
param.Add("BILL_ADDRESS", b_FAddress)
param.Add("BILL_ADDRESS2", s_Faddress)
param.Add("BILL_CITY", b_District)
param.Add("BILL_COUNTRYCODE", b_Country)
param.Add("BILL_EMAIL", mail)
param.Add("BILL_FAX", "-")
param.Add("BILL_FNAME", b_FName)
param.Add("BILL_LNAME", b_LName)
param.Add("BILL_PHONE", b_Phone)
param.Add("BILL_STATE", b_City)
param.Add("BILL_ZIPCODE", "-")
param.Add("CC_CVV", Session("CvcNumber"))
param.Add("CC_NUMBER", Session("CardNumber"))
param.Add("CC_OWNER", Session("CardHolderName"))
param.Add("CLIENT_IP", ip)
param.Add("DELIVERY_ADDRESS", b_FAddress)
param.Add("DELIVERY_ADDRESS2", s_Faddress)
param.Add("DELIVERY_CITY", b_District)
param.Add("DELIVERY_COMPANY", "-")
param.Add("DELIVERY_COUNTRYCODE", b_Country)
param.Add("DELIVERY_EMAIL", mail)
param.Add("DELIVERY_FNAME", b_FName)
param.Add("DELIVERY_LNAME", b_LName)
param.Add("DELIVERY_PHONE", b_Phone)
param.Add("DELIVERY_STATE", b_City)
param.Add("DELIVERY_ZIPCODE", "-")
param.Add("EXP_MONTH", Session("ExpMonthPayuApi"))
param.Add("EXP_YEAR", Session("ExpYearPayuApi"))
param.Add("MERCHANT", clientId)
param.Add("ORDER_DATE", odate)
param.Add("ORDER_HASH", hash)
param.Add("ORDER_PCODE[0]", oid)
param.Add("ORDER_PINFO[0]", productinfo)
param.Add("ORDER_PNAME[0]", "Siparis Kodu : " & oid)
param.Add("ORDER_PRICE[0]", amount)
param.Add("ORDER_QTY[0]", "1")
param.Add("ORDER_REF", oid)
param.Add("PAY_METHOD", "CCVISAMC")
param.Add("PRICES_CURRENCY", currency)
param.Add("SELECTED_INSTALLMENTS_NUMBER", Session("Taksit"))
Dim xml As New XmlDocument()
Dim R As String = Encoding.UTF8.GetString(webClient.UploadValues(address, param))
xml.LoadXml(R)
Dim nodelist1 As XmlNodeList
Dim nodelist2 As XmlNodeList
nodelist1 = xml.GetElementsByTagName("URL_3DS")
nodelist2 = xml.GetElementsByTagName("STATUS")
If nodelist2(0).InnerText = "SUCCESS" Then
If nodelist1.Count > 0 Then
Dim url As String = nodelist1(0).InnerText
Response.Redirect(url)
Response.End()
Else
Response.Redirect(back_url & "&ORDERSTATUS=SUCCESS&STATUS=SUCCESS")
End If
Else
Response.Redirect(back_url)
End If
%>