-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix PR #6 + wxpay/OrderQuery + wxpay/Refund + wxpay/RefundQuery
- Loading branch information
Showing
20 changed files
with
1,187 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.github.cuter44.wxpay.constants; | ||
|
||
/** RefundState | ||
* @since 0.4.1 | ||
* | ||
*/ | ||
public enum RefundStatus | ||
{ | ||
/** code=0, NOTSURE—未确定,需要商户原退款单号重新发起 | ||
*/ | ||
NOTSURE(0), | ||
/** code=1, PROCESSING—退款处理中 | ||
*/ | ||
PROCESSING(1), | ||
|
||
/** code=16, SUCCES—退款成功 | ||
*/ | ||
SUCCESS(16), | ||
|
||
/** code=-1, FAIL—退款失败 | ||
*/ | ||
FAIL(-1), | ||
|
||
/** code=-2, CHANGE—转入代发,退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,资金回流到商户的现金帐号,需要商户人工干预,通过线下或者财付通转账的方式进行退款。 | ||
*/ | ||
CHANGE(-2); | ||
|
||
public byte code; | ||
|
||
private RefundStatus(int code) | ||
{ | ||
this.code = (byte)code; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.github.cuter44.wxpay.constants; | ||
|
||
/** TradeState | ||
* @since 0.4.1 | ||
* | ||
* Notice that <code>code</code> is NOT officially defined by wx. | ||
* And since wx does not provide a status diagram, this distribution is a temporary solution. | ||
* It may be changed in later version. Take consideration before using them. | ||
*/ | ||
public enum TradeState | ||
{ | ||
/** code=0, NOTPAY—未支付 | ||
*/ | ||
NOTPAY(0), | ||
/** code=1, NOPAY--未支付(输入密码或确认支付超时) | ||
*/ | ||
NOPAY(1), | ||
|
||
/** code=2, USERPAYING--用户支付中 | ||
*/ | ||
USERPAYING(2), | ||
|
||
/** code=16, SUCCESS—支付成功 | ||
*/ | ||
SUCCESS(16), | ||
|
||
/** code=32, REFUND—转入退款 | ||
*/ | ||
REFUND(32), | ||
|
||
/** code=64, REVOKED—已撤销 | ||
* This is an unclear state. | ||
*/ | ||
REVOKED(64), | ||
|
||
/** code=-1, PAYERROR--支付失败(其他原因,如银行返回失败) | ||
*/ | ||
PAYERROR(-1), | ||
|
||
/** code=-128, CLOSED—已关闭 | ||
*/ | ||
CLOSED(-128); | ||
|
||
|
||
public byte code; | ||
|
||
private TradeState(int code) | ||
{ | ||
this.code = (byte)code; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package com.github.cuter44.wxpay.reqs; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Properties; | ||
import java.io.IOException; | ||
import java.io.UnsupportedEncodingException; | ||
|
||
import com.github.cuter44.wxpay.resps.OrderQueryResponse; | ||
import com.github.cuter44.wxpay.WxpayException; | ||
import com.github.cuter44.wxpay.WxpayProtocolException; | ||
|
||
/** | ||
* Created by Mklaus on 15/4/21. | ||
*/ | ||
public class OrderQuery extends WxpayRequestBase{ | ||
|
||
public static final String URL_API_BASE = "https://api.mch.weixin.qq.com/pay/orderquery"; | ||
|
||
protected static final String KEY_OUT_TRADE_NO = "out_trade_no"; | ||
protected static final String KEY_TRANSACTION_ID = "transaction_id"; | ||
|
||
public static final List<String> KEYS_PARAM_NAME = Arrays.asList( | ||
"appid", | ||
"mch_id", | ||
"nonce_str", | ||
"out_trade_no", | ||
"transaction_id", | ||
"sign" | ||
); | ||
|
||
//CONSTRUCT | ||
public OrderQuery(Properties prop){ | ||
super(prop); | ||
|
||
return; | ||
} | ||
|
||
//BUILD | ||
@Override | ||
public OrderQuery build() | ||
{ | ||
return(this); | ||
} | ||
|
||
//SIGN | ||
@Override | ||
public OrderQuery sign() | ||
throws UnsupportedEncodingException | ||
{ | ||
this.sign(KEYS_PARAM_NAME); | ||
|
||
return(this); | ||
} | ||
|
||
// TO_URL | ||
public String toURL() | ||
throws UnsupportedOperationException | ||
{ | ||
throw( | ||
new UnsupportedOperationException("This request does not execute on client side") | ||
); | ||
} | ||
|
||
// EXECUTE | ||
@Override | ||
public OrderQueryResponse execute() | ||
throws WxpayException, WxpayProtocolException, IOException | ||
{ | ||
String url = URL_API_BASE; | ||
String body = this.toXml(KEYS_PARAM_NAME); | ||
|
||
String respXml = this.executePostXML(url, body); | ||
|
||
return(new OrderQueryResponse(respXml)); | ||
} | ||
|
||
/** 商户系统内部的订单号,32个字符内、可包含字母 | ||
*/ | ||
public OrderQuery setOutTradeNo(String outTradeNo) | ||
{ | ||
this.setProperty(KEY_OUT_TRADE_NO, outTradeNo); | ||
|
||
return(this); | ||
} | ||
|
||
/** 微信的订单号,优先使用 | ||
*/ | ||
public OrderQuery setTransactionId(String transactionId) | ||
{ | ||
this.setProperty(KEY_TRANSACTION_ID,transactionId); | ||
|
||
return (this); | ||
} | ||
} |
Oops, something went wrong.