123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- require_once dirname(__FILE__) . '/sdk/acp_service.php';
- class unionpay {
- private $config;
- public function __construct($payment_info = array(), $order_info = array()) {
- if (!empty($payment_info)) {
- $this->config = array(
- 'unionpay_merid' => $payment_info['payment_config']['unionpay_merid'],
- );
- com\unionpay\acp\sdk\SDKConfig::setSDKConfig('backUrl',str_replace('/index.php', '', HOME_SITE_URL) . "/payment/unionpay_notify.html");
- com\unionpay\acp\sdk\SDKConfig::setSDKConfig('frontUrl',str_replace('/index.php', '', HOME_SITE_URL) . "/payment/unionpay_return.html");
- com\unionpay\acp\sdk\SDKConfig::setSDKConfig('signCertPath',$payment_info['payment_config']['unionpay_signcert_path']);
- com\unionpay\acp\sdk\SDKConfig::setSDKConfig('signCertPwd',$payment_info['payment_config']['unionpay_signcert_pwd']);
- com\unionpay\acp\sdk\SDKConfig::setSDKConfig('encryptCertPath',dirname(__FILE__).'/asserts/acp_prod_enc.cer');
- com\unionpay\acp\sdk\SDKConfig::setSDKConfig('middleCertPath',dirname(__FILE__).'/asserts/acp_prod_middle.cer');
- com\unionpay\acp\sdk\SDKConfig::setSDKConfig('rootCertPath',dirname(__FILE__).'/asserts/acp_prod_root.cer');
- com\unionpay\acp\sdk\SDKConfig::setSDKConfig('logFilePath',dirname(__FILE__).'/logs');
- }
- }
-
- public function get_payform($order_info) {
- header ( 'Content-type:text/html;charset=utf-8' );
- $params = array(
-
- 'version' => com\unionpay\acp\sdk\SDKConfig::getSDKConfig()->version,
- 'encoding' => 'utf-8',
- 'txnType' => '01',
- 'txnSubType' => '01',
- 'bizType' => '000201',
- 'frontUrl' => com\unionpay\acp\sdk\SDKConfig::getSDKConfig()->frontUrl,
- 'backUrl' => com\unionpay\acp\sdk\SDKConfig::getSDKConfig()->backUrl,
- 'signMethod' => com\unionpay\acp\sdk\SDKConfig::getSDKConfig()->signMethod,
- 'channelType' => '07',
- 'accessType' => '0',
- 'currencyCode' => '156',
-
- 'merId' => $this->config["unionpay_merid"],
- 'orderId' => $order_info['pay_sn'],
- 'txnTime' => date('YmdHis'),
- 'txnAmt' => bcmul($order_info['api_pay_amount'], 100),
-
-
-
-
- 'payTimeout' => date('YmdHis', strtotime('+15 minutes')),
- 'reqReserved'=>$order_info['order_type'],
-
-
-
-
-
-
-
-
-
-
-
-
- );
- com\unionpay\acp\sdk\AcpService::sign($params);
- $uri = com\unionpay\acp\sdk\SDKConfig::getSDKConfig()->frontTransUrl;
- $html_form = com\unionpay\acp\sdk\AcpService::createAutoFormHtml($params, $uri);
- echo $html_form;
- exit;
- }
- public function return_verify() {
- return $this->getPayResult();
- }
-
- public function verify_notify() {
- return $this->getPayResult();
- }
- public function getPayResult() {
- $notify_result = array(
- 'trade_status' => '0',
- );
- $result = com\unionpay\acp\sdk\AcpService::validate ( $_POST );
- if ($result) {
- if (input('post.respCode')=='00' || input('post.respCode')=='A6') {
- $out_trade_no = input('post.orderId');
- $notify_result = array(
- 'out_trade_no' => $out_trade_no,
- 'trade_no' => input('param.traceNo'),
- 'total_fee' => bcdiv(input('param.settleAmt'),100),
- 'order_type' => input('param.reqReserved'),
- 'trade_status' => '1',
- );
- }
- }
- return $notify_result;
- }
- }
|