2017 © Pedro Peláez
 

library atos-sips

image

deruwe/atos-sips

  • Thursday, March 3, 2016
  • by aderuwe
  • Repository
  • 1 Watchers
  • 1 Stars
  • 6,339 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 13 Forks
  • 0 Open issues
  • 5 Versions
  • 4 % Grown

The README.md

Sips PHP library

This library allows you to easily implement a [Sips] integration into your project. It provides the necessary components to complete a correct payment flow with the [Sips] platform., (*1)

Requirements:, (*2)

  • PHP 5.3
  • network connection between your webserver and the Sips platform

The SIPS platform can be reached through the following URL's:, (*3)

  • SIMU: https://payment-webinit.simu.sips-atos.com/paymentInit
  • TEST: https://payment-webinit.test.sips-atos.com/paymentInit
  • PRODUCTION: https://payment-webinit.sips-atos.com/paymentInit

Overview

The library complies to the PSR-0 standard, so it can be autoloaded using PSR-0 classloaders like the one in Symfony2. See autoload.php for an example., (*4)

The library supports the use of Composer., (*5)

  • Create a PaymentRequest, containing all the info needed by Sips.
  • Submit it to Sips (client side)
  • Receive a PaymentResponse back from Sips (as a HTTP Request)

Both PaymentRequest and PaymentResponse are authenticated by comparing the SHA sign, which is a hash of the parameters and a secret passphrase. You can create the hash using a ShaComposer., (*6)

SHA Composer

Sips method to generate a SHA sign:, (*7)

  • "Each parameter followed by the passphrase" This method requires you to use the following encryption method: SHA-256., (*8)

    Implementation using this library is trivial:, (*9)

  <?php
    use Sips\ShaComposer\AllParametersShaComposer;
    $shaComposer = new AllParametersShaComposer($passphrase);

PaymentRequest

    <?php

    use Sips\Passphrase;
    use Sips\PaymentRequest;

    $passphrase = new Passphrase('passphrase-defined-in-sips-interface');
    $shaComposer = new AllParametersShaComposer($passphrase);

    $paymentRequest = new PaymentRequest($shaComposer);

    // Optionally set Sips uri, defaults to TEST account
    //$paymentRequest->setSipsUri(PaymentRequest::PRODUCTION);

    // Set various params:
    $paymentRequest->setMerchantId('123456');
    $paymentRequest->setKeyVersion('1');
    $paymentRequest->setTransactionReference($sipsTransactionReference);
    $paymentRequest->setAmount(1000);
    $paymentRequest->setCurrency('EUR');
    $paymentRequest->setLanguage('nl');
    $paymentRequest->setPaymentBrand('VISA');
    // ...

    $paymentRequest->validate();

    // Create Http client to send the paymentRequest
    // We use Zend_Http_Client here, feel free to use your favourite HTTP client library
    $client = new Zend_Http_Client($paymentRequest->getSipsUri());
    $client->setParameterPost('Data', $paymentRequest->toParameterString());
    $client->setParameterPost('InterfaceVersion', '<Sips interfaceVersion>');
    $client->setParameterPost('Seal', $paymentRequest->getShaSign());

    $response = $client->request(Zend_Http_Client::POST);
    echo $response->getRawBody();
    exit();

PaymentResponse

The PaymentResponse is typically used in a separate endpoint that is available to SIPS. This URL will be used by the SIPS platform to inform the Merchant whether the payment was successful., (*10)

Checking whether the payment is successful relies on checking if the RESPONSECODE parameter is 00 or 60., (*11)

    <?php
    use Sips\PaymentResponse;
    use Sips\ShaComposer\AllParametersShaComposer;

    // ...

    $paymentResponse = new PaymentResponse($_REQUEST);

    $passphrase = new Passphrase('passphrase-defined-in-sips-interface');
    $shaComposer = new AllParametersShaComposer($passphrase);

    if($paymentResponse->isValid($shaComposer) && $paymentResponse->isSuccessful()) {
        // handle payment confirmation
    }
    else {
        // perform logic when the validation fails
    }

Running the tests

The test suite requires PHPUnit to run. Simply run phpunit from the root of the project., (*12)

```sh phpunit, (*13)

The Versions

03/03 2016

dev-master

9999999-dev

  Sources   Download

06/12 2013

1.0.3

1.0.3.0

  Sources   Download

06/12 2013

1.0.2

1.0.2.0

  Sources   Download

03/12 2013

1.0.1

1.0.1.0

  Sources   Download

18/11 2013

1.0.0

1.0.0.0

  Sources   Download