2017 © Pedro PelĆ”ez
 

yii2-extension safecharge

Extension for integration SafeCharge in yii2 project

image

grandmasterx/safecharge

Extension for integration SafeCharge in yii2 project

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 204 % Grown

The README.md

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: https://www.safecharge.com/docs/api/, (*1)

Requirements

PHP 5.4 or later., (*2)

Installation

Installation via Composer

composer require grandmasterx/safecharge

Manual

If you do not wish to use Composer, you can download the latest release. Then include the init.php file., (*3)

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

Dependencies

The PHP SDK require the following extension in order to work properly:, (*4)

Configuration

Client

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

Or, (*5)

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

Logger

Logger can be configured with a PSR-3 compatible logger ., (*6)

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

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

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

$authenticationService = new \grandmasterx\safecharge\api\services\AuthenticationManagement($client);

$authenticationResponse = $authenticationService->getSessionToken([
    'clientRequestId' => '1'
]);

$openOrderParams = [
    'sessionToken'      => $authenticationResponse['sessionToken'],
    'currency'          => 'USD',
    'amount'            => "10",
    'amountDetails'     => [
        "totalShipping" => "0",
        "totalHandling" => "0",
        "totalDiscount" => "0",
        "totalTax"      => "0"
    ],
    'items'             => [
        [
            "id"       => "1",
            "name"     => "name",
            "price"    => "10",
            "quantity" => "1"
        ]
    ],
];

$orderService = new \grandmasterx\safecharge\api\services\OrdersManagement($client);

$openOrderResponse = $orderService->openOrder($openOrderParams);

The Versions

23/11 2017

dev-master

9999999-dev

Extension for integration SafeCharge in yii2 project

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

extension yii2 safecharge

23/11 2017

v1.0.1

1.0.1.0

Extension for integration SafeCharge in yii2 project

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

extension yii2 safecharge