支付方法中的证书文件参数由File调整为InputStream
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
package com.foxinmy.weixin4j.mp.test;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
@@ -22,7 +25,7 @@ import com.foxinmy.weixin4j.type.MPPaymentCheckNameType;
|
||||
public class CashTest extends CouponTest {
|
||||
|
||||
@Test
|
||||
public void sendRedpacket() throws WeixinException {
|
||||
public void sendRedpacket() throws WeixinException, IOException {
|
||||
Redpacket redpacket = new Redpacket("HB001", "无忧钱庄", "无忧钱庄",
|
||||
"oyFLst1bqtuTcxK-ojF8hOGtLQao", 1d);
|
||||
redpacket.setActName("红包测试");
|
||||
@@ -32,23 +35,26 @@ public class CashTest extends CouponTest {
|
||||
redpacket.setRemark("快来领取红包吧!");
|
||||
redpacket.setTotalNum(1);
|
||||
redpacket.setWishing("来就送钱");
|
||||
RedpacketSendResult result = WEIXINPAY.sendRedpack(caFile, redpacket);
|
||||
RedpacketSendResult result = WEIXINPAY.sendRedpack(new FileInputStream(
|
||||
caFile), redpacket);
|
||||
System.err.println(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryRedpacket() throws WeixinException {
|
||||
public void queryRedpacket() throws WeixinException, IOException {
|
||||
String outTradeNo = "HB001";
|
||||
RedpacketRecord record = WEIXINPAY.queryRedpack(caFile, outTradeNo);
|
||||
RedpacketRecord record = WEIXINPAY.queryRedpack(new FileInputStream(
|
||||
caFile), outTradeNo);
|
||||
System.err.println(record);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mpPayment() throws WeixinException {
|
||||
public void mpPayment() throws WeixinException, IOException {
|
||||
MPPayment payment = new MPPayment("MP001",
|
||||
"oyFLst1bqtuTcxK-ojF8hOGtLQao",
|
||||
MPPaymentCheckNameType.NO_CHECK, "企业付款测试", 0.01d, "127.0.0.1");
|
||||
MPPaymentResult result = WEIXINPAY.mpPayment(caFile, payment);
|
||||
MPPaymentResult result = WEIXINPAY.mpPayment(
|
||||
new FileInputStream(caFile), payment);
|
||||
System.err.println(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.foxinmy.weixin4j.mp.test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
import org.junit.Assert;
|
||||
@@ -34,11 +36,11 @@ public class CouponTest {
|
||||
protected final File caFile = new File("证书文件路径(*.p12)");
|
||||
|
||||
@Test
|
||||
public void sendCoupon() throws WeixinException {
|
||||
public void sendCoupon() throws WeixinException, IOException {
|
||||
String partnerTradeNo = String.format("%s%s%s", ACCOUNT.getMchId(),
|
||||
DateUtil.fortmat2yyyyMMdd(new Date()), "1");
|
||||
CouponResult result = WEIXINPAY.sendCoupon(caFile, "123",
|
||||
partnerTradeNo, "oyFLst1bqtuTcxK-ojF8hOGtLQao", null);
|
||||
CouponResult result = WEIXINPAY.sendCoupon(new FileInputStream(caFile),
|
||||
"123", partnerTradeNo, "oyFLst1bqtuTcxK-ojF8hOGtLQao", null);
|
||||
Assert.assertTrue(result.getRetCode().equalsIgnoreCase(Consts.SUCCESS));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.foxinmy.weixin4j.mp.test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -109,13 +111,13 @@ public class PayTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void refundV3() throws WeixinException {
|
||||
public void refundV3() throws WeixinException, IOException {
|
||||
File caFile = new File("签名文件如123.p12");
|
||||
IdQuery idQuery = new IdQuery("TT_1427183696238", IdType.TRADENO);
|
||||
com.foxinmy.weixin4j.payment.mch.RefundResult result = PAY3
|
||||
.refundApply(caFile, idQuery,
|
||||
"TT_R" + System.currentTimeMillis(), 0.01d, 0.01d,
|
||||
null, "10020674");
|
||||
.refundApply(new FileInputStream(caFile), idQuery, "TT_R"
|
||||
+ System.currentTimeMillis(), 0.01d, 0.01d, null,
|
||||
"10020674");
|
||||
System.err.println(result);
|
||||
String sign = result.getSign();
|
||||
result.setSign(null);
|
||||
|
||||
Reference in New Issue
Block a user