🆕 #1639 微信支付增加v3图片上传接口
1. 实现v3上传图片功能 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/tool/chapter3_1.shtml 2. 将接口获取到的证书保存到PayConfig中,v3接口中部分字段是敏感数据,在对这些数据加密时会用到
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package com.github.binarywang.wxpay.service.impl;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.media.ImageUploadResult;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import com.github.binarywang.wxpay.service.MerchantMediaService;
|
||||
import com.github.binarywang.wxpay.service.WxPayService;
|
||||
import com.github.binarywang.wxpay.testbase.ApiTestModule;
|
||||
import com.google.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 媒体文件上传测试类
|
||||
* </pre>
|
||||
*
|
||||
* @author zhouyongshen
|
||||
*/
|
||||
@Slf4j
|
||||
@Test
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class MerchantMediaServiceImplTest {
|
||||
|
||||
@Inject
|
||||
private WxPayService wxPayService;
|
||||
|
||||
@Test
|
||||
public void testImageUploadV3() throws WxPayException, IOException {
|
||||
|
||||
MerchantMediaService merchantMediaService=new MerchantMediaServiceImpl(wxPayService);
|
||||
|
||||
String filePath="你的图片文件的路径地址";
|
||||
// String filePath="WxJava/images/banners/wiki.jpg";
|
||||
|
||||
File file=new File(filePath);
|
||||
|
||||
ImageUploadResult imageUploadResult = merchantMediaService.imageUploadV3(file);
|
||||
String mediaId = imageUploadResult.getMediaId();
|
||||
|
||||
log.info("mediaId1:[{}]",mediaId);
|
||||
|
||||
File file2=new File(filePath);
|
||||
|
||||
ImageUploadResult imageUploadResult2 = merchantMediaService.imageUploadV3(file2);
|
||||
String mediaId2 = imageUploadResult2.getMediaId();
|
||||
|
||||
log.info("mediaId2:[{}]",mediaId2);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -10,4 +10,12 @@
|
||||
-->
|
||||
<keyPath>商户平台的证书文件地址</keyPath>
|
||||
<openid>某个openId</openid>
|
||||
|
||||
<!--
|
||||
apiv3 模式下所需配置
|
||||
<privateKeyPath>apiclient_key.pem证书文件的绝对路径或者以classpath:开头的类路径.</privateKeyPath>
|
||||
<privateCertPath>apiclient_cert.pem证书文件的绝对路径或者以classpath:开头的类路径.</privateCertPath>
|
||||
<apiV3Key> apiV3 秘钥值.</apiV3Key>
|
||||
<certSerialNo>apiV3 证书序列号值</certSerialNo>
|
||||
-->
|
||||
</xml>
|
||||
|
||||
Reference in New Issue
Block a user