Skip to content

Commit

Permalink
Merge pull request #1 from realexpayments-developers/master
Browse files Browse the repository at this point in the history
RXP HPP PHP
  • Loading branch information
RealexITSO committed Sep 15, 2015
2 parents af06db9 + 8655d55 commit 0ad95e1
Show file tree
Hide file tree
Showing 45 changed files with 6,955 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Pay and Shop Ltd ta Realex Payments

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the Software), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, andor sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
90 changes: 88 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,88 @@
# rxp-hpp-php
The official Realex Payments HPP PHP SDK
# Realex Payments HPP PHP SDK
You can sign up for a free Realex Payments sandbox account at https://www.realexpayments.co.uk/developers

## Requirements ##
- PHP >= 5.3.9
- Composer (https://getcomposer.org/)

## Instructions ##

1. Add the following to your 'composer.json' file

```
{
"require": {
"realexpayments/rxp-hpp-php": "1.0.0"
}
}
```
2. Inside the application directory run composer:
```
composer update
```
OR (depending on your server configuration)
```
php composer.phar update
```
3. Add a reference to the autoloader class anywhere you need to use the sdk
```php
require_once ( 'vendor/autoload.php' );
```
4. Use the sdk <br/>
```php
$hppRequest = ( new HppRequest() )
->addMerchantId( "myMerchantId" )
->addAccount( "mySubAccount" )
....
```
##SDK Example##
### Creating Request JSON for Realex JS SDK
```php
require_once ( 'vendor/autoload.php' );
use com\realexpayments\hpp\sdk\domain\HppRequest;
use com\realexpayments\hpp\sdk\RealexHpp;
$hppRequest = ( new HppRequest() )
->addMerchantId( "myMerchantId" )
->addAccount( "mySubAccount" )
->addAmount( "1001" )
->addCurrency( "EUR" )
->addAutoSettleFlag( "1" );
$supplementaryData = array();
$supplementaryData['key1'] = 'value1';
$supplementaryData['key2'] = 'value2';
$hppRequest->addSupplementaryData( $supplementaryData );
$realexHpp = new RealexHpp( "mySecret" );
$requestJson = $realexHpp->requestToJson( $hppRequest );
```

### Consuming Response JSON from Realex Payments JS SDK

```php
require_once ( 'vendor/autoload.php' );

use com\realexpayments\hpp\sdk\domain\HppResponse;
use com\realexpayments\hpp\sdk\RealexHpp;

$realexHpp = new RealexHpp( "mySecret" );
$hppResponse = $realexHpp->responseFromJson( responseJson );
```

## License

See the LICENSE file.
37 changes: 37 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "realexpayments/rxp-hpp-php",
"type": "library",
"description": "SDK to send requests and parse responses from Realex Payments using HPP",
"keywords": [
"realex",
"payments",
"HPP"
],
"authors": [
{
"name": "Realex Payments",
"homepage": "https://www.realexpayments.com/"
},
{
"name": "Victor Palomares",
"homepage": "http://www.softwaredesign.ie",
"role": "Developer"
}
],
"license": "MIT",
"require": {
"php": ">=5.3.9",
"apache/log4php": "2.3.0",
"symfony/validator": "2.7.3",
"doctrine/annotations":"1.2.6",
"doctrine/cache":"1.4.1"
},
"autoload": {
"psr-4": {
"com\\realexpayments\\hpp\\sdk\\": [
"src/main/php/com-realexpayments-hpp-sdk",
"test/main/php/com-realexpayments-hpp-sdk"
]
}
}
}
13 changes: 13 additions & 0 deletions config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<configuration xmlns="http://logging.apache.org/log4php/">
<!--<appender name="myAppender" class="LoggerAppenderFile">
<param name="file" value="myLog.log" />
</appender>-->
<appender name="default" class="LoggerAppenderConsole">
<layout class="LoggerLayoutSimple" />
</appender>

<root>
<level value="TRACE" />
<appender_ref ref="default" />
</root>
</configuration>
52 changes: 52 additions & 0 deletions src/main/php/com-realexpayments-hpp-sdk/RXPLogger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php


namespace com\realexpayments\hpp\sdk;

use Logger;

/**
* Class RXPLogger. Wraps initialisation of the logging framework
* @package com\realexpayments\remote\sdk
*/
class RXPLogger {

/**
* @var bool
*/
private static $initialised = false;

/**
* @param string $className
*
* @return Logger
*/
public static function GetLogger( $className ) {
if ( ! self::IsInitialised() ) {
self::Initialise();
}

$logger = Logger::getLogger( $className );

return $logger;

}

private static function Initialise() {

$path = $_SERVER['DOCUMENT_ROOT'] . '/config.xml';
if ( file_exists( $path ) ) {
Logger::configure( $path );
} else {
Logger::configure( __DIR__ . '/config.xml' );
}


self::$initialised = true;
}

private static function IsInitialised() {
return self::$initialised;
}

}
35 changes: 35 additions & 0 deletions src/main/php/com-realexpayments-hpp-sdk/RealexException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php


namespace com\realexpayments\hpp\sdk;

use Exception;
use RuntimeException;


/**
* An exception class for general Realex SDK errors. All other SDK exceptions will extend this class.
*
* @author vicpada
*
*/
class RealexException extends RuntimeException
{

const serialVersionUID = -2270549234447218179;


/**
* RealexException constructor.
*
* @param string $message
* @param Exception $e
*/
public function __construct($message, Exception $e = null)
{
parent::__construct($message, 0, $e);

}


}
Loading

0 comments on commit 0ad95e1

Please sign in to comment.