Skip to main content

Create an app in BigCommerce using Laravel

By |March 28, 2019 February 10th, 2022No Comments

BigCommerce is one of the most popular e-commerce platforms. It is an excellent and cost-efficient way to implement everything you need in a single platform. BigCommerce is the most sought-after e-commerce platform for businesses that wish to quickly set up their online store with endless and extensible integration possibilities.

Here, we are going to be creating a custom application to customize the existing features and add new features to the store. First, you must download the stable Laravel package to start with the BigCommerce app development. You will need to add the package for integrating with BigCommerce. This package will support version 2 and 3 of the BigCommerce API.

Follow these steps for installation

Step 1:

Add the package to composer.json:

composer require oseintow/laravel-bigcommerce

Step 2:

Add the service provider to config/app.php in the provider’s array.

'providers' => [

Set-up alias for the Facade.

'aliases' => [
  'Bigcommerce' => OseintowBigcommerceFacadesBigcommerce::class,

Step 3:

Create an app in BigCommerce by following these steps:

Go to

Click on Create an app button and choose your app name.

Fill out the App summary and Details tab by referring to can also skip some details for the initial set-up.  

In the Technical tab, choose the app features based on your needs.

Callback URLs and OAuth Scopes:

Callback URLs are more important for app installation and processing. Auth Callback URL gets called when you click on the install button in the BigCommerce app. Load Callback URL gets called whenever you open the app after installation. Uninstall Callback URL is not mandatory, Bigcommerce automatically uninstalls the app when you click on the uninstall button. If you want some functions to get done while uninstalling the app, you can give that function route in this URL.

Most importantly, communication with these endpoints must get done over HTTPS.

Provide your Callback URLs as below:

Create an app in BigCommerce using LaravelOAuth Scopes specify which API resources does your app require access to, so choose the scopes according to your app’s needs.

Click on the update and close button, so that the app will get created successfully.

Step 4:

Create a Laravel App Controller:
bigcommerce = $bigcommerce;
      $this->client_id = "Your App Client ID here";
      $this->client_secret = "Your App Client Secret here";
      $this->redirect_uri = "";

The function given below is the Load Callback; it gets called every time you open the app.

public function loadApp(Request $request)
      $data = $this->verifySignedRequest($request->get('signed_payload'));
      if (empty($data)) {
          return 'Invalid signed_payload.';
          session(['store_hash' => $data['store_hash']]);
      return view('dashboard');

The function below is the Auth Callback; it gets called when you install the app. We have shown it here to save the access token with the storehash in the database, which can be used for future purposes.

public function callBack(Request $request)
      $payload = array(
          'client_id' => $this->client_id,
          'client_secret' => $this->client_secret,
          'redirect_uri' => $this->redirect_uri,
          'grant_type' => 'authorization_code',
          'code' => $request->get('code'),
          'scope' => $request->get('scope'),
          'context' => $request->get('context'),
      $client = new Client("");
      $req = $client->post('/oauth2/token', array(), $payload, array(
          'exceptions' => false,
      $resp = $req->send();
      if ($resp->getStatusCode() == 200) {
          $data = $resp->json();
          list($context, $storehash) = explode('/', $data['context'], 2);
          $key = $this->getUserKey($storehash, $data['user']['email']);
          $access_token = $data['access_token'];
          $storeHash = $data['context'];
          $array = explode('/',$storeHash);
          $storehash = $array[1];
          $email = $data['user']['email'];
          $configValue = Config::select('*')->where('storehash',$storehash)->get()->toArray();
          if(count($configValue) != 0){
              $id = $configValue[0]['id'];
              $configObj = Config::find($id);
              $configObj->access_token = $access_token;
              $configObj = new Config;
              $configObj->email = $email;
              $configObj->storehash = $storehash;
              $configObj->access_token = $access_token;
      if ($access_token != '') {
          return 'App Installed Successfully, Reload the page. ';
      else {
          return 'Something went wrong... [' . $resp->getStatusCode() . '] ' . $resp->getBody();
  public function verifySignedRequest($signedRequest)
      list($encodedData, $encodedSignature) = explode('.', $signedRequest, 2);
      $client_secret = $this->client_secret;
      // decode the data
      $signature = base64_decode($encodedSignature);
      $jsonStr = base64_decode($encodedData);
      $data = json_decode($jsonStr, true);
      // confirm the signature
      $expectedSignature = hash_hmac('sha256', $jsonStr, $client_secret, $raw = false);
      if (!hash_equals($expectedSignature, $signature)) {
          error_log('Bad signed request from BigCommerce!');
          return null;
      return $data;

Step 5:

Now open your BigCommerce store and view the created app in your “My Draft Apps” under My Apps tab.Create an app in BigCommerce using LaravelYour app installation will be shown as above, and then click on the install button. Create an app in BigCommerce using LaravelBigCommerce is a very user-friendly platform for customers, but for developers, not all customizations can get done in the store admin. At this stage, the BigCommerce app will be useful to achieve all the customization needs. In our conclusion, we find Laravel to be very flexible for creating an app in BigCommerce.

Manoj K

Author Manoj K

Manoj is a software developer with around three years of experience in Web Application Development. Apart from being versatile and learning about new technology, he loves spending his time with family and friends. He also enjoys exploring new places and believes that "Traveling gives a more valuable learning experience than years of schooling."

More posts by Manoj K

Discover What You’re Missing

Get the weekly email full of actionable ideas and insights you can use at work and home.