public class LeonaClient extends Object implements Leona
Leona client = new LeonaClient
.Builder(agent_id, agent_key)
// .setPartnerPriKey(cliPriKeyFilePath)
// .setLhPubKey(serPubKeyFilePath)
// .setSecretKey(secret_key)
// .setEncryptionLevel(Const.HEADER_X_LEHUI_ENCRYPTION_LEVEL_L1)
// .setEncryptionAccept(Const.HEADER_X_LEHUI_ENCRYPTION_LEVEL_L0)
.build();
// 异步
try {
final QRCodePayRequest req =
new QRCodePayRequest(merchantID, "2", "xxxxxxx", 1, null, null);
client.qrCodePay(req, (e, data) -> {
if (e != null) {
String type = e.getType();
String code = e.getCode();
String message = e.getMessage();
System.err.printf("type: %s, code: %s, message: %s\n", type, code, message);
return;
}
System.out.println(data);
});
} catch (LeonaException e) {
String type = e.getType();
String code = e.getCode();
String message = e.getMessage();
System.err.printf("type: %s, code: %s, message: %s\n", type, code, message);
// e.printStackTrace();
}
// 同步
try {
final QRCodePayRequest req =
new QRCodePayRequest(merchantID, "2", "xxxxxxx", 1, null, null);
final QRCodePayResponse resp = client.qrCodePay(req);
System.out.println(resp);
} catch (LeonaException e) {
String type = e.getType();
String code = e.getCode();
String message = e.getMessage();
System.err.printf("type: %s, code: %s, message: %s\n", type, code, message);
// e.printStackTrace();
}
该类所有同步的http请求都会抛出LeonaException. 具体情况为--加签验签, 加密解密, 网络IO异常, httpRequest返回状态码不为200, 统一抛出LeonaException,
区别在于LeonaException.getType(), LeonaException.getCode(), LeonaException.getMessage()各自拥有不同的结果.
异常结果详见枚举类 LeonaErrorCodeEnum.
httpRequest返回状态码不为200返回的LeonaException是responseBody的封装, 具体内容见
合作伙伴平台API手册
而该类所有异步的http请求也会抛出LeonaException. 情况为--加签验签, 加密解密, 网络IO异常.
httpRequest返回状态码不为200的异常情况不在其中, 而在方法的callback参数中进行处理.
| 限定符和类型 | 类和说明 |
|---|---|
static class |
LeonaClient.Builder |
| 限定符和类型 | 方法和说明 |
|---|---|
Options |
getOptions()
获得LeonaClient的初始化参数
|
Payment |
getOrder(GetOrderRequest req)
查询交易
|
void |
getOrder(GetOrderRequest req,
Callback<Payment> callback)
查询交易(异步)
|
Refund |
getRefund(GetRefundRequest req)
查询退款
|
void |
getRefund(GetRefundRequest req,
Callback<Refund> callback)
查询退款(异步)
|
Payment |
microPay(MicroPayRequest req)
刷卡交易
|
void |
microPay(MicroPayRequest req,
Callback<Payment> callback)
刷卡交易(异步)
|
QRCodePayResponse |
qrCodePay(QRCodePayRequest req)
二维码支付
|
void |
qrCodePay(QRCodePayRequest req,
Callback<QRCodePayResponse> callback)
二维码支付(异步)
|
Refund |
refund(RefundRequest req)
退款
|
void |
refund(RefundRequest req,
Callback<Refund> callback)
退款(异步)
|
public QRCodePayResponse qrCodePay(QRCodePayRequest req) throws LeonaException
qrCodePay 在接口中 Leonareq - 请求体LeonaException - 说明见类文档public void qrCodePay(QRCodePayRequest req, Callback<QRCodePayResponse> callback) throws LeonaException
qrCodePay 在接口中 Leonareq - 请求体callback - Callback, 定义了请求失败与成功时应有的操作, 详见接口说明LeonaException - 说明见类文档public Payment microPay(MicroPayRequest req) throws LeonaException
microPay 在接口中 Leonareq - 请求体LeonaException - 说明见类文档public void microPay(MicroPayRequest req, Callback<Payment> callback) throws LeonaException
microPay 在接口中 Leonareq - 请求体callback - Callback, 定义了请求失败与成功时应有的操作, 详见接口说明LeonaException - 说明见类文档public Payment getOrder(GetOrderRequest req) throws LeonaException
getOrder 在接口中 Leonareq - 请求体LeonaException - 说明见类文档public void getOrder(GetOrderRequest req, Callback<Payment> callback) throws LeonaException
getOrder 在接口中 Leonareq - 请求体callback - Callback, 定义了请求失败与成功时应有的操作, 详见接口说明LeonaException - 说明见类文档public Refund refund(RefundRequest req) throws LeonaException
refund 在接口中 Leonareq - 请求体LeonaException - 说明见类文档public void refund(RefundRequest req, Callback<Refund> callback) throws LeonaException
refund 在接口中 Leonareq - 请求体callback - Callback, 定义了请求失败与成功时应有的操作, 详见接口说明LeonaException - 说明见类文档public Refund getRefund(GetRefundRequest req) throws LeonaException
getRefund 在接口中 Leonareq - 请求体LeonaException - 说明见类文档public void getRefund(GetRefundRequest req, Callback<Refund> callback) throws LeonaException
getRefund 在接口中 Leonareq - 请求体callback - Callback, 定义了请求失败与成功时应有的操作, 详见接口说明LeonaException - 说明见类文档public Options getOptions()
Copyright © 2020. All rights reserved.