Commit 9a4a1882 authored by zhang_z's avatar zhang_z

更新POS支付;

parent 4eae0d7d
...@@ -661,4 +661,49 @@ public class C { ...@@ -661,4 +661,49 @@ public class C {
public static final int USED = 2; public static final int USED = 2;
public static final int INVALID = 3; 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 ...@@ -186,9 +186,9 @@ public class SettleActivity extends BaseActivity<SettlePresenter, ActivitySettle
} }
@Override @Override
public void showPayFailFragment(Throwable throwable, Saleorder saleorder) { public void showPayFailFragment(String throwable, Saleorder saleorder) {
if (throwable != null) { if (throwable != null) {
LogUtils.e(throwable.getMessage()); LogUtils.e(throwable);
} }
this.start(mPayResultFragment.setResult(false).setSaleorder(saleorder)); this.start(mPayResultFragment.setResult(false).setSaleorder(saleorder));
this.showTitleBarByTitleMode(C.TITLE_MODE.TEXT); this.showTitleBarByTitleMode(C.TITLE_MODE.TEXT);
......
...@@ -125,7 +125,7 @@ interface SettleContract { ...@@ -125,7 +125,7 @@ interface SettleContract {
* @param throwable 错误信息 * @param throwable 错误信息
* @param saleorder 订单信息 * @param saleorder 订单信息
*/ */
void showPayFailFragment(Throwable throwable, Saleorder saleorder); void showPayFailFragment(String throwable, Saleorder saleorder);
/** /**
* 显示支付中页面 * 显示支付中页面
......
...@@ -54,7 +54,9 @@ public class C { ...@@ -54,7 +54,9 @@ public class C {
public final static int QUERY = 400; public final static int QUERY = 400;
} }
/**
* 支付渠道
*/
public final class PAY_CHANNEL { public final class PAY_CHANNEL {
public static final int CASH = 1; public static final int CASH = 1;
public static final int WECHAT = 2; public static final int WECHAT = 2;
...@@ -65,13 +67,34 @@ public class C { ...@@ -65,13 +67,34 @@ public class C {
} }
/** /**
* 渠道 * 支付系统
*/
final class PAY_SYSTEM {
/**
* 浙星
*/
static final int ZX = 100101;
/**
* 拉卡拉
*/ */
static final class HOST { static final int LKL = 100201;
/**
* 百富
*/
final class PAX {
/** /**
* 惠尔丰平台的渠道编号 * 统一支付APP
*/ */
final static int PAX = 100000; static final int APP = 100301;
/**
* 接口
*/
static final int API = 100302;
}
} }
/** /**
......
package com.xingdata.zxpay; 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.api.Response;
import com.xingdata.zxpay.model.Shopppp; import com.xingdata.zxpay.pax.PaxFactory;
import com.xingdata.zxpay.pax.Factory;
import io.reactivex.Observable; import io.reactivex.Observable;
...@@ -19,12 +18,32 @@ public class PayCenter { ...@@ -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; return this;
} }
...@@ -37,11 +56,11 @@ public class PayCenter { ...@@ -37,11 +56,11 @@ public class PayCenter {
* @return 支付结果的Observable * @return 支付结果的Observable
*/ */
public Observable<Response> pay(int payChannel, String payCode, Long orderAmt) { public Observable<Response> pay(int payChannel, String payCode, Long orderAmt) {
switch (mShopppp.getHost().getHostMapId()) { switch (mPaySystem) {
case C.HOST.PAX: case C.PAY_SYSTEM.PAX.API:
return Factory.microPay(payChannel, payCode, Util.fenToYuan(orderAmt)); return PaxFactory.getInstance().microPay(payChannel, payCode, Util.fenToYuan(orderAmt));
default: 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 { ...@@ -54,11 +73,11 @@ public class PayCenter {
* @return 支付结果的Observable * @return 支付结果的Observable
*/ */
public Observable<Response> pay(int payChannel, Long orderAmt) { public Observable<Response> pay(int payChannel, Long orderAmt) {
switch (mShopppp.getHost().getHostMapId()) { switch (mPaySystem) {
case C.HOST.PAX: case C.PAY_SYSTEM.PAX.API:
return Factory.qrPay(payChannel, Util.fenToYuan(orderAmt)); return PaxFactory.getInstance().qrPay(payChannel, Util.fenToYuan(orderAmt));
default: 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 { ...@@ -69,11 +88,11 @@ public class PayCenter {
* @return 查询结果的Observable * @return 查询结果的Observable
*/ */
public Observable<Response> query(int payChannel) { public Observable<Response> query(int payChannel) {
switch (mShopppp.getHost().getHostMapId()) { switch (mPaySystem) {
case C.HOST.PAX: case C.PAY_SYSTEM.PAX.API:
return Factory.query(payChannel); return PaxFactory.getInstance().query(payChannel);
default: 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; 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; package com.xingdata.zxpay.pax;
import com.xingdata.zxpay.PayCenter;
class Api extends com.xingdata.zxpay.api.Api { class Api extends com.xingdata.zxpay.api.Api {
Service service; Service service;
...@@ -21,6 +19,6 @@ class Api extends com.xingdata.zxpay.api.Api { ...@@ -21,6 +19,6 @@ class Api extends com.xingdata.zxpay.api.Api {
@Override @Override
protected String getBaseUrl() { protected String getBaseUrl() {
return PayCenter.getInstance().mShopppp.getHost().getHostAddr(); return PaxFactory.getInstance().mShopppp.getHost().getHostAddr();
} }
} }
...@@ -6,16 +6,6 @@ class C { ...@@ -6,16 +6,6 @@ class C {
*/ */
static final String VERSION = "V1.0"; 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; ...@@ -3,7 +3,6 @@ package com.xingdata.zxpay.pax;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.blankj.utilcode.util.EncryptUtils; import com.blankj.utilcode.util.EncryptUtils;
import com.xingdata.zxpay.PayCenter;
class Request { class Request {
...@@ -14,9 +13,9 @@ class Request { ...@@ -14,9 +13,9 @@ class Request {
this.signType = C.SIGN_TYPE.MD5; this.signType = C.SIGN_TYPE.MD5;
this.version = C.VERSION; this.version = C.VERSION;
this.agentId = PayCenter.getInstance().mShopppp.getHost().getHostAcqCode(); this.agentId = PaxFactory.getInstance().mShopppp.getHost().getHostAcqCode();
this.mchId = PayCenter.getInstance().mShopppp.getPosppp().getHshopNo(); this.mchId = PaxFactory.getInstance().mShopppp.getPosppp().getHshopNo();
this.terId = PayCenter.getInstance().mShopppp.getPosppp().getHposNo(); this.terId = PaxFactory.getInstance().mShopppp.getPosppp().getHposNo();
} }
/** /**
...@@ -147,7 +146,6 @@ class Request { ...@@ -147,7 +146,6 @@ class Request {
@JSONField(name = "sign") @JSONField(name = "sign")
private String sign; private String sign;
String getVersion() { String getVersion() {
return version; return version;
} }
...@@ -204,7 +202,6 @@ class Request { ...@@ -204,7 +202,6 @@ class Request {
this.timeStart = timeStart; this.timeStart = timeStart;
} }
String getSubject() { String getSubject() {
return subject; return subject;
} }
...@@ -213,7 +210,6 @@ class Request { ...@@ -213,7 +210,6 @@ class Request {
this.subject = subject; this.subject = subject;
} }
String getBody() { String getBody() {
return body; return body;
} }
...@@ -238,7 +234,6 @@ class Request { ...@@ -238,7 +234,6 @@ class Request {
this.authCode = authCode; this.authCode = authCode;
} }
String getCurrency() { String getCurrency() {
return currency; return currency;
} }
...@@ -255,7 +250,6 @@ class Request { ...@@ -255,7 +250,6 @@ class Request {
this.totalAmount = totalAmount; this.totalAmount = totalAmount;
} }
String getFeeAmount() { String getFeeAmount() {
return feeAmount; return feeAmount;
} }
...@@ -264,7 +258,6 @@ class Request { ...@@ -264,7 +258,6 @@ class Request {
this.feeAmount = feeAmount; this.feeAmount = feeAmount;
} }
String getReserved() { String getReserved() {
return reserved; return reserved;
} }
...@@ -273,7 +266,6 @@ class Request { ...@@ -273,7 +266,6 @@ class Request {
this.reserved = reserved; this.reserved = reserved;
} }
String getExpTime() { String getExpTime() {
return expTime; return expTime;
} }
......
...@@ -33,13 +33,27 @@ class Response { ...@@ -33,13 +33,27 @@ class Response {
@JSONField(name = "msg") @JSONField(name = "msg")
private String 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") @JSONField(name = "code_url")
private String codeUrl; private String codeUrl;
String getMethod() { public String getMethod() {
return method; return method;
} }
...@@ -47,7 +61,7 @@ class Response { ...@@ -47,7 +61,7 @@ class Response {
this.method = method; this.method = method;
} }
String getAgentId() { public String getAgentId() {
return agentId; return agentId;
} }
...@@ -55,7 +69,7 @@ class Response { ...@@ -55,7 +69,7 @@ class Response {
this.agentId = agentId; this.agentId = agentId;
} }
String getMchId() { public String getMchId() {
return mchId; return mchId;
} }
...@@ -63,7 +77,7 @@ class Response { ...@@ -63,7 +77,7 @@ class Response {
this.mchId = mchId; this.mchId = mchId;
} }
String getCode() { public String getCode() {
return code; return code;
} }
...@@ -71,7 +85,7 @@ class Response { ...@@ -71,7 +85,7 @@ class Response {
this.code = code; this.code = code;
} }
String getMsg() { public String getMsg() {
return msg; return msg;
} }
...@@ -79,7 +93,7 @@ class Response { ...@@ -79,7 +93,7 @@ class Response {
this.msg = msg; this.msg = msg;
} }
String getCodeUrl() { public String getCodeUrl() {
return codeUrl; return codeUrl;
} }
......
package com.xingdata.zxpay.pax; package com.xingdata.zxpay.pax;
import com.alibaba.fastjson.JSON;
import io.reactivex.functions.Function; import io.reactivex.functions.Function;
class ResultFilter implements Function<Response, com.xingdata.zxpay.api.Response> { class ResultFilter implements Function<Response, com.xingdata.zxpay.api.Response> {
...@@ -24,7 +26,7 @@ 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()) { switch (response.getMethod()) {
case C.METHOD.QRPAY: case C.METHOD.QRPAY:
r.setBody(response.getCodeUrl()); r.setBody(JSON.toJSONString(response));
break; break;
} }
return r; 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