2017 © Pedro Peláez
 

library integration-api-client

G2A Integration API client

image

g2a/integration-api-client

G2A Integration API client

  • Thursday, July 26, 2018
  • by g2a-github
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

PHP client for Integration API of G2A.COM

Client library allows to integrate with G2A.COM Integration API
Web site: https://www.g2a.com/integration-api/, (*1)

Documentation

Go to https://www.g2a.com/integration-api/documentation/, (*2)

Requirements

Installation

Package is published on Packagist, (*3)

Add project dependency:, (*4)

composer require g2a/integration-api-client

Usage

Creating API client

<?php

require __DIR__ . '/../vendor/autoload.php';

$config = new \G2A\IntegrationApi\Model\Config(
    'sandboxapitest@g2a.com',
    'sandboxapi.g2a.com',
    'qdaiciDiyMaTjxMt',
    'b0d293f6-e1d2-4629-8264-fd63b5af3207b0d293f6-e1d2-4629-8264-fd63b5af3207'
);

$g2aApiClient = new \G2A\IntegrationApi\Client($config);

`, (*5)

Basic Example

<?php

require __DIR__ . '/../vendor/autoload.php';

$config = new \G2A\IntegrationApi\Model\Config(
    'sandboxapitest@g2a.com',
    'sandboxapi.g2a.com',
    'qdaiciDiyMaTjxMt',
    'b0d293f6-e1d2-4629-8264-fd63b5af3207b0d293f6-e1d2-4629-8264-fd63b5af3207'
);

$g2aApiClient = new \G2A\IntegrationApi\Client($config);

// add an order
$request = new G2A\IntegrationApi\Request\OrderAddRequest($g2aApiClient);
$request
    ->setProductId('10000037846002')
    ->setCurrency('USD')
    ->setMaxPrice(45.12)
    ->call();

$response = $request->getResponse();

echo 'Order ID: ' . $response->getOrderId() . PHP_EOL;
````

See `examples` directory for more use cases

### Get products

```php
<?php
// …
$request = new \G2A\IntegrationApi\Request\ProductsListRequest($g2aApiClient);
$request
    ->setPage(1)
    ->setMinQty(5)
    ->call();

$response = $request->getResponse();

foreach ($response->getProducts() as $product) {
    echo $product->getId() . ' ' . $product->getName() . PHP_EOL;
}

Add an order

<?php
// …
$request = new G2A\IntegrationApi\Request\OrderAddRequest($g2aApiClient);
$request
    ->setProductId('10000037846002')
    ->setCurrency('USD')
    ->setMaxPrice(45.12)
    ->call();

$response = $request->getResponse();

echo 'Order ID: ' . $response->getOrderId() . PHP_EOL;

Pay for rder

<?php
// …
$request = new G2A\IntegrationApi\Request\OrderPaymentRequest($g2aApiClient);
$request
    ->setOrderId(1532096834)
    ->call();

$response = $request->getResponse();

echo 'Payment transaction ID: ' . $response->getTransactionId() . PHP_EOL;
echo 'Payment status: ' . $response->getStatus() . PHP_EOL;

Get order details

<?php
// …
$request = new \G2A\IntegrationApi\Request\OrderDetailsRequest($g2aApiClient);
$request
    ->setOrderId(1532096834)
    ->call();

$response = $request->getResponse();

echo 'Order status: ' . $response->getStatus() . PHP_EOL;
echo 'Price: ' . $response->getPrice() . PHP_EOL;
echo 'Currency: ' . $response->getCurrency() . PHP_EOL;

Get order key

<?php
// …
$request = new \G2A\IntegrationApi\Request\OrderKeyRequest($g2aApiClient);
$request
    ->setOrderId(1532096834)
    ->call();

$response = $request->getResponse();

echo 'Order key: ' . $response->getKey() . PHP_EOL;

Sandbox credentials

API Hash: qdaiciDiyMaTjxMt
API Key: 74026b3dc2c6db6a30a73e71cdb138b1e1b5eb7a97ced46689e2d28db1050875, (*6)

Commands

Code quality

Execute PHPUnit tests, (*7)

make test

Code style

Requires PHP for CLI installed. Execute in root directory, (*8)

make csfixer

Run examples

The following command will send example requests to sandbox environment, (*9)

make run-examples

License

PHP client for Integration API of G2A.COM is released under the MIT license, (*10)

Support

Contact us on G2A Support Hub, (*11)

The Versions

26/07 2018

dev-master

9999999-dev https://www.g2a.com/integration-api

G2A Integration API client

  Sources   Download

proprietary

The Requires

 

The Development Requires

26/07 2018

1.0.0

1.0.0.0 https://www.g2a.com/integration-api

G2A Integration API client

  Sources   Download

proprietary

The Requires

 

The Development Requires