ICBC payment interface-Message notification after ICBC successfully paid

Source: Internet
Author: User

Currently, ICBC's payment interface does not provide order status query to B2B Merchants by order number. Therefore, it is very important to process messages after successful order payment, the following is the core code for the successful notification of ICBC order payment when Lu Ju is working on a bank payment project. [Java]/*** notification of successful ICBC payment processing */public void policydate (String policydatabase64, String signMsg, String merVAR, String realPath) {String encoding = "gbk"; log. debug ("original message for receiving ICBC notifications: yydata:" + notifyDataBase64); log. debug ("original message for receiving ICBC notifications: signMsg:" + signMsg); log. debug ("original message for receiving ICBC notifications: merVAR:" + merVAR); byte [] yydatabytes = null; String yydata = null; try {policydatabytes = ReturnValue. base64dec (notif YDataBase64.getBytes (encoding); policydata = new String (policydatabytes, encoding); log. debug ("receiving ICBC Notification Information: notifyData: base64 decoded:" + notifyData);} catch (UnsupportedEncodingException e) {log. error ("error in ICBC resolution notification content:", e); throw new RuntimeException (e );} string dir = realPath + "/resources/files/bank/icbc/crt/"; // obtain the icbc certificate byte [] bCert = null; try {FileInputStream FCM = new FileInputStream (dir + "admin. crt "); BCert = new byte [FCM. available ()]; FCM. read (bCert); FCM. close ();} catch (IOException e) {log. error ("read admin. crt, file error: ", e); throw new RuntimeException (e);} byte [] bSign = cn.com. infosec. icbc. returnValue. base64dec (signMsg. getBytes (); byte [] bSrc = policydatabytes; // start the int recode =-1; try {recode = cn.com. infosec. icbc. returnValue. verifySign (bSrc, bSrc. length, bCert, bSign);} catch (Exc Eption e) {log. error ("signature error:", e); throw new RuntimeException (e);} if (recode! = 0) {log. debug ("ICBC Verification Failed verification return code:" + recode); return;} log. debug ("ICBC Verification Successful, start to parse the notification content"); // parse the notification content: order Number, payment successful, amount // yydata XmlParser xmlParser = new XmlParser (new ByteArrayInputStream (notifyDataBytes); String orderId = xmlParser. getElementText ("/B2CRes/orderInfo/subOrderInfoList/subOrderInfo/orderid"); String amount = xmlParser. getElementText ("/B2CRes/orderInfo/subOrderInfoList/subOrderInfo/amount "); String tranStat = xmlParser. getElementText ("/B2CRes/bank/tranStat"); log. debug ("Notice of successful ICBC order payment: Order Number:" + orderId + "payment status:" + tranStat + "amount:" + amount); if (! "1 ". equals (tranStat) {log. debug ("order status is unpaid, return"); return;} // query order information ExamOrder examOrder = this. examOrderService. queryExamOrderByOrderNum (orderId); int examOrderMoney = (new Double (examOrder. getMoney () * 100 )). intValue (); if (! Amount. equals (Integer. valueOf (examOrderMoney ). toString () {log. debug ("the actual payment order amount does not match the payable amount, return"); return;} // update the order status to settled try {log. debug ("Update order" + orderId + "status to settled"); this. examOrderService. updateSuccessOrder (orderId);} catch (Exception e) {log. error ("An error occurred while updating the order status to settled", e); throw new RuntimeException (e );}}

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.