{"id":13546442,"url":"https://github.com/oseintow/laravel-shopify","last_synced_at":"2025-04-06T20:13:36.170Z","repository":{"id":57033345,"uuid":"68137189","full_name":"oseintow/laravel-shopify","owner":"oseintow","description":"Laravel Shopify Package","archived":false,"fork":false,"pushed_at":"2023-08-29T11:30:56.000Z","size":2623,"stargazers_count":71,"open_issues_count":9,"forks_count":41,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-30T19:06:54.342Z","etag":null,"topics":["laravel-shopify","php-shopify","shopify","shopify-laravel"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oseintow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2016-09-13T18:45:40.000Z","updated_at":"2024-03-13T13:50:22.000Z","dependencies_parsed_at":"2024-04-16T23:41:43.882Z","dependency_job_id":"aa76f520-1075-4e26-a566-cb72de3f37a9","html_url":"https://github.com/oseintow/laravel-shopify","commit_stats":{"total_commits":115,"total_committers":10,"mean_commits":11.5,"dds":"0.16521739130434787","last_synced_commit":"7253d53adffc86182ad0e3372636943d0c092890"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oseintow%2Flaravel-shopify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oseintow%2Flaravel-shopify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oseintow%2Flaravel-shopify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oseintow%2Flaravel-shopify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oseintow","download_url":"https://codeload.github.com/oseintow/laravel-shopify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247543595,"owners_count":20955865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel-shopify","php-shopify","shopify","shopify-laravel"],"created_at":"2024-08-01T12:00:37.808Z","updated_at":"2025-04-06T20:13:36.153Z","avatar_url":"https://github.com/oseintow.png","language":"PHP","funding_links":[],"categories":["Libraries","库"],"sub_categories":["PHP"],"readme":"# Laravel Shopify\n\nLaravel Shopify is a simple package which helps to build robust integration into Shopify.\n\n## Installation\n\nAdd package to composer.json\n\n    composer require oseintow/laravel-shopify\n\n### Laravel 5.5+\n\nPackage auto discovery will take care of setting up the alias and facade for you\n\n\n### Laravel 5.4 \u003c\n\nAdd the service provider to config/app.php in the providers array.\n\n```php5\n\u003c?php\n\n'providers' =\u003e [\n    ...\n    Oseintow\\Shopify\\ShopifyServiceProvider::class,\n],\n```\n\n\nSetup alias for the Facade\n\n```php5\n\u003c?php\n\n'aliases' =\u003e [\n    ...\n    'Shopify' =\u003e Oseintow\\Shopify\\Facades\\Shopify::class,\n],\n```\n\n## Configuration\n\nLaravel Shopify requires connection configuration. You will need to publish vendor assets\n\n    php artisan vendor:publish\n\nThis will create a shopify.php file in the config directory. You will need to set your **API_KEY** and **SECRET**\n\n## Usage\n\nTo install/integrate a shop you will need to initiate an oauth authentication with the shopify API and this require three components.\n\nThey are:\n\n    1. Shop URL (eg. example.myshopify.com)\n    2. Scope (eg. write_products, read_orders, etc)\n    3. Redirect URL (eg. http://mydomain.com/process_oauth_result)\n\nThis process will enable us to obtain the shops access token\n\n```php5\nuse Oseintow\\Shopify\\Facades\\Shopify;\n\nRoute::get(\"install_shop\",function()\n{\n    $shopUrl = \"example.myshopify.com\";\n    $scope = [\"write_products\",\"read_orders\"];\n    $redirectUrl = \"http://mydomain.com/process_oauth_result\";\n\n    $shopify = Shopify::setShopUrl($shopUrl);\n    return redirect()-\u003eto($shopify-\u003egetAuthorizeUrl($scope,$redirectUrl));\n});\n```\n\nLet's retrieve access token\n\n```php5\nRoute::get(\"process_oauth_result\",function(\\Illuminate\\Http\\Request $request)\n{\n    $shopUrl = \"example.myshopify.com\";\n    $accessToken = Shopify::setShopUrl($shopUrl)-\u003egetAccessToken($request-\u003ecode);\n\n    dd($accessToken);\n    \n    // redirect to success page or billing etc.\n});\n```\n\nTo verify request(hmac)\n\n```php5\npublic function verifyRequest(Request $request)\n{\n    $queryString = $request-\u003egetQueryString();\n\n    if(Shopify::verifyRequest($queryString)){\n        logger(\"verification passed\");\n    }else{\n        logger(\"verification failed\");\n    }\n}\n\n```\n\nTo verify webhook(hmac)\n\n```php5\n\npublic function verifyWebhook(Request $request)\n{\n    $data = $request-\u003egetContent();\n    $hmacHeader = $request-\u003eserver('HTTP_X_SHOPIFY_HMAC_SHA256');\n\n    if (Shopify::verifyWebHook($data, $hmacHeader)) {\n        logger(\"verification passed\");\n    } else {\n        logger(\"verification failed\");\n    }\n}\n\n```\n\nTo access API resource use\n\n```php5\nShopify::get(\"resource uri\", [\"query string params\"]);\nShopify::post(\"resource uri\", [\"post body\"]);\nShopify::put(\"resource uri\", [\"put body\"]);\nShopify::delete(\"resource uri\");\n```\n\nLet use our access token to get products from shopify.\n\n**NB:** You can use this to access any resource on shopify (be it Product, Shop, Order, etc)\n\n```php5\n$shopUrl = \"example.myshopify.com\";\n$accessToken = \"xxxxxxxxxxxxxxxxxxxxx\";\n$products = Shopify::setShopUrl($shopUrl)-\u003esetAccessToken($accessToken)-\u003eget(\"admin/products.json\");\n```\n\nTo pass query params\n\n```php5\n// returns Collection\n$shopify = Shopify::setShopUrl($shopUrl)-\u003esetAccessToken($accessToken);\n$products = $shopify-\u003eget(\"admin/products.json\", [\"limit\"=\u003e20, \"page\" =\u003e 1]);\n```\n\n## Controller Example\n\nIf you prefer to use dependency injection over facades like me, then you can inject the Class:\n\n```php5\nuse Illuminate\\Http\\Request;\nuse Oseintow\\Shopify\\Shopify;\n\nclass Foo\n{\n    protected $shopify;\n\n    public function __construct(Shopify $shopify)\n    {\n        $this-\u003eshopify = $shopify;\n    }\n\n    /*\n    * returns Collection\n    */\n    public function getProducts(Request $request)\n    {\n        $products = $this-\u003eshopify-\u003esetShopUrl($shopUrl)\n            -\u003esetAccessToken($accessToken)\n            -\u003eget('admin/products.json');\n\n        $products-\u003eeach(function($product){\n             \\Log::info($product-\u003etitle);\n        });\n    }\n}\n```\n\n## Miscellaneous\n\nTo get Response headers\n\n```php5\nShopify::getHeaders();\n```\n\nTo get specific header\n```php5\nShopify::getHeader(\"Content-Type\");\n```\n\nCheck if header exist\n```php5\nif(Shopify::hasHeader(\"Content-Type\")){\n    echo \"Yes header exist\";\n}\n```\n\nTo get response status code or status message\n```php5\nShopify::getStatusCode(); // 200\nShopify::getReasonPhrase(); // ok\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foseintow%2Flaravel-shopify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foseintow%2Flaravel-shopify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foseintow%2Flaravel-shopify/lists"}