微信支付通知
parent
f0dd85ec67
commit
8135c6942e
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Endpoint\Callback\Http\Controllers;
|
||||
|
||||
use App\Services\WeChatPayService;
|
||||
|
||||
class WeChatPayController extends Controller
|
||||
{
|
||||
/**
|
||||
* 直接结果通知
|
||||
*
|
||||
* @param \App\Services\WeChatPayService $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function paidNotify(WeChatPayService $weChatPayService)
|
||||
{
|
||||
$weChatPayService->handlePaidNotify(function ($message, $fail) {
|
||||
logger()->debug('wechat notify', $message);
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
<?php
|
||||
|
||||
use App\Endpoint\Callback\Http\Controllers\Kuaidi100Controller;
|
||||
use App\Endpoint\Callback\Http\Controllers\WeChatPayController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::group([
|
||||
'prefix' => 'v1',
|
||||
], function () {
|
||||
Route::post('kuaidi100', [Kuaidi100Controller::class, 'callback']);
|
||||
});
|
||||
Route::post('kuaidi100', [Kuaidi100Controller::class, 'callback']);
|
||||
// 微信支付通知
|
||||
Route::post('wxpay/paid-notify', [WeChatPayController::class, 'paidNotify'])->name('wxpay.paid_notify');
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace App\Providers;
|
||||
|
||||
use EasyWeChat\Factory as EasyWeChatFactory;
|
||||
use EasyWeChat\Payment\Application as EasyWeChatPaymentApplication;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
|
@ -18,6 +20,7 @@ class AppServiceProvider extends ServiceProvider
|
|||
public function register()
|
||||
{
|
||||
$this->registerEasySms();
|
||||
$this->registerEasyWeChat();
|
||||
$this->registerRequestRealIp();
|
||||
}
|
||||
|
||||
|
|
@ -35,6 +38,18 @@ class AppServiceProvider extends ServiceProvider
|
|||
JsonResource::withoutWrapping();
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册微信服务
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerEasyWeChat()
|
||||
{
|
||||
$this->app->singleton(EasyWeChatPaymentApplication::class, function ($app) {
|
||||
return EasyWeChatFactory::payment($app['config']->get('wechat.payment.default'));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册短信发送服务
|
||||
*
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Services;
|
||||
|
||||
use App\Exceptions\WeChatPayException;
|
||||
use Closure;
|
||||
use EasyWeChat\Factory;
|
||||
use EasyWeChat\Payment\Application;
|
||||
|
||||
|
|
@ -87,4 +88,15 @@ class WeChatPayService
|
|||
|
||||
return $this->app->jssdk->bridgeConfig($prepayId, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付结果通知
|
||||
*
|
||||
* @param \Closure $closure
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function handlePaidNotify(Closure $closure)
|
||||
{
|
||||
return $this->app->handlePaidNotify($closure);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
// 应用名称
|
||||
'app_name' => '子春生',
|
||||
|
||||
// 订单支付过期时间(秒)
|
||||
'order_payment_expires_at' => 1800,
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue