Files
kiri-wchat/wchat/qq/Notify.php
T
2020-08-10 11:19:52 +08:00

388 lines
5.5 KiB
PHP

<?php
namespace wchat\qq;
use Exception;
use wchat\common\Help;
/**
* Class Notify
* @package wchat\qq
*/
class Notify extends SmallProgram
{
public $appid = null;
public $mch_id = null;
public $nonce_str = null;
public $sign = null;
public $device_info = null;
public $trade_type = null;
public $trade_state = null;
public $bank_type = null;
public $fee_type = null;
public $total_fee = null;
public $cash_fee = null;
public $coupon_fee = null;
public $transaction_id = null;
public $out_trade_no = null;
public $attach = null;
public $time_end = null;
public $openid = null;
/**
* @return bool
* 判断是否完成支付
*/
public function isSuccess()
{
return $this->getTradeState() === 'SUCCESS';
}
/**
* @param array $params
* @return $this
* @throws Exception
*/
public function setPayNotifyData(array $params)
{
if (!$this->validation($params)) {
throw new Exception('签名错误!');
}
foreach ($params as $key => $val) {
if (!property_exists($this, $key)) {
continue;
}
$this->$key = $val;
}
return $this;
}
/**
* @param array $params
* @return bool
*/
public function validation(array $params)
{
$sign = $params['sign'];
unset($params['sign']);
$signType = $this->config->getSignType();
$privateKey = $this->config->getKey();
$nowSign = Help::sign($params, $privateKey, $signType);
if ($sign === $nowSign) {
return true;
}
return false;
}
/**
* @return null
*/
public function getAppid()
{
return $this->appid;
}
/**
* @param null $appid
* @return Notify
*/
public function setAppid($appid)
{
$this->appid = $appid;
return $this;
}
/**
* @return null
*/
public function getMchId()
{
return $this->mch_id;
}
/**
* @param null $mch_id
* @return Notify
*/
public function setMchId($mch_id)
{
$this->mch_id = $mch_id;
return $this;
}
/**
* @return null
*/
public function getNonceStr()
{
return $this->nonce_str;
}
/**
* @param null $nonce_str
* @return Notify
*/
public function setNonceStr($nonce_str)
{
$this->nonce_str = $nonce_str;
return $this;
}
/**
* @return null
*/
public function getSign()
{
return $this->sign;
}
/**
* @param null $sign
* @return Notify
*/
public function setSign($sign)
{
$this->sign = $sign;
return $this;
}
/**
* @return null
*/
public function getDeviceInfo()
{
return $this->device_info;
}
/**
* @param null $device_info
* @return Notify
*/
public function setDeviceInfo($device_info)
{
$this->device_info = $device_info;
return $this;
}
/**
* @return null
*/
public function getTradeType()
{
return $this->trade_type;
}
/**
* @param null $trade_type
* @return Notify
*/
public function setTradeType($trade_type)
{
$this->trade_type = $trade_type;
return $this;
}
/**
* @return null
*/
public function getTradeState()
{
return $this->trade_state;
}
/**
* @param null $trade_state
* @return Notify
*/
public function setTradeState($trade_state)
{
$this->trade_state = $trade_state;
return $this;
}
/**
* @return null
*/
public function getBankType()
{
return $this->bank_type;
}
/**
* @param null $bank_type
* @return Notify
*/
public function setBankType($bank_type)
{
$this->bank_type = $bank_type;
return $this;
}
/**
* @return null
*/
public function getFeeType()
{
return $this->fee_type;
}
/**
* @param null $fee_type
* @return Notify
*/
public function setFeeType($fee_type)
{
$this->fee_type = $fee_type;
return $this;
}
/**
* @return null
*/
public function getTotalFee()
{
return $this->total_fee;
}
/**
* @param null $total_fee
* @return Notify
*/
public function setTotalFee($total_fee)
{
$this->total_fee = $total_fee;
return $this;
}
/**
* @return null
*/
public function getCashFee()
{
return $this->cash_fee;
}
/**
* @param null $cash_fee
* @return Notify
*/
public function setCashFee($cash_fee)
{
$this->cash_fee = $cash_fee;
return $this;
}
/**
* @return null
*/
public function getCouponFee()
{
return $this->coupon_fee;
}
/**
* @param null $coupon_fee
* @return Notify
*/
public function setCouponFee($coupon_fee)
{
$this->coupon_fee = $coupon_fee;
return $this;
}
/**
* @return null
*/
public function getTransactionId()
{
return $this->transaction_id;
}
/**
* @param null $transaction_id
* @return Notify
*/
public function setTransactionId($transaction_id)
{
$this->transaction_id = $transaction_id;
return $this;
}
/**
* @return null
*/
public function getOutTradeNo()
{
return $this->out_trade_no;
}
/**
* @param null $out_trade_no
* @return Notify
*/
public function setOutTradeNo($out_trade_no)
{
$this->out_trade_no = $out_trade_no;
return $this;
}
/**
* @return null
*/
public function getAttach()
{
return $this->attach;
}
/**
* @param null $attach
* @return Notify
*/
public function setAttach($attach)
{
$this->attach = $attach;
return $this;
}
/**
* @return null
*/
public function getTimeEnd()
{
return $this->time_end;
}
/**
* @param null $time_end
* @return Notify
*/
public function setTimeEnd($time_end)
{
$this->time_end = $time_end;
return $this;
}
/**
* @return null
*/
public function getOpenid()
{
return $this->openid;
}
/**
* @param null $openid
* @return Notify
*/
public function setOpenid($openid)
{
$this->openid = $openid;
return $this;
}
}