Giter Site home page Giter Site logo

gnikyt / laravel-shopify Goto Github PK

View Code? Open in Web Editor NEW
1.2K 49.0 374.0 3.75 MB

A full-featured Laravel package for aiding in Shopify App development

License: MIT License

PHP 95.48% Blade 4.52%
shopify laravel laravel-package laravel-shopify webhook driver scripttags facade callback-url shopify-app

laravel-shopify's Introduction

Laravel Shopify App

Tests codecov License


[Closing]

Please read this announcement.

@kyon147 is going to maintain a version which you can find here https://github.com/Kyon147/laravel-shopify


A full-featured Laravel package for aiding in Shopify App development, similar to shopify_app for Rails. Works for Laravel 7 and up.

Screenshot Screenshot: Billable

Table of Contents

* Wiki pages

For more information, tutorials, etc., please view the project's wiki.

Goals

  • Provide assistance in developing Shopify apps with Laravel
  • Integration with Shopify API (REST, async REST, GraphQL)
  • Authentication & installation for shops (both per-user and offline types)
  • Plan & billing integration for single, recurring, and usage-types
  • Tracking charges to a shop (recurring, single, usage, etc) with trial support
  • Auto install app webhooks and scripttags through background jobs
  • Provide basic AppBridge views
  • Handles and processes incoming webhooks
  • Handles and verifies incoming app proxy requests
  • Namespacing abilities to run multiple apps on the same database

Documentation

For full resources on this package, see the wiki.

For internal documentation, it is available here from phpDocumentor.

Issue or request?

If you have found a bug or would like to request a feature for discussion, please use the ISSUE_TEMPLATE in this repo when creating your issue. Any issue submitted without this template will be closed.

License

This project is released under the MIT license.

Misc

Repository

Contributors

Contributions are always welcome! Contibutors are updated each release, pulled from Github. See CONTRIBUTORS.txt.

If you're looking to become a contributor, please see CONTRIBUTING.md.

Maintainers

Maintainers are users who manage the repository itself, whether it's managing the issues, assisting in releases, or helping with pull requests.

Currently this repository is maintained by:

Looking to become a maintainer? E-mail @osiset directly.

Special Note

I develop this package in my spare time, with a busy family/work life like many of you! So, I would like to thank everyone who's helped me out from submitting PRs, to assisting on issues, and plain using the package (I hope its useful). Cheers.

laravel-shopify's People

Contributors

aepnat avatar amosmos avatar awebartisan avatar bilfeldt avatar c4l3b avatar clydesantiago avatar darrynten avatar dellow avatar enmaboya avatar ericnkatz avatar gnikyt avatar ilamp avatar jedimdan avatar kyon147 avatar lucasmichot avatar mehulvadodariya2012 avatar msonowal avatar mtownsend5512 avatar nahid avatar ncpope avatar niveshsaharan avatar oanhnn avatar onurkose avatar savchukoleksii avatar seka19 avatar squatto avatar steveperrycreative avatar stevesweets avatar thang12l avatar tuimz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-shopify's Issues

Billing not working

I enabled billing in the config (after reinstalling on Laravel 5.5) but when I install the app, it does not take me to the billing page. It just goes straight to the app homepage. Is there anything else that needs to be done apart from setting the billing parameters in the the config file?

Billing Built-In

I'm going to build in the ability to charge for apps. I've done this many times, and figure its good to bake in as an (optional) thing for this package.

I plan on making it a separate middleware which anyone can attach to their routes. All settings for the billing including app name, pricing, trial period, etc, will be configurable.

Essentially the flow will be:

  1. Shop gets authenticated with current middleware
  2. Billing middleware will check if shop has paid (activation charge ID), or is grandfathered in (db flag)
  3. If not paid:
    i. Redirect to Shopify billing screen
    ii. Shop accepts/declines and is redirected back to a billing controller
    iii. If accepted, charge is activated and stored in database for that shop, then redirected to home route.
    iiii. If declined, show error
  4. If paid:
    i. Continue to route as normal

I'll be working on this in a new branch, with tests, and merge in once I feel its OK. Timeline for this is a bit sparse as I'm a tad busy these days so hang tight :)

how to remove signature with new hmac

Undefined index: signature.
My Error : signature is dereated.
MD5 signature is no longer supported since 1st June.Can u help me ?

$signature = $query['signature' in AuthProxy.php

Combine auth

how do I combine auth laravel with this plugin?
need auth()->user()->shopify_domain instead of session('shopify_domain')

so its easy to use eloquent model later

Using triple store as model

Sorry if this isn't appropriate as an issue.

I have a use case where I need to use a triple store (graph database such as Blazegraph or Amazon Neptune) rather than a relational database. From what I can tell laravel-shopify relies on eloquent for storing model information.

Would it be feasible to override parts of the module that use eloquent with my own read and write methods on a graph database?

406 api error

Hi,
I tried to insert a code using asset API of Shopify. but it returned a 406 error - Client error: PUT https://good-time-store.myshopify.com/admin/themes/14690353211/assets.json resulted in a 406 Not Acceptable response

This is my code
$api = $shop->api();
$asset = [
[
'key' => 'layout/theme.liquid',
'value' => 'hello'
]];

    $result = $api->request(
        'PUT',
        '/admin/themes/14690353211/assets.json',
        ['asset' => $asset]
    );

ShopifyAppFacade should be ShopifyApp

Docs instruct you to add this line to config/app
'ShopifyApp' => \OhMyBrew\ShopifyApp\Facades\ShopifyAppFacade::class,

but you should use this line
'ShopifyApp' => \OhMyBrew\ShopifyApp\Facades\ShopifyApp::class,

because ShopifyAppFacade does not exist.

Do I have to check charge_id after some time?

Hello guys,
first of all, thanks for this package! It saves me plenty of time.

Following scenario:

  1. Merchant starts 7 day trial -> charge_id is being filled
  2. Merchant removes the app before the trial ends
  3. Merchant installs app again after the trial -> what now? Since billable middleware is just looking for empty charge_id fields, the merchant can now use the app for free?

How to handle this situation?

Accepting a post request with data via proxy middleware fails proxy signature verification

Hi,

I hope this is not too broad of a question, but I'm having issues accepting an ajax post request in the laravel-shopify app.
I've excluded this particular path from the CSRF verification on VerifyCsrfToken class, and the request does come in. However, if I pass any data to the request I get a 401 Unauthorized error, with the following on the request response preview

exception: "Symfony\Component\HttpKernel\Exception\HttpException"
file : "app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php"
line : 942
message : "Invalid proxy signature"

If I don't pass any data on the request, it does go through.

For a little more context, this request is coming from a react application that is running proxy app requests. I have several working just fine, it was just now that I needed a post request that I ran into problems.

Any help much appreciated. Thank you!

Updating package

Hi,

What would be the best way to update the package using composer when you make a new release?
I have "ohmybrew/laravel-shopify": "^2.0" in my composer.json, but when I run composer update ohmybrew/laravel-shopify, nothing happens.

Also, will this update your ohmybrew/basic-shopify-api package at the same time?

Thanks

404s on the Proxy URL

Sorry for all the questions.
I'm still a bit puzzled with the site communication with the app via proxy.

I have the app proxy setup as follows:
image

When i visit the store URL that is linked to this proxy, I see the activity showing up in the ngrok log, however it seems to return an HTML with a redirect in it:

image 2018-06-16 at 7 37 25 pm

On the frontend the network activity shows the following:
image 2018-06-16 at 7 39 31 pm

Any idea what would cause this?

Thanks so much for any help you may provide.

After login, app doesn't redirect to the billing route

Hi,

In the login screen, I enter the shop name which redirect to the shopify screen to install the app. Then, I go back to the login screen instead of seeing the charge screen.

When I enter my domain with the billing route manually, then I can accept the charge.

Is this a bug or something I'm doing wrong?

Thank you.

charge_id column on charges table needs to be bigint

Hi !
When I tried to activate the app on my store, I got a database error saying the value for "charge_id" column on "charges" table is over range (int range is -2147483648 to 2147483648 if I remember well).
My charge_id was something like 2917400000

I fixed it by setting (manually) the column as BIGINT.

App Proxy Redirect loop

Hi, thanks so much for this awesome library.

I'm exploring in order to explore how viable it would be to add extra functionality for my Shopify projects, and excited for the possibilities this opens.

Going through the install steps, I'm stuck at the App proxy configuration.

I've wen't through the steps for creating the app proxy:
image 2018-06-10 at 6 32 17 pm

Checked that the merchant proxy settings use the same defaults, added the route to the Laravel application:

Route::get('/proxy', function () {
  return response('Hello, world!')->withHeaders(['Content-Type' => 'application/liquid']);
})->middleware('auth.proxy');

But then each time I try to open the app URL in my browser like https://merchant.com/apps/product-builder it keeps redirecting as seen on the ngrok panel:
image 2018-06-10 at 6 35 46 pm

I most be missing some crucial step here, could you help?

Thanks!

Overriding Routes

In the overriding documentation it mentions that:

If you're overriding routes, be sure to open config/app.php and move this package's provider to be after Laravel's provider. Example:

App\Providers\RouteServiceProvider::class,
\OhMyBrew\ShopifyApp\ShopifyAppProvider::class,

When I did this my overrides didn't seem to work but when I did the reverse of what this suggested (putting ShopifyAppProvider before the RouteServiceProvider) it did work. Am I misunderstanding this or could this be a problem with the documentation?

Cannot make Admin API post request from proxy route

I'm building an app that exposes a frontend on the public that feeds from proxy routes to pull data from the store.

This is a product builder, which at the end of the process should make a proxy request, which in turn has a controller method to create a new product in Shopify using the REST API routes.

I've tried two approaches, both resulting in different server errors.

Using the examples from the documentation, I've tried to instantiate a ShopifyApp object as follows:

    $shop = ShopifyApp::shop();

    $response = $shop->api()->request('post', '/admin/products.json', [
      'product' => [
        'title' => 'teste'
      ]
    ]);
    $products = $response->body;

This results in the following error message:

FatalThrowableError: Call to a member function api() on null

With null referring to the $shop instance.

So I've tried a different approach, where I would instantiate from the BasicShopifyAPI class instead, passing the necessary credentials:

    $api = new BasicShopifyAPI(true);
    $api->setShop(env('SHOPIFY_SHOP_URL'));
    $api->setApiKey(env('SHOPIFY_API_KEY'));
    $api->setApiPassword(env('SHOPIFY_API_SECRET'));

    $response = $api->request('post', '/admin/products.json', [
      'product' => [
        'title' => 'test2'
      ]
    ]);
    $products = $response->body;

In this case I get a different error message:

GuzzleHttp\Exception\ClientException: Client error: `POST https://f155dfa1e833a841e33573e00fe3272d:***@storename.myshopify.com/admin/products.json` resulted in a `401 Unauthorized` response:
{"errors":"[API] Invalid API key or access token (unrecognized login or wrong password)"}

I've double checked the env credential variables and they are accurate.

My guess this is because the proxy routes do not use the auth.shop middleware, so I wonder what could be done to get around this and make this request succeed.

Thanks so much for any help.

Not able to overwrite home url

Hi thanks for awesome package

I want to overwrite the home route of package but not able to do
its always redirect to package page

can you tell me how to do that

Multiple Billing Plans

In the documentation it shows using only one billing plan. How would I handle 2 plans? A free and a paid plan.

AuthShop middleware authenticate installed shop

Thanks for a great package.

If a shop owner has installed the app, do you see any issue with checking the hmac and after confirming the request is from Shopify and that the shop exists in the database, to go ahead and set the shop in the session and continue as an authenticated shop?

Currently, after the shop is installed, it works fine with a current session but after the session expires, within the Shopify admin, the login page is displayed where the user would need to re-enter the shop domain to continue.

I've overwritten the home controller index method with my own and assigned my own web route to the method but it seems to match what ships with this package and includes the auth.shop and billable middleware. I don't think I'm overlooking anything.

Just making sure I'm not creating a security issue or doing something that may conflict later with this package. Thanks again.

*** Update ***
I checked back on my development store a few hours later, clicked the app and, this time, my app home page loaded. I can also see that authentication triggered based on jobs I have running after authentication.

The issue of the login page loading inside of Shopify may be related to something in my code but it's pretty straightforward and I can't see anything in my implementation that would cause it.

Authentice redirect_uri returning http not https

Just testing this and noticed that when you attempt to install the app I receive the following error. (store names and urls redacted to protect the guilty!!)

Oauth error invalid_request: The redirect_uri is not whitelisted

however https://xxx.ngrok.io/authenticate is listed. On digging deep, I see the full Uri returned by this package is

https://xxxx.myshopify.com/admin/oauth/authorize?client_id=4b6b4752c52433568d44fae5b68798d3&scope=read_products,read_orders&redirect_uri=http://xxxx.ngrok.io/authenticate

As you see the redirect_uri is only http.(redirect_uri=http://xxxx.ngrok.io/authenticate) I've poked around the src and also the config and can't see what I've missed (which is highly possible).

Thanks for making this plugin, certainly made the first part easy.

Relations between models and stores

Looking at the documentation on Overriding and Extending I couldn't quite understand that in a situation where we need extra models, how can we have those be in relation with the respective store.

That is, lets say I have a model "Accessories", which can be linked to products from the current store. I'm assuming that we need to have something in that model that for each row in the database we can relate to the relevant store so that we can query all "Accessories" from that store for example.

Thank you!

Getting redirected to login page on session expire

My Shopify app is getting redirected to the login screen if the session is expired. Redirect to login screen is used for websites. But here, it's an app installed in a store. So if the session is getting expired, either it should be auto logged in somehow or should be displayed some message of session expire a redirected to app list. I have tried to override AuthShop middleware. But not getting the idea about what to do in the handle.

Here is the screenshot when the user gets redirected to the login screen.

download

Adding an "after authenticate" job

To mimic shopify_app, I will code in an after authenticate job feature to work similar. It will support dispatching later or immediately.

Needed:

  1. New configuration entry
  2. Modification of authentication process
  3. Updated tests
  4. Documentation

Integration with Socialite

Are there any plans to make the OAuth system in this package also work with the Laravel Socialite? I can give it a try and send a PR if it's wanted

Invalid signature

When trying to install my app to shopify, I am able to authenticate it but then it redirects back to the apps login with the error Invalid signature. It shows it installed in the store but when I try to access the app it just redirects back to the login with the same Invalid signature message.

I checked the Key and secret and I dont see much information about this error.

Unable to install on Laravel 5.6

Readme says the package is compatible with Laravel 5.5-5.6 but I tried installing on 5.6 and it failed. Says it only requires 5.5. Any plan to make it compatible with 5.6?

Disabled eSDK

eSDK still not disabled when setting is SHOPIFY_ESDK_ENABLED=0 in env
any idea?

Non-embedded app issue

Hi there, is it possible to make the app not embedded in the Shopify admin? I tried disabling the Embed in Shopify admin setting but when I load the app the following occurs:

  1. A new window is opened.
  2. The index page loads for less than a second.
  3. Some redirect happens and now the Shopify 404 page is shown.

Below is the URI generated:
https://pasartap-dev.myshopify.com/admin/apps/e1ef58708fea1eee57e4b47ba6635a05/?hmac=b79e691545e56d13d4273f50f4a20cee2bb8ff414314fae465292a95d0058fc1&shop=pasartap-dev.myshopify.com&timestamp=1520584470

Appreciate any help, thanks.

Razaly

Test Against 5.5 LTS

Now that 5.5 is released as a LTS I think its good to move the package to 5.5

I am not sure if any breaking changes will happen, but thats what my tests will tell me. Hopefully, 5.4 and 5.5 can work together.

Free access for partners and Shopify employees

What is the best way to enable free access for partners and Shopify employees?

My first idea:

GET /admin/shop.json

Partners

if ($shop->plan_name === 'affiliate') {
    return $next($request);
}

Shopify employees

// @see https://help.shopify.com/en/api/app-store/being-successful-in-the-app-store/offering-employee-discounts
if ($shop->plan_name === 'staff_business') {
   return $next($request);
}

So i would need a way to skip or extend the billable middleware and call the shop.json endpoint (and store the plan_name in session?) before the billable middleware.

Should i add my own billable middleware to App/Http/Kernel.php?

Any ideas?

Object not found when going to authenticate page

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"
}

Webhook is falling

Can anyone please help me to find a solution for this?
Why this is happening? I am getting a lot of emails like this.

Your webhook for orders/cancelled at //url is failing to return a successful response. This webhook has been attempted 2 times. If your webhook continues to fail, it will be removed and your application will not receive any more notifications. Your webhook for orders/cancelled at //url is failing to return a successful response. This webhook has been attempted 2 times. If your webhook continues to fail, it will be removed and your application will not receive any more notifications.
Your webhook for orders/cancelled at //url cancelled is failing to return a successful response.
This webhook has been attempted 2 times. If your webhook continues to fail, it will be removed and your application will not receive any more notifications.

Webhooks don't work

I have updated the package to 2.2.0 and my webhooks stopped working, my guess is that the domain token has changed.

Am I not able to call the shop domain from my webhook job using $shopDomain and the response from shopify with $data?

419 status

I tried to post form data from shopify to my laravel app using jquery ajax. but it is showing 419 status.

Refused to display in a frame because it set 'X-Frame-Options' to 'deny'.

I have Shopify app developed in my local system (https://myapp.local). Now I want to load it in Shopify (embedded mode). But it is throwing an error 'Refused to display 'https://myapp.local/embedded/forms?hmac=xxxxxxxxxxxxxxxx&locale=en&protocol=https%3A%2F%2F&shop=myshop.myshopify.com&timestamp=1529929088' in a frame because it set 'X-Frame-Options' to 'deny'.' I have set SHOPIFY_ESDK_ENABLED = 1 as well as required settings in partners.shopify also. When I have installed this package 3 months ago, it was getting loaded. But now it's not getting loaded. After debugging, I come to know that $response->headers->remove('X-Frame-Options'); of OhMyBrew\ShopifyApp\Middleware\AuthShop should remove the header while SHOPIFY_ESDK_ENABLED is set to 1. But it's not removing. I don't know either it's a bug or something related to laravel or apache2. So can anyone look into this?

Here is my virtual host file

<IfModule mod_ssl.c>
    <VirtualHost _default_:443>
        ServerAdmin webmaster
        ServerName myapp.local
        ServerAlias www.myapp.local
        DocumentRoot /var/www/myapp/public
        <Directory /var/www/myapp/public>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        SSLEngine on
        SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
        SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
        <FilesMatch "\.(cgi|shtml|phtml|php)$">
            SSLOptions +StdEnvVars
        </FilesMatch>
        <Directory /usr/lib/cgi-bin>
            SSLOptions +StdEnvVars
        </Directory>
    </VirtualHost>
</IfModule>

Migration

I think migration file should be copied into migrations folder when php artisan vendor:publish

Homestead installation

Hey, do you know when you'll have the Homestead installation guide done?

I have everything setup with ngrok but when I go to the app in Shopify the page is blocked with the error:

The webpage at [homestead .test domain] might be temporarily down or it may have moved permanently to a new web address.

Cheers

Problem with webhooks

Hi,

I'm trying to setup webhooks and I'm experiencing problems.
Laravel 5.5
I used your command from the wiki : php artisan shopify-app:make:webhook ProductsUpdateJob products/update and the file ProductsUpdateJob is there in the App/Jobs folder.

Also added the webhook in the shopify-app.php as mentioned.

'webhooks' => [
    [
        'topic' => 'products/update',
        'address' => 'https://xxxxxxx/webhook/products-update'
    ],
],

If I make a get request on /admin/webhooks.json, the webhook is correctly installed.

If I update a product on Shopify, nothing happens. I put a log in my ProductsUpdateJob and it never executes.

I also tried to use Insomnia to make a POST request with shopify header and everything, but I only get an error 419 Unknown status with "The page has expired due to inactivity. Please refresh and try again."

It seems like the route doesn't work because nothing seems to get executed.

I might be doing something wrong. Can you help me debug this please? Can't figure it out.

Thanks

Can't get shop name from session

Hello, I like your package, but I can't get the shop name I read the documentation

and I used facade class

`
use OhMyBrew\ShopifyApp\Facades\ShopifyApp;

return var_dump(ShopifyApp::shop());
`
but shop not exists and if I use it without facades I can't call it statically and I have to pass parameter to constructor

there for I tried to get it from session directly

return var_dump(\Session::get('shopify_domain'));

I get null

so how can I get shop name ???

Also the documentation dose state how can I have more than one charges plan I hope you can improve it

Gracefully handle shop install cancel

Currently, if a user initiates installing the app but on the Shopify app installation screen, chooses Cancel, the user is redirected through the billing process but because their is no token available, the call to api setSession fails.

See attached.

screen shot 2018-05-26 at 8 36 40 am

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.