在官方的產(chǎn)品是叫做當(dāng)面付
1曹傀、什么是當(dāng)面付呢辐脖?
簡(jiǎn)單的講就是條碼支付(刷卡支付)、掃碼支付皆愉、聲波支付嗜价。
【官方是這樣解釋的】
商戶可通過(guò)以下任一方式在線下完成交易收款都是當(dāng)面付:
1、商家通過(guò)掃描線下買(mǎi)家支付寶錢(qián)包中的條碼幕庐、二維碼等方式將買(mǎi)家的交易資金直接打入賣(mài)家支付寶賬戶久锥,資金實(shí)時(shí)到賬;
2异剥、線下買(mǎi)家通過(guò)使用支付寶錢(qián)包掃描商家的二維碼等方式完成支付瑟由,提升商家收銀效率,資金實(shí)時(shí)到賬冤寿;
3歹苦、線下買(mǎi)家使用支付寶錢(qián)包中的當(dāng)面付功能青伤,通過(guò)聲波支付的方式向商家完成付款,資金實(shí)時(shí)到賬殴瘦。
2狠角、申請(qǐng)條件
- 申請(qǐng)前必須擁有企業(yè)或個(gè)人支付寶賬號(hào),且通過(guò)支付寶實(shí)名認(rèn)證審核蚪腋;
- 營(yíng)業(yè)執(zhí)照主體需與簽約主體一致丰歌,如不一致者需提供有效授權(quán)函;授權(quán)函要求:公司類型必須蓋公章屉凯、個(gè)體工商戶需兩選一:
a. 法人身份證原件+法人簽字
b. 法人身份證原件+個(gè)體工商戶蓋章立帖; - 部分行業(yè)暫未開(kāi)放簽約,如保險(xiǎn)神得、黃金期貨厘惦、借貸(P2P)、POS等支付業(yè)務(wù)等哩簿;
3宵蕉、產(chǎn)品費(fèi)率
單筆費(fèi)率 0.6%
4、簽約認(rèn)證流程
如果你只是想了解支付流程可以不進(jìn)行簽約节榜,我們可以使用沙箱環(huán)境進(jìn)行測(cè)試羡玛。
5、聊聊條碼支付(刷卡支付)
官方文檔 當(dāng)面付詳細(xì)的產(chǎn)品介紹在這里
條碼支付是支付寶給到線下傳統(tǒng)行業(yè)的一種收款方式宗苍。商家使用掃碼槍等條碼識(shí)別設(shè)備掃描用戶支付寶錢(qián)包上的條碼/二維碼稼稿,完成收款。用戶僅需出示付款碼讳窟,所有收款操作由商家端完成让歼。
使用步驟:
1、用戶登錄支付寶錢(qián)包丽啡,點(diǎn)擊首頁(yè)“付款”谋右,進(jìn)入付款碼界面;
2补箍、收銀員在商家收銀系統(tǒng)操作生成訂單改执,用戶確認(rèn)支付金額;
3坑雅、用戶出示錢(qián)包的“付款碼”辈挂,收銀員用掃碼設(shè)備來(lái)掃描用戶手機(jī)上的條碼/二維碼后,商家收銀系統(tǒng)提交支付裹粤;
4终蒂、付款成功后商家收銀系統(tǒng)會(huì)拿到支付成功或者失敗的結(jié)果。
6、如何接入條碼支付(刷卡支付)呢后豫?
官方接入介紹資料 當(dāng)面付快速接入
前三步任何支付方式對(duì)接必不可少,這些按照文檔操作應(yīng)該沒(méi)有問(wèn)題悉尾。如遇到問(wèn)題歡迎留言
今天的主角要登場(chǎng)了>>>>>>條碼支付
這里主要涉及到三個(gè)接口
這里我們使用官方提供的服務(wù)端SDK(開(kāi)放平臺(tái)服務(wù)端SDK)來(lái)快速接入
7、選擇正確的接入環(huán)境
??上面提到過(guò)如果是測(cè)試或者不上線應(yīng)用可以不用簽約直接使用沙箱環(huán)境
正式環(huán)境支付網(wǎng)關(guān):https://openapi.alipay.com/gateway.do
沙盒環(huán)境支付網(wǎng)關(guān):https://openapi.alipaydev.com/gateway.do
8挫酿、使用SDK封裝接口
添加支付寶相關(guān)的配置文件 alipay.properties
############################
# 支付寶相關(guān)的配置
############################
appId=xxx //測(cè)試號(hào)的APPID
privateKey=xxx //測(cè)試號(hào)的私鑰 建議使用RSA2
alipayPulicKey=xxx //支付寶公鑰
serverUrl=https://openapi.alipaydev.com/gateway.do //支付網(wǎng)關(guān)
notify_domain = xxx //通知域名
8.1 在SDK調(diào)用前需要進(jìn)行初始化
private static final Prop prop = PropKit.use("alipay.properties");
public static AlipayClient alipayClient;
public static String charset = "UTF-8";
public static String privateKey = prop.get("privateKey");
public static String alipayPulicKey = prop.get("alipayPulicKey");
public static String serverUrl = prop.get("serverUrl");
public static String appId = prop.get("appId");
public static String format = "json";
public static String signType = "RSA2";
public static String notify_domain = prop.get("notify_domain");
static {
alipayClient = new DefaultAlipayClient(serverUrl, appId, privateKey, format, charset, alipayPulicKey, signType);
}
8.2 封裝交易支付接口alipay.trade.pay
/**
* 條形碼支付
* https://doc.open.alipay.com/docs/doc.htm?spm=a219a.7629140.0.0.Yhpibd&treeId=194&articleId=105170&docType=1#s4
* @throws AlipayApiException
*/
public static String tradePay(AlipayTradePayModel model) throws AlipayApiException {
AlipayTradePayResponse response = tradePayToResponse(model);
return response.getBody();
}
public static AlipayTradePayResponse tradePayToResponse(AlipayTradePayModel model) throws AlipayApiException{
AlipayTradePayRequest request = new AlipayTradePayRequest();
request.setBizModel(model);// 填充業(yè)務(wù)參數(shù)
return alipayClient.execute(request); // 通過(guò)alipayClient調(diào)用API构眯,獲得對(duì)應(yīng)的response類
}
8.3 交易查詢接口alipay.trade.query
/**
* 交易查詢接口
* https://doc.open.alipay.com/docs/api.htm?spm=a219a.7395905.0.0.8H2JzG&docType=4&apiId=757
* @param bizContent
* @return
* @throws AlipayApiException
*/
public static boolean isTradeQuery(AlipayTradeQueryModel model) throws AlipayApiException{
AlipayTradeQueryResponse response = tradeQuery(model);
if(response.isSuccess()){
return true;
}
return false;
}
public static AlipayTradeQueryResponse tradeQuery(AlipayTradeQueryModel model) throws AlipayApiException{
AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
request.setBizModel(model);
return alipayClient.execute(request);
}
8.4 交易撤銷接口alipay.trade.cancel
/**
* 交易撤銷接口
* https://doc.open.alipay.com/docs/api.htm?spm=a219a.7395905.0.0.XInh6e&docType=4&apiId=866
* @param bizContent
* @return
* @throws AlipayApiException
*/
public static boolean isTradeCancel(AlipayTradeCancelModel model) throws AlipayApiException{
AlipayTradeCancelResponse response = tradeCancel(model);
if(response.isSuccess()){
return true;
}
return false;
}
public static AlipayTradeCancelResponse tradeCancel(AlipayTradeCancelModel model) throws AlipayApiException{
AlipayTradeCancelRequest request = new AlipayTradeCancelRequest();
request.setBizModel(model);
AlipayTradeCancelResponse response = alipayClient.execute(request);
return response;
}
9、使用沙盒環(huán)境測(cè)試
下載沙箱模式下的app【沙箱錢(qián)包】
9.1 交易支付接口alipay.trade.pay測(cè)試
/**
* 條碼支付
* https://doc.open.alipay.com/docs/doc.htm?spm=a219a.7629140.0.0.Yhpibd&treeId=194&articleId=105170&docType=1#s4
*/
public void tradePay() {
String authCode = getPara("auth_code");
String subject = "Javen 支付寶條形碼支付測(cè)試";
String totalAmount = "100";
AlipayTradePayModel model = new AlipayTradePayModel();
model.setAuthCode(authCode);
model.setSubject(subject);
model.setTotalAmount(totalAmount);
model.setOutTradeNo(StringUtils.getOutTradeNo());
model.setScene("bar_code");
try {
String resultStr = AliPayApi.tradePay(model);
renderText(resultStr);
} catch (Exception e) {
e.printStackTrace();
}
}
打開(kāi)沙箱錢(qián)包>付款>輸入條形碼測(cè)試
返回的結(jié)果
{
"alipay_trade_pay_response": {
"code": "10000",
"msg": "Success",
"buyer_logon_id": "abp***@sandbox.com",
"buyer_pay_amount": "100.00",
"buyer_user_id": "2088102169474200",
"fund_bill_list": [
{
"amount": "100.00",
"fund_channel": "ALIPAYACCOUNT"
}
],
"gmt_payment": "2017-05-07 20:28:35",
"invoice_amount": "100.00",
"open_id": "20881035070193409461376162014620",
"out_trade_no": "050720283214941",
"point_amount": "0.00",
"receipt_amount": "100.00",
"total_amount": "100.00",
"trade_no": "2017050721001004200200238428"
},
"sign": "FZVBkb4tuqjM/3OZnAJJ8YFkGSmpcMIum+WdhCNURy+jSs5mZT2RZLlDuzVNHYoZQpItpVscDR86n87wFni/lhaNK0UvCkjQmSeBrmzuntFDrD8rh/KX3U3kpsQEmSzbI/E1VNYM3zL/lVPCnjkc9etVky8w690yHVqsRTBpjXDYUw91zdlm7iXjrRAv1vNWEhfaAgBh3toz8Asra03vFPMXaaGp4ARTI3AkjatH4zPO0JmDu3fMd+jk759FYW1qGf89LpLD/6ng+VNhu4rr3FC4RpLtYed9lKSrehlujGHSkhnWJcr0JZ6doYYF4aJuH7Eflyt+FCg/1JFzd0Mygw=="
}
9.2 交易查詢接口alipay.trade.query測(cè)試
public void tradeQuery(){
try {
AlipayTradeQueryModel model = new AlipayTradeQueryModel();
model.setOutTradeNo("050720283214941");
model.setTradeNo("2017050721001004200200238428");
boolean isSuccess = AliPayApi.isTradeQuery(model);
renderJson(isSuccess);
} catch (AlipayApiException e) {
e.printStackTrace();
}
}
或者
public void tradeQueryByStr(){
String out_trade_no = getPara("out_trade_no");
AlipayTradeQueryModel model = new AlipayTradeQueryModel();
model.setOutTradeNo(out_trade_no);
try {
String resultStr = AliPayApi.tradeQuery(model).getBody();
renderText(resultStr);;
} catch (AlipayApiException e) {
e.printStackTrace();
}
}
返回的結(jié)果
{
"alipay_trade_query_response": {
"code": "10000",
"msg": "Success",
"buyer_logon_id": "abp***@sandbox.com",
"buyer_pay_amount": "100.00",
"buyer_user_id": "2088102169474200",
"fund_bill_list": [
{
"amount": "100.00",
"fund_channel": "ALIPAYACCOUNT"
}
],
"invoice_amount": "100.00",
"open_id": "20881035070193409461376162014620",
"out_trade_no": "050720283214941",
"point_amount": "0.00",
"receipt_amount": "100.00",
"send_pay_date": "2017-05-07 20:28:34",
"total_amount": "100.00",
"trade_no": "2017050721001004200200238428",
"trade_status": "TRADE_SUCCESS"
},
"sign": "DE6qYfU0Nziv3Dxpaj0gUROcqMNmREwYUw/t9qlnLiuM1JkKEdNJtbyJZ8OCoOIkgXEOSs7+mOrGgyxmOQqccwwhkDDsYXhPnc0cy4M7L4sNl5S3nUaveBaZjk3SMMGif43UaYtVI6SF4kq74uyoH15tCWDJ0N3nYct2epgc7r6kprAFqQxszgYp4tfKLw0qPCKnUyo7+WRbrc6UWQVuK+xDlVcvivW5cXjAf/HFyb8o+ddj6g+QQ4jUN2WTc2QGpbtfum6G7oPHT99cjAURVRw2NmU5WfUXNazzSvisa2oYsl8EH7+XHvsAMyIUZw0Ix8ymuAXdMkrUPFY4PfzjIg=="
}
9.3 交易撤銷接口alipay.trade.cancel測(cè)試
public void tradeCancelByStr(){
try {
AlipayTradeCancelModel model = new AlipayTradeCancelModel();
model.setOutTradeNo("050720283214941");
model.setTradeNo("2017050721001004200200238428");
AlipayTradeCancelResponse response = AliPayApi.tradeCancel(model);
renderJson(response.getBody());
} catch (AlipayApiException e) {
e.printStackTrace();
}
}
{
"alipay_trade_cancel_response": {
"code": "10000",
"msg": "Success",
"out_trade_no": "050720283214941",
"retry_flag": "N"
},
"sign": "QFwTwACi/x/qZu7YCapToWKpYDatg7Y06KAxij01PHSQrq0+l9eeFGdNIRpD2rSmkCVN75RQManw4PvIEurN5uW6YSZlZQ0Rj2EeH0eVyNWqNRWmVGeSaLQ+hpAt3vG/cy5vXJ1Zl7yr/VbtRiuSYrbzPhgkG1UNYf9JIb4Nj2iSpo8Ct6Bbhiq848w7ZEN6itBmd04N3O4HkBoueuXtgUmKoaTegDfrtNtQ7dRAkCRnoa43QbHYysqwOO751JjI6HOeviZUrTspegUFbqhSXInaZ4LMqeiPWXeXc7dRmtOlPOSRY5wYzYYNCmEe89HdyLFSzd447QS2b5Ky3wAY3w=="
}