The method of obtaining two-time signature sign for Android micro-credit Payment _android

Source: Internet
Author: User
Tags key string stringbuffer

This example for you to share the Android micro-credit payment to obtain two signed sign method for your reference, the specific content as follows

/** * Get Sign Signature * * @return/private String Genpayreq () {//Get the value of the parameter payreq request = new Payreq ();
  Request.appid = constantsmember.app_id;
  Request.partnerid = Constantsmember.mchid;
  Request.prepayid = Mprepayid;
  Request.packagevalue = "Sign=wxpay";
  Request.noncestr = Datautil.getguid ();

  Request.timestamp = Datautil.gettimestamp ();
Pass the value of the parameter into the SortedMap set sortedmap<object, object> parameters = new Treemap<object, object> (); {APPID=WX34DF375D7DAE8C90, NONCESTR=3BF34EF2CA4A462DB8D4EA48E785CDC3,//Package=sign=wxpay, partnerid= 1349967601,//prepayid=wx2016070910354542c7155d4e0846850809, timestamp=1468031760} parameters.put ("AppID", request
  . appId);
  Parameters.put ("Noncestr", request.noncestr);
  Parameters.put ("package", request.packagevalue);
  Parameters.put ("Partnerid", Request.partnerid);
  Parameters.put ("Prepayid", Request.prepayid);

  Parameters.put ("timestamp", request.timestamp); String characterencoding = "UTF-8";
  String mysign = createsign (characterencoding, parameters);
  System.out.println ("My signature is:" + mysign);
 return mysign; /** * Micro-credit Payment Signature Algorithm sign * * @param characterencoding * @param parameters * @return */public static String CR Eatesign (String characterencoding, sortedmap<object, object> parameters) {StringBuffer sb = new StringBuffer (
  );
  Set es = Parameters.entryset ();//All parameters participating in the argument are sorted by accsii (ascending) Iterator it = Es.iterator ();
   while (It.hasnext ()) {@SuppressWarnings ("rawtypes") map.entry Entry = (map.entry) it.next ();
   String k = (string) entry.getkey ();
   Object v = entry.getvalue (); if (null!= v &&! "". Equals (v) &&! " Sign ". Equals (k) &&!"
   Key ". Equals (k)) {Sb.append (k +" = "+ V +" & "); } sb.append ("key=" + Constantsmember.key);
  Key is the merchant secret key String sign = Md5util.md5encode (Sb.tostring (), characterencoding). toUpperCase (); return sign; d3a5d13e7838e1d453f4f2ea526c4766//d3a5d13e7838e1d453f4f2ea526c4766}
 

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.