小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

Paypal接口配置參數(shù)說明文檔

 昵稱177425 2009-07-14

Paypal接口配置參數(shù)說明文檔

  一、文檔說明

  該方案雖然沒有用到PAYPAL提供的高階特性,也考慮了安全驗(yàn)證以及郵件消息通知的實(shí)現(xiàn)。由于只是基本功能,只用到三個(gè)頁面(JSP實(shí)現(xiàn))。以下將詳細(xì)說明各個(gè)頁面的關(guān)系和職責(zé)。

  二、頁面說明

  1.提交頁面(test.jsp) 該頁面的代碼可以嵌入到購買頁面里,主要功能是按照PAYPAL的接口規(guī)則提交相應(yīng)的參數(shù),供PAYPAL處理訂單的支付請(qǐng)求。

  下面是該頁面的參數(shù)配置

參數(shù)含義

參數(shù)名稱

參數(shù)示例

備注

action

真實(shí)用

https://www.

 

測(cè)試用https://www.

提交模式

cmd

_xclick

可以寫死

商務(wù)網(wǎng)站的郵箱

business

Seller_1210746445_biz@21cn.com

可以寫死

*商品名稱

item_name

Productor/商品一

如果用中文要設(shè)置charset參數(shù)

*商品編號(hào)

item_number

88888111

也可含英文字母

商品數(shù)量

quantity

10

 

*自定義用于加密

custom

sessionID

建議將該IDMD5加密,為以后驗(yàn)證做準(zhǔn)備

*商品價(jià)格

amount

119.00

double

商品運(yùn)費(fèi)

shipping

10.00

double

貨幣類型

currency_code

USD

CNY:人民幣,USD:美元

字符編碼

charset

gb2312

不寫為默認(rèn) 默認(rèn)為ISO8859-1

  1.驗(yàn)證頁面(back.jsp)

  用于接有PAYPAL傳過來的信息,通過里面的字段CUSTOM來驗(yàn)證是否剛才提交的支付信息是否一致。該驗(yàn)證頁的配置在補(bǔ)充說明里參看。

  2.取消頁面(cancel.jsp)

  客戶可能在支付時(shí)臨時(shí)決定取消這次支付,取消后將返回的頁面。該取消頁的配置在補(bǔ)充說明里參看。

  二、補(bǔ)充說明

  1.驗(yàn)證和取消頁面的配置在提交頁加入以下兩個(gè)參數(shù),參數(shù)為實(shí)際驗(yàn)證頁和取消頁。

參數(shù)含義

參數(shù)名稱

參數(shù)示例

備注

取消后返回到的頁面

cancel_return

http://localhost/howie/fail.jsp

 

確認(rèn)以及驗(yàn)證頁面

return

http://localhost/howie/back.jsp

 

  1.驗(yàn)證頁在PAYPAL里的設(shè)置
  在Profile的Selling Preferences一欄,進(jìn)入“Instant Payment Notification Preferences”,然后Edit,選中checkbox,填入notify_url地網(wǎng)址。
  二、各頁面源碼
  1.test.jsp
  <%@ page language="java" import="java.util.*,cn.howie.util.*" pageEncoding="gbk"%>
  <%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://"
  + request.getServerName() + ":" + request.getServerPort()
  + path + "/";
  %>
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  <html>
  <head>
  <base href="<%=basePath%>">
  <title>My JSP 'test.jsp' starting page</title>
  <meta http-equiv="pragma" content="no-cache">
  <meta http-equiv="cache-control" content="no-cache">
  <meta http-equiv="expires" content="0">
  <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
  <meta http-equiv="description" content="This is my page">
  <!--
  <link rel="stylesheet" type="text/css" href="styles.css">
  -->
  </head>
  <%
  //對(duì)sessionID進(jìn)行加密和驗(yàn)證傳回來的加密碼比較
  MD5Code md5 = new MD5Code();
  String custom_Encrypt = md5.getMD5ofStr(session.getId());
  %>
  <body>
  <form action="https://www." method="post">
  <!-- 真實(shí)用   -->
  <!-- <form action="https://www." method="post">  -->
  <!-- 提交模式 -->
  <input type="hidden" name="cmd" value="_xclick">
  <!-- 商務(wù)網(wǎng)站的郵箱 -->
  <input type="hidden" name="business" value="Seller_1210746445_biz@21cn.com">
  <!-- 商品名稱 -->
  <input type="hidden" name="item_name" value="productor-1">
  <!-- 商品編號(hào) -->
  <input type="hidden" name="item_number" value="productor-number">
  <!-- 商品數(shù)量 -->
  <input type="hidden" name="quantity" value="1">
  <!-- 自定義用于加密-->
  <input type="hidden" name="custom" value="<%=custom_Encrypt %>">
  <!-- 商品價(jià)格 -->
  <input type="hidden" name="amount" value="119.00">
  <!-- 商品運(yùn)費(fèi) -->
  <input type="hidden" name="shipping" value="2">
  <!-- 貨幣類型 CNY:人民幣,USD:美元 -->
  <input type="hidden" name="currency_code" value="USD">
  <!-- 字符編碼 -->
  <input type="hidden" name="charset" value="gb2312">
  <!-- 取消后返回到的頁面 -->
  <input type="hidden" name="cancel_return"
  value="http://localhost/howie/fail.jsp">
  <!-- 確認(rèn)以及驗(yàn)證頁面 -->
  <input type="hidden" name="return"
  value="http://localhost/howie/back.jsp">
  <input type="submit" value="buy now">
  </form>
  </body>
  </html>
  2.back.jsp
  <%@ page language="java" import="java.util.*,cn.howie.util.*" pageEncoding="gbk"%>
  <%@ page import="java.net.*"%>
  <%@ page import="java.io.*"%>
  <%
  //對(duì)sessionID進(jìn)行加密和驗(yàn)證傳回來的加密碼比較
  MD5Code md5 = new MD5Code();
  String custom_Encrypt = md5.getMD5ofStr(session.getId());
  %>
  <%
  String str = "cmd=_notify-validate";
  String validate = "";
  Enumeration en = request.getParameterNames();
  while (en.hasMoreElements()) {
  String paramName = (String) en.nextElement();
  String paramValue = request.getParameter(paramName);
  if("custom".equals(paramName)) {
  validate = paramValue;
  }
  str = str + "&" + paramName + "=" + URLEncoder.encode(paramValue);
  }
  URL url = new URL("https://www.");//測(cè)試用URL
  //URL url = new URL("https://www.");//真是用URL
  URLConnection uc = url.openConnection();
  uc.setDoOutput(true);
  uc.setRequestProperty("Content-Type",
  "application/x-www-form-urlencoded");
  PrintWriter pw = new PrintWriter(uc.getOutputStream());
  pw.println(str);
  pw.close();
  BufferedReader in = new BufferedReader(new InputStreamReader(uc
  .getInputStream()));
  String res = in.readLine();
  in.close();
  //out.println(str+"<br/>");
  //out.println(res);
  //out.println(session.getId());
  if ("VERIFIED".equals(res) && custom_Encrypt.equals(validate) ) {
  // 支付成功
  out.println("successful");
  // 加入數(shù)據(jù)庫的操作
  }else if ("INVALID".equals(res)) {
  // 支付失敗
  out.println("fail");
  } else {
  // 支付錯(cuò)誤
  out.println("error");
  }
  %>
  3.cancel.jsp
  <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
  <%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://"
  + request.getServerName() + ":" + request.getServerPort()
  + path + "/";
  %>
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  <html>
  <head>
  <base href="<%=basePath%>">
  <title>My JSP 'test.jsp' starting page</title>
  <meta http-equiv="pragma" content="no-cache">
  <meta http-equiv="cache-control" content="no-cache">
  <meta http-equiv="expires" content="0">
  <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
  <meta http-equiv="description" content="This is my page">
  <!--
  <link rel="stylesheet" type="text/css" href="styles.css">
  -->
  </head>
  <body>
  Cancel !
  </body>
  </html>

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多