交易服务
使用交易服务前, 需要获取INewlandTransactionManager. 点击参考
接口定义
- 管理参数设置
transactionManager.setManageParameter(Pair<PaymentType, String> key, String value); - 获取管理参数
String transactionManager.getManageParameter(Pair<PaymentType,String> key); - 发起消费
transactionManager.startPayment(Payment payment,INewlandTransactionCallback callback); - 预授权完成
transactionManager.authComplete(String approvalCode,Calendar date,long amount,INewlandTransactionCallback callback); - 查看
transactionManager.displayPayment(PaymentType type,String voucherNo,INewlandTransactionCallback callback); transactionManager.displayPayment(String referenceId,INewlandTransactionCallback callback); - 获取
transactionManager.queryPayment(PaymentType type,String voucherNo,INewlandTransactionCallback callback); transactionManager.queryPayment(String referenceId,INewlandTransactionCallback callback); - 撤销
transactionManager.voidPayment(String voucherNo,INewlandTransactionCallback callback); - 退款
transactionManager.refundPayment(PaymentType type,String refNo,Calendar date,long amount,INewlandTransactionCallback callback); transactionManager.refundPayment(PaymentType type,String refNo,Calendar date,INewlandTransactionCallback callback); - 结算
transactionManager.settlePayment(INewlandTransactionCallback callback);
发起消费代码示例
//INewlandTransactionManager transactionManager;
//发起消费
Payment payment = new Payment();
String referenceId = UUID.randomUUID().toString();
payment.setReferenceId(referenceId);
payment.setAmount(amount);
payment.setPaymentType(PaymentType.CUPS);
// payment.setAuthzOnly(true); 设置此方法设置为预授权交易
INewlandTransactionCallback callback = new INewlandTransactionCallback(){
public void onSuccess(Payment payment){
PaymentType type = payment.getPaymentType();//交易类型 , 收单或者扫码支付
PaymentStatus status = payment.getStatus();
if(status == PaymentStatus.COLLECTED){
//付款成功返回
Transaction transaction = payment.getTransaction();//获取交易信息
TransactionStatus transactionStatus = transaction.getTransactionStatus();//获取订单状态
if(transactionStatus == TransactionStatus.COLLECTED){
//订单状态为已付款
}
}else if(status == PaymentStatus.AUTHORIZED){
//预授权成功返回
Transaction transaction = payment.getTransaction();//获取交易信息
TransactionStatus transactionStatus = transaction.getTransactionStatus();//获取订单状态
}else{
//其他更多PaymentStatus说明, 请查看javadoc
}
}
public void onError(NewlandError error){
//失败
}
}
transactionManager.startPayment(payment,callback);