Files

554 lines
9.0 KiB
PHP
Raw Permalink Normal View History

2019-08-29 11:32:58 +08:00
<?php
2020-03-05 12:41:49 +08:00
namespace wchat\wx;
2019-08-29 11:32:58 +08:00
2022-09-09 16:42:55 +08:00
use wchat\common\Help;
2019-08-29 11:32:58 +08:00
2019-11-11 18:14:47 +08:00
class Notify extends SmallProgram
2019-08-29 11:32:58 +08:00
{
2022-09-09 16:42:55 +08:00
public mixed $appid = '';
public mixed $mch_id = '';
public mixed $device_info = '';
public mixed $nonce_str = '';
public mixed $sign = '';
public mixed $sign_type = '';
public mixed $result_code = '';
public mixed $err_code = '';
public mixed $err_code_des = '';
public mixed $openid = '';
public mixed $is_subscribe = '';
public mixed $trade_type = '';
public mixed $bank_type = '';
public mixed $total_fee = '';
public mixed $settlement_total_fee = '';
public mixed $fee_type = '';
public mixed $cash_fee = '';
public mixed $cash_fee_type = '';
public mixed $coupon_fee = '';
public mixed $coupon_count = '';
public mixed $coupon_type_n = '';
public mixed $coupon_id_n = '';
public mixed $coupon_fee_n = '';
public mixed $transaction_id = '';
public mixed $out_trade_no = '';
public mixed $attach = '';
public mixed $time_end = '';
public mixed $return_code = '';
2019-08-29 11:32:58 +08:00
/**
* @return bool
* 判断是否完成支付
*/
2022-09-09 16:42:55 +08:00
public function isSuccess(): bool
2019-08-29 11:32:58 +08:00
{
if ($this->getReturnCode() != "SUCCESS") {
return false;
}
if ($this->getResultCode() != 'SUCCESS') {
return false;
}
return true;
}
/**
* @param array $params
* @return $this
*/
2022-09-09 16:42:55 +08:00
public function setPayNotifyData(array $params): static
2019-08-29 11:32:58 +08:00
{
if (!$this->validation($params)) {
$this->setResultCode('FAIL');
$this->setErrCodeDes('签名错误');
unset($params['result_code'], $params['err_code_des']);
}
foreach ($params as $key => $val) {
2022-09-09 16:42:55 +08:00
$this->__set($key, $val);
2019-08-29 11:32:58 +08:00
}
return $this;
}
2023-12-12 15:35:37 +08:00
/**
* @param string $name
* @param mixed $value
* @return void
*/
2023-11-14 14:10:36 +08:00
public function __set(string $name, mixed $value): void
2022-09-09 16:42:55 +08:00
{
if (property_exists($this, $name)) {
$this->$name = $value;
}
}
2019-08-29 11:32:58 +08:00
/**
* @param array $params
* @return bool
*/
2022-09-09 16:42:55 +08:00
public function validation(array $params): bool
2019-08-29 11:32:58 +08:00
{
$sign = $params['sign'];
unset($params['sign']);
2023-11-14 00:45:54 +08:00
$signType = $this->payConfig->getSignType();
2023-11-14 14:10:36 +08:00
$privateKey = $this->payConfig->pay->wx->secret;
2019-08-29 18:25:42 +08:00
$nowSign = Help::sign($params, $privateKey, $signType);
2019-08-29 11:32:58 +08:00
if ($sign === $nowSign) {
return true;
}
return false;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getAppid(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->appid;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $appid
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setAppid(mixed $appid): void
2019-08-29 11:32:58 +08:00
{
$this->appid = $appid;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getMchId(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->mch_id;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $mch_id
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setMchId(mixed $mch_id): void
2019-08-29 11:32:58 +08:00
{
$this->mch_id = $mch_id;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getDeviceInfo(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->device_info;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $device_info
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setDeviceInfo(mixed $device_info): void
2019-08-29 11:32:58 +08:00
{
$this->device_info = $device_info;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getNonceStr(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->nonce_str;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $nonce_str
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setNonceStr(mixed $nonce_str): void
2019-08-29 11:32:58 +08:00
{
$this->nonce_str = $nonce_str;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getSign(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->sign;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $sign
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setSign(mixed $sign): void
2019-08-29 11:32:58 +08:00
{
$this->sign = $sign;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getSignType(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->sign_type;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $sign_type
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setSignType(mixed $sign_type): void
2019-08-29 11:32:58 +08:00
{
$this->sign_type = $sign_type;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getResultCode(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->result_code;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $result_code
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setResultCode(mixed $result_code): void
2019-08-29 11:32:58 +08:00
{
$this->result_code = $result_code;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getErrCode(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->err_code;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $err_code
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setErrCode(mixed $err_code): void
2019-08-29 11:32:58 +08:00
{
$this->err_code = $err_code;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getErrCodeDes(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->err_code_des;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $err_code_des
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setErrCodeDes(mixed $err_code_des): void
2019-08-29 11:32:58 +08:00
{
$this->err_code_des = $err_code_des;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getOpenid(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->openid;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $openid
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setOpenid(mixed $openid): void
2019-08-29 11:32:58 +08:00
{
$this->openid = $openid;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getIsSubscribe(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->is_subscribe;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $is_subscribe
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setIsSubscribe(mixed $is_subscribe): void
2019-08-29 11:32:58 +08:00
{
$this->is_subscribe = $is_subscribe;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getTradeType(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->trade_type;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $trade_type
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setTradeType(mixed $trade_type): void
2019-08-29 11:32:58 +08:00
{
$this->trade_type = $trade_type;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getBankType(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->bank_type;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $bank_type
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setBankType(mixed $bank_type): void
2019-08-29 11:32:58 +08:00
{
$this->bank_type = $bank_type;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getTotalFee(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->total_fee;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $total_fee
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setTotalFee(mixed $total_fee): void
2019-08-29 11:32:58 +08:00
{
$this->total_fee = $total_fee;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getSettlementTotalFee(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->settlement_total_fee;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $settlement_total_fee
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setSettlementTotalFee(mixed $settlement_total_fee): void
2019-08-29 11:32:58 +08:00
{
$this->settlement_total_fee = $settlement_total_fee;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getFeeType(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->fee_type;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $fee_type
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setFeeType(mixed $fee_type): void
2019-08-29 11:32:58 +08:00
{
$this->fee_type = $fee_type;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getCashFee(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->cash_fee;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $cash_fee
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setCashFee(mixed $cash_fee): void
2019-08-29 11:32:58 +08:00
{
$this->cash_fee = $cash_fee;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getCashFeeType(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->cash_fee_type;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $cash_fee_type
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setCashFeeType(mixed $cash_fee_type): void
2019-08-29 11:32:58 +08:00
{
$this->cash_fee_type = $cash_fee_type;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getCouponFee(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->coupon_fee;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $coupon_fee
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setCouponFee(mixed $coupon_fee): void
2019-08-29 11:32:58 +08:00
{
$this->coupon_fee = $coupon_fee;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getCouponCount(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->coupon_count;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $coupon_count
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setCouponCount(mixed $coupon_count): void
2019-08-29 11:32:58 +08:00
{
$this->coupon_count = $coupon_count;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getCouponTypeN(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->coupon_type_n;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $coupon_type_n
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setCouponTypeN(mixed $coupon_type_n): void
2019-08-29 11:32:58 +08:00
{
$this->coupon_type_n = $coupon_type_n;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getCouponIdN(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->coupon_id_n;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $coupon_id_n
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setCouponIdN(mixed $coupon_id_n): void
2019-08-29 11:32:58 +08:00
{
$this->coupon_id_n = $coupon_id_n;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getCouponFeeN(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->coupon_fee_n;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $coupon_fee_n
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setCouponFeeN(mixed $coupon_fee_n): void
2019-08-29 11:32:58 +08:00
{
$this->coupon_fee_n = $coupon_fee_n;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getTransactionId(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->transaction_id;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $transaction_id
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setTransactionId(mixed $transaction_id): void
2019-08-29 11:32:58 +08:00
{
$this->transaction_id = $transaction_id;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getOutTradeNo(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->out_trade_no;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $out_trade_no
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setOutTradeNo(mixed $out_trade_no): void
2019-08-29 11:32:58 +08:00
{
$this->out_trade_no = $out_trade_no;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getAttach(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->attach;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $attach
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setAttach(mixed $attach): void
2019-08-29 11:32:58 +08:00
{
$this->attach = $attach;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getTimeEnd(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->time_end;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $time_end
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setTimeEnd(mixed $time_end): void
2019-08-29 11:32:58 +08:00
{
$this->time_end = $time_end;
}
/**
2022-09-09 16:42:55 +08:00
* @return mixed|string
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function getReturnCode(): mixed
2019-08-29 11:32:58 +08:00
{
return $this->return_code;
}
/**
2022-09-09 16:42:55 +08:00
* @param mixed|string $return_code
2019-08-29 11:32:58 +08:00
*/
2022-09-09 16:42:55 +08:00
public function setReturnCode(mixed $return_code): void
2019-08-29 11:32:58 +08:00
{
$this->return_code = $return_code;
}
}