### Message example for ant.merchant.expand.shop.save.rejected Source: https://opendocs.alipay.com/open/03s3jn Example of the message sent when a shop creation is rejected. The biz_content contains the order_id, reason, shop_id, shop_name, biz_source, msg_type, out_biz_no, and store_id. The message includes the required public parameters and signature. ```plaintext ISV_GATEWAY_URL?charset=GBK&biz_content= { "order_id":"2018011900502000000005124744", "reason":"资料有问题,拒绝", "shop_id":"2020081400077000000001112602", "shop_name":"支付宝(西溪路店)", "biz_source":"APLUS_SHOP", "msg_type":"SHOP_SETTLE_AUDIT", "out_biz_no":"0001119901210328000565010000", "store_id":"NO0001" } &msg_method=ant.merchant.expand.shop.save.rejected&utc_timestamp=1516797622752&version=1.1&sign_type=RSA2¬ify_id=d275fec564e62af6bedbcee73f3f05fi5x&app_id=2013121700999429&sign=I+Y/lvqYUEEc10EPdpntRhFIQ== ``` -------------------------------- ### Alipay Eco Edu Kt Billing Modify Response Example Source: https://opendocs.alipay.com/open/02auyv Shown as the response example for the billing modification API. The source labels it as a normal example and notes that it is for reference only. ```json { "alipay_eco_edu_kt_billing_modify_response": { "code": "10000", "msg": "Success", "status": "Y" }, "sign": "ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE" } ``` -------------------------------- ### API Response Example Source: https://opendocs.alipay.com/open/02awe4 A standard JSON response structure for a successful historical balance query, including the beginning and ending balance fields. ```JSON { "alipay_data_bill_balancehis_query_response": { "code": "10000", "msg": "Success", "beginning_balance": "10000.00", "ending_balance": "11000.00" }, "sign": "ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE" } ``` -------------------------------- ### alipay.marketing.activity.query Source: https://opendocs.alipay.com/open/5a8350e0_alipay.marketing.activity.query Queries the details of a marketing activity, including voucher configuration and rules. The response contains activity basic info, voucher send mode, deduction info, use rules, display pattern, available scope, and customer guide details. ```APIDOC ## alipay.marketing.activity.query ### Description Queries the details of a marketing activity, including voucher configuration and rules. The response contains activity basic info, voucher send mode, deduction info, use rules, display pattern, available scope, and customer guide details. ### Response Parameters #### activity_base_info (ActivityBaseInfo) - Required Activity basic information. #### voucher_send_mode_info (VoucherSendModeInfo) - Required Voucher send mode information. #### voucher_deduct_info (VoucherDeductInfo) - Required Voucher deduction information. #### voucher_use_rule_info (VoucherUseRuleInfo) - Required Voucher use rule information. #### voucher_display_pattern_info (VoucherDisplayPatternInfo) - Required Voucher display information. #### voucher_available_scope_info (VoucherAvailableScopeInfo) - Optional Available scope information. #### voucher_customer_guide_info (VoucherCustomerGuideInfo) - Optional Customer guide details. ### Response Example ```json { "alipay_marketing_activity_query_response": { "code": "10000", "msg": "Success", "activity_base_info": { "activity_id": "2016042700826004508401111111", "belong_merchant_info": { "merchant_id": "2088102111111111" }, "activity_status": "ACTIVE" }, "voucher_send_mode_info": { "voucher_send_mode": "DIRECT_SEND_MODE", "voucher_sale_mode_info": { "sale_amount": "50.00", "refundable": false, "overdue_refundable": false }, "voucher_package_mode_info": { "voucher_package_id": "IP20220628016671405804297103167741" }, "voucher_send_rule_info": { "quantity": 100, "max_quantity_by_day": 10, "quantity_limit_per_user": 100, "quantity_limit_per_user_period_type": "LIFE_CYCLE", "natural_person_limit": false, "phone_number_limit": false, "real_name_limit": false, "publish_start_time": "2017-01-01 00:00:01", "publish_end_time": "2017-01-29 23:59:59" } }, "voucher_deduct_info": { "voucher_type": "FIX_VOUCHER", "fix_voucher_info": { "amount": "50.00" } } } } ``` ### Detailed Response Fields #### end_time_type (string) - Required End time type. Enum values: SAME_DAY (当日), NEXT_DAY (次日). Example: NEXT_DAY. #### end_time (string) - Required End time in HH:mm:ss format. Example: 23:59:59. #### holiday_rule_info (HolidayRuleInfo) - Optional (required when ruleType = HOLIDAY) Holiday rule information. #### time_range_info (TimeRangeInfo) - Required Time range information. #### begin_time (string) - Required Start time in HH:mm:ss format. Example: 00:00:00. #### end_time_info (EndTimeInfo) - Required End time information, can be set to end on the same day or next day. Example: 22:00~次日07:00. #### voucher_max_use_times (number) - Optional Maximum number of times a voucher can be used. Example: 1. #### voucher_display_pattern_info (VoucherDisplayPatternInfo) - Required Voucher display information. #### brand_name (string) - Required Merchant brand name. If not set, default alias from Alipay merchant system is used. If no alias, default name "商家优惠" is used. Required for ISV mode (belong_merchant_info.business_type = ISV). Example: 商家优惠. #### brand_logo_url (string) - Required Merchant brand logo URL. Example: https://gw.alipayobjects.com/mdn/rms_9822d7/afts/img/A*1F4eSaaPHRQAAAAAAAAAAABkARQnAQ. #### voucher_name (string) - Required Voucher name displayed to consumers. Required for exchange vouchers. Example: 满10减1券. #### voucher_description (string) - Required Detailed usage instructions for the voucher. Example: 1、本券不可兑换现金,不可找零。2、每个用户最多可以领取1张。3、如果订单发生退款,优惠券无法退还。 #### customer_service_mobile (string) - Optional (one of customer_service_mobile or customer_service_url required) Customer service phone number. Example: 81XXXXXXX. #### customer_service_url (string) - Optional (one of customer_service_mobile or customer_service_url required) Customer service link. Example: alipay://xxxx. #### voucher_image_url (string) - Optional Voucher cover image URL. Example: https://gw.alipayobjects.com/mdn/rms_9822d7/afts/img/A*1F4eSaaPHRQAAAAAAAAAAABkARQnAQ. #### voucher_detail_image_urls (string[]) - Optional Voucher detail image URLs. Example: ["https://gw.alipayobjects.com/mdn/rms_9822d7/afts/img/A*1F4eSaaPHRQAAAAAAAAAAABkARQnAQ"]. #### voucher_available_scope_info (VoucherAvailableScopeInfo) - Optional Available scope information. #### voucher_available_goods_info (VoucherAvailableGoodsInfo) - Optional Available goods information. #### goods_name (string) - Optional Goods name. Required for exchange and special price vouchers. Example: 美味甜甜圈. #### goods_description (string) - Optional Goods description. Example: 美味甜甜圈很美味. #### origin_amount (price) - Optional Original price. Required for special price vouchers. Example: 100.00. #### voucher_customer_guide_info (VoucherCustomerGuideInfo) - Optional Customer guide details. #### voucher_use_guide_info (VoucherUseGuideInfo) - Optional Voucher use guide details. #### use_guide_mode (string[]) - Optional Use guide mode. Enum values: OFFLINE_CODE (券码扫码核销), MINI_APP (小程序线上核销), SCAN_CODE (跳转付款码支付核销). Example: ["MINI_APP"]. #### mini_app_use_guide_info (VoucherMiniAppUseGuideInfo) - Optional Mini app use guide information. #### mini_app_url (string) - Optional (one of mini_app_url or mini_app_service_codes required) Specific page path when jumping to mini_app_id. Example: alipays://platformapi/startapp?appId=xxxx. #### mini_app_service_codes (string[]) - Optional (one of mini_app_url or mini_app_service_codes required) Mini app service codes. Obtained from alipay.open.app.service.apply API. Example: ["2020030921000303380758"]. ``` -------------------------------- ### cURL Request for alipay.data.bill.balancehis.query Source: https://opendocs.alipay.com/open/02awe4 A cURL example demonstrating how to call the historical balance query API. Note that the sign and appid parameters must be replaced with your actual credentials. ```cURL curl 'https://openapi.alipay.com/gateway.do?charset=UTF-8&method=alipay.data.bill.balancehis.query&format=json&sign=${sign}&app_id=${appid}&version=1.0&sign_type=RSA2×tamp=${now}' \ -F 'biz_content={ "biz_date":"2019-08-01", "biz_month":"2019-08" }' ``` -------------------------------- ### Initialize AlipayClient with public key certificate mode (Java) Source: https://opendocs.alipay.com/open/009yp8 Initializes the AlipayClient for the public key certificate signing mode. Set the certificate paths and other required parameters, then use certificateExecute to submit data to Alipay. This mode requires the additional JAR packages bcprov-jdk15on, commons-logging, and fastjson. ```java CertAlipayRequest certAlipayRequest = new CertAlipayRequest (); certAlipayRequest.setServerUrl(URL); certAlipayRequest.setAppId(APPID); certAlipayRequest.setPrivateKey(APP_PRIVATE_KEY); certAlipayRequest.setFormat("JSON"); certAlipayRequest.setCharset(CHARSET); certAlipayRequest.setSignType(SIGN_TYPE); certAlipayRequest.setCertPath(app_cert_pathAPP_CERT_PATH); certAlipayRequest.setAlipayPublicCertPath(alipay_cert_path); certAlipayRequest.setRootCertPath(alipay_root_cert_path ); DefaultAlipayClient alipayClient = new DefaultAlipayClient(certAlipayRequest); // 提交数据至支付宝时请使用 alipayClient.certificateExecute(request); ``` -------------------------------- ### 普通公钥模式调用 alipay.trade.precreate Source: https://opendocs.alipay.com/open/009yp8 使用普通公钥模式调用支付宝预下单接口 alipay.trade.precreate。需要先初始化 AlipayClient,传入网关地址、应用ID、应用私钥、格式、字符集、支付宝公钥和签名类型 RSA2。创建 AlipayTradePrecreateRequest 并设置业务参数,然后通过 alipayClient.execute(request) 同步获取响应。 ```java // 获得初始化的AlipayClient AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",APP_ID,APP_PRIVATE_KEY,"json",CHARSET,ALIPAY_PUBLIC_KEY,"RSA2"); // 创建API对应的request类 AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest (); request.setBizContent ("{" + "\"out_trade_no\":\"20150320010101002\"," + //商户订单号 "\"total_amount\":\"88.88\"," + "\"subject\":\"Iphone6 16G\"," + "\"store_id\":\"NJ_001\"," + "\"timeout_express\":\"90m\"}" ); //订单允许的最晚付款时间 AlipayTradePrecreateResponse response = alipayClient.execute( request ); System.out.print(response.getBody()); // 根据response中的结果继续业务逻辑处理 ``` -------------------------------- ### cURL 请求示例:alipay.iservice.ccm.sw.tree.create Source: https://opendocs.alipay.com/open/df029ced_alipay.iservice.ccm.sw.tree.create 调用 alipay.iservice.ccm.sw.tree.create 接口创建知识库类目的 cURL 请求示例。请求参数通过 biz_content 传递,包含 ccs_instance_id 和 name。示例仅供参考。 ```bash curl 'https://openapi.alipay.com/gateway.do?charset=UTF-8&method=alipay.iservice.ccm.sw.tree.create&format=json&sign=${sign}&app_id=${appid}&version=1.0&sign_type=RSA2×tamp=${now}' \ -F 'app_auth_token=${app_auth_token}' \ -F 'biz_content={ "ccs_instance_id":"ZPNASDK", "name":"蚂蚁科技" }' ``` -------------------------------- ### Initialize AlipayClient with normal public key mode (Java) Source: https://opendocs.alipay.com/open/009yp8 Initializes the AlipayClient object for the normal public key signing mode. Configure the required parameters such as server URL, APPID, private key, format, charset, Alipay public key, and sign type before constructing the client. The client can be reused for multiple API calls. ```java AlipayConfig alipayConfig = new AlipayConfig(); alipayConfig.setServerUrl(URL); alipayConfig.setAppId(APP_ID); alipayConfig.setPrivateKey(PRIVATE_KEY); alipayConfig.setFormat("json"); alipayConfig.setCharset(CHARSET); alipayConfig.setAlipayPublicKey(ALIPAY_PUBLIC_KEY); alipayConfig.setSignType(SIGN_TYPE); //构造client AlipayClient alipayClient = new DefaultAlipayClient(alipayConfig); ``` -------------------------------- ### ant.merchant.expand.shop.save.rejected(门店保存拒绝消息) Source: https://opendocs.alipay.com/open/03s3jn 该接口用于在 ant.merchant.expand.shop.create 中创建商户时,如果创建被拒绝,通过此接口返回拒绝结果。 ```APIDOC ## ant.merchant.expand.shop.save.rejected(门店保存拒绝消息) ### Description 该接口用于在 ant.merchant.expand.shop.create 中创建商户时,如果创建被拒绝,通过此接口返回拒绝结果。 ### Method POST ### Endpoint ISV_GATEWAY_URL ### Parameters #### Query Parameters - **charset** (String) - Required - 编码集,该字符集为验签和解密所需要的字符集,示例值:GBK - **biz_content** (String) - Required - 消息报文,参见消息属性 - **msg_method** (String) - Required - 消息接口名称,示例值:ant.merchant.expand.shop.save.rejected - **utc_timestamp** (String) - Required - 消息发送时的服务端时间,示例值:1516797622752 - **version** (String) - Required - 版本号(1.1版本为标准消息),示例值:1.1 - **sign_type** (String) - Required - 签名类型,示例值:RSA2 - **notify_id** (String) - Required - 通知ID,示例值:d275fec564e62af6bedbcee73f3f05fi5x - **app_id** (String) - Required - 消息接受方的应用id,示例值:2013121700999429 - **sign** (String) - Required - 签名,示例值:I+Y/lvqYUEEc10EPdpntRhFIQ== #### Request Body - **order_id** (String) - Required - 申请单id,示例值:2018011900502000000005124744 - **reason** (String) - Required - 拒绝原因,示例值:资料有问题,拒绝 - **shop_id** (String) - Required - 支付宝侧门店id,门店创建成功后支付宝返回的门店 id,示例值:2020081400077000000001112602 - **shop_name** (String) - Required - 门店名称,示例值:支付宝(西溪路店) - **biz_source** (String) - Optional - 业务来源,团购门店:APLUS_SHOP,示例值:APLUS_SHOP - **msg_type** (String) - Optional - 消息类型,枚举值:门店结算审核: SHOP_SETTLE_AUDIT,示例值:SHOP_SETTLE_AUDIT - **out_biz_no** (String) - Optional - 外部业务号,前四位为约定的系统标识符,四位以后部分为外围传入的外部单号,示例值:0001119901210328000565010000 - **store_id** (String) - Optional - 商家侧门店编号,创建门店时由商家自定义传入的编号值,示例值:NO0001 ### Request Example ``` ISV_GATEWAY_URL?charset=GBK&biz_content= { "order_id":"2018011900502000000005124744", "reason":"资料有问题,拒绝", "shop_id":"2020081400077000000001112602", "shop_name":"支付宝(西溪路店)", "biz_source":"APLUS_SHOP", "msg_type":"SHOP_SETTLE_AUDIT", "out_biz_no":"0001119901210328000565010000", "store_id":"NO0001" } &msg_method=ant.merchant.expand.shop.save.rejected&utc_timestamp=1516797622752&version=1.1&sign_type=RSA2¬ify_id=d275fec564e62af6bedbcee73f3f05fi5x&app_id=2013121700999429&sign=I+Y/lvqYUEEc10EPdpntRhFIQ== ``` ### Response #### Success Response (200) - **响应值** (String) - 描述 - 是否重试 - **fail** (String) - 消息获取失败 - 是 - **success** (String) - 消息获取成功 - 否 #### Response Example ``` { "响应值": "success" } ``` ``` -------------------------------- ### 证书模式调用 alipay.trade.precreate Source: https://opendocs.alipay.com/open/009yp8 使用证书模式调用支付宝预下单接口 alipay.trade.precreate。需要先构造 CertAlipayRequest 并设置网关地址、应用ID、应用私钥、格式、字符集、签名类型以及三个证书路径,然后通过 DefaultAlipayClient 构造 AlipayClient。创建 AlipayTradePrecreateRequest 并设置业务参数,最后通过 alipayClient.certificateExecute(request) 同步获取响应。 ```java //构造client CertAlipayRequest certAlipayRequest = new CertAlipayRequest(); //设置网关地址 certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do"); //设置应用Id certAlipayRequest.setAppId(app_id); //设置应用私钥 certAlipayRequest.setPrivateKey(privateKey); //设置请求格式,固定值json certAlipayRequest.setFormat("json"); //设置字符集 certAlipayRequest.setCharset(charset); //设置签名类型 certAlipayRequest.setSignType(sign_type); //设置应用公钥证书路径 certAlipayRequest.setCertPath(app_cert_path); //设置支付宝公钥证书路径 certAlipayRequest.setAlipayPublicCertPath(alipay_cert_path); //设置支付宝根证书路径 certAlipayRequest.setRootCertPath(alipay_root_cert_path); //构造client AlipayClient alipayClient = new DefaultAlipayClient(certAlipayRequest); // 创建API对应的request类 AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest (); request.setBizContent ("{" + "\"out_trade_no\":\"20150320010101002\"," + //商户订单号 "\"total_amount\":\"88.88\"," + "\"subject\":\"Iphone6 16G\"," + "\"store_id\":\"NJ_001\"," + "\"timeout_express\":\"90m\"}" ); //订单允许的最晚付款时间 AlipayTradePrecreateResponse response = alipayClient.certificateExecute( request ); System.out.print(response.getBody()); // 根据response中的结果继续业务逻辑处理 ``` -------------------------------- ### zhima.merchant.zmgo.template.query(芝麻GO模板查询) Source: https://opendocs.alipay.com/open/04m8ci 查询芝麻GO模板的详细信息,包括基本信息、义务配置、权利配置、开通信息配置、结算信息配置、退出信息配置和拓展配置。支持第三方代理调用。 ```APIDOC ## zhima.merchant.zmgo.template.query(芝麻GO模板查询) ### Description 查询芝麻GO模板的详细信息,包括基本信息、义务配置、权利配置、开通信息配置、结算信息配置、退出信息配置和拓展配置。支持第三方代理调用。 ### Method POST ### Endpoint https://openapi.alipay.com/gateway.do ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **app_id** (String) - Required - 支付宝分配给开发者的应用ID - **method** (String) - Required - 接口名称,固定为 zhima.merchant.zmgo.template.query - **format** (String) - Optional - 仅支持JSON - **charset** (String) - Required - 请求使用的编码格式,如utf-8,gbk,gb2312等 - **sign_type** (String) - Required - 签名算法类型,目前支持RSA2和RSA,推荐使用RSA2 - **sign** (String) - Required - 商户请求参数的签名串 - **timestamp** (String) - Required - 发送请求的时间,格式"yyyy-MM-dd HH:mm:ss" - **version** (String) - Required - 调用的接口版本,固定为:1.0 - **app_auth_token** (String) - Optional - 详见应用授权概述 - **biz_content** (String) - Required - 请求参数的集合,最大长度不限,除公共参数外所有请求参数都必须放在这个参数中传递 #### biz_content 参数 - **template_no** (String) - Required - 模板ID,由创建模板接口返回结果提供 - **partner_id** (String) - Required - 商户ID ### Request Example ```json { "app_id": "2014072300007148", "method": "zhima.merchant.zmgo.template.query", "format": "JSON", "charset": "utf-8", "sign_type": "RSA2", "sign": "详见示例", "timestamp": "2014-07-24 03:07:50", "version": "1.0", "app_auth_token": "", "biz_content": { "template_no": "ZMGO_TPL2021061601004538", "partner_id": "208830****697946" } } ``` ### Response #### Success Response (200) - **code** (String) - 网关返回码 - **msg** (String) - 网关返回码描述 - **sub_code** (String) - 业务返回码 - **sub_msg** (String) - 业务返回码描述 - **sign** (String) - 签名 - **basic_config** (ZMGOBasicConfig) - 芝麻GO模板的基本信息 - **obligation_config** (ZMGOObligationConfig) - 芝麻GO模板义务配置 - **right_config** (ZMGORightConfig) - 芝麻GO模板的权利信息配置 - **open_config** (ZMGOOpenConfig) - 芝麻GO模板的开通信息配置 - **settlement_config** (ZMGOSettlementConfig) - 芝麻GO模板的结算信息配置 - **quit_config** (ZMGOQuitConfig) - 芝麻GO模板的退出信息配置 - **ext_config** (ZMGOExtConfig) - 芝麻GO模板拓展配置 #### Response Example ```json { "code": "10000", "msg": "Success", "sub_code": "", "sub_msg": "", "sign": "DZXh8eeTuAHoYE3w1J+POiPhfDxOYBfUNn1lkeT/V7P4zJdyojWEa6IZs6Hz0yDW5Cp/viufUb5I0/V5WENS3OYR8zRedqo6D+fUTdLHdc+EFyCkiQhBxIzgngPdPdfp1PIS7BdhhzrsZHbRqb7o4k3Dxc+AAnFauu4V6Zdwczo=", "basic_config": {}, "obligation_config": {}, "right_config": {}, "open_config": {}, "settlement_config": {}, "quit_config": {}, "ext_config": {} } ``` ### Error Codes #### Business Error Codes - **SYSTEM_ERROR** - 系统繁忙 - 需排查具体原因 - **INVALID_PARAMETER** - 参数有误,请根据提示,确认传参是否正确 - 请根据提示,确认传参是否正确 - **REQUEST_ACCESS_ILLEGAL** - 访问权限校验未通过 - 访问权限校验未通过,请联系小二开通权限 ``` -------------------------------- ### cURL 发送芝麻GO签约通知 Source: https://opendocs.alipay.com/open/03ums1 使用cURL发送POST请求到NOTIFY_URL,请求头为application/x-www-form-urlencoded,包含biz_content等参数。NOTIFY_URL是开发者在开放平台控制台上设置的应用网关地址。 ```bash curl -X POST 'NOTIFY_URL' \ --header 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \ --data-urlencode 'charset=UTF-8' \ --data-urlencode 'biz_content={ "original_price":"5.00", "total_periods":"6", "open_id":"074a1CcTG1LelxKe4xQC0zgNdId0nxi95b5lsNpazWYoCo5", "exemption_end_time":"2021-04-16 00:01:13", "cycle_withhold":"N", "type":"NORMAL", "exp_invalid_time":"2021-02-01 11:35:57", "partner_id":"2088101117755711", "planned_trigger_time":"2021-04-14 00:01:13", "zmgo_opt_no":"ZMGO_ORD2021012910020606010000042037", "agreement_status":"Y", "out_request_no":"63c0efbf3c62cf03ede783257ed66de8", "trans_status":"Y", "freeze_amount":"100.00", "product_version":"zhimaGoV2", "sign_aisle_data":"API", "actual_price":"1.00", "biz_type":"EASY_MEMBER", "alipay_user_id":"2088101117955611", "time_out_time":"2021-05-01 00:01:13", "withhold_plan_no":"ZMGO_WHD2021010910020603000000006002", "sign_time":"2021-01-29 11:35:59", "start_time":"2021-02-01 11:35:57", "agreement_desc":"星巴克免费券购物卡", "agreement_id":"ZMGO_AGR2021012910020604010000000001", "template_id":"2020122900020903940000948530" }' \ --data-urlencode 'utc_timestamp=${now}' \ --data-urlencode 'sign=${sign}' \ --data-urlencode 'app_id=${appid}' \ --data-urlencode 'version=1.1' \ --data-urlencode 'sign_type=RSA2' \ --data-urlencode 'notify_id=${notify_id}' \ --data-urlencode 'msg_method=zhima.credit.pe.zmgo.sign.notify' ``` -------------------------------- ### zhima.credit.payafteruse.creditbizorder.create Source: https://opendocs.alipay.com/open/05yu14 该接口用于生成可信签名字符串(orderStr),以唤起支付宝APP完成芝麻先享信用服务下单(用户确认场景)。需要在服务端调用支付宝SDK的sdkExecute方法,并读取响应中的body()结果。 ```APIDOC ## zhima.credit.payafteruse.creditbizorder.create ### Description 该接口用于生成可信签名字符串(orderStr),以唤起支付宝APP完成芝麻先享信用服务下单(用户确认场景)。需要在服务端调用支付宝SDK的sdkExecute方法,并读取响应中的body()结果。 ### Method POST ### Endpoint https://openapi.alipay.com/gateway.do ### Parameters #### 公共请求参数 - **app_id** (String) - 必选 - 支付宝分配给开发者的应用ID - **method** (String) - 必选 - 接口名称,固定为 zhima.credit.payafteruse.creditbizorder.create - **format** (String) - 可选 - 仅支持JSON - **charset** (String) - 必选 - 请求使用的编码格式,如utf-8,gbk,gb2312等 - **sign_type** (String) - 必选 - 签名算法类型,支持RSA2和RSA,推荐使用RSA2 - **sign** (String) - 必选 - 商户请求参数的签名串 - **timestamp** (String) - 必选 - 发送请求的时间,格式"yyyy-MM-dd HH:mm:ss" - **version** (String) - 必选 - 调用的接口版本,固定为:1.0 - **app_auth_token** (String) - 可选 - 应用授权令牌 - **biz_content** (String) - 必选 - 请求参数的集合,所有业务参数都放在此参数中传递 #### 业务请求参数(biz_content) - **out_order_no** (string) - 必选 - 商户外部订单号,保证不重复 - **zm_service_id** (string) - 必选 - 芝麻信用服务ID - **subject** (string) - 必选 - 订单标题,不可使用特殊字符,如 /,=,& 等 - **out_agreement_no** (string) - 可选 - 商户外部协议号,不传时默认使用out_order_no - **order_amount** (price) - 可选 - 订单金额,为当前订单扣款的累计最大额度 - **amount_type** (string) - 可选 - 金额类型,枚举值:ORDER_AMOUNT(后付金额)、RISK_AMOUNT(评估金额) - **category_id** (string) - 可选 - 芝麻外部类目,无差异化风控诉求可不传 - **product_code** (string) - 可选 - 产品码,不填默认为 CREDIT_PAY_AFTER_USE - **cancel_back_link** (string) - 可选 - 用户点击回退按钮时跳转的商户页面地址 - **return_back_link** (string) - 可选 - 用户开通并下单流程结束后跳转的商户页面地址 - **body** (string) - 可选 - 订单描述 - **extend_params** (string) - 可选 - 业务扩展参数 ### Request Example ```json { "app_id": "2014072300007148", "method": "zhima.credit.payafteruse.creditbizorder.create", "format": "JSON", "charset": "utf-8", "sign_type": "RSA2", "sign": "详见示例", "timestamp": "2014-07-24 03:07:50", "version": "1.0", "biz_content": { "out_order_no": "out00120312323232", "zm_service_id": "2020050722001440031000061082", "subject": "Iphone6 16G", "out_agreement_no": "2014070700166653", "order_amount": 88.66, "amount_type": "RISK_AMOUNT", "category_id": "credit_pay_after_use", "product_code": "CREDIT_PAY_AFTER_USE", "cancel_back_link": "https://www.taobao.com", "return_back_link": "https://www.taobao.com", "body": "Iphone6 16G", "extend_params": "{\"key\":\"value\"}" } } ``` ### Response #### Success Response - 响应为支付宝SDK的sdkExecute方法返回结果,读取body()获取orderStr。 #### Response Example ```json { "alipay_zhima_credit_payafteruse_creditbizorder_create_response": { "code": "10000", "msg": "Success", "orderStr": "..." }, "sign": "..." } ``` ``` -------------------------------- ### Java SDK 示例:创建芝麻先享信用订单 Source: https://opendocs.alipay.com/open/05yu14 使用支付宝Java SDK调用ZhimaCreditPayafteruseCreditbizorderCreate接口。示例中设置了商户外部订单号、协议号、订单金额等业务参数,并展示了如何初始化AlipayConfig和AlipayClient。注意:示例中的私钥、公钥和AppId需要替换为实际值。 ```java package com.java.sdk.demo; import com.alipay.api.AlipayApiException; import com.alipay.api.AlipayClient; import com.alipay.api.DefaultAlipayClient; import com.alipay.api.AlipayConfig; import com.alipay.api.domain.ZhimaCreditPayafteruseCreditbizorderCreateModel; import com.alipay.api.request.ZhimaCreditPayafteruseCreditbizorderCreateRequest; import com.alipay.api.response.ZhimaCreditPayafteruseCreditbizorderCreateResponse; import com.alipay.api.FileItem; import java.util.Base64; import java.util.ArrayList; import java.util.List; public class ZhimaCreditPayafteruseCreditbizorderCreate { public static void main(String[] args) throws AlipayApiException { // 初始化SDK AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig()); // 构造请求参数以调用接口 ZhimaCreditPayafteruseCreditbizorderCreateRequest request = new ZhimaCreditPayafteruseCreditbizorderCreateRequest(); ZhimaCreditPayafteruseCreditbizorderCreateModel model = new ZhimaCreditPayafteruseCreditbizorderCreateModel(); // 设置商户外部订单号 model.setOutOrderNo("out00120312323232"); // 设置商户外部协议号 model.setOutAgreementNo("2014070700166653"); // 设置订单金额 model.setOrderAmount("88.66"); // 设置只有当传递了order_amount时 model.setAmountType("RISK_AMOUNT"); // 设置芝麻信用服务ID model.setZmServiceId("2020050722001440031000061082"); // 设置芝麻外部类目 model.setCategoryId("credit_pay_after_use"); // 设置产品码 model.setProductCode("CREDIT_PAY_AFTER_USE"); // 设置当用户进入芝麻先享下单页面后 model.setCancelBackLink("https://www.taobao.com"); // 设置用户芝麻先享开通并下单流程结束后 model.setReturnBackLink("https://www.taobao.com"); // 设置订单标题 model.setSubject("Iphone6 16G"); // 设置订单描述 model.setBody("Iphone6 16G"); // 设置业务扩展参数 model.setExtendParams("{\"key\":\"value\"}"); request.setBizModel(model); // 第三方代调用模式下请设置app_auth_token // request.putOtherTextParam("app_auth_token", "<-- 请填写应用授权令牌 -->"); ZhimaCreditPayafteruseCreditbizorderCreateResponse response = alipayClient.sdkExecute(request); String orderStr = response.getBody(); System.out.println(orderStr); if (response.isSuccess()) { System.out.println("调用成功"); } else { System.out.println("调用失败"); // sdk版本是"4.38.0.ALL"及以上,可以参考下面的示例获取诊断链接 // String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(response); // System.out.println(diagnosisUrl); } } private static AlipayConfig getAlipayConfig() { String privateKey = "<-- 请填写您的应用私钥,例如:MIIEvQIBADANB ... ... -->"; String alipayPublicKey = "<-- 请填写您的支付宝公钥,例如:MIIBIjANBg... -->"; AlipayConfig alipayConfig = new AlipayConfig(); alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do"); alipayConfig.setAppId("<-- 请填写您的AppId,例如:2019091767145019 -->"); alipayConfig.setPrivateKey(privateKey); alipayConfig.setFormat("json"); alipayConfig.setAlipayPublicKey(alipayPublicKey); alipayConfig.setCharset("UTF-8"); alipayConfig.setSignType("RSA2"); return alipayConfig; } } ``` -------------------------------- ### POST /gateway.do (zhima.credit.payafteruse.creditagreement.query) Source: https://opendocs.alipay.com/open/999ae950_zhima.credit.payafteruse.creditagreement.query 查询服务开通/授权信息接口,通过商户外部协议号或开通/授权协议号查询服务开通/授权状态。支持第三方代理调用。 ```APIDOC ## [POST] /gateway.do ### Description 查询服务开通/授权信息接口,用于根据商户外部协议号或开通/授权协议号查询芝麻先享服务的开通/授权状态。 ### Method POST ### Endpoint https://openapi.alipay.com/gateway.do ### Parameters #### Query Parameters - **app_id** (String) - Required - 支付宝分配给开发者的应用ID,示例值:2014072300007148 - **method** (String) - Required - 接口名称,固定为:zhima.credit.payafteruse.creditagreement.query - **format** (String) - Optional - 仅支持JSON,示例值:JSON - **charset** (String) - Required - 请求使用的编码格式,如utf-8,gbk,gb2312等,示例值:utf-8 - **sign_type** (String) - Required - 商户生成签名字符串所使用的签名算法类型,目前支持RSA2和RSA,推荐使用RSA2,示例值:RSA2 - **sign** (String) - Required - 商户请求参数的签名串,详见签名 - **timestamp** (String) - Required - 发送请求的时间,格式"yyyy-MM-dd HH:mm:ss",示例值:2014-07-24 03:07:50 - **version** (String) - Required - 调用的接口版本,固定为:1.0,示例值:1.0 - **app_auth_token** (String) - Optional - 详见应用授权概述 - **biz_content** (String) - Required - 请求参数的集合,最大长度不限,除公共参数外所有请求参数都必须放在这个参数中传递,具体参照各产品快速接入文档 #### Request Body (biz_content) - **out_agreement_no** (String) - 特殊可选 - 商户外部协议号,必选条件:当无credit_agreement_id时,示例值:2014070700166653 - **credit_agreement_id** (String) - 特殊可选 - 芝麻开通/授权协议号,out_agreement_no与credit_agreement_id必填一个,推荐使用credit_agreement_id,示例值:ZMOP2020050722001440 - **product_code** (String) - 特殊可选 - 当产品是芝麻守约时必填,需传入CREDIT_AGREEMENT,枚举值:当产品是芝麻守约时: CREDIT_AGREEMENT,必选条件:当产品是芝麻守约时必填,需传入CREDIT_AGREEMENT,示例值:CREDIT_AGREEMENT - **service_id** (String) - 特殊可选 - 芝麻信用服务id,上线前提前分配给商户,必选条件:当需要通过serviceId查询授权状态时,示例值:2026041600000000000116203200 - **extra_param** (String) - Optional - 扩展参数,示例值:{"key","value"} ### Request Example ``` curl 'https://openapi.alipay.com/gateway.do?charset=UTF-8&method=zhima.credit.payafteruse.creditagreement.query&format=json&sign=${sign}&app_id=${appid}&version=1.0&sign_type=RSA2×tamp=${now}' \ -F 'app_auth_token=${app_auth_token}' \ -F 'biz_content={ "out_agreement_no":"2014070700166653", "credit_agreement_id":"ZMOP2020050722001440", "product_code":"CREDIT_AGREEMENT", "service_id":"2026041600000000000116203200", "extra_param":"{\"key\",\"value\"}" }' ``` ### Response #### Success Response (200) - 响应内容未在文档中明确给出,请参考支付宝开放平台相关文档。 #### Response Example - 响应示例未在文档中提供。 ``` -------------------------------- ### 正常响应示例:alipay.iservice.ccm.sw.tree.create Source: https://opendocs.alipay.com/open/df029ced_alipay.iservice.ccm.sw.tree.create 接口 alipay.iservice.ccm.sw.tree.create 的正常响应示例,返回 code、msg、id 和 sign 字段。示例仅供参考。 ```json { "alipay_iservice_ccm_sw_tree_create_response": { "code": "10000", "msg": "Success", "id": 1 }, "sign": "ERITJKEIJKJHKKKKKKKHJEREEEEEEEEEEE" } ```