Alipay Interface Development Help (ASP,PHP,ASP.NET,JSP) _ Other integrated

Source: Internet
Author: User
Tags datetime documentation md5

Recommended two text: 1, Alipay purchase process 2, Alipay seller process
Alipay interface to provide the latest ASP, ASP.net, PHP, JSP, such as the current network of the most popular source code package files, programmers can download after the introduction of changes in the parameters and layout can! And this article takes ASP.net (C #) detailed introduction.
-------------------------------------------------------------------------------------excerpted from: Alipay official
Click to download the physical Commodity Trading service Integration technology documentation and service introduction follow the prompts in the documentation to integrate operations.
Four different language Payment treasure interface program, download address is: (direct click to download)

ASP Physical Goods Trading interface

Aspx.net Physical Goods Trading Interface (UTF-8)

Aspx.net Physical Goods Trading Interface (GBK)

JSP Physical Goods Trading Interface (GBK)

JSP Physical Goods Trading Interface (UTF-8)

PHP Physical Goods Trading interface(Link to other forum posts)
Change service to Create_digital_goods_trade_p, cost, notify return address and so on to achieve physical transactions, detailed parameters please set
Change the service to Trade_create_by_buyer, modify the mode of logistics and the cost can realize the physical transaction, detailed parameters please set yourself
Change service to Create_donate_trade_p,total_fee cost, etc. can be donated items, detailed parameters please set yourself
Reminder: If you need to sign up to use Alipay to pay for the interface and permissions, please contact your account Manager or click this application.
---------------------------------------------------------------------------------------
Among them, if the product is many, the proposal uses the order number as the subject (subject). Recommended that you look at the original code in detail, carefully set its parameters, will run normally, please forgive Alipay for safe and comprehensive testing:)
Default.aspx for submission page, quite with cart submission after generating order, send the page to Alipay
Alipay_notify.aspx is the URL that receives the Alipay notification,
Alipay_return.aspx is the URL address for a jump after payment completes.
Code Snippets:
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 style= "Text-align:center" ><span style= "font-size:9pt"; Font-family: Song body "> Payment gateway: </span><asp:textbox id=" T_gateway "runat=" Server "text=" https://www.alipay.com/ Cooperate/gateway.do? "
Width= "350px" ></asp:textbox><br>
<span style= "FONT-SIZE:9PT; Font-family: Song body "> Service parameters: <asp:dropdownlist id=" T_service "runat=" Server "width=" 357px ">
<asp:ListItem>trade_create_by_buyer</asp:ListItem>
</asp:dropdownlist></span><br>
<span style= "FONT-SIZE:9PT; Font-family: XXFarEastFont-Franklin > co-business: </span>
<asp:textbox id= "T_partner" runat= "server" text= "must, Alipay center gets" width= "350px" ></asp:textbox><br>
<span style= "FONT-SIZE:9PT; Font-family: Song Body "> Encryption Protocol: </span><asp:textbox id=" T_sign_type "runat=" Server "text=" MD5 "width=" 350px "> </asp:textbox><br>
<span style= "FONT-SIZE:9PT; Font-family: Song body "> Product Name: </span><asp:textbox id=" T_subject "runat=" Server "text=" bbs.jishu.me "width=" 350px "></asp:textbox><br>
<span style= "FONT-SIZE:9PT; Font-family: Song Body "> Product Description: </span><asp:textbox id=" T_body "runat=" Server "text=" AAA "width=" 350px "> Technology fan </asp:textbox><br>
<span style= "FONT-SIZE:9PT; Font-family: Song body "> Payment type: </span><asp:textbox id=" T_payment_type "runat=" Server "text=" 1 "width=" 350px "> </asp:textbox><br>
<span style= "FONT-SIZE:9PT; Font-family: Song Body "> Price: </span><asp:textbox id=" T_total_fee "runat=" Server "text=" 0.01 "width=" 350px "> </asp:textbox><br>
<span style= "FONT-SIZE:9PT; Font-family: Song Body "> Quantity: </span><asp:textbox id=" TextBox1 "runat=" Server "text=" 1 "width=" 350px "></asp :textbox><br>
<span style= "FONT-SIZE:9PT; font-family: XXFarEastFont-arial > </span><asp:textbox id= "TextBox2" runat= "Server" text= "8" width= "350px" ></asp :textbox><br>
<span style= "FONT-SIZE:9PT; Font-family: Song Body "> Express: </span><asp:textbox id=" TextBox3 "runat=" Server "text=" "width=" 350px "></ Asp:textbox><br>
<span style= "FONT-SIZE:9PT; Font-family: Song body "> Show Address: </span><asp:textbox id=" T_show_url "runat=" Server "text=" "width=" 350px ">http ://bbs.jishu.me</asp:textbox><br>
<span style= "FONT-SIZE:9PT; Font-family: Song body "> Seller account: </span><asp:textbox id=" T_seller_email "runat=" Server "text=" Bobby96333@gmail.com "width=" 350px "></asp:textbox><br>
<span style= "FONT-SIZE:9PT; Font-family: Song body "> Security Check Code: </span><asp:textbox id=" T_key "runat=" server "text=" Note: After signing the merchant in the Alipay member Center can get "Width = "350px" ></asp:textbox><br>
<span style= "FONT-SIZE:9PT; Font-family: Song Body "> Re-set Address: </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 style= "FONT-SIZE:9PT; font-family: XXFarEastFont-Arial "> Server notification Address: </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 style= "FONT-SIZE:9PT; font-family: Arial > Server code: </span><asp:textbox id= "T_inputchatset" runat= "Server" text= "Utf-8" width= "350px "></asp:textbox><br>
<span style= "FONT-SIZE:9PT; Font-family: Song Body ">
<asp:button id= "Button1" runat= "Server" text= "Alipay payment" ></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>
Summary description of the _default.
</summary>
public class _default:system.web.ui.page
{
#region Page Control
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)
{
Place user code here to initialize page
#region can set the value here, or you can send the code in button1_click here, and immediately jump
if (! IsPostBack)
{
}
#endregion
}
Code generated #region the Web forms Designer
Override protected void OnInit (EventArgs e)
{
//
CodeGen: This call is required for the ASP.net Web forms Designer.
//
InitializeComponent ();
Base. OnInit (e);
}
<summary>
Designer supports required methods-do not use the Code editor to modify
The contents of this method.
</summary>
private void InitializeComponent ()
{
This. Button1.Click + = new System.EventHandler (this. Button1_Click);
This. Load + = new System.EventHandler (this. Page_Load);
}
#endregion
#region Payment Button Event
private void Button1_Click (object sender, System.EventArgs e)
{
Construct the order number according to the payment time;
System.DateTime currenttime=new System.DateTime ();
Take time
Currenttime=system.datetime.now;
String out_trade_no = Currenttime.tostring ("G");
To the order number-
Out_trade_no = Out_trade_no. Replace ("-", "");
To the order number:
Out_trade_no = Out_trade_no. Replace (":", "");
Go to the space in the order number
Out_trade_no = Out_trade_no. Replace ("", "");
Business parameter assignment;
string gateway = T_gateway. Text; Default value do not change payment interface https://www.alipay.com/cooperate/gateway.do?
/*create_flower_direct_pay_by_user Flower Interface
Create_digital_goods_trade_p Virtual Interface
Create_direct_pay_by_user Instant to account interface * *
String service = T_service. Selecteditem.text;//trade_create_by_buyer physical interface, can also be set to other values
String partner = T_partner. Text; Partner Partner ID reserved Field
String sign_type = T_sign_type. Text; MD5 type Encryption
String subject = T_subject. Text; Subject Product Name
String BODY = T_body. Text; Body Product Description
String payment_type = T_payment_type. Text; Payment Type: 1 for goods purchase, 2 for service purchase, 3 for network auction, 4 for donation, 5 for postage compensation, 6 for bonuses, 15 for flowers purchase
String price = T_total_fee. Text; Unit price can be set to the Page_Load event in the connection value
String quantity = TextBox1.Text; Number of items
String Show_url =server.urlencode (T_show_url. Text); Product Display Address
String seller_email = T_seller_email. Text; Seller pays treasure Account number
String key = T_key. Text; Partner account of the payment of Baoan School test code
String return_url = T_return_url. Text; Server notification returns the interface to receive the return information after payment is completed
String Notify_url =t_notify_url. Text; Server notification returns the interface, the post way to accept payment after the completion of the return information
String _input_charset = T_inputchatset. Text; Page encoding way, there are utf-8 and GBK, here is Utf-8
Type of logistics: Virtual goods, post for the flat mail, EMS for EMS Express,
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
}
}
Tip: Check your notes more and define them. For example, the Express and Peace Mail selection is set by the "Logistics_type" parameter.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.