PPS業務邏輯流程事項-JAY
注意事項:
1.呼叫支付之前,收款方會呼叫匹配member是否有對應結算賬戶,如果沒有會新建一個。如(就算有基本賬戶也會新建)
100000060023 | 200100200410000006002300001USD | USD-美元 | SETTLEMENT | 1.1700 USD | 正常 | USD |
2.對應支付幣種和賬戶要保持一致,不然通不過。
pps測試程式碼如下:
測試程式碼
package com.netfinworks.ws.api.pps;
/**
* Please modify this class to meet your needs
* This class is not complete
*/
import
com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl;
import
org.omg.CORBA.FREE_MEM;
import java.io.File;
import
java.math.BigDecimal;
import
java.net.MalformedURLException;
import
java.net.URL;
import
java.util.Date;
import
java.util.GregorianCalendar;
import
javax.xml.datatype.DatatypeFactory;
import
javax.xml.namespace.QName;
import
javax.jws.WebMethod;
import
javax.jws.WebParam;
import
javax.jws.WebResult;
import
javax.jws.WebService;
import
javax.xml.bind.annotation.XmlSeeAlso;
import
javax.xml.ws.RequestWrapper;
import
javax.xml.ws.ResponseWrapper;
/**
* This class was generated by Apache CXF 3.2.6
* 2018-09-10T18:08:05.509+08:00
* Generated source version: 3.2.6
*/
public
final
class
PaymentFacade_PaymentFacadeImplPort_Client {
private
static
final
QName SERVICE_NAME =
new
QName(
"http://pps.api.ws.netfinworks.com"
,
"PaymentFacadeImplService"
);
private
PaymentFacade_PaymentFacadeImplPort_Client() {
}
public
static
void
main(String args[])
throws
java.lang.Exception {
URL wsdlURL = PaymentFacadeImplService.WSDL_LOCATION;
if
(args.length >
0
&& args[
0
] !=
null
&& !
""
.equals(args[
0
])) {
File wsdlFile =
new
File(args[
0
]);
try
{
if
(wsdlFile.exists()) {
wsdlURL = wsdlFile.toURI().toURL();
}
else
{
wsdlURL =
new
URL(args[
0
]);
}
}
catch
(MalformedURLException e) {
e.printStackTrace();
}
}
PaymentFacadeImplService ss =
new
PaymentFacadeImplService(wsdlURL, SERVICE_NAME);
PaymentFacade port = ss.getPaymentFacadeImplPort();
{
System.out.println(
"Invoking pay..."
);
com.netfinworks.ws.api.pps.OperationEnvironment _pay_arg0 =
new
OperationEnvironment();
com.netfinworks.ws.api.pps.PaymentRequest paymentRequest =
new
PaymentRequest();
paymentRequest.setAccessChannel(
"WAP"
);
paymentRequest.setBizProductCode(
"10310"
);
paymentRequest.setCallbackAddress(
"TRADE_PAY_RESULT_NOTICE"
);
GregorianCalendar gc =
new
GregorianCalendar();
gc.setTimeInMillis(System.currentTimeMillis());
paymentRequest.setInitiateTime(DatatypeFactory.newInstance().newXMLGregorianCalendar(gc));
paymentRequest.setPayerId(
"200000060034"
);
PaymentInfo paymentInfo =
new
PaymentInfo();
BalancePayMethod PM =
new
BalancePayMethod();
//amount
Money amount =
new
Money();
amount.setAmount(
new
BigDecimal(
"1.1666"
));
amount.setCurrency(
"CNY"
);
amount.setRoundingMode(RoundingMode.HALF_UP);
PM.setAmount(amount);
//fee
Money fee =
new
Money();
fee.setAmount(
new
BigDecimal(
"0.0000"
));
fee.setCurrency(
"CNY"
);
fee.setRoundingMode(RoundingMode.HALF_UP);
PM.setFee(fee);
PM.setPayChannel(
"01"
);
PM.setPayMode(
"BALANCE"
);
PM.setExtension(
"shippingCity\":\"杭州\",\"billState\":\"浙江\",\"shippingPostalCode\":\"310000\",\"orderTerminal\":\"WAP\",\"billFirstName\":\"Adaline\",\"billCountryCode\":\"CN\",\"deviceFingerprintID\":\"\",\"shippingPhoneNumber\":\"13512548545\",\"goodsName\":\"使用者轉賬\",\"goodsDesc\":\"使用者轉賬\",\"customerIp\":\"127.0.0.1\",\"shippingLastName\":\"Zhu\",\"ip\":\"127.0.0.1\",\"tradeOrderNo\":\"20180910055911999300000904131\",\"userAgent\":\"PostmanRuntime/7.2.0\",\"billLastName\":\"Zhu\",\"billEmail\":\"[email protected]\",\"billCity\":\"杭州\",\"billPhoneNumber\":\"13512548545\",\"userId\":\"100015820004\",\"3DCHECK\":\"FALSE\",\"shippingCountryCode\":\"CN\",\"billAddress\":\"祥茂路\",\"shippingFirstName\":\"Adaline\",\"siteId\":\"www.jollychic.com\",\"shippingAddress\":\"祥茂路\",\"shippingState\":\"浙江\",\"billPostalCode\":\"310000\",\"shippingEmail\":\"[email protected]"
);
PM.setPayerAccountNo(
"200100100120000006003400001CNY"
);
PM.setPayerId(
"200000060034"
);
paymentInfo.setPayMethod(PM);
paymentInfo.setSettlementCurrency(
"CNY"
);
paymentInfo.setExtension(
""
);
paymentRequest.setPaymentInfo(paymentInfo);
paymentRequest.setPaymentVoucherNo(
"20181016171117558500001442952"
);
paymentRequest.setTradeOrderNo(
"20181016171117551100001442951"
);
paymentRequest.setSettleId(
"100000060023"
);
com.netfinworks.ws.api.pps.PaymentResponse _pay__return = port.pay(_pay_arg0, paymentRequest);
System.out.println(
"pay.result="
+ _pay__return.getReturnCode() + _pay__return.getPaymentVoucherNo());
}
/*{
System.out.println("Invoking pay...");
com.netfinworks.ws.api.pps.OperationEnvironment _pay_arg0 = new OperationEnvironment();
com.netfinworks.ws.api.pps.PaymentRequest paymentRequest = new PaymentRequest();
paymentRequest.setAccessChannel("WAP");
paymentRequest.setBizProductCode("20201");
paymentRequest.setCallbackAddress("TRADE_PAY_RESULT_NOTICE");
GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis(System.currentTimeMillis());
paymentRequest.setInitiateTime(DatatypeFactory.newInstance().newXMLGregorianCalendar(gc));
paymentRequest.setPayerId("200000060034");
PaymentInfo paymentInfo = new PaymentInfo();
//BalancePayMethod PM = new BalancePayMethod();
QuickPayMethod PM=new QuickPayMethod();
//amount
Money amount = new Money();
amount.setAmount(new BigDecimal("10.000"));
amount.setCurrency("SAR");
amount.setRoundingMode(RoundingMode.HALF_UP);
PM.setAmount(amount);
PM.setBankCardNo("421234");
PM.setBankCode("MASTERCARD");
PM.setCompanyOrPersonal("C");
PM.setDbcr("CC");
//fee
Money fee = new Money();
fee.setAmount(new BigDecimal("0.0000"));
fee.setCurrency("SAR");
fee.setRoundingMode(RoundingMode.HALF_UP);
PM.setFee(fee);
PM.setPayChannel("01");
PM.setPayMode("QPAY");
PM.setExtension("");
//PM.setPayerAccountNo("200100200110001582000400001SAR");
//PM.setPayerId("100015820004");
paymentInfo.setPayMethod(PM);
paymentInfo.setSettlementCurrency("SAR");
paymentInfo.setExtension("");
paymentRequest.setPaymentInfo(paymentInfo);
paymentRequest.setPaymentVoucherNo("20181030190342013500000000891");
paymentRequest.setTradeOrderNo("20181030190337895100000000890");
paymentRequest.setSettleId("200000180001");
com.netfinworks.ws.api.pps.PaymentResponse _pay__return = port.pay(_pay_arg0, paymentRequest);
System.out.println("pay.result=" + _pay__return.getReturnCode() + _pay__return.getPaymentVoucherNo());
}*/
/*{
System.out.println("Invoking settle...");
com.netfinworks.ws.api.pps.OperationEnvironment _settle_arg0 = null;
com.netfinworks.ws.api.pps.SettlementRequest settlementRequest = new SettlementRequest();
settlementRequest.setAccessChannel("WAP");
settlementRequest.setBizProductCode("10310");
settlementRequest.setCallbackAddress("TRADE_SETTLE_RESULT_NOTICE");
GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis(System.currentTimeMillis());
settlementRequest.setInitiateTime(DatatypeFactory.newInstance().newXMLGregorianCalendar(gc));
SettlementInfo settlementInfo = new SettlementInfo();
//amount
Money amount = new Money();
amount.setAmount(new BigDecimal("5.5000"));
amount.setCurrency("SAR");
amount.setRoundingMode(RoundingMode.HALF_UP);
settlementInfo.setAmount(amount);
//fee
Money fee = new Money();
fee.setAmount(new BigDecimal("0.0000"));
fee.setCurrency("SAR");
fee.setRoundingMode(RoundingMode.HALF_UP);
settlementInfo.setFee(fee);
//payeeFunds
BalanceFunds payeeFunds=new BalanceFunds();
payeeFunds.setAccessChannel("WEB");
payeeFunds.setCompanyOrPersonal("C");
payeeFunds.setDbcr("DC");
payeeFunds.setExtension("d");
payeeFunds.setPayeeAccountNo("200100200110001592000200001SAR");
payeeFunds.setPayeeId("100015920002");
payeeFunds.setTargetBankCode("g");
settlementInfo.setPayeeFunds(payeeFunds);
settlementRequest.setPaymentVoucherNo("20180910055912000500000904139");
settlementRequest.setTradeOrderNo("20180910055911999300000904139");
settlementRequest.setSettlementInfo(settlementInfo);
com.netfinworks.ws.api.pps.SettlementResponse response = port.settle(_settle_arg0, settlementRequest);
System.out.println("settle.result=" + response.getState()+"result:"+response.getExtension()+response.getReturnCode());
}*/
/*{
System.out.println("Invoking advance...");
com.netfinworks.ws.api.pps.OperationEnvironment _advance_arg0 = null;
com.netfinworks.ws.api.pps.AdvanceRequest _advance_arg1 = null;
com.netfinworks.ws.response.pps.AdvanceResponse _advance__return = port.advance(_advance_arg0, _advance_arg1);
System.out.println("advance.result=" + _advance__return);
}*/
System.exit(
0
);
}
}
|
3.清算通知由三個地方組成:
一、PaymentServiceImpl-》pay-》afterPayment(result, request); //同步請求返回支付成功,則傳送MQ進行清算處理
判斷條件為支付成功,並且未重複支付。如果重複支付則退款
二、ReconciliationResultMessageHandler-》PAYMENT //對賬結果非同步通知,剛傳送MQ進行清算處理
判斷條件為支付,會返回settlementAmount和settlementCurrency和paymentSeqNo
三、PaymentResultMessageHandler-》payment-》paymentService.handlePaymentResult(paymentResult);-》sendClearingNotifyMessage(paymentResult.getPaymentState().getCode(), paymentVoucherNo); //非同步支付訊息返回成功,傳送MQ到pps清算通知處理
判斷條件為非同步支付訊息返回支付成功。paymentVoucherNo和paymentState作為條件 //ppsNotifyClient.sendClearingNotifyMessage(new ClearingNotifyMessage(paymentVoucherNo, paymentState), paymentSuccessQueueName);
清算條件構成:
paymode為大類:
NETBANK("ONLINE_BANK", "網銀支付"),
DIRECTDEBT("DIRECTDEBT", "一點充支付"),
BALANCE("BALANCE", "餘額支付"),
MPCARD("MOBILE_CARD", "手機充值卡支付"),
MPEXPENSE("MOBILE_BALANCE", "手機話費支付"),
TEL("PHONE_PAY", "固話支付"),
PREPAIDCARD("PRE_CARD", "預付費卡支付"),
ROYALPOINTS("ROYAL_POINT", "積分支付"),
UNIONPAYEXPRESS("CP_FAST_PAY", "銀聯快捷支付"),
OFFLINE("OFFLINE", "線下支付"),
BROADBAND("BROADBAND_PAY", "寬頻支付"),
COUPON("COUPON", "紅包"),
PPC("PPC", "磁條卡支付"),
POSC("POSC", "無磁無密支付"),
POS("POS", "POS支付"),
EPAY("EPAY", "無卡支付"),
QUICKPAY("QPAY", "快捷支付"),
BANKSIGNQUICKPAY("BSQPAY", "銀籤快捷支付"),
CREDITPAY("CRPAY", "信用支付"),
CASH("CASH", "現金支付"),
CONFIRMEDFUND("CFMFUND", "確定性入款"),
GROUP("GROUP", "團購支付"),
TRUSTCOLLECT("TRUST_COLLECT", "代扣"),
PREAUTH("PRE_AUTH", "預授權");
BizProductCode為對應小類:
DEPOSIT("10101","會員充值", new String[]{"02"}),
WITHDRAW("10210","普通提現", new String[]{""}),
TRANSFER("10310", "會員轉賬", new String[]{""}),
INSTANT("20201", "即時到帳", new String[]{"01", "02"}),
ENSURE("20202","擔保交易", new String[]{"01", "02"}),
EXCHANGE("50201","換匯業務", new String[]{"01", "02"}),
PREAUTH("60103","預授權支付", new String[]{"01", "02"});
//比如 QUICKPAY 大類對應小類有 20201 即時到帳 和 20202 擔保交易 ,BANKSIGNQUICKPAY 大類 有 10101小類 會員充值
目前有清算的為:BALANCE、NETBANK、QUICKPAY、BANKSIGNQUICKPAY(新加10101 會員充值 )
NETBANK 和 QUICKPAY 支付如果不是20201即時到帳和20202擔保交易,則根據支付流水號查對賬狀態(counterClient服務去查可用金額)
結算方式為:
smData.setSettleable(true);
// 如果可結算金額幣種 = 支付金額幣種,那麼可結算金額 = 支付金額-費用金額
clearingCarrier.setAvailableSettlementAmount(payAmount.subtract(getFeeAmount(paymentOrderDO)));
smData.setClearingCarrier(clearingCarrier);