Use of Php-java-bridge (Ping An Bank payment feature edition)

Source: Internet
Author: User

Last year, when I was doing ping an bank, I used the Php-java-bridge, and later wrote a blog record of some of the experiences of using Php-java-bridge (connection: http://my.oschina.net/kenblog/blog/316234).

Then there are a lot of friends on the ground to do the safe Bank interface to use Php-java-bridge, read my blog also a bit of pain (probably at that time to start blogging, thinking, organization and description is not very clear).

Recently use Php-java-bridge to do ping An bank development of people still quite a lot, many friends have come to ask, now take time to write an article about ping an bank to pay the use of Php-java-bridge tutorial, I hope to help people.


Usage Environment:

PHP Version: Up to 5.4, current test is 5.4/5.3

JDK: Official latest version, current test is 1.8 and Linux comes with OPENJDK

Operating system: Windows7 32-bit/64-bit | Linux (centos6.5,5.9)


1. Using Php-java-bridge

Download the following files and put them in your project

File Download: https://kanbox.com/f/hA0a4


2. Proper placement of jar packages

1), put your Safe bank Payment related jar package under the Java jar

2), place the Php-java-bridge file under the Java jar

Download the following files and place them under the Java jar installed

file Download:https://kanbox.com/f/RS0a5

The path is as follows:

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: This path will vary depending on the Java version and path you have installed on your system, but probably all the same


3, modify the Ping an bank's configuration file

Find the Payclient.properties file under the classes folder below the two paths above

Modify "cafile=" for your Merchant.jks path, where absolute paths are used, and relative paths 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. Open Php-java-bridge

Execute the Javabridge.jar file below the two paths above

Windows: Directly double-click the Javabridge.jar file under the jar package to run Linux: Use the command "Java-jar Javabridge.jar servlet_local:8080 &"


5. Use Php-java-bridge in your project

Here is an example code that needs to be modified with your project requirements

The code is as follows:

&LT;?PHP//1, reference java.inc  require_once ($_server["Document_root"]. " /bridge/java/java.inc ");   //2, Java method instantiation   try{    $util  = new  Java ("Com.sdb.payclient.core.PayclientInterfaceUtil");    $input  = new java (" Com.ecc.emp.data.KeyedCollection "," input ");    $signDataput  = new java (" Com.ecc.emp.data.KeyedCollection "," Signdataput ");       $urlEncoder  =  New java ("Java.net.URLEncoder");   }catch (javaexception  $e) {   echo  " Error: Instantiation failed:<br/> ", $e;   }  //3, assemble the data, and then generate orig and signature sign  try{    //assembly data to $input    $input->put ("MasterID", $payment _masterid);        $input->put ("OrderId", $payment _orderid);       $input->put (" Currency ", $payment _currency);       $input-&GT;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 initial value        $orig = "";         //raw data        $sign = "";         //Generating Signatures        $encoding  =   "GBK";       //get orig and sign       $signDataput  =  $util->getsigndata ($input);       $orig  =  $signDataput- >getdatavalue ("orig");       $sign  =  $signDataput->getdatavalue (" Sign "); &NBSP;&NBSP;&NBsp;   //encode signatures        $orig  =  $util->base64encode ($ orig,  $encoding);       $sign  =  $util->base64encode ($sign,   $encoding);       $orig  =  $urlEncoder->encode ($orig,  $ encoding);       $sign  =  $urlEncoder->encode ($sign,  $encoding);? >


6, according to the above five operation, Basic is no problem, if there is a problem, please check your code call is correct



About official online:

if the project is to be formally launched, replace the Payclient.properties file with the khpaymenturl=https://testebank.sdb.com.cn:461/corporbank/official payment address for Ping An bank


Note:

1, if you succeed, have time to read this blog: http://my.oschina.net/kenblog/blog/316234

2, if this is not successful, you can contact me to see the specific reasons.





Use of Php-java-bridge (Ping An Bank payment feature edition)

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.