开发者社区
社区提问意见反馈
开发者钉组织
扫描二维码
加入支付宝开发者钉组织
文档中心
开发文档(v3版) 
支付
当面付
app 支付
接入指南
api 列表
交易
账单
相关资料
手机网站支付
电脑网站支付
商家扣款
刷脸付
预授权支付
jsapi 支付
私域
公域
营销
资金
会员
信用
安全
广告
小程序云
其他
api文档 >  >  >  >  > app支付接口2.0接口
收藏
订阅更新
我的文档
设置

接口说明

该接口是 签名数据准备接口,用于生成可信签名字符串(orderstr)。可信签名串中包含业务参数及商户身份信息,可防止数据被篡改,一般用于打开支付宝客户端。请在服务端执行支付宝sdk中sdkexecute方法,读取响应中的body()结果。具体使用方法请参考
外部商户app唤起快捷sdk创建订单并支付

公共请求参数

参数类型是否必选最大长度描述示例值
app_idstring必选32
支付宝分配给开发者的应用id
2014072300007148
methodstring必选128
接口名称
alipay.trade.app.pay
formatstring可选40
仅支持json
json
charsetstring必选10
请求使用的编码格式,如utf-8,gbk,gb2312等
utf-8
sign_typestring必选10
商户生成签名字符串所使用的签名算法类型,目前支持rsa2和rsa,推荐使用rsa2
rsa2
signstring必选344
商户请求参数的签名串,详见签名
详见示例
timestampstring必选19
发送请求的时间,格式"yyyy-mm-dd hh:mm:ss"
2014-07-24 03:07:50
versionstring必选3
调用的接口版本,固定为:1.0
1.0
notify_urlstring可选256
支付宝服务器主动通知商户服务器里指定的页面http/https路径。
http://api.test.alipay.net/atinterface/receive_notify.htm
app_auth_tokenstring可选40
biz_contentstring必选
请求参数的集合,最大长度不限,除公共参数外所有请求参数都必须放在这个参数中传递,具体参照各产品快速接入文档

业务请求参数

out_trade_no必选string(64)
【描述】商户网站唯一订单号。
由商家自定义,64个字符以内,仅支持字母、数字、下划线且需保证在商户端不重复。
【示例值】70501111111s001111119
total_amount必选string(9)
【描述】订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000],金额不能为0
【示例值】9.00
subject必选string(256)
【描述】订单标题。
注意:不可使用特殊字符,如 /,=,& 等。
【示例值】大乐透
notify_url|通知地址可选string(1024)
【描述】支付宝服务器主动通知商户服务器里指定的页面http/https路径。在body参数中传递
【示例值】http://api.test.alipay.net/atinterface/receive_notify.htm
product_code可选string(64)
【描述】销售产品码,商家和支付宝签约的产品码
【示例值】quick_msecurity_pay
goods_detail可选goodsdetail[]
【描述】订单包含的商品列表信息,json格式,其它说明详见商品明细说明
goods_id必选string(64)
【描述】商品的编号
【示例值】apple-01
goods_name必选string(256)
【描述】商品名称
【示例值】ipad
quantity必选number(32)
【描述】商品数量
【示例值】1
price必选price(9)
【描述】商品单价,单位为元
【示例值】2000
alipay_goods_id可选string(32)
【描述】支付宝定义的统一商品编号
【示例值】20010001
goods_category可选string(24)
【描述】商品类目
【示例值】34543238
categories_tree可选string(128)
【描述】商品类目树,从商品类目根节点到叶子节点的类目id组成,类目id值使用|分割
【示例值】124868003|126232002|126252004
show_url可选string(400)
【描述】商品的展示地址
【示例值】http://www.alipay.com/xxx.jpg
time_expire可选string(32)
【描述】绝对超时时间,格式为yyyy-mm-dd hh:mm:ss
【示例值】2016-12-31 10:05:00
extend_params可选extendparams
【描述】业务扩展参数
sys_service_provider_id可选string(64)
【描述】系统商编号
该参数作为系统商返佣数据提取的依据,请填写系统商签约协议的pid
【示例值】2088511833207846
hb_fq_num可选string(5)
【描述】使用花呗分期要进行的分期数
【示例值】3
hb_fq_seller_percent可选string(3)
【描述】使用花呗分期需要卖家承担的手续费比例的百分值,传入100代表100%
【示例值】100
industry_reflux_info可选string(512)
【描述】行业数据回流信息, 详见:地铁支付接口参数补充说明
【示例值】{\"scene_code\":\"metro_tradeorder\",\"channel\":\"xxxx\",\"scene_data\":{\"asset_name\":\"alipay\"}}
specified_seller_name可选string(32)
【描述】特殊场景下,允许商户指定交易展示的卖家名称
【示例值】xxx的跨境小铺
card_type可选string(64)
【描述】卡类型
【枚举值】
s0jp0000: s0jp0000
【示例值】s0jp0000
royalty_freeze可选string(16)
【描述】是否进行资金冻结,用于后续分账,true表示资金冻结,false或不传表示资金不冻结
【示例值】true
passback_params可选string(512)
【描述】公用回传参数,如果请求时传递了该参数,则返回给商户时会回传该参数。支付宝只会在同步返回(包括跳转回商户网站)和异步通知时将该参数原样返回。本参数必须进行urlencode之后才可以发送给支付宝。
【示例值】merchantbiztype=3c&merchantbizno=2016010101111
merchant_order_no可选string(32)
【描述】商户原始订单号,最大长度限制32位
【示例值】20161008001
ext_user_info可选extuserinfo
【描述】外部指定买家
cert_no可选string(64)
【描述】买家证件号。
注:need_check_info=t时该参数才有效,支付宝会比较买家在支付宝留存的证件号码与该参数传入的值是否匹配。
【示例值】362334768769238881
min_age可选string(3)
【描述】允许的最小买家年龄。
买家年龄必须大于等于所传数值
注:
1. need_check_info=t时该参数才有效
2. min_age为整数,必须大于等于0
【示例值】18
name可选string(16)
【描述】指定买家姓名。
注: need_check_info=t时该参数才有效
【示例值】李明
mobile可选string(20)
【描述】指定买家手机号。
注:该参数暂不校验
【示例值】16587658765
cert_type可选string(128)
【描述】指定买家证件类型。
枚举值:
identity_card:身份证;
passport:护照;
officer_card:军官证;
soldier_card:士兵证;
hokou:户口本; permanent_residence_foreigner:外国人永久居留身份证。 如有其它类型需要支持,请与支付宝工作人员联系。
注: need_check_info=t时该参数才有效,支付宝会比较买家在支付宝留存的证件类型与该参数传入的值是否匹配。
【枚举值】
identity_card: identity_card
passport: passport
officer_card: officer_card
【示例值】identity_card
need_check_info可选string(1)
【描述】是否强制校验买家信息;
需要强制校验传:t;
不需要强制校验传:f或者不传;
当传t时,支付宝会校验支付买家的信息与接口上传递的cert_type、cert_no、name或age是否匹配,只有接口传递了信息才会进行对应项的校验;只要有任何一项信息校验不匹配交易都会失败。如果传递了need_check_info,但是没有传任何校验项,则不进行任何校验。
默认为不校验。
【示例值】f
identity_hash可选string(128)
【描述】买家加密身份信息。当指定了此参数且指定need_check_info=t时,支付宝会对买家身份进行校验,校验逻辑为买家姓名、买家证件号拼接后的字符串,以sha256算法utf-8编码计算hash,若与传入的值不匹配则会拦截本次支付。注意:如果同时指定了用户明文身份信息(name,cert_type,cert_no中任意一个),则忽略identity_hash以明文参数校验。
【示例值】27bfcd1dee4f22c8fe8a2374af9b660419d1361b1c207e9b41a754a113f38fcc
query_options可选string[](256)
【描述】返回参数选项。 商户通过传递该参数来定制同步需要额外返回的信息字段,数组格式。包括但不限于:["hyb_amount","enterprise_pay_info"]
【枚举值】
惠营宝回票金额: hyb_amount
因公付支付信息: enterprise_pay_info
医保信息: medical_insurance_info
【示例值】["hyb_amount","enterprise_pay_info"]
常见请求示例
package com.java.sdk.demo;
import com.alipay.v3.apiclient;
import com.alipay.v3.apiexception;
import com.alipay.v3.apiresponse;
import com.alipay.v3.configuration;
import com.alipay.v3.util.genericexecuteapi;
import com.alipay.v3.util.model.alipayconfig;
import com.alipay.v3.util.model.customizedparams;
import com.alipay.v3.util.model.openapigenericrequest;
import java.io.file;
import java.util.arraylist;
import java.util.hashmap;
import java.util.list;
import java.util.map;
public class genericexecute {
    public static void main(string[] args) throws apiexception {
        apiclient defaultclient = configuration.getdefaultapiclient();
        // 初始化alipay参数(全局设置一次)
        defaultclient.setalipayconfig(getalipayconfig());
        genericexecuteapi api = new genericexecuteapi();
        // 构造请求参数以调用接口
        map<string, object> bizparams = new hashmap<>();
        map<string, object> bizcontent = new hashmap<>();
        
        // 设置商户订单号
        bizcontent.put("out_trade_no", "70501111111s001111119");
        
        // 设置订单总金额
        bizcontent.put("total_amount", "9.00");
        
        // 设置订单标题
        bizcontent.put("subject", "大乐透");
        
        // 设置产品码
        bizcontent.put("product_code", "quick_msecurity_pay");
        
        // 设置订单附加信息
        bizcontent.put("body", "iphone6 16g");
        
        // 设置订单包含的商品列表信息
        list<map<string, object>> goodsdetail = new arraylist<>();
        map<string, object> goodsdetail0 = new hashmap<>();
        goodsdetail0.put("out_sku_id", "outsku_01");
        goodsdetail0.put("goods_name", "ipad");
        goodsdetail0.put("alipay_goods_id", "20010001");
        goodsdetail0.put("quantity", 1);
        goodsdetail0.put("price", "2000");
        goodsdetail0.put("out_item_id", "outitem_01");
        goodsdetail0.put("goods_id", "apple-01");
        goodsdetail0.put("goods_category", "34543238");
        goodsdetail0.put("categories_tree", "124868003|126232002|126252004");
        goodsdetail0.put("show_url", "http://www.alipay.com/xxx.jpg");
        goodsdetail.add(goodsdetail0);
        bizcontent.put("goods_detail", goodsdetail);
        
        // 设置订单绝对超时时间
        bizcontent.put("time_expire", "2016-12-31 10:05:00");
        
        // 设置建议使用time_expire字段
        bizcontent.put("timeout_express", "90m");
        
        // 设置业务扩展参数
        map<string, object> extendparams = new hashmap<>();
        extendparams.put("sys_service_provider_id", "2088511833207846");
        extendparams.put("hb_fq_seller_percent", "100");
        extendparams.put("hb_fq_num", "3");
        extendparams.put("tc_installment_order_id", "2015042321001004720200028594");
        extendparams.put("industry_reflux_info", "{\"scene_code\":\"metro_tradeorder\",\"channel\":\"xxxx\",\"scene_data\":{\"asset_name\":\"alipay\"}}");
        extendparams.put("specified_seller_name", "xxx的跨境小铺");
        extendparams.put("royalty_freeze", "true");
        extendparams.put("card_type", "s0jp0000");
        extendparams.put("credit_ext_info", "{\"category\":\"charge_pile_car\",\"serviceid\":\"2020042800000000000001450466\"}");
        extendparams.put("trade_component_order_id", "2023060801502300000008810000005657");
        bizcontent.put("extend_params", extendparams);
        
        // 设置公用回传参数
        bizcontent.put("passback_params", "merchantbiztype=3c&merchantbizno=2016010101111");
        
        // 设置签约参数
        map<string, object> agreementsignparams = new hashmap<>();
        map<string, object> submerchant = new hashmap<>();
        submerchant.put("sub_merchant_name", "滴滴出行");
        submerchant.put("sub_merchant_service_name", "滴滴出行免密支付");
        submerchant.put("sub_merchant_service_description", "免密付车费,单次最高500");
        submerchant.put("sub_merchant_id", "2088123412341234");
        agreementsignparams.put("sub_merchant", submerchant);
        map<string, object> accessparams = new hashmap<>();
        accessparams.put("channel", "alipayapp");
        agreementsignparams.put("access_params", accessparams);
        map<string, object> periodruleparams = new hashmap<>();
        periodruleparams.put("period", 3);
        periodruleparams.put("total_amount", "600");
        periodruleparams.put("execute_time", "2019-01-23");
        periodruleparams.put("single_amount", "10.99");
        periodruleparams.put("total_payments", 12);
        periodruleparams.put("period_type", "day");
        agreementsignparams.put("period_rule_params", periodruleparams);
        agreementsignparams.put("sign_notify_url", "http://www.merchant.com/receivesignnotify");
        list<map<string, object>> recommendsortchannelparams = new arraylist<>();
        map<string, object> recommendsortchannelparams0 = new hashmap<>();
        recommendsortchannelparams0.put("asset_type_code", "alicredit");
        recommendsortchannelparams0.put("inst_id", "inst_alipay");
        recommendsortchannelparams.add(recommendsortchannelparams0);
        agreementsignparams.put("recommend_sort_channel_params", recommendsortchannelparams);
        agreementsignparams.put("external_logon_id", "13888888888");
        agreementsignparams.put("personal_product_code", "cycle_pay_auth_p");
        agreementsignparams.put("external_agreement_no", "test20190701");
        agreementsignparams.put("product_code", "general_withholding");
        agreementsignparams.put("sign_scene", "industry|digital_media");
        agreementsignparams.put("effect_time", "600");
        bizcontent.put("agreement_sign_params", agreementsignparams);
        
        // 设置指定支付渠道
        bizcontent.put("enable_pay_channels", "pcredit,moneyfund,debitcardexpress");
        
        // 设置指定单通道
        bizcontent.put("specified_channel", "pcredit");
        
        // 设置禁用渠道
        bizcontent.put("disable_pay_channels", "pcredit,moneyfund,debitcardexpress");
        
        // 设置商户的原始订单号
        bizcontent.put("merchant_order_no", "20161008001");
        
        // 设置外部指定买家
        map<string, object> extuserinfo = new hashmap<>();
        extuserinfo.put("cert_type", "identity_card");
        extuserinfo.put("cert_no", "362334768769238881");
        extuserinfo.put("name", "李明");
        extuserinfo.put("mobile", "16587658765");
        extuserinfo.put("min_age", "18");
        extuserinfo.put("need_check_info", "f");
        extuserinfo.put("identity_hash", "27bfcd1dee4f22c8fe8a2374af9b660419d1361b1c207e9b41a754a113f38fcc");
        bizcontent.put("ext_user_info", extuserinfo);
        
        // 设置通知参数选项
        list<string> queryoptions = new arraylist<>();
        queryoptions.add("hyb_amount");
        queryoptions.add("enterprise_pay_info");
        bizcontent.put("query_options", queryoptions);
        
        bizparams.put("biz_content", bizcontent);
        try {
            // 如果是第三方代调用模式,请设置app_auth_token(应用授权令牌)
            string orderstr = api.sdkexecute("alipay.trade.app.pay", bizparams, null, "<-- 请填写应用授权令牌 -->", null);
            system.out.println(orderstr);
        } catch (apiexception e) {
            system.out.println("调用失败");
        }
    }
    private static alipayconfig getalipayconfig() {
        alipayconfig alipayconfig = new alipayconfig();
        alipayconfig.setserverurl("https://openapi.alipay.com");
        alipayconfig.setappid("<-- 请填写您的appid,例如:2019091767145019 -->");
        alipayconfig.setprivatekey("<-- 请填写您的应用私钥,例如:miievqibadanb ... ... -->");
        alipayconfig.setalipaypublickey("<-- 请填写您的支付宝公钥,例如:miibijanbg... -->");
        return alipayconfig;
    }
}
说明:本示例仅供参考。

公共响应参数

无公共响应参数

业务响应参数

orderstr|签名字符串必选string(16384)
【描述】获取签名后的业务数据具体使用方法请参考 接入指南
【示例值】请参考响应示例
响应示例
app_id=2017060101317939&biz_content={"time_expire%22:%222016-12-31 10:05:00%22,"extend_params%22:%22%22,"query_options%22:%22[\"hyb_amount\%22,\"enterprise_pay_info\%22]%22,"subject%22:%22大�%90�%80�%22,"product_code%22:"quick_msecurity_pay%22,"body%22:"iphone6 16g%22,"passback_params%22:"merchantbiztype%3d3c%26merchantbizno%3d2016010101111%22,"specified_channel%22:"pcredit%22,"goods_detail%22:%22%22,"merchant_order_no%22:%2220161008001%22,"enable_pay_channels%22:"pcredit,moneyfund,debitcardexpress%22,"out_trade_no%22:"70501111111s001111119%22,"ext_user_info%22:%22%22,"total_amount%22:%229.00%22,"timeout_express%22:"90m%22,"disable_pay_channels%22:"pcredit,moneyfund,debitcardexpress%22,"agreement_sign_params%22:%22%22}&charset=utf-8&format=json&method=alipay.trade.app.pay&sign=eritjkeijkjhkkkkkkkhjereeeeeeeeeee&sign_type=rsa2×tamp=2014-07-24 03:07:50&version=1.0
说明:本示例仅供参考。

公共错误码

业务错误码

错误码错误描述凯发app官方网站的解决方案
acq.access_forbidden无权限使用接口
联系支付宝小二签约
acq.buyer_enable_status_forbid买家状态非法
用户联系支付宝小二,确认买家状态为什么非法
acq.buyer_seller_equal买卖家不能相同
更换买家重新付款
acq.context_inconsistent交易信息被篡改
确认该笔交易信息是否为当前买家的已存订单,如果是则认为本次请求参数与已存交易不一致,如果不是则更换商家订单号后,重新发起请求
acq.exist_forbidden_word订单信息中包含违禁词
修改订单信息后,重新发起请求
acq.invalid_parameter参数无效
若存在参数无效具体错误信息描述,请参考描述检查请求参数后,重新发起
acq.partner_error应用app_id填写错误
联系支付宝小二,确认app_id的状态
acq.risk_merchant_ip_not_exist当前交易未传入ip信息,创单失败,请传入ip后再发起支付
检查请求参数是否已经传入用户ip信息
acq.seller_been_blocked商家账号被冻结
联系支付宝小二,解冻账号
acq.system_error接口返回错误
请立即调用查询订单api,查询当前订单的状态,并根据订单状态决定下一步的操作
acq.total_fee_exceed订单总金额不在允许范围内
修改订单金额再发起请求
acq.trade_buyer_not_match交易买家不匹配
该笔交易已经在支付宝端创建,但请求买家与已存交易中的买家不一致。请商户确认本次请求是否与已存交易有关,若为同一笔交易,则只能用原始买家付款,若无关更换商家订单号后,重新发起请求
acq.trade_has_close交易已经关闭
确认该笔交易信息是否为当前买家的已存订单,如果是则认为交易已经关闭,如果不是则更换商家订单号后,重新发起请求
acq.trade_has_success交易已被支付
确认该笔交易信息是否为当前买家的,如果是则认为交易付款成功,如果不是则更换商家订单号后,重新发起请求

触发通知类型

通知类型描述默认开启
tradestatus.trade_closed交易关闭1
tradestatus.trade_finished交易完结1
tradestatus.trade_success支付成功1
tradestatus.wait_buyer_pay交易创建0

触发通知示例

https://www.merchant.com/receive_notify.htm?notify_type=trade_status_sync¬ify_id=91722adff935e8cfa58b3aabf4dead6ibe¬ify_time=2017-02-16 21:46:15&sign_type=rsa2&sign=wco t3d8kg71dtlkwn7r9pzuoxeabjwp8/fousxcuskxsovyxbpsaidpryscjhcjmaglncjokjqlj28/asl93jotw39fx6i07lxhnbpknezalwmvpdnqui01hzszf9v1i6ggzjbiad5lg8bzttxzoj87ub2i9guj3nr/nuc9vey=&out_channel_type=null&merchant_app_id=2088102146225135&buyer_open_id=074a1cctg1lelxke4xqc0zgndid0nxi95b5lsnpazwyoco5&trade_no=null&app_id=null&out_trade_no=null&seller_id=null&trade_status=null&total_amount=null&refund_fee=null&subject=null&body=null&gmt_create=null&gmt_payment=null&gmt_refund=null&gmt_close=null&buyer_id=null&fund_bill_list=[{"amount":"50.00","fundchannel":"alipayaccount"}]&receipt_amount=null&invoice_amount=null&buyer_pay_amount=null&point_amount=null&voucher_detail_list=null&buyer_logon_id=null&seller_email=null&out_biz_no=null&passback_params=null¬ify_action_type=paybyaccountaction/closetradeaction/reverseaction/finishfpaction/confirmdisburseaction/financingreceiptaction¤t_seller_received_amount=88.88&seller_received_total_amount=88.88&total_from_seller_fee=88.88&ff_current_period=1&discount_amount=88.88&charge_amount=8.88&charge_flags=bluesea_1&settlement_id=2018101610032004620239146945&industry_sepc_detail={"registration_order_pay":{"brlx":"1","cblx":"1"}}&industry_sepc_detail_acc={"registration_order_pay":{"brlx":"1","cblx":"1"}}&industry_sepc_detail_gov={"registration_order_pay":{"brlx":"1","cblx":"1"}}&discount_goods_detail="[{\"goodsid\":\"standard1026181538\",\"goodsname\":\"雪碧\",\"discountamount\":\"10.00\"}]"&mdiscount_amount=88.88&hb_fq_pay_info={"user_install_num":"3"}&receipt_currency_type=dc&enterprise_pay_info={"invoice_amount":"28.00","is_use_enterprise_pay":"true"}&hyb_amount=10.24&charge_info_list=[{"charge_fee":"0.01","original_charge_fee":"0.02","switch_fee_rate":"0.03","is_rating_on_trade_receiver":"y","is_rating_on_switch":"y"}]&medical_insurance_info={"medicarecardtype":"1","medicarecardholderhiddenname":"**专"}&credit_pay_mode=creditadvancev2&buyer_charge_amt=1.00&fulfillment_amount=10.24&cashier_type=app
内容没有解决您的问题?您还可以前往 或 寻求帮助
凯发k8官方网娱乐官方 copyright © 2022 支付宝(杭州)信息技术有限公司  | icp证浙b2-20160559
该文档对你是否有帮助?
当前页面目录
网站地图