<%
const pay_number="000000"				'iPaying 商户代号
const pay_signa="000000"				'商户支付私钥，要与iPaying管理中心里设置的值
const pay_back="http://www.weburl.com/"			'支付成功后默认的返回(URL)地址
const pay_currency="01"					'该值请勿乱改动
const pay_url="https://pay.chinaebank.cn/select_bank.jsp"	'该支持接口地址请不要随意更改
'http://www.ipaying.com.cn/ipaying.asp			'备用的支持接口地址
dim key_key,f,v_moneytype,v_oid,v_ymd,v_mid,BillNo,v_url,key,v_amount

v_ymd="544554"
v_mid = "26935"
v_amount = "10"
key = "ysvoid19821220yuelei"
BillNo=xiaoshi&fenzhong&miao
v_url="http://221.204.4.33/pay_return_shop.asp"
v_oid=v_ymd&"-"&v_mid&"-"&BillNo
v_moneytype = "0" '0为rmb 1为dollor
key_key = v_moneytype+v_ymd+v_amount+v_rcvtel+v_oid+v_mid+v_url+key


function fm_price(pvar,pt)
  if not isnumeric(pvar) then
    fm_price=0
    exit function
  end if
  dim nvar,ni
  nvar=formatnumber(pvar)
  nvar=replace(nvar,",","")
  if left(nvar,1)="." then
    nvar="0"&nvar
  end if
  if pt=1 then
    fm_price=nvar
    exit function
  end if
  for ni=0 to 1
    if cstr(right(nvar,1))="0" then
      nvar=left(nvar,len(nvar)-1)
    else
      ni=1
    end if
  next
  if cstr(right(nvar,1))="." then
    nvar=left(nvar,len(nvar)-1)
  end if
  if not isnumeric(nvar) then nvar=0
  fm_price=csng(nvar)
end function

function pay_encrypt(pvar)
  pay_encrypt=jk_md5(pvar,"long")
end function

class joekoe_pay
  public back_url,pay_sort,pay_ordernum,pay_amount,pay_username,pay_address,pay_post,pay_phone,pay_email,pay_carry,pay_remark,frm_target,frm_js,val_num
  
  private sub class_initialize()
    back_url=""
    frm_target=true
    frm_js=true
    val_num=0
  end sub
  
  public function sort_type(ts)
    dim temp1
    ts=replace(ts,"'","")
    ts=replace(ts,"""","")
    ts=replace(ts,"*","")
    ts=replace(ts,"#","")
    ts=replace(ts,"$","")
    ts=replace(ts,"%","")
    ts=replace(ts," ","")
    select case ts
    case "emoney"
      temp1=ts
    case "shop"
      temp1=ts
    case else
      temp1=ts
    end select
    sort_type=temp1
  end function
  
  public sub pay_return()
    dim re_number,re_safety,var_tmp
    re_number=trim(request.form("re_number"))
    pay_sort=trim(request.form("re_sort"))
    pay_ordernum=trim(request.form("re_ordernum"))
    pay_amount=trim(request.form("re_amount"))
    pay_username=trim(request.form("re_username"))
    re_safety=trim(request.form("re_safety"))
    if pay_sort="" or pay_ordernum="" or pay_amount="" or pay_username="" then
      val_num=1
      exit sub
    end if
    var_tmp=pay_encrypt(cstr(pay_signa)&cstr(pay_number)&cstr(pay_sort)&cstr(pay_ordernum)&cstr(fm_price(pay_amount,1))&cstr(pay_username))
    if re_safety<>var_tmp then
      val_num=2
      exit sub
    end if
  end sub
  
  public sub pay_frm(ftype)
    dim temp1
    pay_amount=fm_price(pay_amount,1)
    dim var_tmp,pay_safety
    pay_sort=sort_type(pay_sort)
    var_tmp=cstr(pay_number)&cstr(pay_signa)&cstr(pay_sort)&cstr(pay_ordernum)&cstr(fm_price(pay_amount,1))&cstr(pay_username)
    pay_safety=pay_encrypt(var_tmp)
    if back_url="" then back_url=pay_back
    temp1=vbcrlf&"<form name=joekoe_pay_frm action='"&pay_url&"' method=post"
    if frm_target then temp1=temp1&" target=pay_win"
    temp1=temp1&">" & _
    vbcrlf&"<input type='hidden' name='v_md5info' size='100' value="&f&">" & _
vbcrlf&"<input type='hidden' name='v_mid' value="&v_mid&">" & _
vbcrlf&"<input type='hidden' name='v_oid' value="&v_oid&">" & _
vbcrlf&"<input type='hidden' name='v_rcvname' value="&pay_username&">" & _
vbcrlf&"<input type='hidden' name='v_rcvaddr' value=收货人姓名>" & _
vbcrlf&"<input type='hidden' name='v_rcvtel' value=收货人地址>" & _
vbcrlf&"<input type='hidden' name='v_ymd' value="&v_ymd&">" & _
vbcrlf&"<input type='hidden' name='v_rcvpost' value=收货人邮编>" & _
vbcrlf&"<input type='hidden' name='v_amount' value="&v_amount&">" & _
vbcrlf&"<input type='hidden' name='v_orderemail' value="&pay_email&">" & _
vbcrlf&"<input type='hidden' name='v_orderstatus'  value=0>" & _
vbcrlf&"<input type='hidden' name='v_ordername'  value="&pay_username&">" & _
vbcrlf&"<input type='hidden' name='v_moneytype'  value="&v_moneytype&">" & _
vbcrlf&"<input type='hidden' name='v_url' value="&v_url&">" & _
   
	  vbcrlf&"</form>"
    if frm_js then
      temp1=temp1&vbcrlf&"<script language=javascript>" & _
	    vbcrlf&"<!--"
    end if
    temp1=temp1&vbcrlf&"function joekoe_online_pay()" & _
	  vbcrlf&"{"
    if frm_target then temp1=temp1&vbcrlf&"  window.open('about:blank','pay_win');"
    temp1=temp1&vbcrlf&"  document.joekoe_pay_frm.submit();" & _
	  vbcrlf&"}"
    if ftype=1 then temp1=temp1&vbcrlf&"joekoe_online_pay();"
    if frm_js then
      temp1=temp1&vbcrlf&"-->" & _
	    vbcrlf&"</script>"
    end if
    response.write temp1
  end sub
end class
%>