Giter Site home page Giter Site logo

imx16 / symfony-shopify-bundle Goto Github PK

View Code? Open in Web Editor NEW

This project forked from richtermeister/symfony-shopify-bundle

1.0 0.0 0.0 160 KB

Makes Shopify app development easier, quicker, stronger.

License: MIT License

PHP 99.89% Dockerfile 0.11%

symfony-shopify-bundle's Introduction

Symfony Shopify Bundle

This bundle enables quick and easy integration with Shopify.

Build Status on Travis Scrutinizer Quality Score

Features

  • Shopify OAuth signup flow with a few configuration options.
  • Thin wrapper around Guzzle for easy API interactions. All API endpoints are supported.
  • Symfony firewall to verify incoming API requests are authenticated (to embed app in Shopify Admin)
  • Webhook support to listen for Shopify events.

The Store Model

Stores are represented by instances of ShopifyStoreInterface. It is up to you to provide an implementation of it and handle persistence.

OAUTH Configuration

// app/confiy.yml

code_cloud_shopify:
    store_manager_id: { id of your store manager service }
    oauth:
        api_key: { your app's API Key }
        shared_secret: { your app's shared secret } 
        scope: { the scopes your app requires, i.e.: "read_customers,write_customers" }
        redirect_route: { the route to redirect users to after installing the app, i.e.: "admin_dashboard".. }
    webhooks:
        - orders/create
        - customers/update

API Usage

You can access the API of an authorized store via the `` service:

// in Controller

$api = $this->get('')->getForStore("name-of-store");

$customers = $api->Customer->findAll();
$orders = $api->Order->findAll();

Webhooks

You can register a list of webhooks you are interested in receiving. The bundle will automatically register them with Shopify and dispatch an event every time a webhook is received.

<?php

namespace AppBundle\Event;

use CodeCloud\Bundle\ShopifyBundle\Event\WebhookEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class WebhookListener implements EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        return [
            WebhookEvent::NAME => 'onWebhook',
        ];
    }

    public function onWebhook(WebhookEvent $event)
    {
        switch ($event->getTopic()) {
            case 'orders/create':
                // your custom logic here
                break;
            case 'orders/update':
                // your custom logic here
                break;
        }
    }
}

Security & Authentication

By default, the bundle provides session-based authentication for admin areas embedded within Shopify.

security:
    providers:
        codecloud_shopify:
            id: codecloud_shopify.security.admin_user_provider

    firewalls:
        admin:
            pattern: ^/admin
            provider: codecloud_shopify
            guard:
                authenticators:
                    - codecloud_shopify.security.session_authenticator

Authenticated users will be an instance of CodeCloud\Bundle\ShopifyBundle\Security\ShopifyAdminUser, their username will be the name of the authenticated store (storename.myshopify.com), and their roles will include ROLE_SHOPIFY_ADMIN.

For development purposes, you can impersonate any existing store.

# in config_dev.yml
code_cloud_shopify:
    dev_impersonate_store: "{store-name}.myshopify.com"

Credits

Many thanks to David Smith for originally creating this bundle.

symfony-shopify-bundle's People

Contributors

codecloud avatar richtermeister avatar

Stargazers

 avatar

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.