payment.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  6. <meta name="HandheldFriendly" content="true">
  7. <meta name="MobileOptimized" content="320">
  8. <title>Payment Document</title>
  9. <link rel="stylesheet" type="text/css" href="res/doc.css" charset="utf-8">
  10. <link rel="stylesheet" type="text/css" href="res/prettify.sons.css" charset="utf-8">
  11. <script type="text/javascript" src="res/doc.js" charset="utf-8"></script><script type="text/javascript" src="res/prettify.js" charset="utf-8"></script>
  12. </head>
  13. <body><div id="content" class="content">
  14. <h1><a name="plus.payment">payment</a></h1>
  15. <p>Payment模块管理支付功能,用于提供网页安全支付能力,支持通过Web接口进行支付操作。通过plus.payment可获取支付管理对象。</p>
  16. <h2>方法:</h2>
  17. <ul>
  18. <li>
  19. <a href="#plus.payment.getChannels">getChannels</a>: 获取支付通道</li>
  20. <li>
  21. <a href="#plus.payment.request">request</a>: 请求支付操作</li>
  22. </ul>
  23. <h2>对象:</h2>
  24. <ul>
  25. <li>
  26. <a href="#plus.payment.PaymentChannel">PaymentChannel</a>: 支付通道对象</li>
  27. <li>
  28. <a href="#plus.payment.OrderStatementIAP">OrderStatementIAP</a>: IAP订单数据对象</li>
  29. <li>
  30. <a href="#plus.payment.PaymentResult">PaymentResult</a>: 支付操作结果对象</li>
  31. <li>
  32. <a href="#plus.payment.IAPProduct">IAPProduct</a>: IAP商品对象</li>
  33. <li>
  34. <a href="#plus.payment.IAPProductInfo">IAPProductInfo</a>: 购买IAP商品对象</li>
  35. <li>
  36. <a href="#plus.payment.IAPTransaction">IAPTransaction</a>: 购买IAP商品交易信息对象</li>
  37. </ul>
  38. <h2>回调方法:</h2>
  39. <ul>
  40. <li>
  41. <a href="#plus.payment.ChannelsSuccessCallback">ChannelsSuccessCallback</a>: 获取支付通道成功回调</li>
  42. <li>
  43. <a href="#plus.payment.IapRequestOrderSuccessCallback">IapRequestOrderSuccessCallback</a>: 请求支付商品列表回调方法</li>
  44. <li>
  45. <a href="#plus.payment.IapRestoreComplateRequestCallback">IapRestoreComplateRequestCallback</a>: 请求已经购买的非消耗性商品和订阅商品回调方法</li>
  46. <li>
  47. <a href="#plus.payment.PaymentSuccessCallback">PaymentSuccessCallback</a>: 支付操作成功回调</li>
  48. <li>
  49. <a href="#plus.payment.PaymentErrorCallback">PaymentErrorCallback</a>: 支付操作失败回调</li>
  50. </ul>
  51. <h2>权限:</h2>
  52. <p>permissions</p>
  53. <pre class="prettyprint linenums">
  54. {
  55. // ...
  56. "permissions":{
  57. // ...
  58. "Payment": {
  59. "description": "支付"
  60. }
  61. }
  62. }
  63. </pre>
  64. <h1><a name="plus.payment.PaymentChannel">PaymentChannel</a></h1>
  65. <p>支付通道对象</p>
  66. <pre class="prettyprint linenums">
  67. interface plus.payment.PaymentChannel{
  68. attribute String id;
  69. attribute String description;
  70. attribute Boolean serviceReady;
  71. function void installService();
  72. // iOS iAP
  73. function void requestOrder(ids, successCB, errorCB);
  74. function void restoreComplateRequest(options, successCB);
  75. }
  76. </pre>
  77. <h2>说明:</h2>
  78. <p class="des">
  79. PaymentChannel对象表示特定的支付通道,用于向系统请求支付操作。
  80. </p>
  81. <h2>属性:</h2>
  82. <ul>
  83. <li>
  84. <a href="#plus.payment.PaymentChannel.id">id</a>: 支付通道标识</li>
  85. <li>
  86. <a href="#plus.payment.PaymentChannel.description">description</a>: 支付通道描述</li>
  87. <li>
  88. <a href="#plus.payment.PaymentChannel.serviceReady">serviceReady</a>: 支付通道服务是否安装</li>
  89. </ul>
  90. <h2>方法:</h2>
  91. <ul>
  92. <li>
  93. <a href="#plus.payment.PaymentChannel.installService">installService</a>: 安装支付通道依赖的服务</li>
  94. <li>
  95. <a href="#plus.payment.PaymentChannel.requestOrder">requestOrder</a>: 向IAP服务器请求支付订单</li>
  96. <li>
  97. <a href="#plus.payment.PaymentChannel.restoreComplateRequest">restoreComplateRequest</a>: 向IAP服务器请求已经购买的非消耗性商品和订阅商品</li>
  98. </ul>
  99. <h1><a name="plus.payment.OrderStatementIAP">OrderStatementIAP</a></h1>
  100. <p>IAP订单数据对象</p>
  101. <pre class="prettyprint linenums">
  102. interface plus.payment.OrderStatementIAP {
  103. attribute String productid;
  104. attribute String username;
  105. attribute String quantity;
  106. }
  107. </pre>
  108. <h2>说明:</h2>
  109. <p class="des">
  110. 描述IAP商品订单信息,如标识、数量等。
  111. </p>
  112. <h2>属性:</h2>
  113. <ul>
  114. <li>productid: <em>(<font class="type">String</font>
  115. 类型
  116. )</em>商品的标识<br>
  117. </li>
  118. <li>username: <em>(<font class="type">String</font>
  119. 类型
  120. )</em>购买用户名称<br>
  121. </li>
  122. <li>quantity: <em>(<font class="type">String</font>
  123. 类型
  124. )</em>商品数量<br>
  125. </li>
  126. </ul>
  127. <h1><a name="plus.payment.PaymentResult">PaymentResult</a></h1>
  128. <p>支付操作结果对象</p>
  129. <pre class="prettyprint linenums">
  130. interface plus.payment.PaymentResult {
  131. attribute PaymentChannel channel;
  132. attribute String tradeno;
  133. attribute String description;
  134. attribute String url;
  135. attribute String signature;
  136. attribute String rawdata;
  137. }
  138. </pre>
  139. <h2>说明:</h2>
  140. <p class="des">
  141. PaymentResult对象表示支付操作返回结果,用于确认支付操作成功。
  142. </p>
  143. <h2>属性:</h2>
  144. <ul>
  145. <li>channel: <em>(<a href="#plus.payment.PaymentChannel">PaymentChannel</a>
  146. 类型
  147. )</em>支付通道对象<br><p>
  148. 用于发起支付操作的支付通道对象。
  149. </p>
  150. </li>
  151. <li>tradeno: <em>(<font class="type">String</font>
  152. 类型
  153. )</em>交易编号信息<br><p>
  154. 如果支付平台不支持此数据则返回undefined。
  155. </p>
  156. </li>
  157. <li>description: <em>(<font class="type">Boolean</font>
  158. 类型
  159. )</em>交易描述信息<br><p>
  160. 如果支付平台不支持此数据则返回undefined。
  161. </p>
  162. </li>
  163. <li>url: <em>(<font class="type">Boolean</font>
  164. 类型
  165. )</em>查找支付交易信息地址<br><p>
  166. 用于向支付平台查询交易信息,如果支付平台不支持此数据则返回undefined。
  167. </p>
  168. </li>
  169. <li>signature: <em>(<font class="type">String</font>
  170. 类型
  171. )</em>支付操作指纹信息<br><p>
  172. 用于向支付平台查询支付订单信息,如果支付平台不支持此数据则返回undefined。
  173. </p>
  174. </li>
  175. <li>rawdata: <em>(<font class="type">String</font>
  176. 类型
  177. )</em>支付平台返回的原始数据<br><p>
  178. 如果支付平台返回key-value类型字符串,则组合成符合JSON格式的字符串。
  179. </p>
  180. </li>
  181. </ul>
  182. <h1><a name="plus.payment.IAPProduct">IAPProduct</a></h1>
  183. <p>IAP商品对象</p>
  184. <pre class="prettyprint linenums">
  185. interface plus.payment.IAPProduct {
  186. attribute String productid;
  187. attribute String price;
  188. attribute String title;
  189. attribute String description;
  190. }
  191. </pre>
  192. <h2>说明:</h2>
  193. <p class="des">
  194. 描述IAP商品详细信息,如标识、价格、标题、描述信息等。
  195. </p>
  196. <h2>属性:</h2>
  197. <ul>
  198. <li>productid: <em>(<font class="type">String</font>
  199. 类型
  200. )</em>商品的标识<br>
  201. </li>
  202. <li>price: <em>(<font class="type">String</font>
  203. 类型
  204. )</em>商品的价格<br>
  205. </li>
  206. <li>title: <em>(<font class="type">String</font>
  207. 类型
  208. )</em>商品标题<br>
  209. </li>
  210. <li>description: <em>(<font class="type">String</font>
  211. 类型
  212. )</em>商品的描述信息<br>
  213. </li>
  214. </ul>
  215. <h1><a name="plus.payment.IAPProductInfo">IAPProductInfo</a></h1>
  216. <p>购买IAP商品对象</p>
  217. <pre class="prettyprint linenums">
  218. interface plus.payment.IAPProductInfo {
  219. attribute String productIdentifier;
  220. attribute String quantity;
  221. }
  222. </pre>
  223. <h2>说明:</h2>
  224. <p class="des">
  225. 描述购买的IAP商品详细信息,如标识、数量等。
  226. </p>
  227. <h2>属性:</h2>
  228. <ul>
  229. <li>productIdentifier: <em>(<font class="type">String</font>
  230. 类型
  231. )</em>商品的标识<br>
  232. </li>
  233. <li>quantity: <em>(<font class="type">String</font>
  234. 类型
  235. )</em>商品的数量<br>
  236. </li>
  237. </ul>
  238. <h1><a name="plus.payment.IAPTransaction">IAPTransaction</a></h1>
  239. <p>购买IAP商品交易信息对象</p>
  240. <pre class="prettyprint linenums">
  241. interface plus.payment.IAPTransaction {
  242. attribute IAPProductInfo payment;
  243. attribute String transactionDate;
  244. attribute String transactionIdentifier;
  245. attribute String transactionReceipt;
  246. attribute String transactionState;
  247. }
  248. </pre>
  249. <h2>说明:</h2>
  250. <p class="des">
  251. 描述购买的IAP商品交易详细信息,如购买商品信息、交易日期、订单标识等。
  252. </p>
  253. <h2>属性:</h2>
  254. <ul>
  255. <li>payment: <em>(<font class="type">String</font>
  256. 类型
  257. )</em>购买商品的信息<br>
  258. </li>
  259. <li>transactionDate: <em>(<font class="type">String</font>
  260. 类型
  261. )</em>购买商品的交易日期<br>
  262. </li>
  263. <li>transactionIdentifier: <em>(<font class="type">String</font>
  264. 类型
  265. )</em>购买商品的交易订单标识<br>
  266. </li>
  267. <li>transactionReceipt: <em>(<font class="type">String</font>
  268. 类型
  269. )</em>购买商品的交易收据<br><p>
  270. base64编码格式字符串数据。
  271. </p>
  272. </li>
  273. <li>transactionState: <em>(<font class="type">String</font>
  274. 类型
  275. )</em>购买商品的交易状态<br><p>
  276. 可取值:"1"为支付成功;"2"为支付失败;"3"为支付已恢复。
  277. </p>
  278. </li>
  279. </ul>
  280. <h1><a name="plus.payment.ChannelsSuccessCallback">ChannelsSuccessCallback</a></h1>
  281. <p>获取支付通道成功回调</p>
  282. <pre class="prettyprint linenums">
  283. void ChannelsSuccessCallback( channels ) {
  284. // Get payment channels success code
  285. }
  286. </pre>
  287. <h2>说明:</h2>
  288. <p class="des">
  289. 当获取支付通道列表成功时的回调函数,用于返回终端支持的支付通道列表。
  290. </p>
  291. <h2>参数:</h2>
  292. <ul><li>channels:
  293. <em>(
  294. <font class="type">Array</font>
  295. )
  296. 必选 </em>数组,系统支持的支付通道PaymentChannel列表<br>
  297. </li></ul>
  298. <h2>返回值:</h2>
  299. <font class="type">void</font>
  300. : 无<h1><a name="plus.payment.IapRequestOrderSuccessCallback">IapRequestOrderSuccessCallback</a></h1>
  301. <p>请求支付商品列表回调方法</p>
  302. <pre class="prettyprint linenums">
  303. void onsuccess( results ) {
  304. // Payment success code
  305. }
  306. </pre>
  307. <h2>说明:</h2>
  308. <p class="des">
  309. 获取IAP商品列表信息成功时的回调函数,返回商品详细信息。
  310. </p>
  311. <h2>参数:</h2>
  312. <ul><li>results:
  313. <em>(
  314. <font class="type">Array</font>[
  315. <a href="#plus.payment.IAPProduct">IAPProduct</a>
  316. ]
  317. )
  318. 必选 </em>商品信息数据<br>
  319. </li></ul>
  320. <h2>返回值:</h2>
  321. <font class="type">void</font>
  322. : 无<h1><a name="plus.payment.IapRestoreComplateRequestCallback">IapRestoreComplateRequestCallback</a></h1>
  323. <p>请求已经购买的非消耗性商品和订阅商品回调方法</p>
  324. <pre class="prettyprint linenums">
  325. void onsuccess( results ) {
  326. // Payment success code
  327. }
  328. </pre>
  329. <h2>说明:</h2>
  330. <p class="des">
  331. 获取IAP商品列表信息成功时的回调函数,返回商品详细信息。
  332. </p>
  333. <h2>参数:</h2>
  334. <ul><li>results:
  335. <em>(
  336. <font class="type">Array</font>[
  337. <a href="#plus.payment.IAPTransaction">IAPTransaction</a>
  338. ]
  339. )
  340. 必选 </em>已购买的非消耗性商品和订阅商品交易信息<br>
  341. </li></ul>
  342. <h2>返回值:</h2>
  343. <font class="type">void</font>
  344. : 无<h1><a name="plus.payment.PaymentSuccessCallback">PaymentSuccessCallback</a></h1>
  345. <p>支付操作成功回调</p>
  346. <pre class="prettyprint linenums">
  347. void PaymentSuccessCallback ( result ) {
  348. // Payment success code
  349. }
  350. </pre>
  351. <h2>说明:</h2>
  352. <p class="des">
  353. 当支付操作成功时的回调函数,用于返回支付操作的成功信息。
  354. </p>
  355. <h2>参数:</h2>
  356. <ul><li>result :
  357. <em>(
  358. <a href="#plus.payment.PaymentResult">PaymentResult</a>
  359. |
  360. <a href="#plus.payment.IAPTransaction">IAPTransaction</a>
  361. )
  362. 必选 </em>支付操作成功的信息<br>
  363. iOS平台使用IAP支付返回的数据类型为IAPTransaction。
  364. </li></ul>
  365. <h2>返回值:</h2>
  366. <font class="type">void</font>
  367. : 无<h1><a name="plus.payment.PaymentErrorCallback">PaymentErrorCallback</a></h1>
  368. <p>支付操作失败回调</p>
  369. <pre class="prettyprint linenums">
  370. void PaymentErrorCallback(error){
  371. // Payment error code
  372. }
  373. </pre>
  374. <h2>说明:</h2>
  375. <p class="des">当支付操作失败时的回调函数,用于返回支付操作失败的错误信息。</p>
  376. <h2>参数:</h2>
  377. <ul><li>error:
  378. <em>(
  379. <font class="type">DOMException</font>
  380. )
  381. 必选 </em>支付操作失败错误信息,可通过error.code获取错误代码,具体错误码有各支付通道定义<br>
  382. 支付宝支付错误代码如下:
  383. 62000,客户端未安装支付通道依赖的服务;
  384. 62001,用户取消支付操作;
  385. 62002,此设备不支持支付;
  386. 62003,数据格式错误;
  387. 62004,支付账号状态错误;
  388. 62005,订单信息错误;
  389. 62006,支付操作内部错误;
  390. 62007,支付服务器错误;
  391. 62008,网络问题引起的错误;
  392. 62009,其它未定义的错误。
  393. 微信支付错误代码如下:
  394. -1,一般错误;
  395. -2,用户取消;
  396. -3,发送失败;
  397. -4,认证被否决;
  398. -5,不支持错误。
  399. </li></ul>
  400. <h2>返回值:</h2>
  401. <font class="type">void</font>
  402. : 无<br><br>
  403. </div></body>
  404. </html>