GithubHelp home page GithubHelp logo

mnwalker / paybox-direct Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nexylan/paybox-direct

0.0 0.0 0.0 119 KB

Paybox Direct and Paybox Direct Plus PHP SDK. Under development.

License: MIT License

PHP 100.00%

paybox-direct's Introduction

PayboxDirect SDK

Paybox Direct and Paybox Direct Plus PHP SDK.

Latest Stable Version Latest Unstable Version License Dependency Status Reference Status

Total Downloads Monthly Downloads Daily Downloads

Build Status Scrutinizer Code Quality Code Climate Coverage Status SensioLabsInsight

Documentation

All the installation and usage instructions are located in this README. Check it for a specific versions:

  • 0.x with support for Symfony ^2.7 || ^3.0

Prerequisites

This version of the project requires:

  • PHP 5.6+
  • Symfony 2.7+ for bundle integration

Installation

First of all, you need to require this library through Composer:

composer require nexylan/paybox-direct

After this, you can use it as is.

If you are using it on a Symfony project, you should read the following instructions for a better integration.

As a Symfony bundle

If your project is not using Symfony Full Stack, you must add the following dependencies:

composer require symfony/dependency-injection symfony/http-kernel

Register the bundle in the kernel of your application:

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Nexy\PayboxDirect\Bridge\Symfony\Bundle\NexyPayboxDirectBundle(),
    );

    // ...

    return $bundles;
}

Some configuration is required. Here is the default one:

nexy_paybox_direct:
    client:               null
    options:
        timeout:              ~
        production:           ~
    paybox:               # Required
        version:              ~ # Required
        site:                 ~ # Required
        rank:                 ~ # Required
        identifier:           ~ # Required
        key:                  ~ # Required
        default_currency:     ~
        default_activity:     ~

Usage

Get the client instance

To communicate with the Paybox Direct (Plus) API, you have to instantiate the Paybox class:

use Nexy\PayboxDirect\Enum\Version;
use Nexy\PayboxDirect\Paybox;

$paybox = new Paybox([
    // Optional parameters:
    'timeout' => 30,        // Change the request timeout.
    'production' => true,   // Set to true to use the production API URL.
    // Required parameters:
    'paybox_version' => Version::DIRECT_PLUS,
    'paybox_site' => '1999888',
    'paybox_rank' => '32',
    'paybox_identifier' => '107904482',
    'paybox_key' => '1999888I',
]);

If you are using the Symfony bundle bridge, all the parameters are already defined on the configuration side.

All you have to do is call the paybox service:

/** @var \Nexy\PayboxDirect\Paybox $paybox */
$paybox = $this->container->get('nexy_paybox_direct.sdk');

Make a request

Here is a commented example of how to make a Paybox Direct request with the SDK:

use Nexy\PayboxDirect\Exception\PayboxException;
use Nexy\PayboxDirect\Request\AuthorizeAndCaptureRequest;

$request = new AuthorizeAndCaptureRequest('CMD-42', 1000, '1111222233334444', '1224');
$request->setCardVerificationValue('123');
try {
    /** @var \Nexy\PayboxDirect\Response\DirectResponse $response */
    $response = $paybox->sendDirectRequest($request);
} catch (PayboxException $e) {
    echo $e->getMessage(); // Prints the Paybox error message.
    /** @var \Nexy\PayboxDirect\Response\DirectResponse $response */
    $response = $e->getResponse(); // Returns the response object if you want to manipulate it.
}
// Do stuff with the response!

If you want to do the same via the Direct Plus protocol with a subscriber reference:

$request = new AuthorizeAndCaptureRequest('CMD-42', 1000, 'subscriberCardRef', '1224', 'subscriberRef');
try {
    /** @var \Nexy\PayboxDirect\Response\DirectPlusResponse $response */
    $response = $paybox->sendDirectPlusRequest($request);
} catch (PayboxException $e) {
    echo $e->getMessage(); // Prints the Paybox error message.
    /** @var \Nexy\PayboxDirect\Response\DirectPlusResponse $response */
    $response = $e->getResponse(); // Returns the response object if you want to manipulate it.
}
// Do stuff with the response!

Note that you have to use Paybox::sendDirectPlusRequest method that returns a DirectPlusResponse object.

Requests reference

Here is a table listing all the available requests:

Request ID RequestInterface Paybox method ResponseInterface
00001 AuthorizeRequest sendDirectRequest DirectResponse
00002 DebitRequest sendDirectRequest DirectResponse
00003 AuthorizeAndCaptureRequest sendDirectRequest DirectResponse
00004 CreditRequest sendDirectRequest DirectResponse
00005 CancelRequest sendDirectRequest DirectResponse
00013 UpdateAmountRequest sendDirectRequest DirectResponse
00014 RefundRequest sendDirectRequest DirectResponse
00017 InquiryRequest sendInquiryRequest InquiryResponse
00051 AuthorizeRequest sendDirectPlusRequest DirectPlusResponse
00052 DebitRequest sendDirectPlusRequest DirectPlusResponse
00053 AuthorizeAndCaptureRequest sendDirectPlusRequest DirectPlusResponse
00054 CreditRequest sendDirectPlusRequest DirectPlusResponse
00055 SubscriberCancelTransactionRequest sendDirectPlusRequest DirectPlusResponse
00056 SubscriberRegisterRequest sendDirectPlusRequest DirectPlusResponse
00057 SubscriberUpdateRequest sendDirectPlusRequest DirectPlusResponse
00058 SubscriberDeleteRequest sendDirectPlusRequest DirectPlusResponse

paybox-direct's People

Contributors

byidi avatar greg0ire avatar mnwalker avatar soullivaneuh 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.