@@ -95,11 +95,13 @@ public function refund($order)
9595 case 'alipay ' :
9696 $ response = $ this ->alipayRefund ($ order , $ gateway );
9797 break ;
98+ case 'wechat ' :
99+ $ response = $ this ->wechatRefund ($ order , $ gateway );
100+ break ;
98101 case 'unionpay ' :
99102 $ response = $ this ->unionpayRefund ($ order , $ gateway );
100103 break ;
101104 }
102- dd ($ response ->getData ());
103105 if ($ response ->isSuccessful ()) {
104106 $ this ->where ('order_id ' , $ order ['order_id ' ])->update (['status ' => 'refund ' ]);
105107 }
@@ -122,6 +124,24 @@ protected function alipayRefund($order, $gateway)
122124 ];
123125 return $ gateway ->refund ()->setBizContent ($ biz )->send ();
124126 }
127+ /**
128+ * [wechatRefund 微信退款]
129+ * @param [type] $order [description]
130+ * @param [type] $gateway [description]
131+ * @return [type] [description]
132+ */
133+ protected function wechatRefund ($ order , $ gateway )
134+ {
135+ // 获取成交金额
136+ $ totalFee = $ this ->getOrder ($ order ['order_id ' ])['fee ' ];
137+ $ biz = [
138+ 'out_trade_no ' => $ order ['order_id ' ],
139+ 'out_refund_no ' => $ order ['order_id ' ],
140+ 'total_fee ' => $ totalFee * 100 ,
141+ 'refund_fee ' => $ order ['fee ' ] * 100 ,
142+ ];
143+ return $ gateway ->refund ($ biz )->send ();
144+ }
125145 /**
126146 * [unionpayRefund 银联退款]
127147 * @param [type] $order [description]
0 commit comments