PHPackages                             grandmasterx/safecharge - 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. [Payment Processing](/categories/payments)
4. /
5. grandmasterx/safecharge

ActiveYii2-extension[Payment Processing](/categories/payments)

grandmasterx/safecharge
=======================

Extension for integration SafeCharge in yii2 project

v1.0.1(8y ago)02.3kBSD-3-ClausePHPPHP &gt;=5.6

Since Nov 23Pushed 8y ago1 watchersCompare

[ Source](https://github.com/GrandMasterX/safecharge)[ Packagist](https://packagist.org/packages/grandmasterx/safecharge)[ RSS](/packages/grandmasterx-safecharge/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

SafeCharge REST API SDK for PHP.
================================

[](#safecharge-rest-api-sdk-for-php)

SafeCharge’s REST API SDK for PHP provides developer tools for accessing Safecharge's REST API. SafeCharge’s REST API is a simple, easy to use, secure and stateless API, which enables online merchants and service providers to process consumer payments through SafeCharge’s payment gateway. The API supports merchants of all levels of PCI certification, from their online and mobile merchant applications, and is compatible with a large variety of payment options, i.e. payment cards, alternative payment methods, etc. For SafeCharge REST API documentation, please see:

Requirements
------------

[](#requirements)

PHP 5.4 or later.

Installation
============

[](#installation)

### Installation via Composer

[](#installation-via-composer)

```
composer require grandmasterx/safecharge
```

### Manual

[](#manual)

If you do not wish to use Composer, you can download the [latest release](https://github.com/SafeChargeInternational/safecharge-php/releases). Then include the `init.php` file.

```
require_once('/path/to/safecharge-sdk/init.php');
```

Dependencies
------------

[](#dependencies)

The PHP SDK require the following extension in order to work properly:

- [`curl`](https://secure.php.net/manual/en/book.curl.php)
- [`json`](https://secure.php.net/manual/en/book.json.php)

Configuration
-------------

[](#configuration)

### Client

[](#client)

```
$client = new \grandmasterx\safecharge\api\RestClient([
    'environment'       => \grandmasterx\safecharge\api\Environment::TEST,
    'merchantId'        => '',
    'merchantSiteId'    => '',
    'merchantSecretKey' => '',
]);
```

Or

```
$client = new \grandmasterx\safecharge\api\RestClient();
$config = $client->getConfig();
$config->setEnvironment(\grandmasterx\safecharge\api\Environment::TEST);
$config->setMerchantId('');
$config->setMerchantSiteId('');
$config->setMerchantSecretKey('');
```

### Logger

[](#logger)

Logger can be configured with a [PSR-3 compatible logger](http://www.php-fig.org/psr/psr-3/) .

#### Example with Monolog

[](#example-with-monolog)

```
$logger = new Monolog\Logger('safecharge-php-sdk');
$logger->pushHandler(new Monolog\Handler\StreamHandler('path/to/log', Monolog\Logger::DEBUG));
$client->setLogger($logger);
```

Example
-------

[](#example)

Safecharge's PHP SDK appends merchantId, merchantSiteId, timestamp and checksum in the request.

```
