Quickstart

To connect your shop with us all you need to do is implementing our unified Plugin API actions that are called from Shopgate. There are just 4 simple steps needed.

Step 1 - Shopgate Cart Integration SDK

Create an empty software project, download and extract our latest Cart Integration SDK on GitHub

Step 2 - Include and extend the Cart Integration SDK

You need to create a plugin.php that includes the Cart Integration SDK and extends the Plugin API class ShopgatePlugin. This will force you to implement predefined abstract methods, that are called automatically from Shopgate on certain actions.

ShopgatePlugin class
<?php
require_once(dirname(__FILE__).'/shopgate-cart-integration-sdk/shopgate.php');

class ShopgatePluginMyShoppingSystem extends ShopgatePlugin {
  public function startup() {
		$configuration = new ShopgateConfig();
		$configuration->setShopNumber(12345);
		$configuration->setCustomerNumber(54321);
		$configuration->setApikey('56b1dbae2696a');
		$this->config = $configuration;
	}
	...
}
Plugin Authentication

To authenticate the request you need to set your shop number, customer number and api key provided by Shopgate. This needs to be done in method startup while creating the instance of the object ShopgateConfig as shown above.

Implement abstract methods

If you are using an IDE like PHPStorm those method stubs will be generated automatically when you extend the existing class ShopgatePlugin.

Step 3 - Create an API endpoint

Create a PHP file in the your web root to define the API endpoint, that need to be callable from Shopgate. Include and invoke the class created in previous step and pass the $REQUEST superglobal to the method handleRequest. The Cart Integration SDK will take care handling the request from Shopgate, doing the authentication, routing the actions, creating the data objects and passing them to the method skeletons created one step above.*

handleRequest
<?php
require_once(dirname(__FILE__).'/plugin.php');

define('SHOPGATE_DEBUG', 1); // important for development, please remove when used live

$plugin = new ShopgatePluginMyShoppingSystem();
$plugin->handleRequest($_REQUEST);
SHOPGATE_DEBUG

In an live environment Shopgate is generating an authorization token to send with each request. The validity of the token is verified inside of the SDK based on shop number, customer number and API key set in configuration one step above. It’s valid for 60 minutes only, so for development it should be skipped, defining the constant as shown in the example above.

Step 4 - Test your interface

You can use any post client like Postman to test your interface.

For a simple ping request to test your interface you just need to send 4 parameters to your api endpoint. e.g. http://myshoppingsystem.localhost.com/api.php

  • action: ping
  • shop_number: 12345
  • customer_nuber: 54321
  • apikey: 56b1dbae2696a