View Javadoc
1   package com.foxinmy.weixin4j.base.test;
2   
3   import org.junit.Assert;
4   import org.junit.Test;
5   
6   import com.foxinmy.weixin4j.exception.WeixinException;
7   import com.foxinmy.weixin4j.payment.mch.CorpPayment;
8   import com.foxinmy.weixin4j.payment.mch.CorpPaymentRecord;
9   import com.foxinmy.weixin4j.payment.mch.CorpPaymentResult;
10  import com.foxinmy.weixin4j.payment.mch.Redpacket;
11  import com.foxinmy.weixin4j.payment.mch.RedpacketRecord;
12  import com.foxinmy.weixin4j.payment.mch.RedpacketSendResult;
13  import com.foxinmy.weixin4j.type.mch.CorpPaymentCheckNameType;
14  import com.foxinmy.weixin4j.util.Consts;
15  
16  /**
17   * 现金发放测试
18   *
19   * @className CashTest
20   * @author jinyu(foxinmy@gmail.com)
21   * @date 2015年4月1日
22   * @since JDK 1.6
23   * @see
24   */
25  public class CashTest extends PayTest {
26  
27  	@Test
28  	public void sendRedpacket() throws WeixinException {
29  		Redpacket redpacket = new Redpacket("HB001",
30  				"oyFLst1bqtuTcxK-ojF8hOGtLQao", "无忧钱庄", 1d, 1, "红包测试",
31  				"127.0.0.1", "快来领取红包吧!", "来就送钱");
32  		RedpacketSendResult result = PAY.sendRedpack(redpacket);
33  		Assert.assertEquals(Consts.SUCCESS, result.getReturnCode());
34  		Assert.assertEquals(Consts.SUCCESS, result.getResultCode());
35  		System.err.println(result);
36  	}
37  
38  	@Test
39  	public void queryRedpacket() throws WeixinException {
40  		String outTradeNo = "HB001";
41  		RedpacketRecord result = PAY.queryRedpack(outTradeNo);
42  		Assert.assertEquals(Consts.SUCCESS, result.getReturnCode());
43  		Assert.assertEquals(Consts.SUCCESS, result.getResultCode());
44  		System.err.println(result);
45  	}
46  
47  	@Test
48  	public void sendCorpPayment() throws WeixinException {
49  		CorpPayment payment = new CorpPayment("MP001",
50  				"ofW1gwok9vZIyle0YbA-eQe83Uk8",
51  				CorpPaymentCheckNameType.NO_CHECK, "企业付款测试", 1d, "127.0.0.1");
52  		CorpPaymentResult result = PAY.sendCorpPayment(payment);
53  		Assert.assertEquals(Consts.SUCCESS, result.getReturnCode());
54  		Assert.assertEquals(Consts.SUCCESS, result.getResultCode());
55  		System.err.println(result);
56  	}
57  
58  	@Test
59  	public void queryCorpPayment() throws WeixinException {
60  		CorpPaymentRecord result = PAY.queryCorpPayment("MP001");
61  		Assert.assertEquals(Consts.SUCCESS, result.getReturnCode());
62  		Assert.assertEquals(Consts.SUCCESS, result.getResultCode());
63  		System.err.println(result);
64  	}
65  }