VB.NET经过长时间的发展,很多用户都很了解VB.NET支付宝接口了,这里我发表一下个人理解,和大家讨论讨论。
曾经为没有VB.NET支付宝接口程序郁闷过很长一段时间,终于忍不住修改了一下,其主要的3个文件修改为VB.NET很容易,不再给出,只给出接口代码:
- Private Sub ImageButton1_Click(ByVal sender As System.Object,
ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click- '按时构造订单号
- Dim currentTime As System.DateTime = New System.DateTime
- currentTime = System.DateTime.Now
- Dim out_trade_no As String
- out_trade_no = currentTime.ToString("g")
- out_trade_noout_trade_no = out_trade_no.Replace("-", "")
- out_trade_noout_trade_no = out_trade_no.Replace(":", "")
- out_trade_noout_trade_no = out_trade_no.Replace(" ", "")
- '业务参数赋值
- Dim gateway As String = "https://www.alipay.com/cooperate/gateway.do?" '支付接口
- Dim service As String = "trade_create_by_buyer"'服务参数
- Dim sign_type As String = "MD5"
- Dim subject, body As String
- body = ""
- sql = "select cp_name from chanpin where cp_id="& cint(label2.text)
- getdata.myconn.Open()
- reader = getdata.getdatareader(sql)
- While reader.Read
- subject = reader.Item(0)'商品名称
- bodybody = body & " " & reader.Item(0)'商品描述 ,不能有太多字符
- End While
- reader.Close()
- Dim quantity As String
- quantity = "1" '商品数量
- Dim payment_type As String
- payment_type = "1"
- '支付类型'1=商品购买,2=服务购买,3=网络拍卖,4=捐赠,5=邮费补偿,6=奖金
- Dim price As String
- sql = "select cp_money from chanpin where cp_id="& cint(label1.text)
- reader = getdata.getdatareader(sql)
- If reader.Read Then
- price = reader.Item(0)'商品价格
- End If
- reader.Close()
- Dim show_url, seller_email, key, partner As String
- show_url = "http://****"'商品描述地址
- seller_email = *** '您的支付宝认证Email,必须通过支付宝认证才可以
- key = ***'安全校验码,在支付宝网站“商家工具”那里可以获得
- partner = ***'partner合作伙伴ID
- Dim return_url As String ="Alipay_Return.aspx" '服务器通知返回接口
- Dim notify_url As String ="Alipay_Notify.aspx" '服务器通知接口
- Dim _input_charset As String = "utf-8" '服务器编码
- Dim logistics_type As String = "POST"
- Dim logistics_fee As String = "0" '平邮费包含在价格中
- Dim logistics_fee_1 As String = "0"'快递费 包含在价格中
- Dim logistics_payment As String = "BUYER_PAY"
- Dim logistics_type_1 As String = "EXPRESS"
- Dim logistics_payment_1 As String = "BUYER_PAY"
- Dim ap As AliPay = New AliPay
- Dim aliay_url As String = ap.CreatUrl(gateway, service, partner, sign_type,
out_trade_no, subject, body, payment_type, price, show_url, seller_email, key,
return_url, _input_charset, notify_url, logistics_type, logistics_fee,
logistics_payment, logistics_type_1, logistics_fee_1, logistics_payment_1, quantity)- Response.Redirect(aliay_url)
- End Sub
【编辑推荐】