补完
This commit is contained in:
parent
e83c62824b
commit
2cdd2a7f4d
@ -1,47 +1,30 @@
|
|||||||
支付模块【JSAPI】【NATIVE】【MICROPAY】
|
支付模块【JSAPI】【NATIVE】【MICROPAY】
|
||||||
|
|
||||||
微信公众平台[V2版本支付](https://mp.weixin.qq.com/paymch/readtemplate?t=mp/business/course2_tmpl&lang=zh_CN)文档
|
目前只支持商户平台v2版本的支付API
|
||||||
|
|
||||||
微信公众平台[V3版本支付](https://mp.weixin.qq.com/paymch/readtemplate?t=mp/business/course3_tmpl&lang=zh_CN)文档
|
**V3版在计划中,但目前因V3版针对的电商平台、微信支付分两类商户目前都是邀请制的,所以具体什么时候开展还未知。有能力的朋友可以帮忙贡献代码**
|
||||||
|
|
||||||
**在`2014年10月9号`之前申请并审核通过的支付接口应该属于`V2版本`支付,而之后申请的接口则为`V3版本(商户平台)`支付**
|
|
||||||
|
|
||||||
|
|
||||||
[WeixinPayProxy](WeixinPayProxy.java)
|
[WeixinPayProxy](https://github.com/foxinmy/weixin4j/blob/master/weixin4j-pay/src/main/java/com/foxinmy/weixin4j/pay/WeixinPayProxy.java)
|
||||||
-------------------------
|
-------------------------
|
||||||
|
这是所有支付平台所有API的代理类,入参是一个WeixinPayAccount,建议调用API都通过代理类去调用,会相对简单些。
|
||||||
* createPayJsRequestJson: 创建V3版本(商户平台)的JSAPI支付串
|
|
||||||
|
|
||||||
* createNativePayRequestURL: 创建V3版本(商户平台)的扫码支付链接
|
|
||||||
|
|
||||||
* createPrePay: 调用V3版本(商户平台)的统一订单接口生成预订单数据
|
|
||||||
|
|
||||||
* createMicroPay: 创建刷卡支付(商户平台)请求
|
|
||||||
|
|
||||||
* orderQuery: 订单查询接口
|
|
||||||
|
|
||||||
* refundOrder: 退款申请接口
|
|
||||||
|
|
||||||
* reverseOrder: 冲正订单接口
|
|
||||||
|
|
||||||
* closeOrder: 关闭订单接口
|
|
||||||
|
|
||||||
* downloadBill: 下载对账单接口
|
|
||||||
|
|
||||||
* refundQuery: 退款查询接口
|
|
||||||
|
|
||||||
|
|
||||||
[Pay2Api](https://github.com/foxinmy/weixin4j/blob/master/weixin4j-mp/src/main/java/com/foxinmy/weixin4j/mp/api/Pay2Api.java)
|
|
||||||
|
[PayApi](https://github.com/foxinmy/weixin4j/blob/master/weixin4j-pay/src/main/java/com/foxinmy/weixin4j/pay/api/PayApi.java)
|
||||||
-------------------------
|
-------------------------
|
||||||
|
微信支付API
|
||||||
|
|
||||||
* createPayJsRequestJson: 创建V2版本的JSAPI支付串
|
[CashApi](https://github.com/foxinmy/weixin4j/blob/master/weixin4j-pay/src/main/java/com/foxinmy/weixin4j/pay/api/CashApi.java)
|
||||||
|
-------------------------
|
||||||
|
微信现金红包API
|
||||||
|
|
||||||
* createNativePayRequestURL: 创建V2版本的扫码支付链接
|
[CouponApi](https://github.com/foxinmy/weixin4j/blob/master/weixin4j-pay/src/main/java/com/foxinmy/weixin4j/pay/api/CouponApi.java)
|
||||||
|
-------------------------
|
||||||
|
微信代金券API
|
||||||
|
|
||||||
* orderQuery: 订单查询接口
|
[ProfitSharingApi](https://github.com/foxinmy/weixin4j/blob/master/weixin4j-pay/src/main/java/com/foxinmy/weixin4j/pay/api/ProfitSharingApi.java)
|
||||||
|
-------------------------
|
||||||
|
微信分帐API
|
||||||
|
|
||||||
* refundOrder: 退款申请接口
|
|
||||||
|
|
||||||
* downloadBill: 下载对账单接口
|
|
||||||
|
|
||||||
* refundQuery: 退款查询接口
|
|
||||||
|
|||||||
@ -0,0 +1,37 @@
|
|||||||
|
package com.foxinmy.weixin4j.pay.test;
|
||||||
|
|
||||||
|
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||||
|
import com.foxinmy.weixin4j.pay.PayPackageBuilder;
|
||||||
|
import com.foxinmy.weixin4j.pay.WeixinPayProxy;
|
||||||
|
import com.foxinmy.weixin4j.pay.model.WeixinPayAccount;
|
||||||
|
import com.foxinmy.weixin4j.pay.payment.mch.MICROPayRequest;
|
||||||
|
import com.foxinmy.weixin4j.pay.payment.mch.MchPayPackage;
|
||||||
|
import com.foxinmy.weixin4j.pay.payment.mch.MchPayRequest;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一个支付例子
|
||||||
|
*
|
||||||
|
* @author kit (kit.li@qq.com)
|
||||||
|
*/
|
||||||
|
public class PayApiExample {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 这是一个付款码支付的例子
|
||||||
|
*
|
||||||
|
* @throws WeixinException
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testPay() throws WeixinException {
|
||||||
|
WeixinPayAccount payAccount = new WeixinPayAccount("你的appid", "支付密钥", "商户号");
|
||||||
|
MchPayPackage payPackage = PayPackageBuilder.microPay("body内容", "商户订单号", 1.00D, "127.0.0.1",
|
||||||
|
"你的付款码")
|
||||||
|
.attach("这是一个测试")
|
||||||
|
.limitPay()
|
||||||
|
.build();
|
||||||
|
WeixinPayProxy proxy = new WeixinPayProxy(payAccount);
|
||||||
|
MICROPayRequest r = (MICROPayRequest) proxy.createPayRequest(payPackage);
|
||||||
|
Assert.assertEquals(r.getResultCode(), "SUCCESS");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,27 +4,29 @@ import com.alibaba.fastjson.JSON;
|
|||||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||||
import com.foxinmy.weixin4j.pay.WeixinPayProxy;
|
import com.foxinmy.weixin4j.pay.WeixinPayProxy;
|
||||||
import com.foxinmy.weixin4j.pay.model.WeixinPayAccount;
|
import com.foxinmy.weixin4j.pay.model.WeixinPayAccount;
|
||||||
import com.foxinmy.weixin4j.pay.profitsharing.Receiver;
|
import com.foxinmy.weixin4j.pay.profitsharing.*;
|
||||||
import com.foxinmy.weixin4j.pay.profitsharing.ReceiverResult;
|
|
||||||
import com.foxinmy.weixin4j.pay.type.profitsharing.ReceiverType;
|
import com.foxinmy.weixin4j.pay.type.profitsharing.ReceiverType;
|
||||||
import com.foxinmy.weixin4j.pay.type.profitsharing.RelationType;
|
import com.foxinmy.weixin4j.pay.type.profitsharing.RelationType;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class TestProfitSharingApi {
|
public class TestProfitSharingApi {
|
||||||
// 微信公众号appid
|
// 微信公众号appid
|
||||||
private static String APPID = "wx8208082617097c70";
|
private static String APPID = "";
|
||||||
// 微信支付商户密钥
|
// 微信支付商户密钥
|
||||||
private static String PAY_SIGN_KEY = "musegogogomusegogogomusegogogo16";
|
private static String PAY_SIGN_KEY = "";
|
||||||
// 商户号
|
// 商户号
|
||||||
private static String MCHID = "1319061501";
|
private static String MCHID = "";
|
||||||
//
|
//
|
||||||
private static String OPENID = "oIkWcwtHXPp32ISw_Ept3FUQ1DM4";
|
private static String OPENID = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 测试添加分帐方
|
* 测试添加分帐方
|
||||||
*/
|
*/
|
||||||
// @Test
|
@Test
|
||||||
public void testAddReceiver() throws WeixinException {
|
public void testAddReceiver() throws WeixinException {
|
||||||
Receiver receiver = new Receiver(ReceiverType.PERSONAL_OPENID, OPENID, RelationType.STAFF);
|
Receiver receiver = new Receiver(ReceiverType.PERSONAL_OPENID, OPENID, RelationType.STAFF);
|
||||||
WeixinPayAccount account = new WeixinPayAccount(APPID, PAY_SIGN_KEY, MCHID);
|
WeixinPayAccount account = new WeixinPayAccount(APPID, PAY_SIGN_KEY, MCHID);
|
||||||
@ -37,7 +39,7 @@ public class TestProfitSharingApi {
|
|||||||
/**
|
/**
|
||||||
* 测试删除分帐方
|
* 测试删除分帐方
|
||||||
*/
|
*/
|
||||||
//@Test
|
@Test
|
||||||
public void testRemoveReceiver() throws WeixinException {
|
public void testRemoveReceiver() throws WeixinException {
|
||||||
Receiver receiver = new Receiver(ReceiverType.PERSONAL_OPENID, OPENID, null);
|
Receiver receiver = new Receiver(ReceiverType.PERSONAL_OPENID, OPENID, null);
|
||||||
WeixinPayAccount account = new WeixinPayAccount(APPID, PAY_SIGN_KEY, MCHID);
|
WeixinPayAccount account = new WeixinPayAccount(APPID, PAY_SIGN_KEY, MCHID);
|
||||||
@ -47,7 +49,21 @@ public class TestProfitSharingApi {
|
|||||||
Assert.assertEquals(result.getReturnCode(), "SUCCESS");
|
Assert.assertEquals(result.getReturnCode(), "SUCCESS");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testProfitPay() throws WeixinException {
|
/**
|
||||||
|
* 单次分帐
|
||||||
|
*
|
||||||
|
* @throws WeixinException
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testProfitSharing() throws WeixinException {
|
||||||
|
ReceiverProfit receiverProfit = new ReceiverProfit(ReceiverType.MERCHANT_ID, "", 1, "test");
|
||||||
|
List<ReceiverProfit> list = new ArrayList<ReceiverProfit>();
|
||||||
|
list.add(receiverProfit);
|
||||||
|
WeixinPayAccount account = new WeixinPayAccount(APPID, PAY_SIGN_KEY, MCHID);
|
||||||
|
WeixinPayProxy proxy = new WeixinPayProxy(account);
|
||||||
|
ProfitSharingResult result = proxy.profitSharing("transactioId", "outOrderNo", list, false);
|
||||||
|
System.out.println(JSON.toJSONString(result));
|
||||||
|
Assert.assertEquals(result.getReturnCode(), "SUCCESS");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user