提交代码
This commit is contained in:
33
app/Agent/Controllers/NotifyController.php
Normal file
33
app/Agent/Controllers/NotifyController.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Agent\Controllers;
|
||||
|
||||
use App\Events\CardOrderPaid;
|
||||
use App\Models\CardPayment;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class NotifyController extends Controller
|
||||
{
|
||||
|
||||
public function payment(Request $request)
|
||||
{
|
||||
$app = app('wechat.payment');
|
||||
return $app->handlePaidNotify(function ($message, $fail) {
|
||||
$payment = CardPayment::where('trade_no', $message['out_trade_no'])->first();
|
||||
$order = $payment->order;
|
||||
|
||||
if ($payment->state != 'SUCCESS') {
|
||||
$payment->state = 'SUCCESS';
|
||||
$payment->transaction_id = $message['transaction_id'];
|
||||
$payment->paid_at = $message['time_end'];
|
||||
$payment->save();
|
||||
|
||||
$order->status = 1;
|
||||
$order->save();
|
||||
event(new CardOrderPaid($payment));
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user