Skip to content

Commit

Permalink
支付优化
Browse files Browse the repository at this point in the history
  • Loading branch information
狂奔的螞蟻 committed May 13, 2020
1 parent b3cfc4d commit ed7c684
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "firstphp/firstphp-wxapp",
"type": "library",
"license": "MIT",
"version": "1.6.7",
"version": "1.6.8",
"authors": [
{
"name": "狂奔的蚂蚁",
Expand Down
18 changes: 15 additions & 3 deletions src/WxappClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public function templateMsg(array $params = [])
* @param string $key
* @return string
*/
public function getSign(array $params, string $key)
public function makeSign(array $params, string $key)
{
ksort($params);
$str = '';
Expand All @@ -334,11 +334,12 @@ public function getSign(array $params, string $key)
/**
* 统一下单
*
* @param string $xmlData
* @param array $orderData
* @param int $second
* @return int|mixed
*/
public function unifiedorder(string $xmlData, int $second) {
public function unifiedorder(array $orderData, int $second = 30) {
$xmlData = $this->dataToXml($orderData);
$ch = curl_init();
curl_setopt($ch, CURLOPT_TIMEOUT, $second);
curl_setopt($ch,CURLOPT_URL, $url = 'https://api.mch.weixin.qq.com/pay/unifiedorder');
Expand Down Expand Up @@ -382,6 +383,17 @@ public function dataToXml(array $data) {
}


/**
* @param string $xml
* @return mixed
*/
public function fromXml(string $xml) {
libxml_disable_entity_loader(true);
$this->values = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
return $this->values;
}


/**
* 以post方式提交xml到对应的接口url
*
Expand Down
13 changes: 10 additions & 3 deletions src/WxappInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function templateMsg(array $params = []);
* @param string $key
* @return mixed
*/
public function getSign(array $params, string $key);
public function makeSign(array $params, string $key);


/**
Expand All @@ -144,14 +144,21 @@ public function getSign(array $params, string $key);
public function dataToXml(array $data);


/**
* @param string $xml
* @return mixed
*/
public function fromXml(string $xml);


/**
* 统一下单
*
* @param string $xmlData
* @param array $orderData
* @param int $second
* @return mixed
*/
public function unifiedorder(string $xmlData, int $second = 30);
public function unifiedorder(array $orderData, int $second = 30);


/**
Expand Down

0 comments on commit ed7c684

Please sign in to comment.