PHPackages                             codeswholesale/sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. codeswholesale/sdk

ActiveLibrary[API Development](/categories/api)

codeswholesale/sdk
==================

A PHP wrapper for CodesWholesale's API

2.2.6(5y ago)3550.3k↓100%21[7 issues](https://github.com/codeswholesale/codeswholesale-sdk-php/issues)[2 PRs](https://github.com/codeswholesale/codeswholesale-sdk-php/pulls)GPL-3.0-onlyPHPPHP &gt;=7.0.0

Since Apr 29Pushed 5mo ago14 watchersCompare

[ Source](https://github.com/codeswholesale/codeswholesale-sdk-php)[ Packagist](https://packagist.org/packages/codeswholesale/sdk)[ Docs](https://github.com/codeswholesale/codeswholesale-sdk-php)[ RSS](/packages/codeswholesale-sdk/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (2)Versions (38)Used By (0)

CodesWholesale PHP SDK
======================

[](#codeswholesale-php-sdk)

CodesWholesale.com is an API-driven wholesale platform for digital game distribution. This is the CodesWholesale SDK for PHP that will enable developers to easily integrate API with any PHP-based application.

Installation
------------

[](#installation)

You can install **codeswholesale-sdk-php** via Composer or by downloading the source.

### Via Composer:

[](#via-composer)

**codeswholesale-sdk-php** is available on Packagist as the [codeswholesale/sdk](https://packagist.org/packages/codeswholesale/sdk) package.

Install Composer on your project root

```
curl -sS https://getcomposer.org/installer | php

```

Or download it from official page:

Configure the **codeswholesale/sdk** dependency in your 'composer.json' file:

```
"require": {
    "codeswholesale/sdk": "2.1"
}

```

Install the latest SDK with its dependencies on your project root

```
php composer.phar install

```

Create your CodesWholesale account
----------------------------------

[](#create-your-codeswholesale-account)

If you don’t have an account yet, sign up at [CodesWholesale](https://app.codeswholesale.com) and set up your API credentials:

1. Create a [CodesWholesale](https://app.codeswholesale.com) account and create your API keys in WEB API tab, under your profile name link. Save your keys in safe place. Your API password is visible only once.

### Getting Started

[](#getting-started)

1. **Require the CodesWholesale PHP SDK** via the composer auto loader

    ```
    require 'vendor/autoload.php';
    ```
2. **Configure the client** using the API keys

    ```
    $params = [
       /**
        * API Keys
        * These are test api keys that can be used for testing your integration:
        */
        'cw.client_id' => 'ff72ce315d1259e822f47d87d02d261e',
        'cw.client_secret' => '$2a$10$E2jVWDADFA5gh6zlRVcrlOOX01Q/HJoT6hXuDMJxek.YEo.lkO2T6',
        /**
         * CodesWholesale ENDPOINT
         */
        'cw.endpoint_uri' => \CodesWholesale\CodesWholesale::SANDBOX_ENDPOINT,
        /**
         * Due to security reasons, you should use SessionStorage only while testing.
         * In order to go live, you should change it to database storage.
        */
        'cw.token_storage' => new \CodesWholesale\Storage\TokenSessionStorage()
    ];

    $clientBuilder = new \CodesWholesale\ClientBuilder($params);
    $client = $clientBuilder->build();
    ```

For production release, please remember to switch from SANDBOX endpoint to LIVE endpoint.

3. **List all available platforms, regions, languages on the CodesWholesale platform**

    ```
    $platforms = $client->getPlatforms()
    $regions   = $client->getRegions();
    $languages = $client->getLanguages();
    ```
4. **List all products from the price list**

    ```
    $products = $client->getProducts();
    foreach($products as $product) {
        $product->getName(); // the name of product
        $product->getStockQuantity(); // current stock quantity
        $product->getImageUrl(ImageType::SMALL) // product image url
    }
    ```
5. **List all products from price list by language/platform/region**

    ```
     $products = $client->getProducts([
           "language" => [
               "Multilanguage",
               "fr"
            ],
            "platform" => [
                "Steam"
            ],
            "region" => [
                "WORLDWIDE"
            ]
        ]);

    foreach($products as $product) {
        $product->getName(); // the name of product
        $product->getStockQuantity(); // current stock quantity
        $product->getImageUrl(ImageType::SMALL) // product image url
    }
    ```
6. **List all products from price list from the last 60 days**

    ```
    $products = $client->getProducts([
        "inStockDaysAgo" => 60
    ]);

    foreach($products as $product) {
        $product->getName(); // the name of product
        $product->getStockQuantity(); // current stock quantity
        $product->getImageUrl(ImageType::SMALL) // product image url
    }
    ```
7. **Fetch invoice for your order**

    ```
    $orderInvoice = Invoice::get($createdOrder->getOrderId());
    $invoicePath = Base64Writer::writeInvoice($orderInvoice, "./invoices");
    ```
8. **Screen your customer before completing order**

    ```
    $securityInformation = Security::check(
        "devteam@codeswholesale.com",
        "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/600.7.12 (KHTML, like Gecko) Version/8.0.7 Safari/600.7.12",
        "devteam-payment@codeswholesale.com",
        "81.90.190.200"
    );

    $ipBlacklisted = $security->isIpBlacklisted();
    $torIp = $security->isTorIp();
    $domainBlackListed = $security->isDomainBlacklisted();
    $subdomain = $security->isSubDomain();
    ```
9. **Check your order history**

    ```
    $orders = Order::getHistory("2017-12-11", "2017-12-12");

    foreach ($orderList as $order) {
        $order->getOrderId();
        $order->getClientOrderId();
        $order->getTotalPrice() ;
        $order->getStatus();
        $order->getCreatedOn();
    }
    ```
10. **Single product details**

```
```php
$product = \CodesWholesale\Resource\Product::get($productHref);
```

```

11. **Retrieve product description**

```
```php
$productDescription = \CodesWholesale\Resource\ProductDescription::get($product->getDescriptionHref());

$productDescription->getLocalizedTitles(); // localized titles
$productDescription->getPegiRating(); // pegi rating
$productDescription->getPlatform(); // platform such as PC/Mac
$productDescription->getFactSheets(); // description in different langauges
$productDescription->getReleases(); // release dates
$productDescription->getEditions(); // editions
$productDescription->getDeveloperHomepage(); // game developer homepage
$productDescription->getKeywords(); // keywords
$productDescription->getGameLanguages(); // languages
$productDescription->getOfficialTitle(); // official title
$productDescription->getDeveloperName(); // game developer name
$productDescription->getEanCodes(); // EAN codes
$productDescription->getLastUpdate(); // last game update
$productDescription->getCategory(); // category of game
$productDescription->getPhotos(); // urls photo
$productDescription->getExtensionPacks(); // extension packs
$productDescription->getVideos(); // urls video
$productDescription->getProductId(); // product id
```

```

12. **Retrieve account details, balance value and available credit**

```
```php
$account = $client->getAccount();
$account->getFullName(); // name of account
$account->getEmail(); // email
$account->getTotalToUse(); // total money to use, balance + credit
$account->getCurrentBalance(); // current balance value
$account->getCurrentCredit(); // current credit value
```

```

13. **Create order**

```
```php
$createdOrder = Order::createOrder(
        [
            [
                "productId" => "6313677f-5219-47e4-a067-7401f55c5a3a",
                "quantity" => "2",
            ],
        ], null);

foreach ($createdOrder->getProducts() as $product) {

     $product->getProductId();
     $product->getUnitPrice();

     foreach ($product->getCodes() as $code) {
          $code->getCodeId();

          if ($code->isPreOrder()) {
              echo "Code has been pre-ordered!" . " ";
          }

          if ($code->isText()) {
              echo "Text code to use: " . $code->getCode() . "";
          }

          if ($code->isImage()) {
              $fullPath = \CodesWholesale\Util\Base64Writer::writeImageCode($code, "./my-codes");
              echo "Product has been saved in " . $fullPath . "";
          }
     }
}
```

```

14. **Receive notifications about product changes via Codeswholesale postback request**

    To receive notifications from CodesWholesale, first you have to configure your postback URL that will be responsible for handling CodesWholesale requests. In order to do that, follow these steps:

```
- Sign in to [CodesWholesale](https://app.codeswholesale.com/)
- Go to API tab
- Configure and test your post back url

If the URL has been successfully configured, you should be able to handle CodesWholesale requests as follow

```php
$client->registerStockAndPriceChangeHandler(function (array $stockAndPriceChanges) {
    foreach ($stockAndPriceChanges as $stockAndPriceChange) {
        /**
         * Here you can save changes to your database
         *
         * @var StockAndPriceChange $stockAndPriceChange
         */
        echo $stockAndPriceChange->getProductId();
        echo $stockAndPriceChange->getQuantity();

        $prices = $stockAndPriceChange->getPrices();

        foreach ($prices as $price) {
            /**
             * @var Price $price
             */
            echo $price->getRange();
            echo $price->getValue();
        }

        echo "";
    }
});

$client->registerHidingProductHandler(function (Notification $notification) {
    /**
     * Here you can request for product which was hidden or just hide it
     * using provided productId
     */
    echo $notification->getProductId();
});

$client->registerPreOrderAssignedHandler(function (AssignedPreOrder $notification) {
    /**
     * Here you can request for ordered product using productId
     */
    echo $notification->getOrderId();
});

$client->registerUpdateProductHandler(function (Notification $notification) {
    /**
     * Here you can request product which was updated.
     * It can be image, name or other product parameter.
     */
    echo $notification->getProductId();
});

$client->registerNewProductHandler(function(Notification $notification) {
    /**
     * Here you can request product which was updated.
     * It can be image, name or other product parameter.
     */
    echo $notification->getProductId();
});

$client->handle(SIGNATURE);
```

```

If you send test request from the API tab and your script is configured to work with sandbox environment, it will download ten fake images.

You can check "examples" directory for more samples and details.

Copyright &amp; Licensing
-------------------------

[](#copyright--licensing)

Copyright © 2014 Codeswholesale

This project is licensed under the [Apache 2.0 Open Source License](http://www.apache.org/licenses/LICENSE-2.0).

For additional information, please see:

1. fkooman OAuth2 client:

###  Health Score

46

↑

FairBetter than 93% of packages

Maintenance43

Moderate activity, may be stable

Popularity37

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~72 days

Recently: every ~111 days

Total

34

Last Release

1969d ago

Major Versions

1.0.2 → 2.02018-01-24

PHP version history (3 changes)1.0.1.betaPHP &gt;=5.3.0

1.0PHP &gt;=5.6.0

2.0PHP &gt;=7.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1a6cd3716952fa5a7e9908bc1fbc4f4bc010105bdc9cfe0f510cdfed823f200d?d=identicon)[codeswholesale](/maintainers/codeswholesale)

---

Top Contributors

[![KodillaUser](https://avatars.githubusercontent.com/u/29016450?v=4)](https://github.com/KodillaUser "KodillaUser (61 commits)")[![codeswholesale](https://avatars.githubusercontent.com/u/7384842?v=4)](https://github.com/codeswholesale "codeswholesale (54 commits)")[![myperit](https://avatars.githubusercontent.com/u/123190635?v=4)](https://github.com/myperit "myperit (6 commits)")[![maciejklowan](https://avatars.githubusercontent.com/u/10298775?v=4)](https://github.com/maciejklowan "maciejklowan (4 commits)")[![rchoffardet](https://avatars.githubusercontent.com/u/5098668?v=4)](https://github.com/rchoffardet "rchoffardet (3 commits)")[![ahfeel](https://avatars.githubusercontent.com/u/43286?v=4)](https://github.com/ahfeel "ahfeel (1 commits)")

---

Tags

apicloudsecuritycodeswholesalegamescd-keys

### Embed Badge

![Health badge](/badges/codeswholesale-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/codeswholesale-sdk/health.svg)](https://phpackages.com/packages/codeswholesale-sdk)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
