当前位置:   article > 正文

微信支付之扫码支付Native支付 模式二_android 微信扫码收费native应用

android 微信扫码收费native应用

一.使用场景

1.福袋机上的屏幕是一个Android平板,相当于一个Android手机

2.需要给用户生成一张二维码,让用户扫描付款

3.得到用户付款的消息后,转动对应的电机,给用户掉落福袋

二.准备资料

1.研究微信支付文档 https://pay.weixin.qq.com/wiki/doc/api/index.html  根据我的需求,我选择了Native支付

2.模式二比较简单,比较容易实现成功,所已选择了模式二

3.拿着公司提供的一个邮箱在微信公众平台https://mp.weixin.qq.com/cgi-bin/loginpage?t=wxm2-login&lang=zh_CN申请一个账号,选择申请的这个公众号为服务号,把公司的相关信息和一些申请资料提交后,1-3天就申请好了.

4.拿到我们申请的公众号后,我们还要花300元进行微信认证,得1-3天就认证好了(可以得到一个AppID)

5.在微信公平平台的微信支付页面,点击 申请接入,发现需要一个商户号,所以我们 现在去微信商户平台https://pay.weixin.qq.com/index.php/core/home/login?return_url=%2F注册一个账户(注意:在电脑自带的IE浏览器上进行操作,因为后边要弄财富通,在谷歌浏览器上识别不到财富通),提交一些公司资料后,过1-3天就申请好了(可以自己设置一个32位的秘钥,可以得到一个商户号)

6.有了AppID,秘钥和商户号就可以进行开发了,即使没有后台,全做到Android都可以实现了

7.看微信支付文档有统一下单接口,查询订单接口,关闭订单接口.

三.开发

CSDN橙子紫了博客主 https://blog.csdn.net/u013164584/article/details/78030481的这片帖子 封装的比较好

1.导入依赖

  1. //网络
  2. implementation 'org.lucee:httpcomponents-httpclient:4.5.6'
  3. //二维码
  4. implementation 'com.google.zxing:core:3.2.1'
  5. implementation 'cn.bingoogolapple:bga-qrcodecore:1.1.7@aar'
  6. implementation 'cn.bingoogolapple:bga-zxing:1.1.7@aar'

2.PayCommonUtil,该工具类中的方法包含:生成签名,判断签名是否正确,生成二维码,xml和map转换,随机字符串,请求下单等等

  1. package com.wjbzg.wxtestdome.util;
  2. import android.content.Context;
  3. import android.content.res.AssetManager;
  4. import android.support.annotation.NonNull;
  5. import android.util.Log;
  6. import org.apache.http.conn.ssl.SSLContexts;
  7. import org.w3c.dom.Node;
  8. import org.w3c.dom.NodeList;
  9. import java.io.BufferedReader;
  10. import java.io.ByteArrayInputStream;
  11. import java.io.DataOutputStream;
  12. import java.io.IOException;
  13. import java.io.InputStream;
  14. import java.io.InputStreamReader;
  15. import java.io.OutputStream;
  16. import java.net.ConnectException;
  17. import java.net.HttpURLConnection;
  18. import java.net.URL;
  19. import java.security.KeyManagementException;
  20. import java.security.KeyStore;
  21. import java.security.KeyStoreException;
  22. import java.security.MessageDigest;
  23. import java.security.NoSuchAlgorithmException;
  24. import java.security.NoSuchProviderException;
  25. import java.security.SecureRandom;
  26. import java.security.UnrecoverableKeyException;
  27. import java.security.cert.CertificateException;
  28. import java.util.HashMap;
  29. import java.util.Iterator;
  30. import java.util.Map;
  31. import java.util.Random;
  32. import java.util.Set;
  33. import java.util.SortedMap;
  34. import java.util.TreeMap;
  35. import javax.net.ssl.HttpsURLConnection;
  36. import javax.net.ssl.KeyManagerFactory;
  37. import javax.net.ssl.SSLContext;
  38. import javax.net.ssl.SSLSocketFactory;
  39. import javax.xml.parsers.DocumentBuilder;
  40. import javax.xml.parsers.DocumentBuilderFactory;
  41. /**
  42. * Created by ${szz} on 2019\6\5 0005
  43. */
  44. public class PayCommonUtil {
  45. //判断签名是否正确
  46. public static boolean isTenpaySign(String characterEncoding, SortedMap<Object, Object> packageParams, String API_KEY) {
  47. StringBuffer sb = new StringBuffer();
  48. Set es = packageParams.entrySet();
  49. Iterator it = es.iterator();
  50. while (it.hasNext()) {
  51. Map.Entry entry = (Map.Entry) it.next();
  52. String k = (String) entry.getKey();
  53. String v = (String) entry.getValue();
  54. if (!"sign".equals(k) && null != v && !"".equals(v)) {
  55. sb.append(k + "=" + v + "&");
  56. }
  57. }
  58. sb.append("key=" + API_KEY);
  59. //算出摘要
  60. String mysign = MD5Encode(sb.toString(), characterEncoding).toLowerCase();
  61. String tenpaySign = ((String) packageParams.get("sign")).toLowerCase();
  62. return tenpaySign.equals(mysign);
  63. }
  64. /**
  65. * 生成签名
  66. * @param characterEncoding 字符编码
  67. * @param parameters
  68. * @return
  69. */
  70. public static String createSign(String characterEncoding, SortedMap<String, Object> parameters) {
  71. StringBuffer sb = new StringBuffer();
  72. Set es = parameters.entrySet();
  73. Iterator it = es.iterator();
  74. while (it.hasNext()) {
  75. Map.Entry entry = (Map.Entry) it.next();
  76. String k = (String) entry.getKey();
  77. Object v = entry.getValue();
  78. if (null != v && !"".equals(v)
  79. && !"sign".equals(k) && !"key".equals(k)) {
  80. sb.append(k + "=" + v + "&");
  81. }
  82. }
  83. sb.append("key=" + Constent.VALUE_API_KEY);
  84. String sign = MD5Encode(sb.toString(), characterEncoding).toUpperCase();
  85. return sign;
  86. }
  87. private static final String hexDigits[] = {"0", "1", "2", "3", "4", "5",
  88. "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};
  89. private static String byteToHexString(byte b) {
  90. int n = b;
  91. if (n < 0)
  92. n += 256;
  93. int d1 = n / 16;
  94. int d2 = n % 16;
  95. return hexDigits[d1] + hexDigits[d2];
  96. }
  97. private static String byteArrayToHexString(byte b[]) {
  98. StringBuffer resultSb = new StringBuffer();
  99. for (int i = 0; i < b.length; i++)
  100. resultSb.append(byteToHexString(b[i]));
  101. return resultSb.toString();
  102. }
  103. public static String MD5Encode(String origin, String charsetname) {
  104. String resultString = null;
  105. try {
  106. resultString = new String(origin);
  107. MessageDigest md = MessageDigest.getInstance("MD5");
  108. resultString = byteArrayToHexString(md.digest(resultString
  109. .getBytes("UTF-8")));
  110. } catch (Exception exception) {
  111. }
  112. return resultString;
  113. }
  114. //随机字符串生成
  115. public static String getRandomString(int length) { //length表示生成字符串的长度
  116. String base = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  117. Random random = new Random();
  118. StringBuffer sb = new StringBuffer();
  119. for (int i = 0; i < length; i++) {
  120. int number = random.nextInt(base.length());
  121. sb.append(base.charAt(number));
  122. }
  123. return sb.toString();
  124. }
  125. //请求xml组装
  126. public static String getRequestXml(SortedMap<String, Object> parameters) {
  127. StringBuffer sb = new StringBuffer();
  128. sb.append("<xml>");
  129. Set es = parameters.entrySet();
  130. Iterator it = es.iterator();
  131. while (it.hasNext()) {
  132. Map.Entry entry = (Map.Entry) it.next();
  133. String key = (String) entry.getKey();
  134. String value = (String) entry.getValue();
  135. sb.append("<" + key + ">" + value + "</" + key + ">");
  136. }
  137. sb.append("</xml>");
  138. return sb.toString();
  139. }
  140. //请求方法
  141. public static String httpsRequest(String requestUrl, String requestMethod, String outputStr) {
  142. try {
  143. URL url = new URL(requestUrl);
  144. HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  145. conn.setDoOutput(true);
  146. conn.setDoInput(true);
  147. conn.setUseCaches(false);
  148. // 设置请求方式(GET/POST)
  149. conn.setRequestMethod(requestMethod);
  150. conn.setRequestProperty("content-type", "application/x-www-form-urlencoded");
  151. // 当outputStr不为null时向输出流写数据
  152. if (null != outputStr) {
  153. OutputStream outputStream = conn.getOutputStream();
  154. // 注意编码格式
  155. outputStream.write(outputStr.getBytes("UTF-8"));
  156. outputStream.close();
  157. }
  158. // 从输入流读取返回内容
  159. InputStream inputStream = conn.getInputStream();
  160. InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "utf-8");
  161. BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
  162. String str = null;
  163. StringBuffer buffer = new StringBuffer();
  164. while ((str = bufferedReader.readLine()) != null) {
  165. buffer.append(str);
  166. }
  167. // 释放资源
  168. bufferedReader.close();
  169. inputStreamReader.close();
  170. inputStream.close();
  171. inputStream = null;
  172. conn.disconnect();
  173. return buffer.toString();
  174. } catch (ConnectException ce) {
  175. // System.out.println("连接超时");
  176. Log.e("Tag","连接超时");
  177. ce.printStackTrace();
  178. } catch (Exception e) {
  179. // System.out.println("https请求异常");
  180. Log.e("Tag","https请求异常"+e);
  181. e.printStackTrace();
  182. }
  183. return null;
  184. }
  185. // public static String httpsRequest(Context context, String data) throws IOException, KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException, KeyManagementException, CertificateException, NoSuchProviderException {
  186. // String result = null;
  187. // // 证书密码(默认为商户ID)
  188. // String password = Constent.VALUE_MCH_ID;
  189. // // 实例化密钥库
  190. // KeyStore ks = KeyStore.getInstance("PKCS12");
  191. // // 获得密钥库文件流
  192. // AssetManager am = context.getResources().getAssets();
  193. // InputStream fis = am.open("apiclient_cert.p12");
  194. // // 加载密钥库
  195. // ks.load(fis, password.toCharArray());
  196. // // 关闭密钥库文件流
  197. // fis.close();
  198. // // 实例化密钥库
  199. // KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
  200. // // 初始化密钥工厂
  201. // kmf.init(ks, password.toCharArray());
  202. // // 创建SSLContext
  203. // SSLContext sslContext = SSLContexts.custom()
  204. // .loadKeyMaterial(ks, Constent.VALUE_MCH_ID.toCharArray()) //加载证书密码,默认为商户ID
  205. // .build();
  206. // sslContext.init(kmf.getKeyManagers(), null, new SecureRandom());
  207. // // 获取SSLSocketFactory对象
  208. // SSLSocketFactory ssf = sslContext.getSocketFactory();
  209. // URL url = new URL(Constent.URL_TUIKUAN);
  210. // HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
  211. // conn.setRequestMethod("POST");
  212. // //设置当前实例使用的SSLSocketFactory
  213. // conn.setSSLSocketFactory(ssf);
  214. // conn.setDoOutput(true);
  215. // conn.setDoInput(true);
  216. // conn.connect();
  217. // DataOutputStream out = new DataOutputStream(
  218. // conn.getOutputStream());
  219. // if (data != null)
  220. // out.writeBytes(data);
  221. // out.flush();
  222. // out.close();
  223. // //获取输入流
  224. // BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  225. // int code = conn.getResponseCode();
  226. // if (HttpsURLConnection.HTTP_OK == code) {
  227. // String temp = in.readLine();
  228. // while (temp != null) {
  229. // if (result != null)
  230. // result += temp;
  231. // else
  232. // result = temp;
  233. // temp = in.readLine();
  234. // }
  235. // }
  236. // return result;
  237. // }
  238. public static Map<String, String> xmlToMap(String strXML) throws Exception {
  239. try {
  240. Map<String, String> data = new HashMap<String, String>();
  241. DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
  242. DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
  243. InputStream stream = new ByteArrayInputStream(strXML.getBytes("UTF-8"));
  244. org.w3c.dom.Document doc = documentBuilder.parse(stream);
  245. doc.getDocumentElement().normalize();
  246. NodeList nodeList = doc.getDocumentElement().getChildNodes();
  247. for (int idx = 0; idx < nodeList.getLength(); ++idx) {
  248. Node node = nodeList.item(idx);
  249. if (node.getNodeType() == Node.ELEMENT_NODE) {
  250. org.w3c.dom.Element element = (org.w3c.dom.Element) node;
  251. data.put(element.getNodeName(), element.getTextContent());
  252. }
  253. }
  254. try {
  255. stream.close();
  256. } catch (Exception e) {
  257. e.printStackTrace();
  258. }
  259. return data;
  260. } catch (Exception ex) {
  261. ex.printStackTrace();
  262. throw ex;
  263. }
  264. }
  265. @NonNull
  266. public static SortedMap<Object, Object> getSortedMap(Map<String, String> map) {
  267. //过滤空 设置 TreeMap
  268. SortedMap<Object, Object> packageParams = new TreeMap<Object, Object>();
  269. Iterator it = map.keySet().iterator();
  270. while (it.hasNext()) {
  271. String parameter = (String) it.next();
  272. String parameterValue = map.get(parameter);
  273. String v = "";
  274. if (null != parameterValue) {
  275. v = parameterValue.trim();
  276. }
  277. packageParams.put(parameter, v);
  278. }
  279. return packageParams;
  280. }
  281. //---------------------
  282. // 作者:橙子紫了
  283. // 来源:CSDN
  284. // 原文:https://blog.csdn.net/u013164584/article/details/78030481
  285. // 版权声明:本文为博主原创文章,转载请附上博文链接!
  286. }

3.MainActivty

  1. package com.wjbzg.wxtestdome;
  2. import android.graphics.Bitmap;
  3. import android.os.AsyncTask;
  4. import android.os.Handler;
  5. import android.support.v7.app.AppCompatActivity;
  6. import android.os.Bundle;
  7. import android.util.Log;
  8. import android.widget.ImageView;
  9. import com.wjbzg.wxtestdome.util.Constent;
  10. import com.wjbzg.wxtestdome.util.PayCommonUtil;
  11. import org.apache.http.client.methods.HttpPost;
  12. import org.apache.http.impl.client.CloseableHttpClient;
  13. import org.apache.http.impl.client.HttpClients;
  14. import org.json.JSONObject;
  15. import java.util.Map;
  16. import java.util.SortedMap;
  17. import java.util.TreeMap;
  18. import cn.bingoogolapple.qrcode.core.BGAQRCodeUtil;
  19. import cn.bingoogolapple.qrcode.zxing.QRCodeEncoder;
  20. public class MainActivity extends AppCompatActivity {
  21. //Native支付
  22. //统一下单:https://api.mch.weixin.qq.com/pay/unifiedorder
  23. // 公众账号ID appid
  24. // 商户号 mch_id
  25. // 随机字符串 nonce_str 随机字符串,长度要求在32位以内。推荐随机数生成算法 秘钥
  26. // 签名 sign
  27. // 商品描述 body
  28. // 商户订单号 out_trade_no
  29. // 标价金额 total_fee
  30. // 终端IP spbill_create_ip
  31. // 通知地址 notify_url
  32. // 交易类型 trade_type NATIVE -Native支付
  33. ImageView img_ewm;
  34. String time;
  35. SortedMap<Object, Object> packageParams;
  36. Handler handler = new Handler();
  37. Runnable runnable = new Runnable() {
  38. @Override
  39. public void run() {
  40. try {
  41. updateUI(packageParams);
  42. } catch (InterruptedException e) {
  43. e.printStackTrace();
  44. }
  45. }
  46. };
  47. Handler handler2 = new Handler();
  48. Runnable runnable2 = new Runnable() {
  49. @Override
  50. public void run() {
  51. new Thread(new Runnable() {//每次都要开一个线程去查询订单情况,直到有用户支付成功的结果。
  52. @Override
  53. public void run() {
  54. checkOrder();
  55. }
  56. }).start();
  57. handler2.postDelayed(runnable2, 5000);
  58. }
  59. };
  60. @Override
  61. protected void onCreate(Bundle savedInstanceState) {
  62. super.onCreate(savedInstanceState);
  63. setContentView(R.layout.activity_main);
  64. initView();
  65. createQRCode();//生成二维码
  66. }
  67. private void initView() {
  68. img_ewm = (ImageView) findViewById(R.id.img_ewm);
  69. }
  70. /**
  71. * 生成二维码
  72. */
  73. private void createQRCode() {
  74. new AsyncTask<Void, Void, Bitmap>() {
  75. @Override
  76. protected Bitmap doInBackground(Void... params) {
  77. // System.out.println("ds>>> 生成二维码成功");
  78. return QRCodeEncoder.syncEncodeQRCode(unifiedOrder(), BGAQRCodeUtil.dp2px(MainActivity.this, 150));
  79. }
  80. @Override
  81. protected void onPostExecute(Bitmap bitmap) {
  82. if (bitmap != null) {
  83. Log.e("Tag","生成二维码成功");
  84. img_ewm.setImageBitmap(bitmap);
  85. handler2.post(runnable2);//在main中调用 查询订单
  86. } else {
  87. // System.out.println("ds>>> 生成二维码失败");
  88. Log.e("Tag","生成二维码失败");
  89. }
  90. }
  91. }.execute();
  92. }
  93. //1 统一下单
  94. public String unifiedOrder() {
  95. Log.e("Tag","****准备下单数据****");
  96. SortedMap<String, Object> parameterMap = new TreeMap<String, Object>();
  97. parameterMap.put(Constent.APPID, Constent.VALUE_APPID);//公众号ID
  98. parameterMap.put(Constent.MCH_ID, Constent.VALUE_MCH_ID);//商户号
  99. parameterMap.put(Constent.NONCE_STR, PayCommonUtil.getRandomString(32));//随机字符串
  100. parameterMap.put(Constent.BODY, "一瓶可乐");//商品描述
  101. parameterMap.put(Constent.SIGN_TYPE, Constent.MD);//签名类型
  102. // parameterMap.put(Constent.DETAIL, "");//商品详情
  103. // parameterMap.put(Constent.ATTACH, "欧亚国际分店");//附加数据
  104. time = System.currentTimeMillis() + "";
  105. parameterMap.put(Constent.OUT_TRADE_NO, time);//商户订单号
  106. // parameterMap.put(Constent.FEE_TYPE, Constent.CNY);//标价币种
  107. parameterMap.put(Constent.TOTAL_FEE, "1");//标价金额
  108. parameterMap.put(Constent.SPBILL_CREATE_IP, "127.0.0.1");//终端IP
  109. parameterMap.put(Constent.TIME_START, System.currentTimeMillis() + "");//交易起始时间
  110. //异步接收微信支付结果通知的回调地址,通知url必须为外网可访问的,不能携带参数。
  111. parameterMap.put(Constent.NOTIFY_URL, "http://www.wjbzg.cn/");//通知地址(支付结果通知)
  112. parameterMap.put(Constent.TRADE_TYPE, Constent.NATIVE);//交易类型
  113. // parameterMap.put(Constent.PRODUCT_ID, "");//商品ID(和设备ID一起需知,扫码支付时必须传)
  114. // parameterMap.put(Constent.LIMIT_PAY, Constent.NO_CREDIT);//指定支付方式
  115. parameterMap.put(Constent.SIGN, PayCommonUtil.createSign(Constent.UTF, parameterMap));//签名
  116. final String requestXML = PayCommonUtil.getRequestXml(parameterMap);//将请求组装成xml形式
  117. Log.e("Tag","----下单的xml-----"+requestXML);
  118. String result = PayCommonUtil.httpsRequest(
  119. Constent.URL_TONGYI_XIADAN, Constent.POST,
  120. requestXML);//调用统一支付接口返回String类型字符串
  121. Log.e("Tag","----下单后微信后台返回的结果xml-----"+result);
  122. Map<String, String> map = null;
  123. try {
  124. map = PayCommonUtil.xmlToMap(result);//将返回的结果转为map形式
  125. } catch (Exception e) {
  126. Log.e("Tag","---------下单失败----------"+e);
  127. e.printStackTrace();
  128. }
  129. String string = map.toString();
  130. Log.e("Tag","---------返回的结果xml转成Map.toString----------"+string);
  131. String result_code = map.get("result_code");
  132. Log.e("Tag","****下单结果****"+result_code);
  133. if (result_code.equals("SUCCESS")){
  134. //下单成功
  135. String code_url = map.get("code_url");
  136. Log.e("Tag","二维码的url为:"+ code_url);
  137. return code_url;
  138. }else {
  139. return null;
  140. }
  141. }
  142. // 2 查询订单 每5秒查询一次订单
  143. public void checkOrder() {
  144. SortedMap<String, Object> parameterMap = new TreeMap<String, Object>();
  145. parameterMap.put(Constent.APPID, Constent.VALUE_APPID);//公众号ID
  146. parameterMap.put(Constent.MCH_ID, Constent.VALUE_MCH_ID);//商户号
  147. parameterMap.put(Constent.OUT_TRADE_NO, time);//商户订单号
  148. parameterMap.put(Constent.NONCE_STR, PayCommonUtil.getRandomString(32));//随机字符串
  149. parameterMap.put(Constent.SIGN, PayCommonUtil.createSign(Constent.UTF, parameterMap));//签名
  150. String requestXML = PayCommonUtil.getRequestXml(parameterMap);//将请求组装成xml形式
  151. Log.e("Tag","调用查询订单准备的xml:"+requestXML);
  152. String result = PayCommonUtil.httpsRequest(
  153. Constent.URL_CHAXUN_DINGDAN, Constent.POST,
  154. requestXML);//调用查询订单接口返回String类型字符串
  155. Log.e("Tag","调用查询订单接口返回String类型字符串:"+result);
  156. Map<String, String> map = null;
  157. try {
  158. if (result != null)
  159. map = PayCommonUtil.xmlToMap(result);//将返回的结果转为map形式
  160. } catch (Exception e) {
  161. e.printStackTrace();
  162. }
  163. if (map != null) {
  164. packageParams = PayCommonUtil.getSortedMap(map);
  165. }
  166. if (packageParams != null && PayCommonUtil.isTenpaySign(Constent.UTF, packageParams, Constent.VALUE_API_KEY)) {
  167. handler.post(runnable);//在新的线程去匹配返回的信息,做相应的UI变化
  168. } else {
  169. System.out.println("通知签名验证失败");
  170. }
  171. }
  172. private void updateUI(SortedMap<Object, Object> packageParams) throws InterruptedException {
  173. String result_code = (String) packageParams.get(Constent.RESULT_CODE);
  174. String return_code = (String) packageParams.get(Constent.RETURN_CODE);
  175. String trade_state = (String) packageParams.get(Constent.TRADE_STATE);
  176. String trade_state_desc = (String) packageParams.get(Constent.TRADE_STATE_DESC);
  177. String error_code = (String) packageParams.get(Constent.ERROR_CODE);
  178. Log.e("Tag","result_code=" + result_code + ", return_code=" + return_code + ", trade_state=" + trade_state);
  179. Log.e("Tag","trade_state_desc=" + trade_state_desc + ", error_code=" + error_code);
  180. if (result_code.equals(Constent.SUCCESS) && return_code.equals(Constent.SUCCESS) && trade_state.equals(Constent.SUCCESS)) {
  181. handler2.removeCallbacks(runnable2);
  182. //支付成功,做相关逻辑。
  183. } else if (Constent.PAYERROR.equals(packageParams.get(Constent.TRADE_STATE))) {
  184. handler2.removeCallbacks(runnable2);
  185. //支付失败,做相关逻辑。
  186. }
  187. }
  188. }

3.Constent

  1. package com.wjbzg.wxtestdome.util;
  2. /**
  3. * Created by ${szz} on 2019\6\5 0005
  4. */
  5. public class Constent {
  6. //秘钥
  7. public static final String VALUE_API_KEY = "";
  8. //商户ID kv
  9. public static final String MCH_ID = "mch_id";
  10. public static final String VALUE_MCH_ID = "";
  11. //退款url
  12. // public static final String URL_TUIKUAN = ;
  13. //APPID kv
  14. public static final String APPID = "appid";
  15. public static final String VALUE_APPID = "";
  16. //随机字符串 k
  17. public static final String NONCE_STR = "nonce_str";
  18. //商品描述 k
  19. public static final String BODY = "body";
  20. //签名类型 kv
  21. public static final String SIGN_TYPE = "sign_type";
  22. public static final String MD = "MD5";
  23. //商品详情
  24. // public static final String DETAIL = ;
  25. //附加数据
  26. public static final String ATTACH = "ATTACH";
  27. //商户订单号 k
  28. public static final String OUT_TRADE_NO = "out_trade_no";
  29. //标价金额 k
  30. public static final String TOTAL_FEE = "total_fee";
  31. //终端IP k
  32. public static final String SPBILL_CREATE_IP = "spbill_create_ip";
  33. //交易起始时间 k
  34. public static final String TIME_START = "time_start";
  35. //异步接收微信支付结果通知的回调地址 K
  36. public static final String NOTIFY_URL = "notify_url";
  37. //交易类型
  38. public static final String TRADE_TYPE = "trade_type";
  39. public static final String NATIVE = "NATIVE";
  40. public static final String SIGN = "sign";
  41. public static final String UTF = "UTF-8";
  42. public static final String URL_TONGYI_XIADAN = "https://api.mch.weixin.qq.com/pay/unifiedorder";
  43. public static final String POST = "POST";
  44. public static final String CODE_URL = "CODE_URL";
  45. //2.查询订单接口
  46. public static final String URL_CHAXUN_DINGDAN = "https://api.mch.weixin.qq.com/pay/orderquery";
  47. public static final String RESULT_CODE = "return_code";
  48. public static final String RETURN_CODE = "result_code";
  49. public static final String TRADE_STATE = "trade_state";
  50. public static final String TRADE_STATE_DESC = "trade_state_desc";
  51. public static final String ERROR_CODE = "err_code";
  52. public static final String SUCCESS = "SUCCESS";
  53. public static final String PAYERROR = "PAYERROR";
  54. }

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/122861
推荐阅读
相关标签
  

闽ICP备14008679号