Code Monkey home page Code Monkey logo

php-keyclient's Introduction

PHP KEYCLIENT LIBRARY

Build Status Scrutinizer Code Quality Code Coverage Total Downloads Latest Stable Version

KeyClient library for PHP 5.3+

Installing

Using Composer

To add PHP-KeyClient as a local, per-project dependency to your project, simply add a dependency on eo/keyclient to your project's composer.json file. Here is a minimal example of a composer.json file that just defines a development-time dependency on the latest version of the library:

{
    "require": {
        "eo/keyclient": "dev-master"
    }
}

Usage Example

Workflow

                                                    --> canceled
                                                    |
Create payment url โ€“> Redirect user to payment url -|
                                                    |
                                                    --> confirmed -> Handle return response

Creating payment url

<?php

use Eo\KeyClient\Client;
use Eo\KeyClient\Payment\PaymentRequest;

$client  = new Client('YOUR-ALIAS', 'YOUR-SECRET');
$payment = new PaymentRequest(5000, 'EUR', 'UNIQUE-ID', 'http://example.com/completed', 'http://example.com/canceled');

$url = $client->createPaymentUrl($payment);

// Redirect to payment url
header( "Location: $url" );

Handling return response

<?php

use Eo\KeyClient\Client;

$client   = new Client('YOUR-ALIAS', 'YOUR-SECRET');
$response = $client->parsePaymentResponse();

// $response is an instance of Eo\KeyClient\Payment\PaymentResponse
switch ($response->get('esito')) {
    case 'OK':
        # Payment success...
        break;
    case 'KO':
        # Payment error...
        break;
}

Requirements

  • PHP 5.3+

Breaking Changes

Version 0.2.0

Running Tests

Before submitting a patch for inclusion, you need to run the test suite to check that you have not broken anything.

To run the test suite, install PHPUnit 3.7 (or later) first.

Dependencies

To run the entire test suite, including tests that depend on external dependencies, php-keyclient needs to be able to autoload them. By default, they are autoloaded from vendor/ under the main root directory (see vendor/autoload.php).

To install them all, use Composer:

Step 1: Get Composer

curl -s http://getcomposer.org/installer | php

Make sure you download composer.phar in the same folder where the composer.json file is located.

Step 2: Install vendors

php composer.phar --dev install

Note that the script takes some time to finish.

Running

First, install the vendors (see above).

Then, run the test suite from the package root directory with the following command:

phpunit

The output should display OK. If not, you need to figure out what's going on and if the tests are broken because of your modifications.

Reporting an issue or a feature request

Issues and feature requests related to this library are tracked in the Github issue tracker: https://github.com/eymengunay/php-keyclient/issues

php-keyclient's People

Contributors

eymengunay avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.