Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add improvements to README #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 33 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,95 +9,101 @@ You can sign up for a free Realex Payments sandbox account at https://developer.

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

```
```json
{
"require": {
"realexpayments/rxp-hpp-php": "1.1.1"
}
}
```

Or run just:

```cli
composer require realexpayments/rxp-hpp-php
```

2. Inside the application directory run composer:

```
```cli
composer update
```

OR (depending on your server configuration)

```
```cli
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' );
require_once 'vendor/autoload.php';
```

4. Use the sdk <br/>

```php
$hppRequest = ( new HppRequest() )
->addMerchantId( "myMerchantId" )
->addAccount( "mySubAccount" )
->addMerchantId( 'myMerchantId' )
->addAccount( 'mySubAccount' )
....
```

##SDK Example##
## SDK Example ##

### Creating Request JSON for Realex JS SDK

```php
require_once ( 'vendor/autoload.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" );
->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" );
$realexHpp = new RealexHpp( 'mySecret' );
$requestJson = $realexHpp->requestToJson( $hppRequest );
```

### Consuming Response JSON from Realex Payments JS SDK

```php
require_once ( 'vendor/autoload.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 );
$realexHpp = new RealexHpp( 'mySecret' );
$hppResponse = $realexHpp->responseFromJson( $responseJson );
```
### HPP Select Stored Card
```php
$hppRequest = new HppRequest();
$hppRequest
->addAmount("1001")
->addCurrency("EUR")
->addAccount("accountId")
->addMerchantId("merchantId")
->addAutoSettleFlag("1")
->addHppSelectStoredCard("payerRef")
->addPayerExists("1")
->addOfferSaveCard("1");
->addAmount('1001')
->addCurrency('EUR')
->addAccount('accountId')
->addMerchantId('merchantId')
->addAutoSettleFlag('1')
->addHppSelectStoredCard('payerRef')
->addPayerExists('1')
->addOfferSaveCard('1');

$realexHpp = new RealexHpp("secret");
$realexHpp = new RealexHpp('secret');
$requestJson = $realexHpp->requestToJson($hppRequest);
```
## License

See the LICENSE file.
See the [LICENSE](LICENSE) file.