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

Object not found when going to authenticate page #62

Closed
lucasvm opened this issue Aug 6, 2018 · 8 comments
Closed

Object not found when going to authenticate page #62

lucasvm opened this issue Aug 6, 2018 · 8 comments
Assignees

Comments

@lucasvm
Copy link

lucasvm commented Aug 6, 2018

Hello

I have followed all the steps, my app, is under src/ShopifyApp i have created on psr-4 the namespace like this:

"src\ShopifyApp\": "src/ShopifyApp"

however when i try to see the site im getting object not found

Also i have added this and everything is ok:

$ php artisan vendor:publish --tag=config
Copied File [\src\ShopifyApp\resources\config\shopify-app.php] To [\config\shopify-app.php]
Publishing complete.

Any ideas? im missing something? using url: http://local.shopify-app.com/authenticate, the url is on my localhost because i can see the index.html with the title.

added to My composer.json:
"psr-4": {
"App\": "app/",
"src\ShopifyApp\": "src/ShopifyApp"
}

@gnikyt
Copy link
Owner

gnikyt commented Aug 7, 2018

Not sure what you're trying to do, wrong install method it seems. You need to install via composer, the PSR4 is for composer to know where the files are for the package.

@gnikyt gnikyt self-assigned this Aug 7, 2018
@gnikyt gnikyt added the invalid Invalid to the repository (not a code issue, etc) label Aug 7, 2018
@lucasvm
Copy link
Author

lucasvm commented Aug 8, 2018

Ok, i think i get it, i was able to see everything like demo, anyway when i click on Install, then it redirects to authenticate i get this error:

GuzzleHttp \ Exception \ ClientException (422)
Client error: POST https://mystore.myshopify.com/admin/webhooks.json resulted in a 422 Unprocessable Entity response: {"errors":{"address":["is invalid"]}}

"""
Client error: POST https://mystire.myshopify.com/admin/webhooks.json resulted in a 422 Unprocessable Entity response:\n
{"errors":{"address":["is invalid"]}}\n

Any ideas?

@gnikyt
Copy link
Owner

gnikyt commented Aug 8, 2018

What do you have setup in your shopify-app config for the webhook?

@CamilleBB
Copy link

Hi guys !
Just got the same issue today when I created a new laravel app.

@ohmybrew : your answer about the webhook config helped me a lot :
I had forgotten to set SHOPIFY_WEBHOOK_1_ADDRESS with my app URL. I added it in my .env file and everything works like a charm now.

@lucasvm
Copy link
Author

lucasvm commented Aug 11, 2018

Ok got it working by adding my app url!

So now, whats the best way to get the webhook info? is there any example? using the create orders.

webhook is not being created on web shop in Shopify, this is my shopify-app.php file:

'webhooks' => [
        [
            'topic' => env('SHOPIFY_WEBHOOK_1_TOPIC', 'app/uninstalled'),
            'address' => env('SHOPIFY_WEBHOOK_1_ADDRESS', 'https://myappurl.com')
        ],
        [
            'topic' => 'orders/create',
            'address' => 'https://myadppurl.com/webhook/orders-create'
         ],
        
    ],

and i dont see the order create webhook on my admin.

I have added this on OrdersCreateJob.php

/**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        // Dispatch
        $shopDomain = request()->header('x-shopify-shop-domain');
        $data = json_decode(request()->getContent());
        dispatch(new $classPath($shopDomain, $data));

        return response('', 201);
    }

How can a try the webhook and see it on my url i have added on webhook endpoint?

i think i need the last step to see if i can get the order data when its being created, i would like to store on my db for export later on csv

@lucasvm
Copy link
Author

lucasvm commented Aug 12, 2018

@gnikyt gnikyt removed the invalid Invalid to the repository (not a code issue, etc) label Aug 13, 2018
@gnikyt
Copy link
Owner

gnikyt commented Aug 13, 2018

@lucasvm Yes, so long as you have a url path matching the job, example: "xxxxyyyzzzz.com/webhook/orders-create", the package will convert order-create into App\Jobs\OrderCreateJob.php and expect the job there. It has a built in controller for handling the webhook jobs.

It will then pass the shop domain, and webhook data to the contructor of the job, then once queue'd, the job worker will fire handle() of that job class.

For example data, I do not have this off-hand, however, you can find information per resource on Shopify's API docs. Example: https://help.shopify.com/en/api/reference/orders/order#show is data you would get through a webhook for an order, similar for a product update/create, etc, a singular object.

Does this solve your problem?

@lucasvm
Copy link
Author

lucasvm commented Aug 13, 2018

Yes its working great, if someone needs to get the data printed on some file to check what is comming from Shopify on order creation i have done this:
use Log; at the begining

Create a construct:

/**
     * Shop's myshopify domain
     *
     * @var string
     */
    public $shopDomain;

    /**
     * The webhook data
     *
     * @var object
     */
    public $data;

    /**
     * Create a new job instance.
     *
     * @param string $shopDomain The shop's myshopify domain
     * @param object $webhook The webhook data (JSON decoded)
     *
     * @return void
     */
    public function __construct($shopDomain, $data)
    {
        $this->shopDomain = $shopDomain;
        $this->data = $data;
    }

On the handle function.
Log::info("Logging an array: " . print_r($this->data, true));

This will print the data from Shopify on laravel.log file as Info with all the array of the order :)

Thank you for the support!

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

3 participants