Skip to content

Commit

Permalink
Merge pull request #20 from slogsdon/update-3ds-fields
Browse files Browse the repository at this point in the history
Include mandatory/recommended 3DS 2.0 fields
  • Loading branch information
RealexITSO authored Jun 19, 2019
2 parents 95437a2 + e99c080 commit b58f3a8
Show file tree
Hide file tree
Showing 7 changed files with 922 additions and 54 deletions.
6 changes: 3 additions & 3 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
The MIT License (MIT)

Copyright (c) 2018 Pay and Shop Ltd t/a Global Payments
Copyright (c) 2019 Global 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
to use, copy, modify, merge, publish, distribute, sublicense, and or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions

Expand All @@ -18,4 +18,4 @@ 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.
THE SOFTWARE.
109 changes: 63 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# Please use our new PHP SDK
We've moved. We highly recommend you use the Global Payments PHP SDK
which supports all the features of this SDK and will benefit from all future releases:
https://github.com/globalpayments/php-sdk

With the latest update (1.1.3) this SDK supports the mandatory and recommended HPP fields for 3D Secure 2. Going forward it will only receive critical security updates, no further feature updates will be released beyond 3D Secure 2.

# Realex Payments HPP PHP SDK
You can sign up for a free Realex Payments sandbox account at https://developer.realexpayments.com
You can sign up for a Global Payments (formerly Realex Payments) account at https://developer.globalpay.com

## Requirements ##
- PHP >= 5.3.9
- For security and support we highly recommend you use PHP 7
- Composer (https://getcomposer.org/)

## Instructions ##
Expand All @@ -12,7 +20,7 @@ You can sign up for a free Realex Payments sandbox account at https://developer.
```
{
"require": {
"realexpayments/rxp-hpp-php": "1.1.2"
"realexpayments/rxp-hpp-php": "1.1.3"
}
}
```
Expand All @@ -32,71 +40,80 @@ You can sign up for a free Realex Payments sandbox account at https://developer.
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" )
....
$hppRequest = new HppRequest();
$hppRequest->addMerchantId("MerchantId");
$hppRequest->addAccount("internet");
....
```
##SDK Example##
## Usage
### Creating Request JSON for Realex JS SDK
### Creating HPP Request JSON for Realex Payments JS Library
```php
require_once ( 'vendor/autoload.php' );
<?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 );
use com\realexpayments\hpp\sdk\RealexValidationException;
use com\realexpayments\hpp\sdk\RealexException;
$hppRequest = new HppRequest();
$hppRequest->addMerchantId("MerchantId");
$hppRequest->addAccount("internet");
$hppRequest->addAmount("1001");
$hppRequest->addCurrency("EUR");
$hppRequest->addAutoSettleFlag(TRUE);
$hppRequest->addHppVersion("2");
// 3D Secure 2 Mandatory and Recommended Fields
$hppRequest->addCustomerEmailAddress("[email protected]");
$hppRequest->addCustomerMobilePhoneNumber("44|07123456789");
$hppRequest->addBillingAddressLine1("Flat 123");
$hppRequest->addBillingAddressLine2("House 456");
$hppRequest->addBillingAddressLine3("Unit 4");
$hppRequest->addBillingCity("Halifax");
$hppRequest->addBillingPostalCode("W5 9HR");
$hppRequest->addBillingCountryCode("826");
$hppRequest->addShippingAddressLine1("Apartment 825");
$hppRequest->addShippingAddressLine2("Complex 741");
$hppRequest->addShippingAddressLine3("House 963");
$hppRequest->addShippingCity("Chicago");
$hppRequest->addShippingState("IL");
$hppRequest->addShippingPostalCode("50001");
$hppRequest->addShippingCountryCode("840");
$realexHpp = new RealexHpp("Shared Secret");
try {
$requestJson = $realexHpp->requestToJson($hppRequest, false);
// TODO: pass the HPP request JSON to the JavaScript, iOS or Android Library
}
catch (RealexValidationException $e) {
// TODO: Add your error handling here
}
catch (RealexException $e) {
// TODO: Add your error handling here
}
```

### Consuming Response JSON from Realex Payments JS SDK
### Consuming Response JSON from Realex Payments JS Library

```php
require_once ( 'vendor/autoload.php' );
<?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 );
```
### 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");

$realexHpp = new RealexHpp("secret");
$requestJson = $realexHpp->requestToJson($hppRequest);
$realexHpp = new RealexHpp("mySecret");
$hppResponse = $realexHpp->responseFromJson(responseJson);
```
## License

Expand Down
10 changes: 10 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,17 @@
"doctrine/annotations":"1.2.*",
"doctrine/cache":"1.4.*"
},
"require-dev": {
"phpunit/phpunit": "^5.7"
},
"autoload": {
"psr-4": {
"com\\realexpayments\\hpp\\sdk\\": [
"src/main/php/com-realexpayments-hpp-sdk"
]
}
},
"autoload-dev": {
"psr-4": {
"com\\realexpayments\\hpp\\sdk\\": [
"src/main/php/com-realexpayments-hpp-sdk",
Expand Down
22 changes: 22 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.7/phpunit.xsd"
bootstrap="vendor/autoload.php"
executionOrder="depends,defects"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">
<testsuites>
<testsuite name="default">
<directory suffix="Test.php">test</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
Loading

0 comments on commit b58f3a8

Please sign in to comment.