This commit is contained in:
root 2020-01-05 15:48:51 +08:00
parent 0de4a137bf
commit 44e57b7073

View File

@ -12,7 +12,7 @@ class TomatoPay {
$this->key = $key; $this->key = $key;
} }
public function pay ($cny, $type, $trade) { public function alipay ($cny, $type, $trade) {
$params = [ $params = [
'mchid' => $this->mchid, 'mchid' => $this->mchid,
'account' => $this->account, 'account' => $this->account,
@ -21,16 +21,17 @@ class TomatoPay {
'trade' => $trade 'trade' => $trade
]; ];
$params['signs'] = $this->sign(http_build_query($params)); $params['signs'] = $this->sign(http_build_query($params));
return $this->buildHtml($params); return $this->buildHtml('https://b.fanqieui.com/gateways/alipay.php', $params);
} }
public function sign ($str) { public function sign ($str) {
return md5($str.$this->key); return md5($str.$this->key);
} }
public function buildHtml($params, $method = 'post', $target = '_self'){ public function buildHtml($url, $params, $method = 'post', $target = '_self'){
// var_dump($params);exit; // var_dump($params);exit;
$html = "<form id='submit' name='submit' action='https://b.fanqieui.com/gateways/submit.php' method='$method' target='$target'>"; $html = "<form id='submit' name='submit' action='".$url."' method='$method' target='$target'>";
foreach ($params as $key => $value) { foreach ($params as $key => $value) {
$html .= "<input type='hidden' name='$key' value='$value'/>"; $html .= "<input type='hidden' name='$key' value='$value'/>";
} }