WeChat payment practice version

WeChat payment practice version

Source code introduction: Through the call of code, we can overcome the disadvantage of not having our own server. First, we can test whether the code can run smoothly. It is absolutely different from the WeChat payment demo.

Source code effect:

Source code snippet:

  1. private String genProductArgs() {
  2. StringBuffer xml = new StringBuffer();
  3.   
  4. try {
  5. String nonceStr = genNonceStr();
  6.   
  7.   
  8. xml.append( "" );
  9. List<namevaluepair> packageParams = new LinkedList<namevaluepair>();
  10. packageParams.add( new BasicNameValuePair( "appid" , Constants.APP_ID));
  11. packageParams.add( new BasicNameValuePair( "body" , "weixin" ));
  12. packageParams.add( new BasicNameValuePair( "mch_id" , Constants.MCH_ID));
  13. packageParams.add( new BasicNameValuePair( "nonce_str" , nonceStr));
  14. packageParams.add( new BasicNameValuePair( "notify_url" , "http://121.40.35.3/test" ));
  15. packageParams.add( new BasicNameValuePair( "out_trade_no" ,genOutTradNo()));
  16. packageParams.add( new BasicNameValuePair( "spbill_create_ip" , "127.0.0.1" ));
  17. packageParams.add( new BasicNameValuePair( "total_fee" , "1" ));
  18. packageParams.add( new BasicNameValuePair( "trade_type" , "APP" ));
  19.   
  20.   
  21. String sign = genPackageSign(packageParams);
  22. packageParams.add( new BasicNameValuePair( "sign" , sign));
  23.   
  24.   
  25. String xmlstring =toXml(packageParams);
  26.   
  27. return xmlstring;
  28.   
  29. } catch (Exception e) {
  30. Log.e(TAG, "genProductArgs fail, ex = " + e.getMessage());
  31. return   null ;
  32. }
  33.           
  34.   
  35. }</namevaluepair></namevaluepair>

Download address: http://download..com/data/2190131

<<:  Seven Xcode tips every developer should know

>>:  Practical explanation of efficiently adding rounded corners effect on iOS

Recommend

Hankook's senior management reshuffles to place more emphasis on China

Hankook Tire and its holding company Hana Tire Wo...

12 misunderstandings about community operations!

There must be many friends around you who are eng...

DSP | Introduction to NetEase Youdao promotion products!

NetEase’s promotional products are divided into t...

How to make a one-yuan dating blind box (making a blind box dating applet)

In the past few days, several people asked me if ...

AiKop | "Cats" on the big ship

One, two, three...prepare to sing Let's learn...

Help! Why do dogs always like to eat poop? The reason is not simple...

This article was reviewed by Lin Zhideng, PhD in ...

Today, let us pay tribute to them together!

END Tadpole five-line score original work, please...

This boy band disbanded, not because of their mediocre singing, but because...

There are few insects whose names are often unkno...

How much does it cost to be an agent for a homestay mini program in Hengshui?

Why should you be an agent for WeChat Mini Progra...

How does a P2P platform choose high-quality channels?

As we all know, the cost of acquiring P2P custome...