34 lines
915 B
PHP
34 lines
915 B
PHP
<?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;
|
|
});
|
|
}
|
|
}
|