Help customers to integrate the interface when found that the PHP version of the client site is not required as long as the call to Java to solve the problem <?php
/**
* ECSHOP UnionPay Electronic Payment (ChinaPay) plugin
* ============================================================================
* @author: qq:3037704620
* @email: 3037704620#qq.com
* @date: 2017-01-02
*/
if (!defined (' in_ecs '))
{
Die (' Hacking attempt ');
}
$payment _lang = Root_path. ' languages/'. $GLOBALS [' _cfg '] [' Lang ']. '/payment/chinapay.php ';
Include Root_path. ' Includes/modules/payment/chinapay/common.php ';
Include Root_path. ' Includes/modules/payment/chinapay/secssutil.class.php ';
if (file_exists ($payment _lang))
{
Global $_lang;
Include_once ($payment _lang);
}
/* Basic information for module */
if (Isset ($set _modules) && $set _modules = = TRUE)
{
$i = Isset ($modules)? Count ($modules): 0;
/* Code */
$modules [$i] [' code '] = basename (__file__, '. php ');
/* Describe the corresponding language item */
$modules [$i] [' desc '] = ' chinapay_desc ';
/* Whether to support cash on delivery */
$modules [$i] [' is_cod '] = ' 0 ';
/* Whether online payment is supported */
$modules [$i] [' is_online '] = ' 1 ';
/* Pay fees */
$modules [$i] [' pay_fee '] = ' 1.5% ';
/* Author */
$modules [$i] [' author '] = ' qq:3037704620 ';
/* URL */
$modules [$i] [' website '] = ' http://www.chinapay.com ';
/* Version number */
$modules [$i] [' version '] = ' V2.8.3 ';
/* Configuration information */
$modules [$i] [' config '] = array (
Array (' name ' = = ' Merid ', ' type ' = ' text ', ' value ' = ' 000000000017 ')
Array (' name ' = = ' chinapay_merprk ', ' type ' = ' text ', ' value ' = ' can not be filled in '),
Array (' name ' = = ' chinapay_pgpubk ', ' type ' = ' text ', ' value ' = ' can not be filled in ')
);
Return
}
/**
* Class
*/
Class Chinapay
{
/**
* Constructor function
* @access Public
* @param
* @return void
*/
Private $securityPropFile = ";//configuration file
Private $pay _url = ";//configuration file
function Chinapay ()
{
$this->pay_url= "https://payment.chinapay.com/CTITS/service/rest/page/nref/000000000017/0/0/0/0/0";
$this->securitypropfile = Root_path. " Includes/modules/payment/chinapay/security.properties ";
$this->securitypropfile = Root_path. " Includes/modules/payment/chinapay/security_test.properties ";
$this->pay_url= "http://newpayment-test.chinapay.com/CTITS/service/rest/page/nref/000000000017/0/0/0/0/0";
}
function __construct ()
{
$this->chinapay ();
}
/**
* Generate payment Codes
* @param array $order order information
* @param Array $payment payment method information
*/
function Get_code ($order, $payment)
{
$MerId = Trim ($payment [' chinapay_account ']);
$orderNo = Pad (Mt_rand (), "L", 16, "0");
echo $payment [' Merid '];
/**
* Configuration
* Enter description here ...
* @var Unknown_type
*/
$Config =array (
' Merid ' = Trim ($payment [' Merid ']),//merchant number
' Merorderno ' =>pad (Mt_rand (), "L", 16, "0"),//order length 16 position
' Merorderno ' =>ecshopsn2chinapaysn ($order [' order_sn '], $payment [' Chinapay_account ']),//order length 16 position
' Orderamt ' =>intval (Floor ($order [' Order_amount ']*100)],
' Trandate ' = Date (' Ymd ', Time ()),
' Trantime ' =-date (' His ', Time ()),
' Trantype ' = ' 0001 ',
' Busitype ' = ' 0001 ',
' Version ' = ' 20140728 ',
' SplitType ' and ' ",
' Splitmethod ' and ' ",
' Mersplitmsg ' and ' ",
' Bankinstno ' and ' ",
' Paytimeout ' and ' ",
' TimeStamp ' and ' ",
' Remoteaddr ' and ' ",
' Curryno ' = ' CNY ',
' AccessType ' = ' 0 ',
' Acqcode ' = ' 000000000000014 ',
' Commoditymsg ' and ' ",
' Merpageurl ' =>return_url (basename (__file__, '. php '),//return address
' Merbgurl ' = Return_url (basename (__file__, '. php '),//return address
' MERRESV ' = $order [' ORDER_SN '],
' tranreserved ' = ' {' busiid ': ' 00000001 ', ' P1 ': ' 123 ', ' P2 ': ' 756 ', ' P3 ': ' 123 ', ' P4 ': ' 23 '} ',
' Trans_busiid ' and ' ",
' Trans_p1 ' and ' ",
' Trans_p2 ' and ' ",
' Trans_p3 ' and ' ",
' Trans_p4 ' and ' ",
' Trans_p5 ' and ' ",
' Trans_p6 ' and ' ",
' Trans_p7 ' and ' ",
' Trans_p8 ' and ' ",
' Trans_p9 ' and ' ",
' Trans_p10 ' = ' "
);
/**
* Signature section starts
* Enter description here ...
* @var Unknown_type
*/
try{
Require_once ("Http://localhost:8080/JavaBridgeTemplate621/java/Java.inc");
Java_set_file_encoding ("Utf-8");
$map =new Java ("Java.util.HashMap");
foreach ($Config as $l = = $s) {
$l =new Java ("java.lang.String", $l);
$s =new Java ("java.lang.String", $s);
$map->put ($l, $s);//Merchant number
}
$index =new Java ("Com.chinapay.util.index");
$Path =new Java ("java.lang.String", $this->securitypropfile);
$index->quest= $map;
$respone =java_values ($index->getsign ($Path));//Read signature information
$def _url = "<form name= ' payment ' id= ' payment ' action= '". $this->pay_url. "' method= ' POST ' target= ' _blank ' >";
$params = "tranreserved; Merid; Merorderno;orderamt; Curryno; Trandate; Splitmethod; Busitype; Merpageurl; Merbgurl; SplitType; mersplitmsg; Paytimeout; MERRESV; Version; Bankinstno; commoditymsg; Signature; AccessType; Acqcode;orderexpirytime; Trantype; remoteaddr; Referred; Trantime; TimeStamp; Cardtrandata ";
foreach ($respone as $k = $v)
{
if (Strstr ($params, $k))
{
$def _url. = "<input type= ' text ' name = '". $k. "' value= '". $v. "' /> ";
}
}
$def _url.= "<input type= ' submit ' value= '". $GLOBALS [' _lang '] [' Pay_button ']. "' >";
$def _url. = "</form>";
return $def _url;
}
catch (Exception $e)
{
Return "<br><font color= ' #FF0000 ' > System error:". $e. " </font> ";
}
}
/**
* Response Action
*/
function respond ()
{
$payment = Get_payment (basename (__file__, '. php '));
$return =false;
if (count ($_post) > 0)
{
$MerOrderNo = Trim ($_post[' merorderno ');
$OrderStatus = Trim ($_post[' orderstatus ');
$MERRESV =trim ($_post[' MERRESV ');
if ($OrderStatus = = ' 0000 ')
{
Try
{
Require_once ("Http://localhost:8080/JavaBridgeTemplate621/java/Java.inc");
Java_set_file_encoding ("Utf-8");
$resultMap =new Java ("Java.util.HashMap");
foreach ($_post as $l = $s)
{
$l =new Java ("java.lang.String", $l);
$s =new Java ("java.lang.String", $s);
$resultMap->put ($l, $s);//Merchant number
}
$SignUtil =new Java ("Com.chinapay.util.SignUtil");
Verifying signatures
if ($SignUtil->verify ($RESULTMAP))
{
/* Change Order Status */
$order _id = GET_ORDER_ID_BY_SN ($MERRESV);
if (! $order _id)
{
$order _id = GET_ORDER_ID_BY_SN ($MERRESV, "true");//Member Recharge
}
Order_paid ($order _id,2);
$return =true;
}
Else
{
$return =false;
}
}
catch (Exception $e)
{
echo "Caught exception:". $e. " \ n ";
}
}
}
return $return;
}
}
?>
This article from "QQ3037704620" blog, declined reprint!
ECSHOP UnionPay e-payment (ChinaPay) plugin dropped with Java signature