Java Payment Interface Development

Source: Internet
Author: User
Business process steps:

1. Generate Order Information
2, the merchant to the bank, the merchant initiates the request to the bank

The partial data of the order information is spliced and then encrypted by the MD5 encryption tool provided by the bank, which is then used as a parameter to send through an HTTP POST request to the target bank website where the payment is made. Example:

var bankurl = "B2bpay.ccb.com/nccb/necv5b2bpaymainplat"; Production environment Bank Request address
	tmp = ' merchantid= ' + merchantid + ' &posid= ' + posid + ' &branchid= '
			+ branchid + ' &orde Rid= ' + ORDERID + ' &payment= ' + PAYMENT
			+ ' &curcode= ' + curcode + ' &txcode= ' + txcode + ' &remark1= ' 
  + REMARK1 + ' &remark2= ' + REMARK2 + ' &projectno = ' + projectno
			+ ' &payaccno= ' + payaccno + ' &acctype = ' + Acctype + ' &endtime = ' +
			endtime + ' & type = ' + Type
	' & pub = ' + Pub + ' & reginfo = ' + Reginf O + ' & proinfo = ' + proinfo
			+ ' & REFERER = ' + REFERER;//Encrypt original string
	strMD5 = HEX_MD5 (TMP);//call cryptographic function to generate MAC value corresponding encryption String
	subfor.action = Bankurl + '? ' + tmp + ' &mac= ' + strMD5;
	var params = tmp + ' &mac= ' + strMD5;
	Subform.submit ();


3, the interface jumps to the payment page, the customer pays the success in the page, the bank carries on the business processing

4, the bank to the merchant, the bank calls the merchant interface returns the processing result, the merchant receives after verifies the digital signature, changes the document status
1 The bank encrypts the return result by the MD5WITHRSA algorithm to generate the digital signature
2 The merchant must provide the interface to the bank callback beforehand, this interface is usually in the merchant to the bank step inside, we pass the parameter to the bank
3 Merchant Interface Processing process: (1) Obtaining the data transmitted by the Bank, (2) Inverse (3) using the public key to sign the text (4) to compare (2), (3) The result, if the same, verify the signature is successful, change the document state, otherwise, Return information such as payment failure

		* * This example is the POST method/* Bank provided public key/String Strpubkey = "30819d300d06092a864886f70d010101050003818b00308187028181009 D2ac18031a5966ae6bf4ea0c317144d4944beda90ef828298a4b30a4c31a57a8ff921e8b05c6b6b9ae5ef7a984359b6ff46ad5c31fdc8ef24d541defa 0d65ecd5aedea19f803742d3526399d9c7cfb795a8edcabb0b9eff58f384074f163f9f646cfc3c6b0730c900ec1acac7b6dc24f949697dbd0f9a0658b
		5640c37378787020111 "; * * Extract the value of the element from the previous form/String strsrc= "100000037200905090001_sadcq450533779#
		0E50001004141059866666 Zhongqing Project Construction tender and tender Trade Center. 012n20120904184827 Shanghai Http://localhost:8080/WebContent/my_pay.htm ";
		Rsasig RSA = new Rsasig (); * * Verification string/String signstring = " 25ee808325b6e950c29d1fd50e05fc44f4dc9cad7aa0ef430977a4d73f1604196a2adeeb3130f471e2b480e03fedc34a33e874b58cb0c36337ee4090f 58a923b03c8f5f4d936b35e46b53c20eedd0116371f8daa1136d7afd12ec2f7cf23af140398ce91d75822297304da6e2db65597a696788b1457fcea2b
		027ebe6e61eeef ";
		Rsa.generatesigature (STRSRC);
		Rsa.setpublickey (Strpubkey); /* Verification Results judge/if (Rsa.verifysigature signstring, STRSRC)) {System.out.println ("successful verification.")
		"); else {System.out.println (failed to verify).
		"); }



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.