The use of PHP-Java-Bridge (Ping An Bank payment function Special Edition) used PHP-Java-Bridge last year when Ping An Bank was made, later I wrote a blog record some of my experiences using PHP-Java-Bridge (connection: http://my.oschina.net/kenblog/blog/316234 ).
Later, many of my friends started to use PHP-Java-Bridge on the Ping An Bank interface. after reading my blog, it was also a bit painful (maybe I started to write a blog at that time, the concept, organization, and description are not clear ).
Recently, many people have used PHP-Java-Bridge for the development of Ping An Bank, and many of them have come to ask, now I am taking the time to write a tutorial on using PHP-Java-Bridge for Ping An Bank payment, hoping to help people.
Environment:
PHP version: the maximum value is 5.4. The current test is 5.4/5.3.
JDK: The latest official version. The current test is 1.8 and openjdk is provided for linux.
Operating system: Windows7 32-bit/64-bit | Linux (Centos6.5, 5.9)
1. use PHP-Java-Bridge
Download the following files and put them in your project.
Https://kanbox.com/f/hA0a4 download
2. properly place the jar package
1) Place the jar package related to your Ping An Bank payment to the jar package of java.
2) place the php-java-bridge file under the jar of java.
Download the following file and place it under the installed java jar.
Https://kanbox.com/f/RS0a5 download
Path:
windows:C:\Program Files\Java\jre1.8.0_25\lib\extlinux:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64/jre/lib/ext
Note: The path varies depending on the java version and path installed on your system, but it is probably similar.
3. modify the configuration file of Ping An Bank
Find the payclient. properties file under the classes folder under the two paths above.
Modify "cafile =" to your merchant. jks path. here the absolute path is used, or the relative path can be used.
The code is as follows:
windows:"cafile=C:/Program Files/Java/jre1.8.0_25/lib/ext/classes/merchant.jks"linux:"cafile=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64/jre/lib/ext/classes/merchant.jks"
4. enable PHP-Java-Bridge
Execute the JavaBridge. jar file under the above two paths.
Windows: Double-click the JavaBridge. jar file under the jar package to run linux: run the "Java-jar JavaBridge. jar SERVLET_LOCAL: 8080 &" command &"
5. use PHP-Java-Bridge in your project
The following provides an instance code, which must be modified according to your project requirements.
The code is as follows:
", $ E;} // 3. assemble the data, and then generate orig and signature sign try {// assemble the data to $ input-> put (" masterId ", $ payment_masterId); $ input-> put ("orderId", $ payment_orderId); $ input-> put ("currency", $ payment_currency ); $ input-> put ("amount", $ payment_amount); $ input-> put ("paydate", $ payment_paydate); $ input-> put ("remark ", $ payment_remark); $ input-> put ("objectName", $ payment_objectName); $ input-> put ("validtime", $ payment_validtime); // set the initial value $ Orig = ""; // raw data $ sign = ""; // Generate a signature $ encoding = "GBK "; // Obtain orig and sign $ signDataput = $ util-> getSignData ($ input); $ orig = $ signDataput-> getDataValue ("orig "); $ sign = $ signDataput-> getDataValue ("sign"); // Encode the signature $ orig = $ util-> Base64Encode ($ orig, $ encoding ); $ sign = $ util-> Base64Encode ($ sign, $ encoding); $ orig = $ urlEncoder-> encode ($ orig, $ encoding ); $ sign = $ urlEncoder-> encode ($ sign, $ encoding);?>
6. follow the preceding five steps to check whether your code is correctly called.
About official launch:
If the project is to be officially launched, you need to replace the khPaymentUrl = https://testebank.sdb.com.cn: 461/bank/for the official payment address of Ping An Bank in the payclient. properties file
Note:
1. if you have succeeded, you can read this blog if you have time:
2. if the problem persists, contact me to find out why.