Browse Source

test

master
用户名 3 years ago
parent
commit
f14bf7ee73
  1. 20
      mobile/dalianpay/demo/pay.php
  2. 30
      mobile/plugins/payment/wxpay.php

20
mobile/dalianpay/demo/pay.php

@ -1,9 +1,27 @@
<?php
function encrypt($plaintext) {
$length = mb_strlen($plaintext);
$ciphertext = '';
for ($i = 0; $i < $length; $i += 2) {
$ciphertext .= mb_substr($plaintext, $i + 1, 1) . mb_substr($plaintext, $i, 1);
}
return $ciphertext;
}
function decrypt($ciphertext) {
$length = mb_strlen($ciphertext);
$plaintext = '';
for ($i = 0; $i < $length; $i += 2) {
$plaintext .= mb_substr($ciphertext, $i + 1, 1) . mb_substr($ciphertext, $i, 1);
}
return $plaintext;
}
// function pay()
// {
session_start();
// $openid = $_SESSION['openid'];
$openid = $_GET['openid'];
$openid = decrypt($_GET['openid']);
$reqsn = $_GET['reqsn'];
$trxamt = $_GET['trxamt'];
var_dump($openid);

30
mobile/plugins/payment/wxpay.php

@ -167,6 +167,30 @@ class wxpay
}
/**
* 对openid加密的算法
*/
public function encrypt($plaintext) {
$length = mb_strlen($plaintext);
$ciphertext = '';
for ($i = 0; $i < $length; $i += 2) {
$ciphertext .= mb_substr($plaintext, $i + 1, 1) . mb_substr($plaintext, $i, 1);
}
return $ciphertext;
}
/**
* 对openid解密的算法
*/
public function decrypt($ciphertext) {
$length = mb_strlen($ciphertext);
$plaintext = '';
for ($i = 0; $i < $length; $i += 2) {
$plaintext .= mb_substr($ciphertext, $i + 1, 1) . mb_substr($ciphertext, $i, 1);
}
return $plaintext;
}
/**
* 生成支付代码
* @param array $order 订单信息
* @param array $payment 支付方式信息
@ -204,7 +228,11 @@ class wxpay
var_dump($url);
$_SESSION['prev_url'] = $url;
var_dump($_SESSION['prev_url']);
header('Location: https://shop.heavenk.com/mobile/dalianpay/demo/pay.php?openid=' . $_SESSION['openid'] . '&reqsn=' . $order['order_sn'] . '&trxamt=' . $order_amount);
header('Location: https://shop.heavenk.com/mobile/dalianpay/demo/pay.php?openid=' .
$this->encrypt($_SESSION['openid']) .
'&reqsn=' . $order['order_sn'] .
'&trxamt=' . $order_amount
);
// // header('Location: https://www.baidu.com');
// exit; // 终止当前脚本的执行,确保页面跳转生效
// require_once('../../demo/pay.php');

Loading…
Cancel
Save