手机
当前位置:查字典教程网 >编程开发 >其他综合 >支付宝 接口开发帮助(asp,php,asp.net,jsp)
支付宝 接口开发帮助(asp,php,asp.net,jsp)
摘要:推荐两文:1、支付宝购买流程2、支付宝卖家流程支付宝接口提供最新的ASP、ASP.NET、PHP、JSP等目前网络上最流行的源码包文件,程序...

推荐两文:1、支付宝购买流程 2、支付宝卖家流程

支付宝接口提供最新的ASP、ASP.NET、PHP、JSP等目前网络上最流行的源码包文件,程序员可以下载后按本文介绍更改参数和布置即可!而本文拿ASP.NET(C#)详细介绍。

------------------------------------------------------------------------------------- 摘自:支付宝官方

点击下载实物商品交易服务集成技术文档和服务介绍按照文档中的提示进行集成操作。

四种不同语言的支付宝接口程序,下载地址是:(直接点击下载)

asp实物物品交易接口

aspx.net实物物品交易接口(utf-8)

aspx.net实物物品交易接口(gbk)

jsp实物物品交易接口(gbk)

jsp实物物品交易接口(utf-8)

php实物物品交易接口(链接到论坛其他帖子)

将service改成create_digital_goods_trade_p,费用,通知返回地址等即可实现实物交易,详细参数请自行设定

将service改成trade_create_by_buyer,修改物流方式以及费用等即可实现实物交易,详细参数请自行设定

将service改成create_donate_trade_p,total_fee费用等即可实捐赠项目,详细参数请自行 设定

提醒:如需签约使用支付宝收款接口及权限,欢迎联系您的客户经理或点此申请。

---------------------------------------------------------------------------------------

其中,如果产品多了,建议使用订单号做为主题(subject)。推荐大家详细查看原码,细心设置其参数,才会运行正常,请原谅支付宝为了安全而周全的检测 :)

Default.aspx 为提交页面,相当与购物车提交后生成定单后,向支付宝发送的页面

alipay_Notify.aspx是接收支付宝通知的URL地址,

alipay_Return.aspx是支付完成后跳转的URL地址。

代码段:

HTML Code

<%@ Page language="c#" Codebehind="Default.aspx.cs" AutoEventWireup="false" Inherits="shiwuUTF_8aspx03._Default" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<HTML>

<HEAD>

<title>Default</title>

<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">

<meta content="C#" name="CODE_LANGUAGE">

<meta content="JavaScript" name="vs_defaultClientScript">

<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">

</HEAD>

<body MS_POSITIONING="GridLayout">

<form id="Form1" method="post" runat="server">

<div><span>支付网关:</span><asp:textbox id="T_gateway" runat="server" Text="https://www.alipay.com/cooperate/gateway.do?"

Width="350px"></asp:textbox><br>

<span>服务参数:<asp:dropdownlist id="T_service" runat="server" Width="357px">

<asp:ListItem>trade_create_by_buyer</asp:ListItem>

</asp:dropdownlist></span><br>

<span>合作商: </span>

<asp:textbox id="T_partner" runat="server" Text="必须,支付宝中心获得" Width="350px"></asp:textbox><br>

<span>加密协议:</span><asp:textbox id="T_sign_type" runat="server" Text="MD5" Width="350px"></asp:textbox><br>

<span>商品名称:</span><asp:textbox id="T_subject" runat="server" Text="bbs.jishu.me" Width="350px"></asp:textbox><br>

<span>商品描述:</span><asp:textbox id="T_body" runat="server" Text="aaa" Width="350px">技术迷</asp:textbox><br>

<span>支付类型:</span><asp:textbox id="T_payment_type" runat="server" Text="1" Width="350px"></asp:textbox><br>

<span>单 价 : </span><asp:textbox id="T_total_fee" runat="server" Text="0.01" Width="350px"></asp:textbox><br>

<span>数 量 : </span><asp:textbox id="TextBox1" runat="server" Text="1" Width="350px"></asp:textbox><br>

<span>平 邮 : </span><asp:textbox id="TextBox2" runat="server" Text="8" Width="350px"></asp:textbox><br>

<span>快 递 : </span><asp:textbox id="TextBox3" runat="server" Text="15" Width="350px"></asp:textbox><br>

<span>展示地址:</span><asp:textbox id="T_show_url" runat="server" Text="" Width="350px">http://bbs.jishu.me</asp:textbox><br>

<span>卖家账号:</span><asp:textbox id="T_seller_email" runat="server" Text="bobby96333@gmail.com" Width="350px"></asp:textbox><br>

<span>安全校验码:</span><asp:textbox id="T_key" runat="server" Text="注:商家签约后在支付宝会员中心里面可以获得" Width="350px"></asp:textbox><br>

<span>重定下地址:</span><asp:textbox id="T_return_url" runat="server" Text="http://60.191.43.90/temp/Alipay_Return.aspx"

Width="350px">http://bbs.jishu.me/alipay/Alipay_Return.aspx</asp:textbox><br>

<span>服务器通知地址:</span><asp:textbox id="T_notify_url" runat="server" Text="http://60.191.43.90/temp/Alipay_Notify.aspx"

Width="350px">http://bbs.jishu.me/alipay/Alipay_Notify.aspx</asp:textbox><br>

<span>服务器编码:</span><asp:textbox id="T_inputchatset" runat="server" Text="utf-8" Width="350px"></asp:textbox><br>

<span>

<asp:button id="Button1" runat="server" Text="支付宝付款"></asp:button> </span></div>

</form>

</body>

</HTML>

C# Code

using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using System.Configuration;

using System.Web.Security;

using shiwuUTF_8aspx03.App_Code;

namespace shiwuUTF_8aspx03

{

/// <summary>

/// _Default 的摘要说明。

/// </summary>

public class _Default : System.Web.UI.Page

{

#region 页面控件

protected System.Web.UI.WebControls.TextBox T_gateway;

protected System.Web.UI.WebControls.DropDownList T_service;

protected System.Web.UI.WebControls.TextBox T_partner;

protected System.Web.UI.WebControls.TextBox T_sign_type;

protected System.Web.UI.WebControls.TextBox T_subject;

protected System.Web.UI.WebControls.TextBox T_body;

protected System.Web.UI.WebControls.TextBox T_payment_type;

protected System.Web.UI.WebControls.TextBox T_total_fee;

protected System.Web.UI.WebControls.TextBox TextBox1;

protected System.Web.UI.WebControls.TextBox TextBox2;

protected System.Web.UI.WebControls.TextBox TextBox3;

protected System.Web.UI.WebControls.TextBox T_show_url;

protected System.Web.UI.WebControls.TextBox T_seller_email;

protected System.Web.UI.WebControls.TextBox T_key;

protected System.Web.UI.WebControls.TextBox T_return_url;

protected System.Web.UI.WebControls.TextBox T_notify_url;

protected System.Web.UI.WebControls.TextBox T_inputchatset;

protected System.Web.UI.WebControls.Button Button1;

#endregion

private void Page_Load(object sender, System.EventArgs e)

{

// 在此处放置用户代码以初始化页面

#region 可以在此处设置接值,也可以把Button1_Click里的代码发在这里,然后立即跳转

if(!IsPostBack)

{

}

#endregion

}

#region Web 窗体设计器生成的代码

override protected void OnInit(EventArgs e)

{

//

// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。

//

InitializeComponent();

base.OnInit(e);

}

/// <summary>

/// 设计器支持所需的方法 - 不要使用代码编辑器修改

/// 此方法的内容。

/// </summary>

private void InitializeComponent()

{

this.Button1.Click += new System.EventHandler(this.Button1_Click);

this.Load += new System.EventHandler(this.Page_Load);

}

#endregion

#region 支付按钮事件

private void Button1_Click(object sender, System.EventArgs e)

{

//按支付时间构造订单号;

System.DateTime currentTime=new System.DateTime();

//取时间

currentTime=System.DateTime.Now;

string out_trade_no = currentTime.ToString("g");

//去订单号里的-

out_trade_no = out_trade_no.Replace("-", "");

//去订单号里的:

out_trade_no = out_trade_no.Replace(":", "");

//去订单号里的空格

out_trade_no = out_trade_no.Replace(" ", "");

//业务参数赋值;

string gateway = T_gateway.Text; //默认值不要改支付接口https://www.alipay.com/cooperate/gateway.do?

/*create_flower_direct_pay_by_user鲜花接口

create_digital_goods_trade_p虚拟接口

create_direct_pay_by_user即时到帐接口*/

string service = T_service.SelectedItem.Text;//trade_create_by_buyer实物接口,也可以设置为其他值

string partner = T_partner.Text; //partner 合作伙伴ID 保留字段

string sign_type = T_sign_type.Text; //MD5类型加密

string subject = T_subject.Text; //subject 商品名称

string body = T_body.Text; //body 商品描述

string payment_type = T_payment_type.Text; //支付类型:1为商品购买,2为服务购买,3为网络拍卖,4为捐赠,5为邮费补偿,6为奖金,15为鲜花购买

string price = T_total_fee.Text; //单价可以在Page_Load事件里设置接值

string quantity = TextBox1.Text; //商品数量

string show_url =Server.UrlEncode( T_show_url.Text); //商品展示地址

string seller_email = T_seller_email.Text; //卖家支付宝账号

string key = T_key.Text; //partner账户的支付宝安全校验码

string return_url = T_return_url.Text; //服务器通知返回接口,通过get方式接受支付完成后的返回信息

string notify_url =T_notify_url.Text; //服务器通知返回接口,通过post方式接受支付完成后的返回信息

string _input_charset = T_inputchatset.Text; //页面编码方式,有utf-8和gbk,此处是utf-8

//物流类型:VIRTUAL为虚拟物品,POST为平邮,EMS为EMS快递,

string logistics_type = "POST";

string logistics_fee = TextBox2.Text;

string logistics_payment = "BUYER_PAY";

string logistics_type_1 = "EXPRESS";

string logistics_fee_1 = TextBox3.Text;

string logistics_payment_1 = "BUYER_PAY";

AliPay ap = new AliPay();

string aliay_url=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);

}

#endregion

}

}

提示:请多查看备注,并进行定义。比如快递和平邮选择由“logistics_type”参数设置。

【支付宝 接口开发帮助(asp,php,asp.net,jsp)】相关文章:

HTTP提交方式之PUT详细介绍及POST和PUT的区别

比较经典技术普及帖 以你刚才在淘宝上买了一件东西

一张图告诉你计算机编程语言的发展历史

24种编程语言的Hello World程序

计算机科学中32个常用的基础算法

初探 SOA

二维码的生成细节和原理

伪静态技术介绍与优缺点分析(较完整篇)

asp php 清空access mysql mssql数据库的代码

5个Linux平台程序员最爱的开发工具汇总

精品推荐
分类导航