<?php
namespace App\Http\Controllers\Api\V1;
use App\Http\Controllers\Controller;use App\Jobs\DeliverMerchantWebhookJob;use App\Models\WebhookDelivery;use App\Support\ApiResponse;use Illuminate\Http\Request;
final class WebhookReplayController extends Controller {public function __invoke(Request $r,int $deliveryId){$d=WebhookDelivery::whereKey($deliveryId)->whereHas('endpoint',fn($q)=>$q->where('merchant_id',$r->user()->id))->firstOrFail();$d->update(['status'=>'retrying','next_attempt_at'=>now(),'exhausted_at'=>null]);DeliverMerchantWebhookJob::dispatch($d->id)->onQueue('merchant-webhooks');return ApiResponse::success(['delivery_id'=>$d->id,'event_id'=>$d->event_id,'status'=>'queued'],202);}}
