Commit 9a4a1882 authored by zhang_z's avatar zhang_z

更新POS支付;

parent 4eae0d7d
......@@ -661,4 +661,49 @@ public class C {
public static final int USED = 2;
public static final int INVALID = 3;
}
/**
* 支付系统
*/
public final class PAY_SYSTEM {
/**
* 当前支付系统
*/
public static final int CURRENT = PAX.APP;
/**
* 浙星
*/
public static final int ZX = 100101;
/**
* 拉卡拉
*/
public static final int LKL = 100201;
/**
* 百富
*/
public final class PAX {
/**
* 统一支付APP
*/
public static final int APP = 100301;
/**
* 接口
*/
public static final int API = 100302;
}
/**
* 交易类型
*/
public final class Trans_Type {
public static final int Trans_Type_Return = 0;
public static final int Trans_Type_Recharge = 1;
}
}
}
......@@ -186,9 +186,9 @@ public class SettleActivity extends BaseActivity<SettlePresenter, ActivitySettle
}
@Override
public void showPayFailFragment(Throwable throwable, Saleorder saleorder) {
public void showPayFailFragment(String throwable, Saleorder saleorder) {
if (throwable != null) {
LogUtils.e(throwable.getMessage());
LogUtils.e(throwable);
}
this.start(mPayResultFragment.setResult(false).setSaleorder(saleorder));
this.showTitleBarByTitleMode(C.TITLE_MODE.TEXT);
......
......@@ -125,7 +125,7 @@ interface SettleContract {
* @param throwable 错误信息
* @param saleorder 订单信息
*/
void showPayFailFragment(Throwable throwable, Saleorder saleorder);
void showPayFailFragment(String throwable, Saleorder saleorder);
/**
* 显示支付中页面
......
......@@ -54,7 +54,9 @@ public class C {
public final static int QUERY = 400;
}
/**
* 支付渠道
*/
public final class PAY_CHANNEL {
public static final int CASH = 1;
public static final int WECHAT = 2;
......@@ -65,13 +67,34 @@ public class C {
}
/**
* 渠道
* 支付系统
*/
static final class HOST {
final class PAY_SYSTEM {
/**
* 浙星
*/
static final int ZX = 100101;
/**
* 惠尔丰平台的渠道编号
* 拉卡拉
*/
final static int PAX = 100000;
static final int LKL = 100201;
/**
* 百富
*/
final class PAX {
/**
* 统一支付APP
*/
static final int APP = 100301;
/**
* 接口
*/
static final int API = 100302;
}
}
/**
......
package com.xingdata.zxpay;
import com.alibaba.fastjson.JSON;
import com.blankj.utilcode.util.Utils;
import com.xingdata.zxpay.api.Response;
import com.xingdata.zxpay.model.Shopppp;
import com.xingdata.zxpay.pax.Factory;
import com.xingdata.zxpay.pax.PaxFactory;
import io.reactivex.Observable;
......@@ -19,12 +18,32 @@ public class PayCenter {
}
/**
* 交易基本信息
* 支付系统
*/
public Shopppp mShopppp;
private int mPaySystem;
public PayCenter init(String json) {
mShopppp = JSON.parseObject(json, Shopppp.class);
/**
* 支付信息
*/
public String mShoppppJson;
/**
* 设置支付信息
*/
public PayCenter setPayKey(String json) {
mShoppppJson = json;
return this;
}
/**
* 初始化
*
* @param paySystem 支付系统
* @return this
*/
public PayCenter init(int paySystem) {
this.mPaySystem = paySystem;
return this;
}
......@@ -37,11 +56,11 @@ public class PayCenter {
* @return 支付结果的Observable
*/
public Observable<Response> pay(int payChannel, String payCode, Long orderAmt) {
switch (mShopppp.getHost().getHostMapId()) {
case C.HOST.PAX:
return Factory.microPay(payChannel, payCode, Util.fenToYuan(orderAmt));
switch (mPaySystem) {
case C.PAY_SYSTEM.PAX.API:
return PaxFactory.getInstance().microPay(payChannel, payCode, Util.fenToYuan(orderAmt));
default:
return Observable.just(new Response(C.PAY_STATE.FAIL_CUSTOM, "未知渠道"));
return Observable.just(new Response(C.PAY_STATE.FAIL_CUSTOM, Utils.getApp().getResources().getString(R.string.unknown_channels)));
}
}
......@@ -54,11 +73,11 @@ public class PayCenter {
* @return 支付结果的Observable
*/
public Observable<Response> pay(int payChannel, Long orderAmt) {
switch (mShopppp.getHost().getHostMapId()) {
case C.HOST.PAX:
return Factory.qrPay(payChannel, Util.fenToYuan(orderAmt));
switch (mPaySystem) {
case C.PAY_SYSTEM.PAX.API:
return PaxFactory.getInstance().qrPay(payChannel, Util.fenToYuan(orderAmt));
default:
return Observable.just(new Response(C.PAY_STATE.FAIL_CUSTOM, "未知渠道"));
return Observable.just(new Response(C.PAY_STATE.FAIL_CUSTOM, Utils.getApp().getResources().getString(R.string.unknown_channels)));
}
}
......@@ -69,11 +88,11 @@ public class PayCenter {
* @return 查询结果的Observable
*/
public Observable<Response> query(int payChannel) {
switch (mShopppp.getHost().getHostMapId()) {
case C.HOST.PAX:
return Factory.query(payChannel);
switch (mPaySystem) {
case C.PAY_SYSTEM.PAX.API:
return PaxFactory.getInstance().query(payChannel);
default:
return Observable.just(new Response(C.PAY_STATE.FAIL_CUSTOM, "未知渠道"));
return Observable.just(new Response(C.PAY_STATE.FAIL_CUSTOM, Utils.getApp().getResources().getString(R.string.unknown_channels)));
}
}
}
package com.xingdata.zxpay.api;
public class Factory {
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
public class Factory {
protected static <T> Observable<T> run(Observable<T> observable) {
return observable.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
}
package com.xingdata.zxpay.pax;
import com.xingdata.zxpay.PayCenter;
class Api extends com.xingdata.zxpay.api.Api {
Service service;
......@@ -21,6 +19,6 @@ class Api extends com.xingdata.zxpay.api.Api {
@Override
protected String getBaseUrl() {
return PayCenter.getInstance().mShopppp.getHost().getHostAddr();
return PaxFactory.getInstance().mShopppp.getHost().getHostAddr();
}
}
......@@ -6,16 +6,6 @@ class C {
*/
static final String VERSION = "V1.0";
/**
* 重试次数
*/
static final int RETRY_COUNT = 6;
/**
* 重试延迟时间
*/
static final int RETRY_DELAY_TIME = 5 * 1000;
/**
* 测试数据
*/
......
......@@ -3,7 +3,6 @@ package com.xingdata.zxpay.pax;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.blankj.utilcode.util.EncryptUtils;
import com.xingdata.zxpay.PayCenter;
class Request {
......@@ -14,9 +13,9 @@ class Request {
this.signType = C.SIGN_TYPE.MD5;
this.version = C.VERSION;
this.agentId = PayCenter.getInstance().mShopppp.getHost().getHostAcqCode();
this.mchId = PayCenter.getInstance().mShopppp.getPosppp().getHshopNo();
this.terId = PayCenter.getInstance().mShopppp.getPosppp().getHposNo();
this.agentId = PaxFactory.getInstance().mShopppp.getHost().getHostAcqCode();
this.mchId = PaxFactory.getInstance().mShopppp.getPosppp().getHshopNo();
this.terId = PaxFactory.getInstance().mShopppp.getPosppp().getHposNo();
}
/**
......@@ -147,7 +146,6 @@ class Request {
@JSONField(name = "sign")
private String sign;
String getVersion() {
return version;
}
......@@ -204,7 +202,6 @@ class Request {
this.timeStart = timeStart;
}
String getSubject() {
return subject;
}
......@@ -213,7 +210,6 @@ class Request {
this.subject = subject;
}
String getBody() {
return body;
}
......@@ -238,7 +234,6 @@ class Request {
this.authCode = authCode;
}
String getCurrency() {
return currency;
}
......@@ -255,7 +250,6 @@ class Request {
this.totalAmount = totalAmount;
}
String getFeeAmount() {
return feeAmount;
}
......@@ -264,7 +258,6 @@ class Request {
this.feeAmount = feeAmount;
}
String getReserved() {
return reserved;
}
......@@ -273,7 +266,6 @@ class Request {
this.reserved = reserved;
}
String getExpTime() {
return expTime;
}
......
......@@ -33,13 +33,27 @@ class Response {
@JSONField(name = "msg")
private String msg;
public Long getTime_start() {
return time_start;
}
public void setTime_start(Long time_start) {
this.time_start = time_start;
}
/**
* 交易时间
*/
@JSONField(name = "time_start")
private Long time_start;
/**
* 二维码地址
*/
@JSONField(name = "code_url")
private String codeUrl;
String getMethod() {
public String getMethod() {
return method;
}
......@@ -47,7 +61,7 @@ class Response {
this.method = method;
}
String getAgentId() {
public String getAgentId() {
return agentId;
}
......@@ -55,7 +69,7 @@ class Response {
this.agentId = agentId;
}
String getMchId() {
public String getMchId() {
return mchId;
}
......@@ -63,7 +77,7 @@ class Response {
this.mchId = mchId;
}
String getCode() {
public String getCode() {
return code;
}
......@@ -71,7 +85,7 @@ class Response {
this.code = code;
}
String getMsg() {
public String getMsg() {
return msg;
}
......@@ -79,7 +93,7 @@ class Response {
this.msg = msg;
}
String getCodeUrl() {
public String getCodeUrl() {
return codeUrl;
}
......
package com.xingdata.zxpay.pax;
import com.alibaba.fastjson.JSON;
import io.reactivex.functions.Function;
class ResultFilter implements Function<Response, com.xingdata.zxpay.api.Response> {
......@@ -24,7 +26,7 @@ class ResultFilter implements Function<Response, com.xingdata.zxpay.api.Response
}
switch (response.getMethod()) {
case C.METHOD.QRPAY:
r.setBody(response.getCodeUrl());
r.setBody(JSON.toJSONString(response));
break;
}
return r;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment