Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Custom webhook controller for custom dispatch not used #1063

Open
HugoHeneault opened this issue Jan 21, 2022 · 1 comment
Open

Custom webhook controller for custom dispatch not used #1063

HugoHeneault opened this issue Jan 21, 2022 · 1 comment

Comments

@HugoHeneault
Copy link

For bug reporting only! If you're posting a feature request or discussion, please ignore.

Expected Behavior

I'm trying to create a route as stated in doc but it seems my route it still handled by default webhook controller.

Current Behavior

I got an error

Too few arguments to function App\Jobs\OrdersPaidJob::__construct(), 2 passed in vendor/laravel/framework/src/Illuminate/Foundation/Bus/Dispatchable.php on line 17 and exactly 3 expected

Which seems to demonstrate the dispatch is still made by the default WebhookController https://github.com/osiset/laravel-shopify/blob/3ed1a8f3f95cacbdfba65b69857fbc529ecbcb51/src/Traits/WebhookController.php#L29

Failure Information

Please help provide information about the failure if this is a bug.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Add a route for your webhook in routes/web.php:
Route::post(
    '/webhook/orders-paid',
    [OrderPaidController::class, 'handle']
)->middleware('auth.webhook');
  1. Create the according controller:
<?php

namespace App\Http\Controllers;

use App\Jobs\OrdersPaidJob;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Osiset\ShopifyApp\Util;
use Illuminate\Http\Response as ResponseResponse;

class OrderPaidController extends Controller
{
    /**
     * Handles an incoming webhook.
     *
     * @param string  $type    The type of webhook
     * @param Request $request The request object.
     *
     * @return ResponseResponse
     */
    public function handle(Request $request): ResponseResponse
    {
        dd('in custom OrderPaidController');
        // Get the job class and dispatch
        $jobData = json_decode($request->getContent());

        OrdersPaidJob::dispatch(
            $request->header('x-shopify-shop-domain'),
            $request->header('x-shopify-webhook-id'),
            $jobData
        )->onQueue(Util::getShopifyConfig('job_queues')['webhooks']);

        return Response::make('', ResponseResponse::HTTP_CREATED);
    }
}
  1. Call a webhook on the route.
  2. You won't get the expected in custom OrderPaidController message as result.

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

  • Package Version: v17.1.10
  • Laravel Version: v8.65
  • PHP Version: v8.0
  • Using a toolset (Docker, Laradock, Vagrant, etc.): No

Failure Logs

Please include any relevant log snippets or files here.

@HugoHeneault
Copy link
Author

I'm working on a PR passing webhookId to all jobs as it might be useful to others :)

If it suits you, I can also edit documentation & wikis. Tell me!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant