1 | # Alipay Serverless SDK
|
2 |
|
3 | > 支付宝小程序端**Serverless**配套SDK,让您享受极简编程体验的同时,快速集成支付宝、阿里云等阿里经济体开放的各项核心能力。
|
4 |
|
5 | # Installation 安装
|
6 |
|
7 | ```sh
|
8 | npm install alipay-serverless-sdk --save
|
9 | npm install @alicloud/mpserverless-sdk --save
|
10 | ```
|
11 |
|
12 | > `alipay-serverless-sdk` 依赖 `@alicloud/mpserverless-sdk`,使用时需要传入 mpserverless-sdk 实例进行初始化
|
13 |
|
14 | # Usage 快速示例
|
15 |
|
16 | ```js
|
17 | // 1. 引入必要的 sdk
|
18 | import MPServerless from '@alicloud/mpserverless-sdk';
|
19 | import cloud from 'alipay-serverless-sdk';
|
20 |
|
21 | // 2. 在 app.js 中对 sdk 进行初始化
|
22 | // 2.1 初始化 MPServerless
|
23 | my.serverless = my.serverless || new MPServerless({
|
24 | uploadFile: my.uploadFile,
|
25 | request: my.request,
|
26 | getAuthCode: my.getAuthCode,
|
27 | }, {
|
28 | // 2.2 参数能在小程序云服务空间详情中获取
|
29 | appId: '',
|
30 | spaceId: '',
|
31 | clientSecret: '',
|
32 | endpoint: ''
|
33 | });
|
34 | // 2.3 初始化 alipay-serverless-sdk
|
35 | cloud.init(my.serverless);
|
36 |
|
37 | // 3. 在想要使用的页面导入 alipay-serverless-sdk 即可使用
|
38 | // 比如在 page.js
|
39 | import cloud from 'alipay-serverless-sdk';
|
40 |
|
41 | cloud.base.qrcode.create(urlParam, queryParam, describe);
|
42 |
|
43 | ```
|
44 |
|
45 | # API Doc
|
46 |
|
47 | 将API Doc中API的上两级标题中的英文(转首字符小写驼峰格式),用点号拼接在一起作为前缀,就是这个API的完整引用路径。Alipay Serverless SDK致力于保持良好的API命名,以符合开发者的编程直觉。
|
48 |
|
49 | 下面是几个典型的例子。
|
50 |
|
51 | ```ts
|
52 | import cloud from 'alipay-serverless-sdk';
|
53 |
|
54 | //调用基础能力-用户授权-获取授权访问令牌API
|
55 | cloud.base.oauth.getToken
|
56 |
|
57 | //调用营销能力-小程序模板消息-发送模板消息API
|
58 | cloud.marketing.templateMessage.send
|
59 |
|
60 | //调用营销能力-兑换券使用
|
61 | cloud.marketing.exchangevoucher.use
|
62 |
|
63 | //调用会员能力-支付宝身份认证-生成认证链接API
|
64 | cloud.member.identification.certify
|
65 |
|
66 | //调用支付能力-花呗分期-创建花呗分期交易API
|
67 | cloud.payment.huabei.create
|
68 |
|
69 | // 调用资金能力-无密转账到支付宝账户-单笔转账API
|
70 | cloud.fund.transferAccount.transfer
|
71 |
|
72 | // 调用资金能力-B2C现金红包-发放现金红包
|
73 | cloud.fund.b2cRedPacket.send
|
74 |
|
75 | //调用安全能力-文本风险识别-检测内容风险API
|
76 | cloud.security.textRisk.detect
|
77 |
|
78 | //调用阿里云能力-短信-发送API
|
79 | cloud.aliyun.shortMessage.send
|
80 | ```
|
81 |
|
82 | ## 基础能力 Base
|
83 | ### 用户授权 OAuth
|
84 | #### 获取授权访问令牌
|
85 | * API声明
|
86 |
|
87 | getToken(code: string)
|
88 |
|
89 | * 入参说明
|
90 |
|
91 | | 字段名 | 类型 | 必填 | 说明 |
|
92 | |------|--------|----|----|
|
93 | | code | string | 是 | 授权码,用户对应用授权后得到 |
|
94 |
|
95 | * 出参说明
|
96 |
|
97 | 可前往[alipay.system.oauth.token](https://docs.open.alipay.com/api_9/alipay.system.oauth.token)查看更加详细的参数说明。
|
98 |
|
99 | #### 刷新授权访问令牌
|
100 | * API声明
|
101 |
|
102 | refreshToken(refreshToken: string)
|
103 |
|
104 | * 入参说明
|
105 |
|
106 | | 字段名 | 类型 | 必填 | 说明 |
|
107 | |------|--------|----|----|
|
108 | | refreshToken | string | 是 | 刷新令牌,上次换取访问令牌时得到,见出参的refresh_token字段 |
|
109 |
|
110 | * 出参说明
|
111 |
|
112 | 可前往[alipay.system.oauth.token](https://docs.open.alipay.com/api_9/alipay.system.oauth.token)查看更加详细的参数说明。
|
113 |
|
114 | ---
|
115 |
|
116 | ### 小程序二维码 Qrcode
|
117 | #### 创建小程序二维码
|
118 | * API声明
|
119 |
|
120 | create(urlParam: string, queryParam: string, describe: string)
|
121 |
|
122 | * 入参说明
|
123 |
|
124 | | 字段名 | 类型 | 必填 | 说明 |
|
125 | |------|--------|----|----|
|
126 | | urlParam | string | 是 | 小程序中能访问到的页面路径,例如:page/component/component-pages/view/view |
|
127 | | queryParam | string | 是 | 小程序的启动参数,打开小程序的query ,在小程序 onLaunch的方法中获取 |
|
128 | | describe | string | 是 | 二维码描述 |
|
129 |
|
130 | * 出参说明
|
131 |
|
132 | 可前往[alipay.open.app.qrcode.create](https://docs.open.alipay.com/api_5/alipay.open.app.qrcode.create)查看更加详细的参数说明。
|
133 |
|
134 | ---
|
135 |
|
136 | ## 营销能力 Marketing
|
137 | ### 小程序模板消息 TemplateMessage
|
138 | #### 发送模板消息
|
139 | * API声明
|
140 |
|
141 | send(toUserId: string, formId: string, userTemplateId: string, page: string, data: string)
|
142 |
|
143 | * 入参说明
|
144 |
|
145 | | 字段名 | 类型 | 必填 | 说明 |
|
146 | |------|--------|----|----|
|
147 | | toUserId | string | 是 | 发送消息的支付宝账号 |
|
148 | | formId | string | 是 | 用户发生的交易行为的交易号,或者用户在小程序产生表单提交的表单号,用于信息发送的校验 |
|
149 | | userTemplateId | string | 是 | 用户申请的模板id号,固定的模板id会发送固定的消息 |
|
150 | | page | string | 是 | 小程序的跳转页面,用于消息中心用户点击之后详细跳转的小程序页面,例如:page/component/index |
|
151 | | data | string | 是 | 开发者需要发送模板消息中的自定义部分来替换模板的占位符,例如:{"keyword1": {"value" : "12:00"},"keyword2": {"value" : "20180808"},"keyword3": {"value" : "支付宝"}} |
|
152 |
|
153 | * 出参说明
|
154 |
|
155 | 可前往[alipay.open.app.mini.templatemessage.send](https://docs.open.alipay.com/api_5/alipay.open.app.mini.templatemessage.send)查看更加详细的参数说明。
|
156 |
|
157 | ---
|
158 |
|
159 | ### 兑换券 Exchangevoucher
|
160 | #### 创建兑换券模板
|
161 | * API声明
|
162 |
|
163 | create(outBizNo: string, brandName: string, voucherName: string, quantity: number, publishStartTime: string, publishEndTime: string, validPeriod: string, availableTime: string, description: string, extensionInfo: string)
|
164 |
|
165 | * 入参说明
|
166 |
|
167 | | 字段名 | 类型 | 必填 | 说明 |
|
168 | |------|--------|----|----|
|
169 | | outBizNo | string | 是 | 外部业务单号。用作幂等控制。同一个pid下相同的外部业务单号作唯一键。 |
|
170 | | brandName | string | 是 | 品牌名。用于在卡包中展示,长度不能超过12个字符。 |
|
171 | | voucherName | string | 是 | 券名称。用于在卡包中展示,长度不能超过20个字符。展示的实际名称为:券名称+兑换券。如,voucher_name为咖啡。则,卡包展示名称为:咖啡兑换券。 |
|
172 | | quantity | number | 是 | 拟发行券的数量。单位为张。该数值必须是大于0的整数。 |
|
173 | | publishStartTime | string | 是 | 发放开始时间,早于该时间不能发券。发放开始时间不能大于当前时间15天。格式为:yyyy-MM-dd HH:mm:ss |
|
174 | | publishEndTime | string | 是 | 发放结束时间,晚于该时间不能发券。券的发放结束时间和发放开始时间跨度不能大于90天。发放结束时间必须晚于发放开始时间。格式为:yyyy-MM-dd HH:mm:ss |
|
175 | | validPeriod | string | 是 | 券有效期。具体取值规则可前往[alipay.marketing.exchangevoucher.template.create](https://opendocs.alipay.com/apis/api_5/alipay.marketing.exchangevoucher.template.create)查看更加详细的参数说明。 |
|
176 | | availableTime | string | 是 | 券可用时段。具体取值规则可前往[alipay.marketing.exchangevoucher.template.create](https://opendocs.alipay.com/apis/api_5/alipay.marketing.exchangevoucher.template.create)查看更加详细的参数说明。 |
|
177 | | description | string | 是 | 券使用说明。JSON数组字符串,最多可以有10条,每条最多50字。不采用时输入"[]" |
|
178 | | extensionInfo | string | 是 | 扩展字段,JSON字符串。具体取值规则可前往[alipay.marketing.exchangevoucher.template.create](https://opendocs.alipay.com/apis/api_5/alipay.marketing.exchangevoucher.template.create)查看更加详细的参数说明。 |
|
179 |
|
180 | * 出参说明
|
181 |
|
182 | 可前往[alipay.marketing.exchangevoucher.template.create](https://opendocs.alipay.com/apis/api_5/alipay.marketing.exchangevoucher.template.create)查看更加详细的参数说明。
|
183 |
|
184 | #### 发放兑换券
|
185 | * API声明
|
186 |
|
187 | send(templateId: string, userId: string, outBizNo: string)
|
188 |
|
189 | * 入参说明
|
190 |
|
191 | | 字段名 | 类型 | 必填 | 说明 |
|
192 | |------|--------|----|----|
|
193 | | templateId | string | 是 | 券模板ID。 |
|
194 | | userId | string | 是 | 支付宝用户ID 。 |
|
195 | | outBizNo | string | 是 | 外部业务订单号,用于幂等控制,相同template_id和out_biz_no认为是同一次业务。 |
|
196 |
|
197 | * 出参说明
|
198 |
|
199 | 可前往[alipay.marketing.voucher.send](https://opendocs.alipay.com/apis/api_5/alipay.marketing.voucher.send)查看更加详细的参数说明。
|
200 |
|
201 | #### 使用兑换券
|
202 | * API声明
|
203 |
|
204 | use(voucherId: string, userId: string, outBizNo: string)
|
205 |
|
206 | * 入参说明
|
207 |
|
208 | | 字段名 | 类型 | 必填 | 说明 |
|
209 | |------|--------|----|----|
|
210 | | voucherId | string | 是 | 待使用的券id ,来自发券接口alipay.marketing.voucher.send |
|
211 | | userId | string | 是 | 支付宝用户ID ,必须保证待使用的券ID归属于该支付宝用户ID。 |
|
212 | | outBizNo | string | 是 | 外部业务号,用户幂等控制。相同voucher_id和out_biz_no被认为是同一次核销。 |
|
213 |
|
214 | * 出参说明
|
215 |
|
216 | 可前往[alipay.marketing.exchangevoucher.use](https://opendocs.alipay.com/apis/api_5/alipay.marketing.exchangevoucher.use)查看更加详细的参数说明。
|
217 |
|
218 | #### 查询兑换券
|
219 | * API声明
|
220 |
|
221 | query(voucherId: string)
|
222 |
|
223 | * 入参说明
|
224 |
|
225 | | 字段名 | 类型 | 必填 | 说明 |
|
226 | |------|--------|----|----|
|
227 | | voucherId | string | 是 | 券ID(券唯一标识, 发券接口返回参数) 。 |
|
228 |
|
229 | * 出参说明
|
230 |
|
231 | 可前往[alipay.marketing.voucher.query](https://opendocs.alipay.com/apis/api_5/alipay.marketing.voucher.query)查看更加详细的参数说明。
|
232 |
|
233 | ---
|
234 |
|
235 | ## 会员能力 Member
|
236 | ### 支付宝身份认证 Identification
|
237 | #### 身份认证初始化
|
238 | * API声明
|
239 |
|
240 | init(outerOrderNo: string, bizCode: string, identityParam: IdentityParam, merchantConfig: MerchantConfig)
|
241 |
|
242 | * 入参说明
|
243 |
|
244 | | 字段名 | 类型 | 必填 | 说明 |
|
245 | |------|--------|----|----|
|
246 | | outerOrderNo | string | 是 | 商户请求的唯一标识,商户要保证其唯一性,值为32位长度的字母数字组合,建议前面几位字符是商户自定义的简称,中间可以使用一段时间,后段可以使用一个随机或递增序列 |
|
247 | | bizCode | string | 是 | 认证场景码,入参支持的认证场景码和商户签约的认证场景相关,可选值有如下,FACE:多因子人脸认证;CERT_PHOTO:多因子证照认证;CERT_PHOTO_FACE:多因子证照和人脸认证;SMART_FACE:多因子快捷认证 |
|
248 | | identityParam | IdentityParam | 是 | 需要验证的身份信息参数 |
|
249 | | merchantConfig | MerchantConfig | 是 | 商户个性化配置 |
|
250 |
|
251 | IdentityParam对象说明
|
252 |
|
253 | | 字段名 | 类型 | 必填 | 说明 |
|
254 | |------|--------|----|----|
|
255 | | identityType | string | 是 | 身份信息参数类型,必须传入CERT_INFO |
|
256 | | certType | string | 是 | 证件类型,当前支持身份证,必须传入IDENTITY_CARD |
|
257 | | certName | string | 是 | 真实姓名 |
|
258 | | certNo | string | 是 | 证件号码 |
|
259 |
|
260 | MerchantConfig对象说明
|
261 |
|
262 | | 字段名 | 类型 | 必填 | 说明 |
|
263 | |------|--------|----|----|
|
264 | | returnUrl | string | 是 | 需要回跳的目标URL地址,一般指定为商户业务页面 |
|
265 |
|
266 | * 出参说明
|
267 |
|
268 | 可前往[alipay.user.certify.open.initialize](https://docs.open.alipay.com/api_2/alipay.user.certify.open.initialize)查看更加详细的参数说明。
|
269 |
|
270 | #### 生成认证链接
|
271 | * API声明
|
272 |
|
273 | certify(certifyId: string)
|
274 |
|
275 | * 入参说明
|
276 |
|
277 | | 字段名 | 类型 | 必填 | 说明 |
|
278 | |------|--------|----|----|
|
279 | | certifyId | string | 是 | 本次申请操作的唯一标识,由身份认证初始化接口调用后生成,后续的操作都需要用到 |
|
280 |
|
281 | * 出参说明
|
282 |
|
283 | 可前往[alipay.user.certify.open.certify](https://docs.open.alipay.com/api_2/alipay.user.certify.open.certify)查看更加详细的参数说明。
|
284 |
|
285 | #### 身份认证记录查询
|
286 | * API声明
|
287 |
|
288 | query(certifyId: string)
|
289 |
|
290 | * 入参说明
|
291 |
|
292 | | 字段名 | 类型 | 必填 | 说明 |
|
293 | |------|--------|----|----|
|
294 | | certifyId | string | 是 | 身份认证操作的唯一标识,由身份认证初始化接口调用后生成 |
|
295 |
|
296 | * 出参说明
|
297 |
|
298 | 可前往[alipay.user.certify.open.query](https://docs.open.alipay.com/api_2/alipay.user.certify.open.query)查看更加详细的参数说明。
|
299 |
|
300 | ---
|
301 |
|
302 |
|
303 | ## 支付能力 Payment
|
304 | ### 通用接口 Common
|
305 | #### 创建交易
|
306 | * API声明
|
307 |
|
308 | create(subject: string, outTradeNo: string, totalAmount: string, buyerId: string)
|
309 |
|
310 | * 入参说明
|
311 |
|
312 | | 字段名 | 类型 | 必填 | 说明 |
|
313 | |------|--------|----|----|
|
314 | | subject | string | 是 | 订单标题 |
|
315 | | outTradeNo | string | 是 | 商户订单号,64个字符以内,可包含字母、数字、下划线,需保证在商户端不重复 |
|
316 | | totalAmount | string | 是 | 订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000] |
|
317 | | buyerId | string | 是 | 买家的支付宝用户ID,如果为空,会从传入的码值信息中获取买家ID |
|
318 |
|
319 | * 出参说明
|
320 |
|
321 | 可前往[alipay.trade.create](https://docs.open.alipay.com/api_1/alipay.trade.create)查看更加详细的参数说明。
|
322 |
|
323 | #### 查询交易
|
324 | * API声明
|
325 |
|
326 | query(outTradeNo: string)
|
327 |
|
328 | * 入参说明
|
329 |
|
330 | | 字段名 | 类型 | 必填 | 说明 |
|
331 | |------|--------|----|----|
|
332 | | outTradeNo | string | 是 | 交易创建时传入的商户订单号 |
|
333 |
|
334 | * 出参说明
|
335 |
|
336 | 可前往[alipay.trade.query](https://docs.open.alipay.com/api_1/alipay.trade.query)查看更加详细的参数说明。
|
337 |
|
338 | #### 交易退款
|
339 | * API声明
|
340 |
|
341 | refund(outTradeNo: string, refundAmount: string)
|
342 |
|
343 | * 入参说明
|
344 |
|
345 | | 字段名 | 类型 | 必填 | 说明 |
|
346 | |------|--------|----|----|
|
347 | | outTradeNo | string | 是 | 交易创建时传入的商户订单号 |
|
348 | | refundAmount | string | 是 | 需要退款的金额,该金额不能大于订单金额,单位为元,支持两位小数 |
|
349 |
|
350 | * 出参说明
|
351 |
|
352 | 可前往[alipay.trade.refund](https://docs.open.alipay.com/api_1/alipay.trade.refund)查看更加详细的参数说明。
|
353 |
|
354 | #### 关闭交易
|
355 | * API声明
|
356 |
|
357 | close(outTradeNo: string)
|
358 |
|
359 | * 入参说明
|
360 |
|
361 | | 字段名 | 类型 | 必填 | 说明 |
|
362 | |------|--------|----|----|
|
363 | | outTradeNo | string | 是 | 交易创建时传入的商户订单号 |
|
364 |
|
365 | * 出参说明
|
366 |
|
367 | 可前往[alipay.trade.close](https://docs.open.alipay.com/api_1/alipay.trade.close)查看更加详细的参数说明。
|
368 |
|
369 | #### 撤销交易
|
370 | * API声明
|
371 |
|
372 | cancel(outTradeNo: string)
|
373 |
|
374 | * 入参说明
|
375 |
|
376 | | 字段名 | 类型 | 必填 | 说明 |
|
377 | |------|--------|----|----|
|
378 | | outTradeNo | string | 是 | 交易创建时传入的商户订单号 |
|
379 |
|
380 | * 出参说明
|
381 |
|
382 | 可前往[alipay.trade.cancel](https://docs.open.alipay.com/api_1/alipay.trade.cancel)查看更加详细的参数说明。
|
383 |
|
384 | ---
|
385 |
|
386 | ### 花呗分期 Huabei
|
387 | #### 创建花呗分期交易
|
388 | * API声明
|
389 |
|
390 | create(subject: string, outTradeNo: string, totalAmount: string, buyerId: string, extendParams: HuabeiConfig)
|
391 |
|
392 | * 入参说明
|
393 |
|
394 | | 字段名 | 类型 | 必填 | 说明 |
|
395 | |------|--------|----|----|
|
396 | | subject | string | 是 | 订单标题 |
|
397 | | outTradeNo | string | 是 | 商户订单号,64个字符以内,可包含字母、数字、下划线,需保证在商户端不重复 |
|
398 | | totalAmount | string | 是 | 订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000] |
|
399 | | buyerId | string | 是 | 买家的支付宝用户ID,如果为空,会从传入的码值信息中获取买家ID |
|
400 | | extendParams | HuabeiConfig | 是 | 花呗交易扩展参数 |
|
401 |
|
402 | HuabeiConfig对象说明
|
403 |
|
404 | | 字段名 | 类型 | 必填 | 说明 |
|
405 | |------|--------|----|----|
|
406 | | hbFqNum | string | 是 | 花呗分期数,仅支持传入3、6、12 |
|
407 | | hbFqSellerPercent | string | 是 | 代表卖家承担收费比例,商家承担手续费传入100,用户承担手续费传入0,仅支持传入100、0两种 |
|
408 |
|
409 |
|
410 | * 出参说明
|
411 |
|
412 | 可前往[alipay.trade.create](https://docs.open.alipay.com/api_1/alipay.trade.create)查看更加详细的参数说明。
|
413 |
|
414 | ---
|
415 |
|
416 | ### 当面付 FaceToFace
|
417 | #### 当面付交易付款
|
418 | * API声明
|
419 |
|
420 | pay(subject: string, outTradeNo: string, totalAmount: string, authCode: string)
|
421 |
|
422 | * 入参说明
|
423 |
|
424 | | 字段名 | 类型 | 必填 | 说明 |
|
425 | |------|--------|----|----|
|
426 | | subject | string | 是 | 订单标题 |
|
427 | | outTradeNo | string | 是 | 交易创建时传入的商户订单号 |
|
428 | | totalAmount | string | 是 | 订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000] |
|
429 | | authCode | string | 是 | 支付授权码,25~30开头的长度为16~24位的数字,实际字符串长度以开发者获取的付款码长度为准 |
|
430 |
|
431 | * 出参说明
|
432 |
|
433 | 可前往[alipay.trade.pay](https://docs.open.alipay.com/api_1/alipay.trade.pay)查看更加详细的参数说明。
|
434 |
|
435 | ---
|
436 |
|
437 | ## 资金能力 Fund
|
438 | ### 无密转账到支付宝账户 TransferAccount
|
439 | #### 单笔转账
|
440 | * API声明
|
441 |
|
442 | transfer(outBizNo: string, transAmount: string, payee: object, orderTitle: string)
|
443 |
|
444 | * 入参说明
|
445 |
|
446 | | 字段名 | 类型 | 必填 | 说明 |
|
447 | |--------|--------|----|----|
|
448 | | outBizNo | string | 是 | 商户端的唯一订单号,对于同一笔转账请求,商户需保证该订单号唯一。 |
|
449 | | transAmount | string | 是 | 订单总金额,单位为元,精确到小数点后两位,取值范围[0.1,100000000]。 |
|
450 | | + payee | object | 是 | 收款方信息。 |
|
451 | |└ identity | string | 是 | 参与方的唯一标识。 |
|
452 | |└ identity_type | string | 是 | 参与方的标识类型,目前支持如下类型:1、ALIPAY_USER_ID 支付宝的会员ID 2、ALIPAY_LOGON_ID:支付宝登录号,支持邮箱和手机号格式。 |
|
453 | | └ name | string | 否 | 参与方真实姓名,如果非空,将校验收款支付宝账号姓名一致性。当identity_type=ALIPAY_LOGON_ID时,本字段必填。 |
|
454 | | orderTitle | string | 是 | 转账业务的标题,用于在支付宝用户的账单里显示。 |
|
455 |
|
456 | * 出参说明
|
457 |
|
458 | 可前往[alipay.fund.trans.uni.transfer](https://opendocs.alipay.com/apis/api_28/alipay.fund.trans.uni.transfer)查看更加详细的参数说明。
|
459 |
|
460 | #### 查询转账单据
|
461 | * API声明
|
462 |
|
463 | query(payFundOrderId: string)
|
464 |
|
465 | * 入参说明
|
466 |
|
467 | | 字段名 | 类型 | 必填 | 说明 |
|
468 | |--------|--------|----|----|
|
469 | | payFundOrderId | string | 是 | 支付宝支付资金流水号。 |
|
470 |
|
471 | * 出参说明
|
472 |
|
473 | 可前往[alipay.fund.trans.common.query](https://opendocs.alipay.com/apis/api_28/alipay.fund.trans.common.query)查看更加详细的参数说明。
|
474 |
|
475 | ---
|
476 |
|
477 | ### 无密转账到银行卡 TransferBankcard
|
478 | #### 单笔转账
|
479 | * API声明
|
480 |
|
481 | transfer(outBizNo: string, transAmount: string, payee: object, orderTitle: string)
|
482 |
|
483 | * 入参说明
|
484 |
|
485 | | 字段名 | 类型 | 必填 | 说明 |
|
486 | |--------|--------|----|----|
|
487 | | outBizNo | string | 是 | 商户端的唯一订单号,对于同一笔转账请求,商户需保证该订单号唯一。 |
|
488 | | transAmount | string | 是 | 订单总金额,单位为元,精确到小数点后两位,取值范围[0.1,100000000]。 |
|
489 | | + payee | object | 是 | 收款方信息。 |
|
490 | |└ identity | string | 是 | 参与方的唯一标识。 |
|
491 | |└ identity_type | string | 是 | 参与方的标识类型,目前支持如下类型:1、ALIPAY_USER_ID 支付宝的会员ID 2、ALIPAY_LOGON_ID:支付宝登录号,支持邮箱和手机号格式。 |
|
492 | | └ name | string | 否 | 参与方真实姓名,如果非空,将校验收款支付宝账号姓名一致性。当identity_type=ALIPAY_LOGON_ID时,本字段必填。 |
|
493 | | orderTitle | string | 是 | 转账业务的标题,用于在支付宝用户的账单里显示。 |
|
494 |
|
495 | * 出参说明
|
496 |
|
497 | 可前往[alipay.fund.trans.uni.transfer](https://opendocs.alipay.com/apis/api_28/alipay.fund.trans.uni.transfer)查看更加详细的参数说明。
|
498 |
|
499 | #### 查询转账单据
|
500 | * API声明
|
501 |
|
502 | query(payFundOrderId: string)
|
503 |
|
504 | * 入参说明
|
505 |
|
506 | | 字段名 | 类型 | 必填 | 说明 |
|
507 | |--------|--------|----|----|
|
508 | | payFundOrderId | string | 是 | 支付宝支付资金流水号。 |
|
509 |
|
510 | * 出参说明
|
511 |
|
512 | 可前往[alipay.fund.trans.common.query](https://opendocs.alipay.com/apis/api_28/alipay.fund.trans.common.query)查看更加详细的参数说明。
|
513 |
|
514 | ---
|
515 |
|
516 | ### B2C现金红包 B2cRedPacket
|
517 | #### 发放现金红包
|
518 | * API声明
|
519 |
|
520 | send(outBizNo: string, transAmount: string, payee: object, orderTitle: string)
|
521 |
|
522 | * 入参说明
|
523 |
|
524 | | 字段名 | 类型 | 必填 | 说明 |
|
525 | |--------|--------|----|----|
|
526 | | outBizNo | string | 是 | 商户端的唯一订单号,对于同一笔转账请求,商户需保证该订单号唯一。 |
|
527 | | transAmount | string | 是 | 订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000]。 |
|
528 | | + payee | object | 是 | 收款方信息。 |
|
529 | |└ identity | string | 是 | 参与方的唯一标识。 |
|
530 | |└ identity_type | string | 是 | 参与方的标识类型,目前支持如下类型:1、ALIPAY_USER_ID 支付宝的会员ID 2、ALIPAY_LOGON_ID:支付宝登录号,支持邮箱和手机号格式。 |
|
531 | | └ name | string | 否 | 参与方真实姓名,如果非空,将校验收款支付宝账号姓名一致性。当identity_type=ALIPAY_LOGON_ID时,本字段必填。 |
|
532 | | orderTitle | string | 是 | 转账业务的标题,用于在支付宝用户的账单里显示。 |
|
533 |
|
534 | * 出参说明
|
535 |
|
536 | 可前往[alipay.fund.trans.uni.transfer](https://opendocs.alipay.com/apis/api_28/alipay.fund.trans.uni.transfer)查看更加详细的参数说明。
|
537 |
|
538 | #### 查询转账单据
|
539 | * API声明
|
540 |
|
541 | query(payFundOrderId: string)
|
542 |
|
543 | * 入参说明
|
544 |
|
545 | | 字段名 | 类型 | 必填 | 说明 |
|
546 | |--------|--------|----|----|
|
547 | | payFundOrderId | string | 是 | 支付宝支付资金流水号。 |
|
548 |
|
549 | * 出参说明
|
550 |
|
551 | 可前往[alipay.fund.trans.common.query](https://opendocs.alipay.com/apis/api_28/alipay.fund.trans.common.query)查看更加详细的参数说明。
|
552 |
|
553 | ---
|
554 |
|
555 |
|
556 | ## 安全能力 Security
|
557 | ### 文本风险识别 TextRisk
|
558 | #### 检测内容风险
|
559 | * API声明
|
560 |
|
561 | detect(content: string)
|
562 |
|
563 | * 入参说明
|
564 |
|
565 | | 字段名 | 类型 | 必填 | 说明 |
|
566 | |------|--------|----|----|
|
567 | | content | string | 是 | 待检测的文本内容 |
|
568 |
|
569 | * 出参说明
|
570 |
|
571 | 可前往[alipay.security.risk.content.detect](https://docs.open.alipay.com/api_49/alipay.security.risk.content.detect)查看更加详细的参数说明。
|
572 |
|
573 | ## 阿里云能力 Aliyun
|
574 | ### 短信 ShortMessage
|
575 | #### 发送
|
576 | * API声明
|
577 |
|
578 | send(phoneNumbers: string, signName: string, templateCode: string, templateParam: string)
|
579 |
|
580 | * 入参说明
|
581 |
|
582 | | 字段名 | 类型 | 必填 | 说明 |
|
583 | |------|--------|----|----|
|
584 | | phoneNumbers | string | 是 | 短信接收号码,支持以逗号分隔的形式进行批量调用,批量上限为1000个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式;发送国际/港澳台消息时,接收号码格式为:国际区号+号码,如“85200000000” |
|
585 | | signName | string | 是 | 短信签名 |
|
586 | | templateCode | string | 是 | 短信模板ID,发送国际/港澳台消息时,请使用国际/港澳台短信模版 |
|
587 | | templateParam | string | 否 | 短信模板变量替换JSON串,例如:{"code":"1234","product":"ytx"} |
|
588 |
|
589 | * 出参说明
|
590 |
|
591 | 可前往[SendSms](https://help.aliyun.com/document_detail/55284.htm)查看更加详细的参数说明。
|
592 |
|
593 | #### 批量发送
|
594 | * API声明
|
595 |
|
596 | batchSend(phoneNumberJson: object, signNameJson: object, templateCode: string, templateParamJson: string)
|
597 |
|
598 | * 入参说明
|
599 |
|
600 | | 字段名 | 类型 | 必填 | 说明 |
|
601 | |------|--------|----|----|
|
602 | | phoneNumberJson | string | 是 | 短信接收号码,JSON格式,批量上限为100个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式 |
|
603 | | signNameJson | string | 是 | JOSN格式短信签名,例如:[“云通信”,”云通信”] |
|
604 | | templateCode | string | 是 | 短信模板ID,发送国际/港澳台消息时,请使用国际/港澳台短信模版 |
|
605 | | templateParamJson | string | 是 | 短信模板变量替换JSON串,例如:[{"code":"1234","product":"ytx1"},{"code":"5678","product":"ytx2"}] |
|
606 |
|
607 | * 出参说明
|
608 |
|
609 | 可前往[SendBatchSms](https://help.aliyun.com/document_detail/66041.html)查看更加详细的参数说明。
|
610 |
|
611 | #### 查询
|
612 | * API声明
|
613 |
|
614 | query(phoneNumber: string, sendDate: string, pageSize: number, currentPage: number)
|
615 |
|
616 | * 入参说明
|
617 |
|
618 | | 字段名 | 类型 | 必填 | 说明 |
|
619 | |------|--------|----|----|
|
620 | | phoneNumber | string | 是 | 短信接收号码,如果需要查询国际短信,号码前需要带上对应国家的区号,区号的获取详见国际短信支持国家信息查询API接口 |
|
621 | | sendDate | string | 是 | 短信发送日期格式yyyyMMdd,支持最近30天记录查询,例如:20170525 |
|
622 | | pageSize | number | 是 | 页大小,最大不超过50 |
|
623 | | currentPage | number | 是 | 当前页码 |
|
624 |
|
625 | * 出参说明
|
626 |
|
627 | 可前往[QuerySendDetails](https://help.aliyun.com/document_detail/55289.html)查看更加详细的参数说明。
|
628 |
|
629 | #### 精准查询
|
630 | * API声明
|
631 |
|
632 | preciseQuery(phoneNumber: string, sendDate: string, pageSize: number, currentPage: number, bizId: string)
|
633 |
|
634 | * 入参说明
|
635 |
|
636 | | 字段名 | 类型 | 必填 | 说明 |
|
637 | |------|--------|----|----|
|
638 | | phoneNumber | string | 是 | 短信接收号码,如果需要查询国际短信,号码前需要带上对应国家的区号,区号的获取详见国际短信支持国家信息查询API接口 |
|
639 | | sendDate | string | 是 | 短信发送日期格式yyyyMMdd,支持最近30天记录查询,例如:20170525 |
|
640 | | pageSize | number | 是 | 页大小,最大不超过50 |
|
641 | | currentPage | number | 是 | 当前页码 |
|
642 | | bizId | string | 是 | 发送流水号,从调用发送接口返回值中获取 |
|
643 |
|
644 | * 出参说明
|
645 |
|
646 | 可前往[QuerySendDetails](https://help.aliyun.com/document_detail/55289.html)查看更加详细的参数说明。
|
647 |
|
648 | ## 辅助工具 Util
|
649 | ### 通用 Generic
|
650 | #### 通用接口
|
651 | * API声明
|
652 |
|
653 | execute(method: string, params: object)
|
654 |
|
655 | * 入参说明
|
656 |
|
657 | | 字段名 | 类型 | 必填 | 说明 |
|
658 | |------|--------|----|----|
|
659 | | method | string | 是 | API接口名称,例如:alipay.trade.create |
|
660 | | params | object | 是 | 被包装在biz_content下的请求参数集合,例如:{ url_param: 'pages/cloud/cloud', query_param: 'key=value', describe: '我是二维码描述'} |
|
661 |
|
662 | * 出参说明
|
663 |
|
664 | | 字段名 | 类型 | 必填 | 说明 |
|
665 | |------|--------|----|----|
|
666 | | code | string | 是 | [网关返回码](https://docs.open.alipay.com/common/105806) |
|
667 | | msg | string | 是 | [网关返回码描述](https://docs.open.alipay.com/common/105806) |
|
668 | | subCode | string | 否 | 业务返回码,参见具体的API接口文档 |
|
669 | | subMsg | string | 否 | 业务返回码描述,参见具体的API接口文档 |
|