支付宝 接口开发帮助(asp,php,asp.net,jsp)_其它综合_

更新时间:2023-05-28 00:49:00      浏览量:280

推荐两文: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" %>



Default







支付网关:Width="350px">

服务参数:
trade_create_by_buyer


合作商:


加密协议:

商品名称:

商品描述:技术迷

支付类型:

单 价 :

数 量 :

平 邮 :

快 递 :

展示地址:http://bbs.jishu.me

卖家账号:

安全校验码:

重定下地址:Width="350px">http://bbs.jishu.me/alipay/Alipay_Return.aspx

服务器通知地址:Width="350px">http://bbs.jishu.me/alipay/Alipay_Notify.aspx

服务器编码:






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
{
///
/// _Default 的摘要说明。
///

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);
}
///
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///

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”参数设置。

网站类容多为转载,如有侵权,请联系站长删除

-六神源码网 出售域名-六神源码网 比特派-六神源码网 微信公众号抽奖-六神源码网 vr全景制作-六神源码网 特产购买-六神源码网 听歌-六神源码网