如何集成花呗分期支付注意事项:[url]https://openclub.alipay.com/read.php?tid=13779&fid=56[/url]
一、注意事项
1、调用接口代码前必须了解自己需要实现的场景功能;
2、通过集成代码实现的是花呗分期支付的花呗分期单渠道模式;
二、参数说明
(1)hb_fq_num代表花呗分期数,仅支持传入3、6、12,其他期数暂不支持,传入会报错;
(2)hb_fq_seller_percent代表卖家承担收费比例,商家承担手续费传入100,用户承担手续费传入0,仅支持传入100、0两种,其他比例暂不支持,传入会报错。
(3)花呗分期参数传入到extend_params中,格式如下:"extend_params":{"hb_fq_num":"3","hb_fq_seller_percent":"100"}
(4)total_amount:由于该方式为花呗分期支付,交易金额建议大于等于100元;
以当面付扫码支付的接口进行花呗分期支付为例:
三、调用请求示例
JAVA版请求示例
public static void main(String[] args) throws AlipayApiException { AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.gatewayUrl, AlipayConfig.app_id, AlipayConfig.merchant_private_key, AlipayConfig.format, AlipayConfig.charset, AlipayConfig.alipay_public_key, AlipayConfig.sign_type); AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest(); AlipayTradePrecreateModel model = new AlipayTradePrecreateModel(); //out_trade_no(订单号)必须是唯一的,测试一次必须修改新的订单号 model.setOutTradeNo("sao2018816105156165"); model.setTotalAmount("200"); model.setSubject("Iphone6 16G"); // hb_fq_seller_percent:商家承担手续费传入100,用户承担手续费传入0。 ExtendParams extendParams = new ExtendParams(); extendParams.setHbFqNum("3"); extendParams.setHbFqSellerPercent("100"); model.setExtendParams(extendParams); request.setBizModel(model); // request.setNotifyUrl("http://notify.dengw.online/do/b07c0dc6-0bdd-474e-bf5f-39bbc6bc3e9d"); AlipayTradePrecreateResponse response = alipayClient.execute(request); if(response.isSuccess()){ System.out.println("调用成功"); } else { System.out.println("调用失败"); } //条码支付详细信息 System.out.println(response.getBody()); //qr_Code当前预下单请求生成的二维码码串,可以用二维码生成工具根据该码串值生成对应的二维码 }
响应参数
{"alipay_trade_precreate_response":{"code":"10000","msg":"Success","out_trade_no":"sao2018816105156170","qr_code":"https://qr.alipay.com/bax03555xrrk9b5hyzer606a"},"sign":"OqS3p6uOxCw08IBANKaRvnH9F7fY/WQaX+005O8/F4L1fQSc0h7gBR4klfkZr+HYgRo+S9RJaL7hM7mmKiqoRcYy72o66nZxv/UkO1v3HTG+70SP314DsJSiWVvW1vYdzpqt2sm+nI6PRp2cyGLMEd++Lpu7ttI44K1LWM0gHUHqq277RHIyReaivz2RLSxGbukVpE+GKD1E4emnwBk6rWA1N0deKAlqfX2gTRxofBafwEYvZUnbRz/gM2UaTyFd5FxMlRxLSMSXbBG/AkCR0ZD+PRx06gUMfE1dLPXrt/InM6uy3X1zhG3/ZjSFuL/tXhHpKZcUdrGRNKuIr/SW4w=="}
PHP版请求示例
require_once 'AopSdk.php';
$aop = new AopClient ();
$aop->appId = '填写您的appid';
$aop->rsaPrivateKey = '填写您的私钥';
$aop->alipayrsaPublicKey='填写您的支付宝公钥';
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset='utf-8';
$aop->format='json';
$date=date("YmdHis");
$arr=range(1000,9999);
shuffle($arr);
$request = new AlipayTradePrecreateRequest ();
$request->setBizContent("{" .
""out_trade_no":"201503200101010054"," .
""subject":"Iphone6 16G"," .
""total_amount":200," .
""extend_params":{" .
""hb_fq_num":"3"," .
""hb_fq_seller_percent":"100"" .
"}" .
" }");
// $request->setNotifyUrl('请填写您的异步通知地址');
$result = $aop->execute($request);
//第三方调用
//$result = $aop->execute($request,"","app_auth_token");
var_dump($result);
响应参数
object(stdClass)[10] public 'alipay_trade_precreate_response' => object(stdClass)[9] public 'code' => string '10000' (length=5) public 'msg' => string 'Success' (length=7) public 'out_trade_no' => string '201503200101010054' (length=18) public 'qr_code' => string 'https://qr.alipay.com/bax07597hhpq6nnziixl4065' (length=46) public 'sign' => string 'VEm8IYUsP97D4hPAVAI673rtTTFjnOM887U5K2IllI98mmxrAsWFcnF8uE6Z/GJ0GhJzPumEnTu7IvqPbjy96leZg28AF772CBPLXzadhNFQ0iDFOQVGj4O481oRAWI21PgJslCJ7aaI40rr1DW4W2YIO5StXcpEyAHGYpwC3CV2Cm5VHsiV60Gi6v6fieKuS/Vh4NVtSAxaQnH9x87ZKPDJKvl4vpM8596EsjvBWoihvpKLFSEUs7ZKotjqXxVs2HF1BgGpRVp9kmkOrqO71+bm26624n2pi74rFVvkKybVQdwBBT0xIfTRHP8Wi+VWq7+i5mzlaTK8XYQn0lNvUw==' (length=344)
.NET版请求示例
IAopClient client = new DefaultAopClient(config.gatewayUrl, config.app_id, config.private_key, "json", "1.0", "RSA2", config.alipay_public_key, config.charset, false); AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest(); request.BizContent = "{" + ""out_trade_no":"20190313ygyg45447000001"," + ""body":"煜雨测试扫码支付"," + ""total_amount": 0.03," + ""extend_params":{" + ""hb_fq_num":"3","+ ""hb_fq_seller_percent":"100"}," + ""subject":"煜雨购买Iphone XS"" + "}"; AlipayTradePrecreateResponse response = client.Execute(request); Console.WriteLine(response.Body);
响应参数
{"alipay_trade_precreate_response":{"code":"10000","msg":"Success","out_trade_no":"20190313ygyg45447000001","qr_code":"https://qr.alipay.com/bax037749x7ovxhv9gdb00c1"},"sign":"U9Thmij1VqpVSFFZIxWWx3+H9zodRBj8qHDVejEtZG8Yd8D2X4buio5CpKGmyt2/HS4TBGs1oGYTe4xTF4yZFC1wUJ9zbfrIOGEUgwUiDBpcWK7uza8l+kNxKjJbjo7ww6InGdN5RCHMxLZ8MT4RcBMqcSLTR+2fQ9gykfpeVtKLgBKBOmg370LSk9q5FpZEREGvkBRJRFemIzOS8Te0JPJdmbK70W9l8S96fVpFwC22DeYAMqdM0rhCZy8cZI98Igw/PdvGj/qKzKpqIErSA4HOASjr4vk9/Dcv5d8EPZNHLa+QK8nQRC1deAeMezJEhdro1GNmmoxL05RWodCyoQ=="}
四、显示效果
如果还是报错,请按如下方式进行提问:
正确提问方式:使用环境(沙箱还是正式环境)+接口名称(中文+英文)+ 请求参数 + 报错信息详情