mirror of
https://github.com/v2board/v2board.git
synced 2025-06-14 13:47:49 +08:00
format
This commit is contained in:
@ -1,18 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Library;
|
||||
|
||||
class BitpayX {
|
||||
class BitpayX
|
||||
{
|
||||
private $bitpayxAppSecret;
|
||||
private $bitpayxGatewayUri;
|
||||
|
||||
/**
|
||||
* 签名初始化
|
||||
* @param merKey 签名密钥
|
||||
*/
|
||||
public function __construct($bitpayxAppSecret) {
|
||||
$this->bitpayxAppSecret = $bitpayxAppSecret;
|
||||
$this->bitpayxGatewayUri = 'https://api.mugglepay.com/v1/';
|
||||
}
|
||||
|
||||
* 签名初始化
|
||||
* @param merKey 签名密钥
|
||||
*/
|
||||
public function __construct($bitpayxAppSecret)
|
||||
{
|
||||
$this->bitpayxAppSecret = $bitpayxAppSecret;
|
||||
$this->bitpayxGatewayUri = 'https://api.mugglepay.com/v1/';
|
||||
}
|
||||
|
||||
public function prepareSignId($tradeno)
|
||||
{
|
||||
$data_sign = array();
|
||||
@ -22,15 +26,18 @@ class BitpayX {
|
||||
ksort($data_sign);
|
||||
return http_build_query($data_sign);
|
||||
}
|
||||
|
||||
public function sign($data)
|
||||
{
|
||||
return strtolower(md5(md5($data) . $this->bitpayxAppSecret));
|
||||
}
|
||||
|
||||
public function verify($data, $signature)
|
||||
{
|
||||
$mySign = $this->sign($data);
|
||||
return $mySign === $signature;
|
||||
}
|
||||
|
||||
public function mprequest($data)
|
||||
{
|
||||
$headers = array('content-type: application/json', 'token: ' . $this->bitpayxAppSecret);
|
||||
@ -48,6 +55,7 @@ class BitpayX {
|
||||
curl_close($curl);
|
||||
return json_decode($data, true);
|
||||
}
|
||||
|
||||
public function mpcheckout($orderId, $data)
|
||||
{
|
||||
$headers = array('content-type: application/json', 'token: ' . $this->bitpayxAppSecret);
|
||||
@ -65,17 +73,21 @@ class BitpayX {
|
||||
curl_close($curl);
|
||||
return json_decode($data, true);
|
||||
}
|
||||
public function refund($merchantTradeNo) {
|
||||
|
||||
public function refund($merchantTradeNo)
|
||||
{
|
||||
// TODO
|
||||
return true;
|
||||
}
|
||||
public function buildHtml($params, $method = 'post', $target = '_self'){
|
||||
|
||||
public function buildHtml($params, $method = 'post', $target = '_self')
|
||||
{
|
||||
// var_dump($params);exit;
|
||||
$html = "<form id='submit' name='submit' action='".$this->gatewayUri."' method='$method' target='$target'>";
|
||||
foreach ($params as $key => $value) {
|
||||
$html .= "<input type='hidden' name='$key' value='$value'/>";
|
||||
}
|
||||
$html .= "</form><script>document.forms['submit'].submit();</script>";
|
||||
return $html;
|
||||
$html = "<form id='submit' name='submit' action='" . $this->gatewayUri . "' method='$method' target='$target'>";
|
||||
foreach ($params as $key => $value) {
|
||||
$html .= "<input type='hidden' name='$key' value='$value'/>";
|
||||
}
|
||||
$html .= "</form><script>document.forms['submit'].submit();</script>";
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user