資源簡介
JAVA微信支付退款接口demo
應用場景
當交易發(fā)生之后一段時間內(nèi),由于買家或者賣家的原因需要退款時,賣家可以通過退款接口將支付款退還給買家,微信支付將在收到退款請求并且驗證成功之后,按照退款規(guī)則將支付款按原路退到買家?guī)ぬ柹稀?img width=510 src=http://www.sh-liguang.com/pic/217555.jpg />
代碼片段和文件信息
package?com.shusheng.refund;
/*
?*?====================================================================
?*?Licensed?to?the?Apache?Software?Foundation?(ASF)?under?one
?*?or?more?contributor?license?agreements.??See?the?NOTICE?file
?*?distributed?with?this?work?for?additional?information
?*?regarding?copyright?ownership.??The?ASF?licenses?this?file
?*?to?you?under?the?Apache?License?Version?2.0?(the
?*?“License“);?you?may?not?use?this?file?except?in?compliance
?*?with?the?License.??You?may?obtain?a?copy?of?the?License?at
?*
?*???http://www.apache.org/licenses/LICENSE-2.0
?*
?*?Unless?required?by?applicable?law?or?agreed?to?in?writing
?*?software?distributed?under?the?License?is?distributed?on?an
?*?“AS?IS“?BASIS?WITHOUT?WARRANTIES?OR?CONDITIONS?OF?ANY
?*?KIND?either?express?or?implied.??See?the?License?for?the
?*?specific?language?governing?permissions?and?limitations
?*?under?the?License.
?*?====================================================================
?*
?*?This?software?consists?of?voluntary?contributions?made?by?many
?*?individuals?on?behalf?of?the?Apache?Software?Foundation.??For?more
?*?information?on?the?Apache?Software?Foundation?please?see
?*? .
?*
?*/
import?java.io.File;
import?java.io.FileInputStream;
import?java.net.URI;
import?java.net.URL;
import?java.security.KeyStore;
import?javax.net.ssl.SSLContext;
import?org.apache.http.HttpEntity;
import?org.apache.http.client.methods.CloseableHttpResponse;
import?org.apache.http.client.methods.HttpPost;
import?org.apache.http.conn.ssl.SSLContexts;
import?org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import?org.apache.http.entity.StringEntity;
import?org.apache.http.impl.client.CloseableHttpClient;
import?org.apache.http.impl.client.HttpClients;
import?org.apache.http.util.EntityUtils;
/**
?*?This?example?demonstrates?how?to?create?secure?connections?with?a?custom?SSL
?*?context.
?*/
public?class?ClientCustomSSL?{
//商戶號
//微信公眾平臺:“微信支付”--》“商戶信息”--》“商戶號”,將該值賦值給partner
private?static?String?partner?=?“xxxx“;
//p12證書的位置
//微信公眾平臺:“微信支付”--》“商戶信息”--》“交易數(shù)據(jù)”--》“詳情請登錄微信支付商戶平臺查看”(登錄)--》“API安全”--》“API證書”--》“下載證書”
//下載證書后將apiclient_cert.p12放在src目錄下面(出于安全考慮,請自行下載自己的證書)
private?static?String?apiclient_certLocation?=?“apiclient_cert.p12“;
????public?static?String?doRefund(String?urlString?data)?throws?Exception?{
????????KeyStore?keyStore??=?KeyStore.getInstance(“PKCS12“);
????????URL?url2?=?ClientCustomSSL.class.getClassLoader().getResource(apiclient_certLocation);
????????URI?uri?=?url2.toURI();
????????FileInputStream?instream?=?new?FileInputStream(new?File(uri));//P12文件目錄
????????try?{
????????????keyStore.load(instream?partner.toCharArray());
????????}?finally?{
????????????instream.close();
????????}
????????SSLContext?sslcontext?=?SSLContexts.custom()
????????????????.loadKeyMaterial(keyStore?partner.toCharArray())//這里也是寫密碼的
????????????????.build();
????????SSLConnectionSoc
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????500??2016-03-20?23:24??.settings\.jsdtscope
?????文件????????364??2016-03-20?23:24??.settings\org.eclipse.jdt.core.prefs
?????文件????????483??2016-03-20?23:24??.settings\org.eclipse.wst.common.component
?????文件????????252??2016-03-20?23:24??.settings\org.eclipse.wst.common.project.facet.core.xm
?????文件?????????49??2016-03-20?23:24??.settings\org.eclipse.wst.jsdt.ui.superType.container
?????文件??????????6??2016-03-20?23:24??.settings\org.eclipse.wst.jsdt.ui.superType.name
?????文件???????4734??2016-03-21?00:05??src\com\shusheng\refund\ClientCustomSSL.java
?????文件???????1161??2016-03-20?23:26??src\com\shusheng\refund\MD5Util.java
?????文件???????3976??2016-03-21?08:34??src\com\shusheng\refund\RefundUtil.java
?????文件???????6575??2016-03-20?23:26??src\com\shusheng\refund\RequestHandler.java
?????文件???????2108??2016-03-20?23:26??src\com\shusheng\refund\Sha1Util.java
?????文件???????3656??2016-03-20?23:52??src\com\shusheng\refund\TenpayUtil.java
?????文件????????829??2016-03-20?23:24??WebRoot\index.jsp
?????文件?????????36??2016-03-20?23:24??WebRoot\me
?????文件???????4531??2016-03-21?00:05??WebRoot\WEB-INF\classes\com\shusheng\refund\ClientCustomSSL.class
?????文件???????2174??2016-03-20?23:47??WebRoot\WEB-INF\classes\com\shusheng\refund\MD5Util.class
?????文件???????3529??2016-03-21?08:34??WebRoot\WEB-INF\classes\com\shusheng\refund\RefundUtil.class
?????文件???????6319??2016-03-20?23:47??WebRoot\WEB-INF\classes\com\shusheng\refund\RequestHandler.class
?????文件???????3399??2016-03-20?23:47??WebRoot\WEB-INF\classes\com\shusheng\refund\Sha1Util.class
?????文件???????3416??2016-03-20?23:52??WebRoot\WEB-INF\classes\com\shusheng\refund\TenpayUtil.class
?????文件????????125??2016-03-21?08:33??WebRoot\WEB-INF\classes\readme
?????文件??????62050??2016-01-15?23:26??WebRoot\WEB-INF\lib\commons-logging-1.1.3.jar
?????文件??????44598??2016-01-15?23:26??WebRoot\WEB-INF\lib\commons-logging-api-1.1.jar
?????文件?????313898??2016-01-15?23:26??WebRoot\WEB-INF\lib\dom4j-1.6.1.jar
?????文件?????590004??2016-01-15?23:26??WebRoot\WEB-INF\lib\httpclient-4.3.4.jar
?????文件?????149768??2016-01-15?23:26??WebRoot\WEB-INF\lib\httpclient-cache-4.3.4.jar
?????文件?????282269??2016-01-15?23:26??WebRoot\WEB-INF\lib\httpcore-4.3.2.jar
?????文件??????37276??2016-01-15?23:26??WebRoot\WEB-INF\lib\httpmime-4.3.4.jar
?????文件?????153253??2016-01-15?23:26??WebRoot\WEB-INF\lib\jdom-1.0.jar
?????文件????????404??2016-03-20?23:24??WebRoot\WEB-INF\web.xm
............此處省略20個文件信息
評論
共有 條評論