新增药品订单支付回调
This commit is contained in:
@@ -21,11 +21,14 @@ class WechatPay
|
||||
{
|
||||
protected array $config;// 系统配置
|
||||
protected array $pay_config;// 支付系统配置
|
||||
protected string $pay_notify_url;// 支付回调地址
|
||||
protected string $refund_notify_url;// 退款回调地址
|
||||
|
||||
/**
|
||||
* @param string $user_type
|
||||
* @param string $user_type 用户类型(1:患者端 2:专家端 3:药师端)
|
||||
* @param int $order_type 订单类型(1:问诊订单 2:药品订单)
|
||||
*/
|
||||
public function __construct(string $user_type)
|
||||
public function __construct(string $user_type,int $order_type)
|
||||
{
|
||||
if ($user_type == 1){
|
||||
$this->config = config("we_chat.applets.patient");
|
||||
@@ -40,6 +43,20 @@ class WechatPay
|
||||
if (empty($this->config)){
|
||||
throw new BusinessException("系统配置错误", HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
if (!in_array($order_type,[1,2])){
|
||||
throw new BusinessException("订单类型错误", HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
if ($order_type == 1){
|
||||
$this->pay_notify_url = $this->config['inquiry_pay_notify_url'];
|
||||
$this->refund_notify_url = $this->config['inquiry_refund_notify_url'];
|
||||
}
|
||||
|
||||
if ($order_type == 2){
|
||||
$this->pay_notify_url = $this->config['product_pay_notify_url'];
|
||||
$this->refund_notify_url = $this->config['product_refund_notify_url'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,7 +126,7 @@ class WechatPay
|
||||
"out_trade_no" => $out_trade_no, // 商户系统内部订单号
|
||||
"appid" => $this->config['app_id'],
|
||||
"description" => "问诊服务",
|
||||
"notify_url" => env('DOMAIN_NAME_DEV') . $this->config['pay_notify_url'],
|
||||
"notify_url" => env('DOMAIN_NAME_DEV') . $this->pay_notify_url,
|
||||
"amount" => [
|
||||
"total" => $total,//订单总金额,单位为分。
|
||||
"currency" => "CNY"
|
||||
@@ -178,7 +195,7 @@ class WechatPay
|
||||
try {
|
||||
$app = $this->createApp();
|
||||
|
||||
$options['notify_url'] = env('DOMAIN_NAME_DEV') . $this->config['refund_notify_url'];
|
||||
$options['notify_url'] = env('DOMAIN_NAME_DEV') . $this->refund_notify_url;
|
||||
|
||||
$response = $app->getClient()->postJson("v3/refund/domestic/refunds", $options);
|
||||
if ($response->isFailed()) {
|
||||
|
||||
Reference in New Issue
Block a user