Как установить клиент / создать интернет-магазин Shopify - Laravel - PullRequest
0 голосов
/ 17 октября 2018

Я устанавливаю веб-крючок, который будет уведомлять administrators о добавлении новых customers.

Документация находится в Ruby, но я пытаюсь сделать это в laravel.

Этовот что я сделал:

  1. Я создал задание CustomerInstallShopifyWebhook
  2. Я добавил маршрут для адреса в моем web.php

Сейчас, когда я добавляю customer, я все еще не получаю свое уведомление.

Правильно ли отправляется моя работа?

CustomerInstallShopifyWebhook

class CustomerInstallShopifyWebhook implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public $domain;  
    public $token;
    public $store;

    public function __construct($domain, $token, \App\Store $store)
    {
    $this->domain = $domain;
    $this->token = $token;
    $this->store = $store;
    }

    public function handle()
    {
        //
       $shopify = \Shopify::retrieve($this->domain, $this->token);
       $customerCreate = array
         (
      'webhook'=>array
       (
        'topic'=> 'customers/create',
        'address'=> 'https://shopify.com/webhook/shopify/customer-created',
        'format'=> 'json'
       )
       );

     $customerCreate_webhook = $sc->call('POST', '/admin/webhooks.json', $customerCreate);

     header('Content-type: application/json');
     echo json_encode(array("state"=>"success", "customer_create"=>$customerCreate_webhook));

    }
}

Маршрут

Route::post('webhook/shopify/customer-created', function(\Illuminate\Http\Request $request) {
        $query = "?key=**********&to=0501149794&msg=Testing Shopify App&sender_id=Shopify";
        $final_uri = $baseurl.$query;
        $response = file_get_contents($final_uri);
        header ("Content-Type:text/xml");
})->middleware('webhook');
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...