├── .gitignore ├── LICENSE.txt ├── README.md ├── composer.json ├── config.xml ├── phpunit.xml ├── src └── main │ └── php │ └── com-realexpayments-hpp-sdk │ ├── RXPLogger.php │ ├── RealexException.php │ ├── RealexHpp.php │ ├── RealexValidationException.php │ ├── config.xml │ ├── domain │ ├── Flag.php │ ├── HppRequest.php │ └── HppResponse.php │ ├── utils │ ├── GenerationUtils.php │ ├── JsonUtils.php │ ├── RequestMapper.php │ ├── ResponseMapper.php │ ├── SafeArrayAccess.php │ ├── ValidationUtils.php │ └── iMapper.php │ └── validators │ ├── OtbAmount.php │ ├── OtbAmountValidator.php │ ├── SupplementaryDataLength.php │ ├── SupplementaryDataLengthValidator.php │ ├── SupplementaryDataPattern.php │ ├── SupplementaryDataPatternValidator.php │ └── ValidationMessages.php └── test └── main ├── php └── com-realexpayments-hpp-sdk │ ├── RealexHppTest.php │ ├── SampleJsonData.php │ ├── domain │ └── HppRequestTest.php │ └── utils │ ├── GenerationUtilsTest.php │ ├── JsonUtilsTest.php │ └── ValidationUtilsTest.php └── resources └── sample-json ├── hpp-request-card-storage.json ├── hpp-request-encoded-valid.json ├── hpp-request-hpp-version-fail.json ├── hpp-request-hpp-version-valid.json ├── hpp-request-hpp-version2.json ├── hpp-request-post-both-invalid-both.json ├── hpp-request-post-both-valid-both.json ├── hpp-request-post-dimensions-invalid-pattern.json ├── hpp-request-post-dimensions-invalid-size.json ├── hpp-request-post-dimensions-valid.json ├── hpp-request-post-response-invalid-size.json ├── hpp-request-post-response-valid.json ├── hpp-request-unknown-data.json ├── hpp-request-valid.json ├── hpp-response-empty-ECI.json ├── hpp-response-encoded-valid.json ├── hpp-response-no-ECI-field-encoded.json ├── hpp-response-no-ECI-field.json ├── hpp-response-no-TSS-encoded.json ├── hpp-response-no-TSS.json ├── hpp-response-unknown-data.json └── hpp-response-valid.json /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/* 2 | vm-config/* 3 | .vagrant/ 4 | Vagrantfile 5 | composer.lock 6 | composer.phar 7 | phpunit.phar 8 | Would skip repository vendor/apache/log4php 9 | vendor/autoload.php 10 | vendor/composer 11 | vendor/doctrine 12 | vendor/symfony 13 | vm-config/ 14 | adhoc/ -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019 Global Payments 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the Software), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Please use our new PHP SDK 2 | We've moved. We highly recommend you use the Global Payments PHP SDK 3 | which supports all the features of this SDK and will benefit from all future releases: 4 | https://github.com/globalpayments/php-sdk 5 | 6 | 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. 7 | 8 | # Realex Payments HPP PHP SDK 9 | You can sign up for a Global Payments (formerly Realex Payments) account at https://developer.globalpay.com 10 | 11 | ## Requirements ## 12 | - PHP >= 5.3.9 13 | - For security and support we highly recommend you use PHP 7 14 | - Composer (https://getcomposer.org/) 15 | 16 | ## Instructions ## 17 | 18 | 1. Add the following to your 'composer.json' file 19 | 20 | ``` 21 | { 22 | "require": { 23 | "realexpayments/rxp-hpp-php": "1.1.3" 24 | } 25 | } 26 | ``` 27 | 28 | 2. Inside the application directory run composer: 29 | 30 | ``` 31 | composer update 32 | ``` 33 | 34 | OR (depending on your server configuration) 35 | 36 | ``` 37 | php composer.phar update 38 | ``` 39 | 40 | 3. Add a reference to the autoloader class anywhere you need to use the sdk 41 | 42 | ```php 43 | require_once ('vendor/autoload.php'); 44 | ``` 45 | 46 | 4. Use the sdk
47 | 48 | ```php 49 | $hppRequest = new HppRequest(); 50 | $hppRequest->addMerchantId("MerchantId"); 51 | $hppRequest->addAccount("internet"); 52 | .... 53 | ``` 54 | 55 | ## Usage 56 | 57 | ### Creating HPP Request JSON for Realex Payments JS Library 58 | 59 | ```php 60 | addMerchantId("MerchantId"); 70 | $hppRequest->addAccount("internet"); 71 | $hppRequest->addAmount("1001"); 72 | $hppRequest->addCurrency("EUR"); 73 | $hppRequest->addAutoSettleFlag(TRUE); 74 | $hppRequest->addHppVersion("2"); 75 | // 3D Secure 2 Mandatory and Recommended Fields 76 | $hppRequest->addCustomerEmailAddress("james.mason@example.com"); 77 | $hppRequest->addCustomerMobilePhoneNumber("44|07123456789"); 78 | $hppRequest->addBillingAddressLine1("Flat 123"); 79 | $hppRequest->addBillingAddressLine2("House 456"); 80 | $hppRequest->addBillingAddressLine3("Unit 4"); 81 | $hppRequest->addBillingCity("Halifax"); 82 | $hppRequest->addBillingPostalCode("W5 9HR"); 83 | $hppRequest->addBillingCountryCode("826"); 84 | $hppRequest->addShippingAddressLine1("Apartment 825"); 85 | $hppRequest->addShippingAddressLine2("Complex 741"); 86 | $hppRequest->addShippingAddressLine3("House 963"); 87 | $hppRequest->addShippingCity("Chicago"); 88 | $hppRequest->addShippingState("IL"); 89 | $hppRequest->addShippingPostalCode("50001"); 90 | $hppRequest->addShippingCountryCode("840"); 91 | 92 | $realexHpp = new RealexHpp("Shared Secret"); 93 | 94 | try { 95 | $requestJson = $realexHpp->requestToJson($hppRequest, false); 96 | // TODO: pass the HPP request JSON to the JavaScript, iOS or Android Library 97 | } 98 | catch (RealexValidationException $e) { 99 | // TODO: Add your error handling here 100 | } 101 | catch (RealexException $e) { 102 | // TODO: Add your error handling here 103 | } 104 | ``` 105 | 106 | ### Consuming Response JSON from Realex Payments JS Library 107 | 108 | ```php 109 | responseFromJson(responseJson); 117 | ``` 118 | ## License 119 | 120 | See the LICENSE file. 121 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "realexpayments/rxp-hpp-php", 3 | "type": "library", 4 | "description": "SDK to send requests and parse responses from Realex Payments using HPP", 5 | "keywords": [ 6 | "realex", 7 | "payments", 8 | "HPP" 9 | ], 10 | "authors": [ 11 | { 12 | "name": "Realex Payments", 13 | "homepage": "https://www.realexpayments.com/" 14 | }, 15 | { 16 | "name": "Victor Palomares", 17 | "homepage": "http://www.softwaredesign.ie", 18 | "role": "Developer" 19 | } 20 | ], 21 | "license": "MIT", 22 | "require": { 23 | "php": ">=5.3.9", 24 | "apache/log4php": "2.3.*", 25 | "symfony/validator": "2.7.*", 26 | "doctrine/annotations":"1.2.*", 27 | "doctrine/cache":"1.4.*" 28 | }, 29 | "require-dev": { 30 | "phpunit/phpunit": "^5.7" 31 | }, 32 | "autoload": { 33 | "psr-4": { 34 | "com\\realexpayments\\hpp\\sdk\\": [ 35 | "src/main/php/com-realexpayments-hpp-sdk" 36 | ] 37 | } 38 | }, 39 | "autoload-dev": { 40 | "psr-4": { 41 | "com\\realexpayments\\hpp\\sdk\\": [ 42 | "src/main/php/com-realexpayments-hpp-sdk", 43 | "test/main/php/com-realexpayments-hpp-sdk" 44 | ] 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /config.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | test 14 | 15 | 16 | 17 | 18 | 19 | src 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/php/com-realexpayments-hpp-sdk/RXPLogger.php: -------------------------------------------------------------------------------- 1 | 15 | * RealexHpp class for converting HPP requests and responses to and from JSON. 16 | * This class is also responsible for validating inputs, generating defaults and encoding parameter values. 17 | *

18 | *

19 | * Creating Request JSON for Realex JS SDK 20 | *

 21 |  * $hppRequest = (new HppRequest())->addMerchantId("merchantId")->addAmount(100)...addAutoSettleFlag(true);
 22 |  * $realexHpp = new RealexHpp("mySecret");
 23 |  * $json = $realexHpp->requestToJson($hppRequest);
 24 |  * 
25 | *

26 | *

27 | * Consuming Response JSON from Realex JS SDK 28 | *

 29 |  * $realexHpp = new RealexHpp("mySecret");
 30 |  * $hppResponse = $realexHpp->responseFromJson($responseJson);
 31 |  * 
32 | *

33 | * @author vicpada 34 | * 35 | */ 36 | class RealexHpp 37 | { 38 | 39 | /** 40 | * @var Logger logger 41 | */ 42 | private $logger; 43 | 44 | /** 45 | * Character set to use for encoding/decoding. 46 | */ 47 | const ENCODING_CHARSET = "UTF-8"; 48 | 49 | 50 | /** 51 | * @var string The shared secret issued by Realex. Used to create the SHA-1 hash in the request and 52 | * to verify the validity of the XML response. 53 | */ 54 | private $secret; 55 | 56 | /** 57 | * RealexHpp constructor 58 | * 59 | * @param string $secret 60 | */ 61 | public function __construct($secret) 62 | { 63 | $this->logger = RXPLogger::getLogger(__CLASS__); 64 | $this->secret = $secret; 65 | } 66 | 67 | /** 68 | *

69 | * Method produces JSON from HppRequest object. 70 | * Carries out the following actions: 71 | *

77 | *

78 | * 79 | * @param HppRequest $hppRequest 80 | * @param bool $encoded true if the JSON values will be encoded. 81 | * @return HppRequest 82 | */ 83 | public function requestToJson(HppRequest $hppRequest, $encoded = true) 84 | { 85 | 86 | $this->logger->info("Converting HppRequest to JSON."); 87 | 88 | $json = null; 89 | 90 | //generate defaults 91 | $this->logger->debug("Generating defaults."); 92 | $hppRequest->generateDefaults($this->secret); 93 | 94 | //validate request 95 | $this->logger->debug("Validating request."); 96 | ValidationUtils::validate($hppRequest); 97 | 98 | // build request 99 | $this->logger->debug("Encoding object."); 100 | try { 101 | if ($encoded === true) { 102 | $hppRequest = $hppRequest->encode(self::ENCODING_CHARSET); 103 | } 104 | else { 105 | $hppRequest = $hppRequest->formatRequest(self::ENCODING_CHARSET); 106 | } 107 | } catch (Exception $e) { 108 | $this->logger->error("Exception encoding HPP request.", $e); 109 | throw new RealexException("Exception encoding HPP request.", $e); 110 | } 111 | 112 | //convert to JSON 113 | $this->logger->debug("Converting to JSON."); 114 | $json = JsonUtils::toJson($hppRequest); 115 | 116 | return $json; 117 | } 118 | 119 | /** 120 | *

121 | * Method produces HppRequest object from JSON. 122 | * Carries out the following actions: 123 | *

128 | *

129 | * 130 | * @param string $json 131 | * @param bool $encoded true if the JSON values have been encoded. 132 | * @return HppRequest 133 | */ 134 | public function requestFromJson($json, $encoded = true) 135 | { 136 | $this->logger->info("Converting JSON to HppRequest."); 137 | 138 | //convert to HppRequest from JSON 139 | $hppRequest = JsonUtils::fromJsonHppRequest($json); 140 | 141 | //decode if necessary 142 | if ($encoded) { 143 | $this->logger->debug("Decoding object."); 144 | try { 145 | $hppRequest = $hppRequest->decode(self::ENCODING_CHARSET); 146 | } catch (Exception $e) { 147 | $this->logger->error("Exception encoding HPP request.", $e); 148 | throw new RealexException("Exception decoding HPP request.", $e); 149 | } 150 | } 151 | 152 | //validate HPP request 153 | $this->logger->debug("Validating request."); 154 | ValidationUtils::validate($hppRequest); 155 | 156 | return $hppRequest; 157 | } 158 | 159 | /** 160 | *

161 | * Method produces JSON from HppResponse object. 162 | * Carries out the following actions: 163 | *

169 | *

170 | * 171 | * @param HppResponse $hppResponse 172 | * @return string 173 | */ 174 | public function responseToJson(HppResponse $hppResponse) 175 | { 176 | 177 | $this->logger->info("Converting HppResponse to JSON."); 178 | 179 | $json = null; 180 | 181 | //generate hash 182 | $this->logger->debug("Generating hash."); 183 | $hppResponse->hash($this->secret); 184 | 185 | //encode 186 | $this->logger->debug("Encoding object."); 187 | try { 188 | $hppResponse = $hppResponse->encode(self::ENCODING_CHARSET); 189 | } catch (Exception $e) { 190 | $this->logger->error("Exception encoding HPP response.", $e); 191 | throw new RealexException("Exception encoding HPP response.", $e); 192 | } 193 | 194 | //convert to JSON 195 | $this->logger->debug("Converting to JSON."); 196 | $json = JsonUtils::toJson($hppResponse); 197 | 198 | return $json; 199 | } 200 | 201 | 202 | /** 203 | *

204 | * Method produces HppResponse object from JSON. 205 | * Carries out the following actions: 206 | *

211 | *

212 | * 213 | * @param string $json 214 | * @param bool $encoded 215 | * @return HppResponse 216 | */ 217 | public function responseFromJson($json, $encoded = true) 218 | { 219 | $this->logger->info("Converting JSON to HppResponse."); 220 | 221 | //convert to HppResponse from JSON 222 | $hppResponse = JsonUtils::fromJsonHppResponse($json); 223 | 224 | //decode if necessary 225 | if ($encoded) { 226 | $this->logger->debug("Decoding object."); 227 | try { 228 | $hppResponse = $hppResponse->decode(self::ENCODING_CHARSET); 229 | } catch (Exception $e) { 230 | $this->logger->error("Exception decoding HPP response.", $e); 231 | throw new RealexException("Exception decoding HPP response.", $e); 232 | } 233 | } 234 | 235 | //validate HPP response hash 236 | $this->logger->debug("Validating response hash."); 237 | ValidationUtils::validateResponse($hppResponse, $this->secret); 238 | 239 | return $hppResponse; 240 | } 241 | 242 | 243 | } -------------------------------------------------------------------------------- /src/main/php/com-realexpayments-hpp-sdk/RealexValidationException.php: -------------------------------------------------------------------------------- 1 | validationMessages; 31 | } 32 | 33 | 34 | /** 35 | * RealexValidationException constructor. 36 | * 37 | * @param string $message 38 | * @param string[] $validationMessages 39 | */ 40 | public function __construct( $message, array $validationMessages = array() ) { 41 | parent::__construct( $message ); 42 | 43 | $this->validationMessages = $validationMessages; 44 | } 45 | 46 | 47 | } -------------------------------------------------------------------------------- /src/main/php/com-realexpayments-hpp-sdk/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/main/php/com-realexpayments-hpp-sdk/domain/Flag.php: -------------------------------------------------------------------------------- 1 | 67 | * The result of the Card Verification check (if enabled): 68 | * 75 | *

76 | * 77 | * @var string cvn result 78 | */ 79 | private $cvnResult; 80 | 81 | /** 82 | * @var string A unique reference that Realex Payments assign to your transaction. 83 | */ 84 | private $pasRef; 85 | 86 | /** 87 | * @var string This is the Realex Payments batch that this transaction will be in. 88 | * (This is equal to "-1" if the transaction was sent in with the autosettle flag off. 89 | * After you settle it (either manually or programmatically) the response to that transaction 90 | * will contain the batch id.) 91 | */ 92 | private $batchId; 93 | 94 | /** 95 | * @var string This is the ecommerce indicator (this will only be returned for 3DSecure transactions). 96 | */ 97 | private $eci; 98 | 99 | /** 100 | * @var string Cardholder Authentication Verification Value (this will only be returned for 3DSecure transactions). 101 | */ 102 | private $cavv; 103 | 104 | /** 105 | * @var string Exchange Identifier (this will only be returned for 3DSecure transactions). 106 | */ 107 | private $xid; 108 | 109 | /** 110 | * @var string Whatever data you have sent in the request will be returned to you. 111 | */ 112 | private $commentOne; 113 | 114 | /** 115 | * @var string Whatever data you have sent in the request will be returned to you. 116 | */ 117 | private $commentTwo; 118 | 119 | /** 120 | * The Transaction Suitability Score for the transaction. The RealScore is comprised of various distinct tests. 121 | * Using the RealControl application you can request that Realex Payments return certain individual scores to you. 122 | * These are identified by numbers - thus TSS_1032 would be the result of the check with id 1032. 123 | * You can then use these specific checks in conjunction with RealScore score to ascertain whether 124 | * or not you wish to continue with the settlement. 125 | * 126 | * @var array TSS 127 | */ 128 | private $tss = array(); 129 | 130 | /** 131 | * 132 | * Anything else you sent to us in the request will be returned to you in supplementary data. 133 | * 134 | * @var array Supplementary data 135 | */ 136 | private $supplementaryData = array(); 137 | 138 | /** 139 | * @var string Address Verification Service result for cardholder address 140 | */ 141 | private $AVSAddressResult; 142 | 143 | /** 144 | * @var string Address Verification Service result for cardholder billing code 145 | */ 146 | private $AVSPostCodeResult; 147 | 148 | 149 | /** 150 | * HppResponse constructor. 151 | */ 152 | public function __construct() { 153 | } 154 | 155 | /** 156 | * Getter for merchantId 157 | * 158 | * @return string 159 | */ 160 | public function getMerchantId() { 161 | return $this->merchantId; 162 | } 163 | 164 | /** 165 | * Setter for merchantId 166 | * 167 | * @param string $merchantId 168 | */ 169 | public function setMerchantId( $merchantId ) { 170 | $this->merchantId = $merchantId; 171 | } 172 | 173 | /** 174 | * Getter for account 175 | * 176 | * @return string 177 | */ 178 | public function getAccount() { 179 | return $this->account; 180 | } 181 | 182 | /** 183 | * Setter for account 184 | * 185 | * @param string $account 186 | */ 187 | public function setAccount( $account ) { 188 | $this->account = $account; 189 | } 190 | 191 | /** 192 | * Getter for orderId 193 | * 194 | * @return string 195 | */ 196 | public function getOrderId() { 197 | return $this->orderId; 198 | } 199 | 200 | /** 201 | * Setter for orderId 202 | * 203 | * @param string $orderId 204 | */ 205 | public function setOrderId( $orderId ) { 206 | $this->orderId = $orderId; 207 | } 208 | 209 | /** 210 | * Getter for amount 211 | * 212 | * @return string 213 | */ 214 | public function getAmount() { 215 | return $this->amount; 216 | } 217 | 218 | /** 219 | * Setter for amount 220 | * 221 | * @param string $amount 222 | */ 223 | public function setAmount( $amount ) { 224 | $this->amount = $amount; 225 | } 226 | 227 | /** 228 | * Getter for authCode 229 | * 230 | * @return string 231 | */ 232 | public function getAuthCode() { 233 | return $this->authCode; 234 | } 235 | 236 | /** 237 | * Setter for authCode 238 | * 239 | * @param string $authCode 240 | */ 241 | public function setAuthCode( $authCode ) { 242 | $this->authCode = $authCode; 243 | } 244 | 245 | /** 246 | * Getter for timeStamp 247 | * 248 | * @return string 249 | */ 250 | public function getTimeStamp() { 251 | return $this->timeStamp; 252 | } 253 | 254 | /** 255 | * Setter for timeStamp 256 | * 257 | * @param string $timeStamp 258 | */ 259 | public function setTimeStamp( $timeStamp ) { 260 | $this->timeStamp = $timeStamp; 261 | } 262 | 263 | /** 264 | * Getter for hash 265 | * 266 | * @return string 267 | */ 268 | public function getHash() { 269 | return $this->hash; 270 | } 271 | 272 | /** 273 | * Setter for hash 274 | * 275 | * @param string $hash 276 | */ 277 | public function setHash( $hash ) { 278 | $this->hash = $hash; 279 | } 280 | 281 | /** 282 | * Getter for result 283 | * 284 | * @return string 285 | */ 286 | public function getResult() { 287 | return $this->result; 288 | } 289 | 290 | /** 291 | * Setter for result 292 | * 293 | * @param string $result 294 | */ 295 | public function setResult( $result ) { 296 | $this->result = $result; 297 | } 298 | 299 | /** 300 | * Getter for message 301 | * 302 | * @return string 303 | */ 304 | public function getMessage() { 305 | return $this->message; 306 | } 307 | 308 | /** 309 | * Setter for message 310 | * 311 | * @param string $message 312 | */ 313 | public function setMessage( $message ) { 314 | $this->message = $message; 315 | } 316 | 317 | /** 318 | * Getter for cvnResult 319 | * 320 | * @return string 321 | */ 322 | public function getCvnResult() { 323 | return $this->cvnResult; 324 | } 325 | 326 | /** 327 | * Setter for cvnResult 328 | * 329 | * @param string $cvnResult 330 | */ 331 | public function setCvnResult( $cvnResult ) { 332 | $this->cvnResult = $cvnResult; 333 | } 334 | 335 | /** 336 | * Getter for pasRef 337 | * 338 | * @return string 339 | */ 340 | public function getPasRef() { 341 | return $this->pasRef; 342 | } 343 | 344 | /** 345 | * Setter for pasRef 346 | * 347 | * @param string $pasRef 348 | */ 349 | public function setPasRef( $pasRef ) { 350 | $this->pasRef = $pasRef; 351 | } 352 | 353 | /** 354 | * Getter for batchId 355 | * 356 | * @return string 357 | */ 358 | public function getBatchId() { 359 | return $this->batchId; 360 | } 361 | 362 | /** 363 | * Setter for batchId 364 | * 365 | * @param string $batchId 366 | */ 367 | public function setBatchId( $batchId ) { 368 | $this->batchId = $batchId; 369 | } 370 | 371 | /** 372 | * Getter for eci 373 | * 374 | * @return string 375 | */ 376 | public function getEci() { 377 | return $this->eci; 378 | } 379 | 380 | /** 381 | * Setter for eci 382 | * 383 | * @param string $eci 384 | */ 385 | public function setEci( $eci ) { 386 | $this->eci = $eci; 387 | } 388 | 389 | /** 390 | * Getter for cavv 391 | * 392 | * @return string 393 | */ 394 | public function getCavv() { 395 | return $this->cavv; 396 | } 397 | 398 | /** 399 | * Setter for cavv 400 | * 401 | * @param string $cavv 402 | */ 403 | public function setCavv( $cavv ) { 404 | $this->cavv = $cavv; 405 | } 406 | 407 | /** 408 | * Getter for xid 409 | * 410 | * @return string 411 | */ 412 | public function getXid() { 413 | return $this->xid; 414 | } 415 | 416 | /** 417 | * Setter for xid 418 | * 419 | * @param string $xid 420 | */ 421 | public function setXid( $xid ) { 422 | $this->xid = $xid; 423 | } 424 | 425 | /** 426 | * Getter for commentOne 427 | * 428 | * @return string 429 | */ 430 | public function getCommentOne() { 431 | return $this->commentOne; 432 | } 433 | 434 | /** 435 | * Setter for commentOne 436 | * 437 | * @param string $commentOne 438 | */ 439 | public function setCommentOne( $commentOne ) { 440 | $this->commentOne = $commentOne; 441 | } 442 | 443 | /** 444 | * Getter for commentTwo 445 | * 446 | * @return string 447 | */ 448 | public function getCommentTwo() { 449 | return $this->commentTwo; 450 | } 451 | 452 | /** 453 | * Setter for commentTwo 454 | * 455 | * @param string $commentTwo 456 | */ 457 | public function setCommentTwo( $commentTwo ) { 458 | $this->commentTwo = $commentTwo; 459 | } 460 | 461 | /** 462 | * Getter for tss 463 | * 464 | * @return array 465 | */ 466 | public function getTss() { 467 | return $this->tss; 468 | } 469 | 470 | /** 471 | * Setter for tss 472 | * 473 | * @param array $tss 474 | */ 475 | public function setTss( $tss ) { 476 | $this->tss = $tss; 477 | } 478 | 479 | /** 480 | * Getter for supplementaryData 481 | * 482 | * @return array 483 | */ 484 | public function getSupplementaryData() { 485 | return $this->supplementaryData; 486 | } 487 | 488 | /** 489 | * Setter for supplementaryData 490 | * 491 | * @param string $name 492 | * @param string $value 493 | */ 494 | public function setSupplementaryDataValue( $name, $value ) { 495 | $this->supplementaryData[ $name ] = $value; 496 | } 497 | 498 | /** 499 | * Getter for AVSAddressResult 500 | * 501 | * @return string 502 | */ 503 | public function getAVSAddressResult() { 504 | return $this->AVSAddressResult; 505 | } 506 | 507 | /** 508 | * Setter for AVSAddressResult 509 | * 510 | * @param string $AVSAddressResult 511 | */ 512 | public function setAVSAddressResult( $AVSAddressResult ) { 513 | $this->AVSAddressResult = $AVSAddressResult; 514 | } 515 | 516 | /** 517 | * Getter for AVSPostCodeResult 518 | * 519 | * @return string 520 | */ 521 | public function getAVSPostCodeResult() { 522 | return $this->AVSPostCodeResult; 523 | } 524 | 525 | /** 526 | * Setter for AVSPostCodeResult 527 | * 528 | * @param string $AVSPostCodeResult 529 | */ 530 | public function setAVSPostCodeResult( $AVSPostCodeResult ) { 531 | $this->AVSPostCodeResult = $AVSPostCodeResult; 532 | } 533 | 534 | 535 | /** 536 | * Helper method for adding a merchantId 537 | * 538 | * @param string $merchantId 539 | * 540 | * @return HppResponse 541 | */ 542 | public function addMerchantId( $merchantId ) { 543 | $this->merchantId = $merchantId; 544 | 545 | return $this; 546 | } 547 | 548 | /** 549 | * Helper method for adding a account 550 | * 551 | * @param string $account 552 | * 553 | * @return HppResponse 554 | */ 555 | public function addAccount( $account ) { 556 | $this->account = $account; 557 | 558 | return $this; 559 | } 560 | 561 | /** 562 | * Helper method for adding a orderId 563 | * 564 | * @param string $orderId 565 | * 566 | * @return HppResponse 567 | */ 568 | public function addOrderId( $orderId ) { 569 | $this->orderId = $orderId; 570 | 571 | return $this; 572 | } 573 | 574 | /** 575 | * Helper method for adding a amount 576 | * 577 | * @param string $amount 578 | * 579 | * @return HppResponse 580 | */ 581 | public function addAmount( $amount ) { 582 | $this->amount = $amount; 583 | 584 | return $this; 585 | } 586 | 587 | /** 588 | * Helper method for adding a authCode 589 | * 590 | * @param string $authCode 591 | * 592 | * @return HppResponse 593 | */ 594 | public function addAuthCode( $authCode ) { 595 | $this->authCode = $authCode; 596 | 597 | return $this; 598 | } 599 | 600 | /** 601 | * Helper method for adding a timeStamp 602 | * 603 | * @param string $timeStamp 604 | * 605 | * @return HppResponse 606 | */ 607 | public function addTimeStamp( $timeStamp ) { 608 | $this->timeStamp = $timeStamp; 609 | 610 | return $this; 611 | } 612 | 613 | /** 614 | * Helper method for adding a hash 615 | * 616 | * @param string $hash 617 | * 618 | * @return HppResponse 619 | */ 620 | public function addHash( $hash ) { 621 | $this->hash = $hash; 622 | 623 | return $this; 624 | } 625 | 626 | /** 627 | * Helper method for adding a result 628 | * 629 | * @param string $result 630 | * 631 | * @return HppResponse 632 | */ 633 | public function addResult( $result ) { 634 | $this->result = $result; 635 | 636 | return $this; 637 | } 638 | 639 | /** 640 | * Helper method for adding a message 641 | * 642 | * @param string $message 643 | * 644 | * @return HppResponse 645 | */ 646 | public function addMessage( $message ) { 647 | $this->message = $message; 648 | 649 | return $this; 650 | } 651 | 652 | /** 653 | * Helper method for adding a cvnResult 654 | * 655 | * @param string $cvnResult 656 | * 657 | * @return HppResponse 658 | */ 659 | public function addCvnResult( $cvnResult ) { 660 | $this->cvnResult = $cvnResult; 661 | 662 | return $this; 663 | } 664 | 665 | /** 666 | * Helper method for adding a pasRef 667 | * 668 | * @param string $pasRef 669 | * 670 | * @return HppResponse 671 | */ 672 | public function addPasRef( $pasRef ) { 673 | $this->pasRef = $pasRef; 674 | 675 | return $this; 676 | } 677 | 678 | /** 679 | * Helper method for adding a batchId 680 | * 681 | * @param string $batchId 682 | * 683 | * @return HppResponse 684 | */ 685 | public function addBatchId( $batchId ) { 686 | $this->batchId = $batchId; 687 | 688 | return $this; 689 | } 690 | 691 | /** 692 | * Helper method for adding a eci 693 | * 694 | * @param string $eci 695 | * 696 | * @return HppResponse 697 | */ 698 | public function addEci( $eci ) { 699 | $this->eci = $eci; 700 | 701 | return $this; 702 | } 703 | 704 | /** 705 | * Helper method for adding a cavv 706 | * 707 | * @param string $cavv 708 | * 709 | * @return HppResponse 710 | */ 711 | public function addCavv( $cavv ) { 712 | $this->cavv = $cavv; 713 | 714 | return $this; 715 | } 716 | 717 | /** 718 | * Helper method for adding a xid 719 | * 720 | * @param string $xid 721 | * 722 | * @return HppResponse 723 | */ 724 | public function addXid( $xid ) { 725 | $this->xid = $xid; 726 | 727 | return $this; 728 | } 729 | 730 | /** 731 | * Helper method for adding a commentOne 732 | * 733 | * @param string $commentOne 734 | * 735 | * @return HppResponse 736 | */ 737 | public function addCommentOne( $commentOne ) { 738 | $this->commentOne = $commentOne; 739 | 740 | return $this; 741 | } 742 | 743 | /** 744 | * Helper method for adding a commentTwo 745 | * 746 | * @param string $commentTwo 747 | * 748 | * @return HppResponse 749 | */ 750 | public function addCommentTwo( $commentTwo ) { 751 | $this->commentTwo = $commentTwo; 752 | 753 | return $this; 754 | } 755 | 756 | /** 757 | * Helper method for adding a AVSAddressResult 758 | * 759 | * @param string $AVSAddressResult 760 | * 761 | * @return HppResponse 762 | */ 763 | public function addAVSAddressResult( $AVSAddressResult ) { 764 | $this->AVSAddressResult = $AVSAddressResult; 765 | 766 | return $this; 767 | } 768 | 769 | /** 770 | * Helper method for adding a AVSPostCodeResult 771 | * 772 | * @param string $AVSPostCodeResult 773 | * 774 | * @return HppResponse 775 | */ 776 | public function addAVSPostCodeResult( $AVSPostCodeResult ) { 777 | $this->AVSPostCodeResult = $AVSPostCodeResult; 778 | 779 | return $this; 780 | } 781 | 782 | 783 | /** 784 | * Helper method for adding a tss 785 | * 786 | * @param array $tss 787 | * 788 | * @return HppResponse 789 | */ 790 | public function addTss( $tss ) { 791 | $this->tss = $tss; 792 | 793 | return $this; 794 | } 795 | 796 | 797 | /** 798 | * @return string The class name 799 | */ 800 | public static function GetClassName() { 801 | return __CLASS__; 802 | } 803 | 804 | public function hash( $secret ) { 805 | $this->hash = $this->generateHash( $secret ); 806 | 807 | return $this; 808 | } 809 | 810 | /** 811 | * Creates the security hash from a number of fields and the shared secret. 812 | * 813 | * @param string $secret 814 | * 815 | * @return String 816 | */ 817 | public function generateHash( $secret ) { 818 | //check for any null values and set them to empty string for hashing 819 | $timeStamp = null == $this->timeStamp ? "" : $this->timeStamp; 820 | $merchantId = null == $this->merchantId ? "" : $this->merchantId; 821 | $orderId = null == $this->orderId ? "" : $this->orderId; 822 | $result = null == $this->result ? "" : $this->result; 823 | $message = null == $this->message ? "" : $this->message; 824 | $pasRef = null == $this->pasRef ? "" : $this->pasRef; 825 | $authCode = null == $this->authCode ? "" : $this->authCode; 826 | 827 | //create $to hash 828 | $toHash = $timeStamp 829 | . "." 830 | . $merchantId 831 | . "." 832 | . $orderId 833 | . "." 834 | . $result 835 | . "." 836 | . $message 837 | . "." 838 | . $pasRef 839 | . "." 840 | . $authCode; 841 | 842 | 843 | return GenerationUtils::generateHash( $toHash, $secret ); 844 | } 845 | 846 | /** 847 | * Helper method to determine if the HPP response security hash is valid. 848 | * 849 | * @param string $secret 850 | * 851 | * @return bool 852 | */ 853 | public function isHashValid( $secret ) { 854 | $generatedHash = $this->generateHash( $secret ); 855 | 856 | return $generatedHash == $this->hash; 857 | } 858 | 859 | /** 860 | * Base64 encodes the HPP response values. 861 | * 862 | * @param string $charset 863 | * 864 | * @return HppResponse 865 | * @throws Exception 866 | */ 867 | public function encode( $charset ) { 868 | $this->merchantId = base64_encode( $this->merchantId ); 869 | $this->account = base64_encode( $this->account ); 870 | $this->amount = base64_encode( $this->amount ); 871 | $this->authCode = base64_encode( $this->authCode ); 872 | $this->batchId = base64_encode( $this->batchId ); 873 | $this->cavv = base64_encode( $this->cavv ); 874 | $this->cvnResult = base64_encode( $this->cvnResult ); 875 | $this->eci = base64_encode( $this->eci ); 876 | $this->commentOne = base64_encode( $this->commentOne ); 877 | $this->commentTwo = base64_encode( $this->commentTwo ); 878 | $this->message = base64_encode( $this->message ); 879 | $this->pasRef = base64_encode( $this->pasRef ); 880 | $this->hash = base64_encode( $this->hash ); 881 | $this->result = base64_encode( $this->result ); 882 | $this->xid = base64_encode( $this->xid ); 883 | $this->orderId = base64_encode( $this->orderId ); 884 | $this->timeStamp = base64_encode( $this->timeStamp ); 885 | $this->AVSAddressResult = base64_encode( $this->AVSAddressResult ); 886 | $this->AVSPostCodeResult = base64_encode( $this->AVSPostCodeResult ); 887 | 888 | if (is_array($this->tss)) { 889 | foreach ( $this->tss as $key => $value ) { 890 | $this->tss[ $key ] = base64_encode( $value ); 891 | } 892 | } 893 | 894 | if (is_array($this->supplementaryData)) { 895 | foreach ( $this->supplementaryData as $key => $value ) { 896 | $this->supplementaryData[ $key ] = base64_encode( $value ); 897 | } 898 | } 899 | 900 | return $this; 901 | } 902 | 903 | /** 904 | * Base64 decodes the HPP response values. 905 | * 906 | * @param string $charset 907 | * 908 | * @return HppResponse 909 | * @throws Exception 910 | */ 911 | public function decode( $charset ) { 912 | $this->merchantId = base64_decode( $this->merchantId ); 913 | $this->account = base64_decode( $this->account ); 914 | $this->amount = base64_decode( $this->amount ); 915 | $this->authCode = base64_decode( $this->authCode ); 916 | $this->batchId = base64_decode( $this->batchId ); 917 | $this->cavv = base64_decode( $this->cavv ); 918 | $this->cvnResult = base64_decode( $this->cvnResult ); 919 | $this->eci = base64_decode( $this->eci ); 920 | $this->commentOne = base64_decode( $this->commentOne ); 921 | $this->commentTwo = base64_decode( $this->commentTwo ); 922 | $this->message = base64_decode( $this->message ); 923 | $this->pasRef = base64_decode( $this->pasRef ); 924 | $this->hash = base64_decode( $this->hash ); 925 | $this->result = base64_decode( $this->result ); 926 | $this->xid = base64_decode( $this->xid ); 927 | $this->orderId = base64_decode( $this->orderId ); 928 | $this->timeStamp = base64_decode( $this->timeStamp ); 929 | $this->AVSAddressResult = base64_decode( $this->AVSAddressResult ); 930 | $this->AVSPostCodeResult = base64_decode( $this->AVSPostCodeResult ); 931 | 932 | if (is_array($this->tss)) { 933 | foreach ( $this->tss as $key => $value ) { 934 | $this->tss[ $key ] = base64_decode( $value ); 935 | } 936 | } 937 | 938 | if (is_array($this->supplementaryData)) { 939 | foreach ( $this->supplementaryData as $key => $value ) { 940 | $this->supplementaryData[ $key ] = base64_decode( $value ); 941 | } 942 | } 943 | 944 | return $this; 945 | } 946 | 947 | } -------------------------------------------------------------------------------- /src/main/php/com-realexpayments-hpp-sdk/utils/GenerationUtils.php: -------------------------------------------------------------------------------- 1 | 25 | * Hashing takes a string as input, and produce a fixed size number (160 bits for SHA-1 which 26 | * this implementation uses). This number is a hash of the input, and a small change in the 27 | * input results in a substantial change in the output. The functions are thought to be secure 28 | * in the sense that it requires an enormous amount of computing power and time to find a string 29 | * that hashes to the same value. In others words, there's no way to decrypt a secure hash. 30 | * Given the larger key size, this implementation uses SHA-1 which we prefer that you, but Realex 31 | * has retained compatibilty with MD5 hashing for compatibility with older systems. 32 | *

33 | *

34 | * To construct the hash for the remote interface follow this procedure: 35 | * 36 | * To construct the hash for the remote interface follow this procedure: 37 | * Form a string by concatenating the above fields with a period ('.') in the following order 38 | *

39 | * (TIMESTAMP.MERCHANT_ID.ORDER_ID.AMOUNT.CURRENCY) 40 | *

41 | * Like so (where a field is empty an empty string "" is used): 42 | *

43 | * (20120926112654.thestore.ORD453-11.29900.EUR) 44 | *

45 | * Get the hash of this string (SHA-1 shown below). 46 | *

47 | * (b3d51ca21db725f9c7f13f8aca9e0e2ec2f32502) 48 | *

49 | * Create a new string by concatenating this string and your shared secret using a period. 50 | *

51 | * (b3d51ca21db725f9c7f13f8aca9e0e2ec2f32502.mysecret ) 52 | *

53 | * Get the hash of this value. This is the value that you send to Realex Payments. 54 | *

55 | * (3c3cac74f2b783598b99af6e43246529346d95d1) 56 | * 57 | * This method takes the pre-built string of concatenated fields and the secret and returns the 58 | * SHA-1 hash to be placed in the request sent to Realex. 59 | * 60 | * @param string $toHash 61 | * @param string $secret 62 | * @return string The hash as a hex string 63 | */ 64 | public static function generateHash( $toHash, $secret ) { 65 | 66 | //first pass hashes the String of required fields 67 | $toHashFirstPass = sha1( $toHash ); 68 | 69 | //second pass takes the first hash, adds the secret and hashes again 70 | $toHashSecondPass = $toHashFirstPass . "." . $secret; 71 | 72 | return sha1( $toHashSecondPass ); 73 | } 74 | 75 | /** 76 | * Generate the current datetimestamp in the string formaat (YYYYMMDDHHSS) required in a 77 | * request to Realex. 78 | * 79 | * @return string current timestamp in YYYYMMDDHHSS format 80 | */ 81 | public static function generateTimestamp() { 82 | 83 | $date = new DateTime(); 84 | 85 | return $date->format( "YmdHis" ); 86 | 87 | } 88 | 89 | /** 90 | * Order Id for a initial request should be unique per client ID. This method generates a unique 91 | * order Id using the Java UUID class and then convert it to base64 to shorten the length to 22 92 | * characters. Order Id for a subsequent request (void, rebate, settle ect.) should use the 93 | * order Id of the initial request. 94 | * 95 | * * the order ID uses the Java UUID (universally unique identifier) so in theory it may not 96 | * be unique but the odds of this are extremely remote (see 97 | * 98 | * http://en.wikipedia.org/wiki/Universally_unique_identifier#Random_UUID_probability_of_duplicates) 99 | * 100 | */ 101 | public static function generateOrderId() { 102 | 103 | $uuid = self::getGuid(); 104 | $mostSignificantBits = substr( $uuid, 0, 8 ); 105 | $leastSignificantBits = substr( $uuid, 23, 8 ); 106 | 107 | 108 | return substr( base64_encode( $mostSignificantBits . $leastSignificantBits ), 0, 22 ); 109 | } 110 | 111 | 112 | private static function getGuid() { 113 | if ( function_exists( 'com_create_guid' ) ) { 114 | return trim( com_create_guid(), '{}' ); 115 | } else { 116 | 117 | mt_srand( (double) microtime() * 10000 );//optional for php 4.2.0 and up. 118 | $charId = strtoupper( md5( uniqid( rand(), true ) ) ); 119 | $hyphen = chr( 45 );// "-" 120 | $uuid = chr( 123 )// "{" 121 | . substr( $charId, 0, 8 ) . $hyphen 122 | . substr( $charId, 8, 4 ) . $hyphen 123 | . substr( $charId, 12, 4 ) . $hyphen 124 | . substr( $charId, 16, 4 ) . $hyphen 125 | . substr( $charId, 20, 12 ) 126 | . chr( 125 );// "}" 127 | return $uuid; 128 | } 129 | 130 | } 131 | } -------------------------------------------------------------------------------- /src/main/php/com-realexpayments-hpp-sdk/utils/JsonUtils.php: -------------------------------------------------------------------------------- 1 | HppRequest or HppResponse to JSON. 29 | * 30 | * @param $hppObject 31 | * @return string 32 | */ 33 | public static function toJson($hppObject) 34 | { 35 | self::Initialise(); 36 | 37 | $mapper = self::$mappers[get_class($hppObject)]; 38 | return $mapper->WriteValueAsString($hppObject); 39 | 40 | } 41 | 42 | /** 43 | * Method deserialises JSON to HppRequest. 44 | * 45 | * @param $json 46 | * @return HppRequest 47 | */ 48 | public static function fromJsonHppRequest($json) 49 | { 50 | self::Initialise(); 51 | 52 | $mapper = self::$mappers[HppRequest::GetClassName()]; 53 | return $mapper->ReadValue($json); 54 | } 55 | 56 | /** 57 | * Method deserialises JSON to HppResponse. 58 | * 59 | * @param $json 60 | * @return HppResponse 61 | */ 62 | public static function fromJsonHppResponse($json) 63 | { 64 | self::Initialise(); 65 | 66 | $mapper = self::$mappers[HppResponse::GetClassName()]; 67 | return $mapper->ReadValue($json); 68 | } 69 | 70 | 71 | 72 | private static function Initialise() 73 | { 74 | if (self::$initialised) { 75 | return; 76 | } 77 | 78 | 79 | self::$logger = RXPLogger::getLogger(__CLASS__); 80 | 81 | self::$mappers = array(); 82 | 83 | self::$mappers[HppRequest::GetClassName()] = new RequestMapper(); 84 | self::$mappers[HppResponse::GetClassName()] = new ResponseMapper(); 85 | 86 | self::$initialised = true; 87 | } 88 | } -------------------------------------------------------------------------------- /src/main/php/com-realexpayments-hpp-sdk/utils/RequestMapper.php: -------------------------------------------------------------------------------- 1 | $hppRequest->getMerchantId(), 74 | 'ACCOUNT' => $hppRequest->getAccount(), 75 | 'ORDER_ID' => $hppRequest->getOrderId(), 76 | 'AMOUNT' => $hppRequest->getAmount(), 77 | 'CURRENCY' => $hppRequest->getCurrency(), 78 | 'TIMESTAMP' => $hppRequest->getTimeStamp(), 79 | 'SHA1HASH' => $hppRequest->getHash(), 80 | 'AUTO_SETTLE_FLAG' => $hppRequest->getAutoSettleFlag(), 81 | 'COMMENT1' => $hppRequest->getCommentOne(), 82 | 'COMMENT2' => $hppRequest->getCommentTwo(), 83 | 'RETURN_TSS' => $hppRequest->getReturnTss(), 84 | 'SHIPPING_CODE' => $hppRequest->getShippingCode(), 85 | 'SHIPPING_CO' => $hppRequest->getShippingCountry(), 86 | 'BILLING_CODE' => $hppRequest->getBillingCode(), 87 | 'BILLING_CO' => $hppRequest->getBillingCountry(), 88 | 'CUST_NUM' => $hppRequest->getCustomerNumber(), 89 | 'VAR_REF' => $hppRequest->getVariableReference(), 90 | 'PROD_ID' => $hppRequest->getProductId(), 91 | 'HPP_LANG' => $hppRequest->getLanguage(), 92 | 'CARD_PAYMENT_BUTTON' => $hppRequest->getCardPaymentButtonText(), 93 | 'CARD_STORAGE_ENABLE' => $hppRequest->getCardStorageEnable(), 94 | 'OFFER_SAVE_CARD' => $hppRequest->getOfferSaveCard(), 95 | 'PAYER_REF' => $hppRequest->getPayerReference(), 96 | 'PMT_REF' => $hppRequest->getPaymentReference(), 97 | 'PAYER_EXIST' => $hppRequest->getPayerExists(), 98 | 'VALIDATE_CARD_ONLY' => $hppRequest->getValidateCardOnly(), 99 | 'DCC_ENABLE' => $hppRequest->getDccEnable() 100 | ); 101 | 102 | $supplementaryData = $hppRequest->getSupplementaryData(); 103 | 104 | if ( is_array( $supplementaryData ) ) { 105 | foreach ( $supplementaryData as $key => $value ) { 106 | $prop[ $key ] = $value; 107 | } 108 | } 109 | 110 | if($hppRequest->getHppVersion() != null) 111 | $prop['HPP_VERSION'] = $hppRequest->getHppVersion(); 112 | 113 | if($hppRequest->getHppSelectStoredCard() != null) 114 | $prop['HPP_SELECT_STORED_CARD'] = $hppRequest->getHppSelectStoredCard(); 115 | 116 | if($hppRequest->getPostDimensions() != null) 117 | $prop['HPP_POST_DIMENSIONS'] = $hppRequest->getPostDimensions(); 118 | 119 | if($hppRequest->getPostResponse() != null) 120 | $prop['HPP_POST_RESPONSE'] = $hppRequest->getPostResponse(); 121 | 122 | if ($hppRequest->getCustomerEmailAddress() != null) { 123 | $prop['HPP_CUSTOMER_EMAIL'] = $hppRequest->getCustomerEmailAddress(); 124 | } 125 | 126 | if ($hppRequest->getCustomerMobilePhoneNumber() != null) { 127 | $prop['HPP_CUSTOMER_PHONENUMBER_MOBILE'] = $hppRequest->getCustomerMobilePhoneNumber(); 128 | } 129 | 130 | if ($hppRequest->getBillingAddressLine1() != null) { 131 | $prop['HPP_BILLING_STREET1'] = $hppRequest->getBillingAddressLine1(); 132 | } 133 | 134 | if ($hppRequest->getBillingAddressLine2() != null) { 135 | $prop['HPP_BILLING_STREET2'] = $hppRequest->getBillingAddressLine2(); 136 | } 137 | 138 | if ($hppRequest->getBillingAddressLine3() != null) { 139 | $prop['HPP_BILLING_STREET3'] = $hppRequest->getBillingAddressLine3(); 140 | } 141 | 142 | if ($hppRequest->getBillingCity() != null) { 143 | $prop['HPP_BILLING_CITY'] = $hppRequest->getBillingCity(); 144 | } 145 | 146 | if ($hppRequest->getBillingState() != null) { 147 | $prop['HPP_BILLING_STATE'] = $hppRequest->getBillingState(); 148 | } 149 | 150 | if ($hppRequest->getBillingPostalCode() != null) { 151 | $prop['HPP_BILLING_POSTALCODE'] = $hppRequest->getBillingPostalCode(); 152 | } 153 | 154 | if ($hppRequest->getBillingCountryCode() != null) { 155 | $prop['HPP_BILLING_COUNTRY'] = $hppRequest->getBillingCountryCode(); 156 | } 157 | 158 | if ($hppRequest->getShippingAddressLine1() != null) { 159 | $prop['HPP_SHIPPING_STREET1'] = $hppRequest->getShippingAddressLine1(); 160 | } 161 | 162 | if ($hppRequest->getShippingAddressLine2() != null) { 163 | $prop['HPP_SHIPPING_STREET2'] = $hppRequest->getShippingAddressLine2(); 164 | } 165 | 166 | if ($hppRequest->getShippingAddressLine3() != null) { 167 | $prop['HPP_SHIPPING_STREET3'] = $hppRequest->getShippingAddressLine3(); 168 | } 169 | 170 | if ($hppRequest->getShippingCity() != null) { 171 | $prop['HPP_SHIPPING_CITY'] = $hppRequest->getShippingCity(); 172 | } 173 | 174 | if ($hppRequest->getShippingState() != null) { 175 | $prop['HPP_SHIPPING_STATE'] = $hppRequest->getShippingState(); 176 | } 177 | 178 | if ($hppRequest->getShippingPostalCode() != null) { 179 | $prop['HPP_SHIPPING_POSTALCODE'] = $hppRequest->getShippingPostalCode(); 180 | } 181 | 182 | if ($hppRequest->getShippingCountryCode() != null) { 183 | $prop['HPP_SHIPPING_COUNTRY'] = $hppRequest->getShippingCountryCode(); 184 | } 185 | 186 | if ($hppRequest->getShippingAddressMatchIndicator() != null) { 187 | $prop['HPP_ADDRESS_MATCH_INDICATOR'] = $hppRequest->getShippingAddressMatchIndicator() ? 'TRUE' : 'FALSE'; 188 | } 189 | 190 | if ($hppRequest->getChallengeRequestIndicator() != null) { 191 | $prop['HPP_CHALLENGE_REQUEST_INDICATOR'] = $hppRequest->getChallengeRequestIndicator(); 192 | } 193 | 194 | return json_encode( $prop ); 195 | } 196 | 197 | 198 | /** 199 | * 200 | * Receives a Json string and generates a domain object 201 | * 202 | * @param string $value 203 | * 204 | * @return HppRequest 205 | */ 206 | public function ReadValue( $value ) { 207 | $array = json_decode( $value, true ); 208 | $array = new SafeArrayAccess( $array, "" ); 209 | 210 | if ( $array ) { 211 | 212 | $hppRequest = new HppRequest(); 213 | 214 | $hppRequest->setMerchantId( $array['MERCHANT_ID'] ); 215 | $hppRequest->setAccount( $array['ACCOUNT'] ); 216 | $hppRequest->setOrderId( $array['ORDER_ID'] ); 217 | $hppRequest->setAmount( $array['AMOUNT'] ); 218 | $hppRequest->setCurrency( $array['CURRENCY'] ); 219 | $hppRequest->setTimeStamp( $array['TIMESTAMP'] ); 220 | $hppRequest->setHash( $array['SHA1HASH'] ); 221 | $hppRequest->setAutoSettleFlag( $array['AUTO_SETTLE_FLAG'] ); 222 | $hppRequest->setCommentOne( $array['COMMENT1'] ); 223 | $hppRequest->setCommentTwo( $array['COMMENT2'] ); 224 | $hppRequest->setReturnTss( $array['RETURN_TSS'] ); 225 | $hppRequest->setShippingCode( $array['SHIPPING_CODE'] ); 226 | $hppRequest->setShippingCountry( $array['SHIPPING_CO'] ); 227 | $hppRequest->setBillingCode( $array['BILLING_CODE'] ); 228 | $hppRequest->setBillingCountry( $array['BILLING_CO'] ); 229 | $hppRequest->setCustomerNumber( $array['CUST_NUM'] ); 230 | $hppRequest->setVariableReference( $array['VAR_REF'] ); 231 | $hppRequest->setProductId( $array['PROD_ID'] ); 232 | $hppRequest->setLanguage( $array['HPP_LANG'] ); 233 | $hppRequest->setCardPaymentButtonText( $array['CARD_PAYMENT_BUTTON'] ); 234 | $hppRequest->setValidateCardOnly( $array['VALIDATE_CARD_ONLY'] ); 235 | $hppRequest->setDccEnable( $array['DCC_ENABLE'] ); 236 | $hppRequest->setCardStorageEnable( $array['CARD_STORAGE_ENABLE'] ); 237 | $hppRequest->setOfferSaveCard( $array['OFFER_SAVE_CARD'] ); 238 | $hppRequest->setPayerReference( $array['PAYER_REF'] ); 239 | $hppRequest->setPaymentReference( $array['PMT_REF'] ); 240 | $hppRequest->setPayerExists( $array['PAYER_EXIST'] ); 241 | $hppRequest->setHppVersion( $array['HPP_VERSION'] ); 242 | $hppRequest->setHppSelectStoredCard( $array['HPP_SELECT_STORED_CARD'] ); 243 | $hppRequest->setPostDimensions( $array['HPP_POST_DIMENSIONS'] ); 244 | $hppRequest->setPostResponse( $array['HPP_POST_RESPONSE'] ); 245 | $hppRequest->setCustomerEmailAddress( $array['HPP_CUSTOMER_EMAIL'] ); 246 | $hppRequest->setCustomerMobilePhoneNumber( $array['HPP_CUSTOMER_PHONENUMBER_MOBILE'] ); 247 | $hppRequest->setBillingAddressLine1( $array['HPP_BILLING_STREET1'] ); 248 | $hppRequest->setBillingAddressLine2( $array['HPP_BILLING_STREET2'] ); 249 | $hppRequest->setBillingAddressLine3( $array['HPP_BILLING_STREET3'] ); 250 | $hppRequest->setBillingCity( $array['HPP_BILLING_CITY'] ); 251 | $hppRequest->setBillingState( $array['HPP_BILLING_STATE'] ); 252 | $hppRequest->setBillingPostalCode( $array['HPP_BILLING_POSTALCODE'] ); 253 | $hppRequest->setBillingCountryCode( $array['HPP_BILLING_COUNTRY'] ); 254 | $hppRequest->setShippingAddressLine1( $array['HPP_SHIPPING_STREET1'] ); 255 | $hppRequest->setShippingAddressLine2( $array['HPP_SHIPPING_STREET2'] ); 256 | $hppRequest->setShippingAddressLine3( $array['HPP_SHIPPING_STREET3'] ); 257 | $hppRequest->setShippingCity( $array['HPP_SHIPPING_CITY'] ); 258 | $hppRequest->setShippingState( $array['HPP_SHIPPING_STATE'] ); 259 | $hppRequest->setShippingPostalCode( $array['HPP_SHIPPING_POSTALCODE'] ); 260 | $hppRequest->setShippingCountryCode( $array['HPP_SHIPPING_COUNTRY'] ); 261 | $hppRequest->setShippingAddressMatchIndicator( $array['HPP_ADDRESS_MATCH_INDICATOR'] ); 262 | $hppRequest->setChallengeRequestIndicator( $array['HPP_CHALLENGE_REQUEST_INDICATOR'] ); 263 | 264 | $supplementaryData = array(); 265 | 266 | foreach ( $array->getUnderLayingArray() as $key => $value ) { 267 | 268 | if ( ! $this->isKnownProperty( $key ) ) { 269 | $supplementaryData[ $key ] = $value; 270 | } 271 | } 272 | 273 | $hppRequest->setSupplementaryData( $supplementaryData ); 274 | 275 | 276 | return $hppRequest; 277 | } 278 | 279 | return $array; 280 | } 281 | 282 | private function isKnownProperty( $key ) { 283 | return in_array( strtoupper( $key ), self::$KNOWN_FIELDS ); 284 | } 285 | 286 | 287 | } -------------------------------------------------------------------------------- /src/main/php/com-realexpayments-hpp-sdk/utils/ResponseMapper.php: -------------------------------------------------------------------------------- 1 | $hppResponse->getMerchantId(), 46 | 'ACCOUNT' => $hppResponse->getAccount(), 47 | 'ORDER_ID' => $hppResponse->getOrderId(), 48 | 'AMOUNT' => $hppResponse->getAmount(), 49 | 'AUTHCODE' => $hppResponse->getAuthCode(), 50 | 'TIMESTAMP' => $hppResponse->getTimeStamp(), 51 | 'SHA1HASH' => $hppResponse->getHash(), 52 | 'RESULT' => $hppResponse->getResult(), 53 | 'MESSAGE' => $hppResponse->getMessage(), 54 | 'CVNRESULT' => $hppResponse->getCvnResult(), 55 | 'PASREF' => $hppResponse->getPasRef(), 56 | 'BATCHID' => $hppResponse->getBatchId(), 57 | 'ECI' => $hppResponse->getEci(), 58 | 'CAVV' => $hppResponse->getCavv(), 59 | 'XID' => $hppResponse->getXid(), 60 | 'COMMENT1' => $hppResponse->getCommentOne(), 61 | 'COMMENT2' => $hppResponse->getCommentTwo(), 62 | 'TSS' => $hppResponse->getTss(), 63 | 'AVSADDRESSRESULT' => $hppResponse->getAVSAddressResult(), 64 | 'AVSPOSTCODERESULT' => $hppResponse->getAVSPostCodeResult() 65 | ); 66 | 67 | 68 | $supplementaryData = $hppResponse->getSupplementaryData(); 69 | 70 | if ( is_array( $supplementaryData ) ) { 71 | foreach ( $supplementaryData as $key => $value ) { 72 | $prop[ $key ] = $value; 73 | } 74 | } 75 | 76 | 77 | return json_encode( $prop ); 78 | } 79 | 80 | 81 | /** 82 | * 83 | * Receives a Json string and generates a domain object 84 | * 85 | * @param string $value 86 | * 87 | * @return HppResponse 88 | */ 89 | public function ReadValue( $value ) { 90 | $array = json_decode( $value, true ); 91 | $array = new SafeArrayAccess( $array, "" ); 92 | 93 | if ( $array ) { 94 | 95 | $hppResponse = new HppResponse(); 96 | 97 | $hppResponse->setMerchantId( $array['MERCHANT_ID'] ); 98 | $hppResponse->setAccount( $array['ACCOUNT'] ); 99 | $hppResponse->setOrderId( $array['ORDER_ID'] ); 100 | $hppResponse->setAmount( $array['AMOUNT'] ); 101 | $hppResponse->setAuthCode( $array['AUTHCODE'] ); 102 | $hppResponse->setTimeStamp( $array['TIMESTAMP'] ); 103 | $hppResponse->setHash( $array['SHA1HASH'] ); 104 | $hppResponse->setResult( $array['RESULT'] ); 105 | $hppResponse->setMessage( $array['MESSAGE'] ); 106 | $hppResponse->setCvnResult( $array['CVNRESULT'] ); 107 | $hppResponse->setPasRef( $array['PASREF'] ); 108 | $hppResponse->setBatchId( $array['BATCHID'] ); 109 | $hppResponse->setEci( $array['ECI'] ); 110 | $hppResponse->setCavv( $array['CAVV'] ); 111 | $hppResponse->setXid( $array['XID'] ); 112 | $hppResponse->setCommentOne( $array['COMMENT1'] ); 113 | $hppResponse->setCommentTwo( $array['COMMENT2'] ); 114 | $hppResponse->setTss( $array['TSS'] ); 115 | $hppResponse->setAVSAddressResult( $array['AVSADDRESSRESULT'] ); 116 | $hppResponse->setAVSPostCodeResult( $array['AVSPOSTCODERESULT'] ); 117 | 118 | 119 | foreach ( $array->getUnderLayingArray() as $key => $value ) { 120 | 121 | if ( ! $this->isKnownProperty( $key ) ) { 122 | $hppResponse->setSupplementaryDataValue( $key, $value ); 123 | } 124 | } 125 | 126 | return $hppResponse; 127 | } 128 | 129 | return $array; 130 | } 131 | 132 | private function isKnownProperty( $key ) { 133 | return in_array( strtoupper( $key ), self::$KNOWN_FIELDS ); 134 | } 135 | 136 | 137 | } -------------------------------------------------------------------------------- /src/main/php/com-realexpayments-hpp-sdk/utils/SafeArrayAccess.php: -------------------------------------------------------------------------------- 1 | array = $array; 15 | $this->default = $default; 16 | } 17 | 18 | public function offsetExists( $offset ) { 19 | return isset( $this->array[ $offset ] ); 20 | } 21 | 22 | public function offsetGet( $offset ) { 23 | return isset( $this->array[ $offset ] ) 24 | ? $this->array[ $offset ] 25 | : $this->default; 26 | } 27 | 28 | public function offsetSet( $offset, $value ) { 29 | $this->array[ $offset ] = $value; 30 | } 31 | 32 | public function offsetUnset( $offset ) { 33 | unset( $this->array[ $offset ] ); 34 | } 35 | 36 | public function getUnderLayingArray() 37 | { 38 | return $this->array; 39 | } 40 | } -------------------------------------------------------------------------------- /src/main/php/com-realexpayments-hpp-sdk/utils/ValidationUtils.php: -------------------------------------------------------------------------------- 1 | validate( $hppRequest ); 46 | 47 | if ( $violations->count() > 0 ) { 48 | $validationMessages = array(); 49 | 50 | foreach ( $violations as $violation ) { 51 | 52 | /* @var ConstraintViolationInterface $violation */ 53 | $validationMessages[] = $violation->getMessage(); 54 | } 55 | 56 | $message = "HppRequest failed validation with the following errors:"; 57 | foreach ( $validationMessages as $validationMessage ) { 58 | $message .= $validationMessage . '.'; 59 | } 60 | 61 | self::$logger->info( $message ); 62 | throw new RealexValidationException( "HppRequest failed validation", $validationMessages ); 63 | } 64 | 65 | } 66 | 67 | 68 | private static function Initialise() { 69 | if ( self::$initialised ) { 70 | return; 71 | } 72 | 73 | $file = self::getVendorFile(); 74 | $loader = require $file; 75 | 76 | AnnotationRegistry::registerLoader( array( $loader, 'loadClass' ) ); 77 | 78 | self::$logger = RXPLogger::getLogger( __CLASS__ ); 79 | 80 | self::$validator = Validation::createValidatorBuilder() 81 | ->enableAnnotationMapping() 82 | ->getValidator(); 83 | 84 | 85 | self::$initialised = true; 86 | } 87 | 88 | private static function getVendorFile() { 89 | $vendor_dir = __DIR__ . "/../../../../../vendor"; 90 | $file = $vendor_dir . '/autoload.php'; 91 | 92 | 93 | if ( ! file_exists( $file ) ) { 94 | $vendor_dir = __DIR__ . "/../../../../../../../../vendor"; 95 | $file = $vendor_dir . '/autoload.php'; 96 | } 97 | 98 | return $file; 99 | } 100 | 101 | /** 102 | * Method validates HPP response hash. 103 | * 104 | * @param HppResponse $hppResponse 105 | * @param string $secret 106 | */ 107 | public static function validateResponse( HppResponse $hppResponse, $secret ) { 108 | self::Initialise(); 109 | 110 | if ( ! $hppResponse->isHashValid( $secret ) ) { 111 | self::$logger->error( "HppResponse contains an invalid security hash." ); 112 | throw new RealexValidationException( "HppResponse contains an invalid security hash", array( "HppResponse contains an invalid security hash" ) ); 113 | } 114 | } 115 | } -------------------------------------------------------------------------------- /src/main/php/com-realexpayments-hpp-sdk/utils/iMapper.php: -------------------------------------------------------------------------------- 1 | getValidateCardOnly()) { 36 | if ($hppRequest->getAmount() != "0") { 37 | $this->context->buildViolation($constraint->message) 38 | ->atPath('amount') 39 | ->addViolation(); 40 | 41 | } 42 | } 43 | 44 | } 45 | } -------------------------------------------------------------------------------- /src/main/php/com-realexpayments-hpp-sdk/validators/SupplementaryDataLength.php: -------------------------------------------------------------------------------- 1 | getSupplementaryData() as $supplementaryData ) { 34 | if ( strlen( $supplementaryData ) > $this->maxLength ) { 35 | $this->context->buildViolation( $constraint->message ) 36 | ->atPath( 'supplementaryData' ) 37 | ->addViolation(); 38 | } 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/main/php/com-realexpayments-hpp-sdk/validators/SupplementaryDataPattern.php: -------------------------------------------------------------------------------- 1 | getSupplementaryData() as $supplementaryData ) { 32 | if ( ! preg_match( $constraint->pattern, $supplementaryData ) ) { 33 | $this->context->buildViolation( $constraint->message ) 34 | ->atPath( 'supplementaryData' ) 35 | ->addViolation(); 36 | } 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/main/php/com-realexpayments-hpp-sdk/validators/ValidationMessages.php: -------------------------------------------------------------------------------- 1 | | and contain only a-z A-Z 0-9 , . - / | spaces"; 44 | 45 | const hppRequest_shippingCountry_size = "Shipping country must not contain more than 50 characters"; 46 | const hppRequest_shippingCountry_pattern = "Shipping country must only contain the characters A-Z a-z 0-9 , . -"; 47 | 48 | const hppRequest_billingCode_size = "Billing code must not be more than 60 characters in length"; 49 | const hppRequest_billingCode_pattern = "Billing code must be of format | and contain only a-z A-Z 0-9 , . - / | spaces"; 50 | 51 | const hppRequest_billingCountry_size = "Billing country must not contain more than 50 characters"; 52 | const hppRequest_billingCountry_pattern = "Billing country must only contain the characters A-Z a-z 0-9 , . -"; 53 | 54 | const hppRequest_customerNumber_size = "Customer number must not contain more than 50 characters"; 55 | const hppRequest_customerNumber_pattern = "Customer number must only contain the characters a-z A-Z 0-9 - _ . , + @ spaces"; 56 | 57 | const hppRequest_variableReference_size = "Variable reference must not contain more than 50 characters"; 58 | const hppRequest_variableReference_pattern = "Variable reference must only contain the characters a-z A-Z 0-9 - _ . , + @ spaces"; 59 | 60 | const hppRequest_productId_size = "Product ID must not contain more than 50 characters"; 61 | const hppRequest_productId_pattern = "Product ID must only contain the characters a-z A-Z 0-9 - _ . , + @ spaces"; 62 | 63 | const hppRequest_language_pattern = "Language must be 2 alphabetic characters only"; 64 | 65 | const hppRequest_cardPaymentButtonText_size = "Card payment button text must not contain more than 25 characters"; 66 | const hppRequest_cardPaymentButtonText_pattern = "Card payment button text must only contain the characters a-z A-Z 0-9 ' , + \\u201C \\u201D ._ - & \\ / @!? % ( ) * :� $ & \\u20AC # [] | =\""; 67 | 68 | const hppRequest_cardStorageEnable_size = "Card storage enable flag must not be more than 1 character in length"; 69 | const hppRequest_cardStorageEnable_pattern = "Card storage enable flag must be 1 or 0"; 70 | 71 | const hppRequest_offerSaveCard_size = "Offer to save card flag must not be more than 1 character in length"; 72 | const hppRequest_offerSaveCard_pattern = "Offer to save card flag must be 1 or 0"; 73 | 74 | const hppRequest_payerReference_size = "Payer reference must not be more than 50 characters in length"; 75 | const hppRequest_payerReference_pattern = "Payer reference must only contain the characters a-z A-Z\\ 0-9 _ spaces"; 76 | 77 | const hppRequest_paymentReference_size = "Payment reference must not be more than 50 characters in length"; 78 | const hppRequest_paymentReference_pattern = "Payment reference must only contain characters a-z A-Z 0-9 _ - spaces"; 79 | 80 | const hppRequest_payerExists_size = "Payer exists flag must not be more than 1 character in length"; 81 | const hppRequest_payerExists_pattern = "Payer exists flag must be 0, 1 or 2"; 82 | 83 | const hppRequest_validateCardOnly_size = "Validate card only flag must not be more than 1 character in length"; 84 | const hppRequest_validateCardOnly_pattern = "Validate card only flag must be 1 or 0"; 85 | 86 | const hppRequest_dccEnable_size = "DCC enable flag must not be more than 1 character in length"; 87 | const hppRequest_dccEnable_pattern = "DCC enable flag must be 1 or 0"; 88 | 89 | const hppRequest_supplementary_data_pattern = "Supplementary data text must only contain the characters a-z A-Z 0-9 ' , + \\u201C \\u201D ._ - & \\ / @!? % ( ) * :� $ & \\u20AC # [] | =\""; 90 | const hppRequest_supplementary_data_size = "Supplementary data must not be more than 255 character in length"; 91 | 92 | const hppRequest_hppVersion_size = "Version flag must not be more than 1 character in length"; 93 | const hppRequest_hppVersion_pattern = "Version must only contain the numbers between 1 and 2"; 94 | 95 | const hppRequest_hppSelectStoredCard_size = "Select stored card must not be more than 50 characters in length"; 96 | const hppRequest_hppSelectStoredCard_pattern = "Select stored card must only contain the characters a-z A-Z/0-9 _ spaces"; 97 | 98 | const hppRequest_postDimensions_size = "Post Dimensions must be less than 255 characters in length"; 99 | const hppRequest_postDimensions_pattern = "Post Dimensions must only contain the characters a-z A-Z 0-9 ' \", + \\u201C\\u201D ._ - & \\ / @ ! ? % ( ) * : £ $ & \\u20AC # [ ] | = ; ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿ\\u0152\\u017D\\u0161\\u0153\\u017E\\u0178¥"; 100 | 101 | const hppRequest_postResponse_size = "Post Response must be less than 255 characters in length"; 102 | const hppRequest_postResponse_pattern = "Post Dimensions must only contain the characters a-z A-Z 0-9 ' \", + \\u201C\\u201D ._ - & \\ / @ ! ? % ( ) * : £ $ & \\u20AC # [ ] | = ; ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿ\\u0152\\u017D\\u0161\\u0153\\u017E\\u0178¥"; 103 | 104 | } -------------------------------------------------------------------------------- /test/main/php/com-realexpayments-hpp-sdk/RealexHppTest.php: -------------------------------------------------------------------------------- 1 | requestToJson($hppRequestExpected); 32 | 33 | $realexHPP = self::$realex_HPP; 34 | 35 | $hppRequestConverted = self::$realex_HPP->requestFromJson($json); 36 | $hppRequestExpected->decode($realexHPP::ENCODING_CHARSET); 37 | SampleJsonData::checkValidHppRequest($hppRequestExpected, $hppRequestConverted, false, $this); 38 | SampleJsonData::checkValidHppRequestSupplementaryData($hppRequestConverted, $this); 39 | } 40 | 41 | /** 42 | * Test converting encoded JSON to {@link HppRequest}. 43 | */ 44 | public function testRequestFromJsonEncodedSuccess() 45 | { 46 | $hppRequestExpected = SampleJsonData::generateValidHppRequest(false); 47 | 48 | $path = SampleJsonData::VALID_HPP_REQUEST_ENCODED_JSON_PATH; 49 | $prefix = __DIR__ . '/../../resources'; 50 | $json = file_get_contents($prefix . $path); 51 | 52 | $realexHPP = self::$realex_HPP; 53 | $hppRequestConverted = $realexHPP->requestFromJson($json); 54 | SampleJsonData::checkValidHppRequest($hppRequestExpected, $hppRequestConverted, false, $this); 55 | } 56 | 57 | /** 58 | * Test converting unencoded JON to {@link HppRequest}. 59 | */ 60 | public function testRequestFromJsonDecodedSuccess() 61 | { 62 | $hppRequestExpected = SampleJsonData::generateValidHppRequest(false); 63 | 64 | $path = SampleJsonData::VALID_HPP_REQUEST_JSON_PATH; 65 | $prefix = __DIR__ . '/../../resources'; 66 | $json = file_get_contents($prefix . $path); 67 | 68 | $realexHPP = self::$realex_HPP; 69 | $hppRequestConverted = $realexHPP->requestFromJson($json, false); 70 | SampleJsonData::checkValidHppRequest($hppRequestExpected, $hppRequestConverted, false, $this); 71 | } 72 | 73 | 74 | public function testRequestFromJsonCardStorageSuccess() 75 | { 76 | $hppRequestExpected = SampleJsonData::generateValidHppRequest(true); 77 | 78 | $path = SampleJsonData::VALID_HPP_REQUEST_CARD_STORAGE_JSON_PATH; 79 | $prefix = __DIR__ . '/../../resources'; 80 | $json = file_get_contents($prefix . $path); 81 | 82 | $realexHPP = self::$realex_HPP; 83 | $hppRequestConverted = $realexHPP->requestFromJson($json, false); 84 | SampleJsonData::checkValidHppRequest($hppRequestExpected, $hppRequestConverted, false, $this); 85 | } 86 | 87 | /** 88 | * Test converting {@link HppResponse} to JSON. Includes hash validation. 89 | */ 90 | public function testResponseToJsonSuccess() 91 | { 92 | $hppResponseExpected = SampleJsonData::generateValidHppResponse(); 93 | $json = self::$realex_HPP->responseToJson($hppResponseExpected); 94 | 95 | $realexHPP = self::$realex_HPP; 96 | 97 | $hppResponseConverted = self::$realex_HPP->responseFromJson($json); 98 | $hppResponseExpected->decode($realexHPP::ENCODING_CHARSET); 99 | 100 | SampleJsonData::checkValidHppResponse($hppResponseExpected, $hppResponseConverted, $this); 101 | SampleJsonData::checkValidHppResponseSupplementaryData($hppResponseConverted, $this); 102 | } 103 | 104 | /** 105 | * Test converting encoded JSON to {@link HppResponse}. 106 | */ 107 | public function testResponseFromJsonEncodedSuccess() 108 | { 109 | $hppResponseExpected = SampleJsonData::generateValidHppResponse(); 110 | 111 | $path = SampleJsonData::VALID_HPP_RESPONSE_ENCODED_JSON_PATH; 112 | $prefix = __DIR__ . '/../../resources'; 113 | $json = file_get_contents($prefix . $path); 114 | 115 | $hppResponseConverted = self::$realex_HPP->responseFromJson($json); 116 | 117 | SampleJsonData::checkValidHppResponse($hppResponseExpected, $hppResponseConverted, $this); 118 | SampleJsonData::checkValidHppResponseSupplementaryData($hppResponseConverted, $this); 119 | } 120 | 121 | /** 122 | * Test converting unencoded JSON to {@link HppResponse}. 123 | */ 124 | public function testResponseFromJsonDecodedSuccess() 125 | { 126 | $hppResponseExpected = SampleJsonData::generateValidHppResponse(); 127 | 128 | $path = SampleJsonData::VALID_HPP_RESPONSE_JSON_PATH; 129 | $prefix = __DIR__ . '/../../resources'; 130 | $json = file_get_contents($prefix . $path); 131 | 132 | $hppResponseConverted = self::$realex_HPP->responseFromJson($json, false); 133 | 134 | SampleJsonData::checkValidHppResponse($hppResponseExpected, $hppResponseConverted, $this); 135 | } 136 | 137 | /** 138 | * Test converting unencoded JSON to {@link HppResponse}. 139 | */ 140 | public function testResponseFromJsonDecodedSuccessWithUnknown() 141 | { 142 | $hppResponseExpected = SampleJsonData::generateValidHppResponse(); 143 | 144 | $path = SampleJsonData::UNKNOWN_DATA_HPP_RESPONSE_JSON_PATH; 145 | $prefix = __DIR__ . '/../../resources'; 146 | $json = file_get_contents($prefix . $path); 147 | 148 | $hppResponseConverted = self::$realex_HPP->responseFromJson($json, false); 149 | 150 | SampleJsonData::checkValidHppResponse($hppResponseExpected, $hppResponseConverted, $this); 151 | SampleJsonData::checkValidHppResponseSupplementaryData($hppResponseConverted, $this); 152 | } 153 | 154 | 155 | } 156 | -------------------------------------------------------------------------------- /test/main/php/com-realexpayments-hpp-sdk/SampleJsonData.php: -------------------------------------------------------------------------------- 1 | addHash(self::HASH_REQUEST) 126 | ->addOrderId(self::ORDER_ID) 127 | ->addTimeStamp(self::TIMESTAMP); 128 | 129 | return $hppRequest; 130 | 131 | } 132 | 133 | /** 134 | * Generates {@link HppRequest} object with empty defaults (time stamp and order ID). 135 | * 136 | * @param bool $cardStorage 137 | * 138 | * @return HppRequest 139 | */ 140 | public static function generateValidHppRequestWithEmptyDefaults($cardStorage) 141 | { 142 | $hppRequest = new HppRequest(); 143 | $hppRequest->addAccount(self::ACCOUNT) 144 | ->addAmount(self::AMOUNT) 145 | ->addAutoSettleFlag(self::AUTO_SETTLE_FLAG == Flag::TRUE ? 1 : 0) 146 | ->addBillingCode(self::BILLING_CODE) 147 | ->addBillingCountry(self::BILLING_COUNTRY) 148 | ->addCardPaymentButtonText(self::CARD_PAYMENT_BUTTON_TEXT) 149 | ->addCardStorageEnable(self::CARD_STORAGE_ENABLE == Flag::TRUE ? 1 : 0) 150 | ->addCommentOne(self::COMMENT_ONE) 151 | ->addCommentTwo(self::COMMENT_TWO) 152 | ->addCurrency(self::CURRENCY) 153 | ->addCustomerNumber(self::CUSTOMER_NUMBER) 154 | ->addLanguage(self::LANGUAGE) 155 | ->addMerchantId(self::MERCHANT_ID) 156 | ->addOfferSaveCard(self::OFFER_SAVE_CARD == Flag::TRUE ? 1 : 0) 157 | ->addPayerExists(self::PAYER_EXISTS == Flag::TRUE ? 1 : 0) 158 | ->addPayerReference(self::PAYER_REF) 159 | ->addPaymentReference(self::PAYMENT_REF) 160 | ->addProductId(self::PRODUCT_ID) 161 | ->addReturnTss(self::RETURN_TSS == Flag::TRUE ? 1 : 0) 162 | ->addShippingCode(self::SHIPPING_CODE) 163 | ->addShippingCountry(self::SHIPPING_COUNTRY) 164 | ->addVariableReference(self::VARIABLE_REFERENCE) 165 | ->addValidateCardOnly(self::VALIDATE_CARD_ONLY) 166 | ->addDccEnable(self::DCC_ENABLE) 167 | ->addHppVersion(self::HPP_VERSION) 168 | ->addhppSelectStoredCard(self::HPP_SELECT_STORED_CARD); 169 | 170 | 171 | $hppRequest->setTimeStamp(self::TIMESTAMP); 172 | $hppRequest->setHash(self::HASH_REQUEST); 173 | 174 | if ($cardStorage) { 175 | $hppRequest->setCardStorageEnable(Flag::TRUE); 176 | $hppRequest->setOfferSaveCard(Flag::TRUE); 177 | } 178 | 179 | 180 | $hppRequest->setSupplementaryData(self::$SUPPLEMENTARY_DATA); 181 | 182 | return $hppRequest; 183 | } 184 | 185 | 186 | static function Init() 187 | { 188 | self::$SUPPLEMENTARY_DATA = self::generateSupplementaryData(); 189 | self::$TSS = self::generateTSS(); 190 | } 191 | 192 | /** 193 | * Generate map of supplementary data. 194 | * @return array 195 | */ 196 | public static function generateSupplementaryData() 197 | { 198 | 199 | $data = array(); 200 | $data[self::UNKNOWN_ONE_KEY] = self::UNKNOWN_ONE_VALUE; 201 | $data[self::UNKNOWN_TWO_KEY] = self::UNKNOWN_TWO_VALUE; 202 | $data[self::UNKNOWN_THREE_KEY] = self::UNKNOWN_THREE_VALUE; 203 | $data[self::UNKNOWN_FOUR_KEY] = self::UNKNOWN_FOUR_VALUE; 204 | 205 | return $data; 206 | } 207 | 208 | public static function generateTSS() 209 | { 210 | $data = array(); 211 | $data[self::TSS_ONE_KEY] = self::TSS_ONE_VALUE; 212 | $data[self::TSS_TWO_KEY] = self::TSS_TWO_VALUE; 213 | 214 | 215 | return $data; 216 | } 217 | 218 | 219 | 220 | /** 221 | * Checks expected and converted {@link HppRequest} objects. 222 | * 223 | * @param HppRequest $hppRequestExpected 224 | * @param HppRequest $hppRequestConverted 225 | * @param bool $defaultsGenerated 226 | * @param PHPUnit_Framework_TestCase $testCase 227 | */ 228 | public static function checkValidHppRequest(HppRequest $hppRequestExpected, HppRequest $hppRequestConverted, 229 | $defaultsGenerated, PHPUnit_Framework_TestCase $testCase) 230 | { 231 | $testCase->assertEquals($hppRequestExpected->getAccount(), $hppRequestConverted->getAccount(), "Json conversion incorrect Account"); 232 | $testCase->assertEquals($hppRequestExpected->getAmount(), $hppRequestConverted->getAmount(), "Json conversion incorrect Amount"); 233 | $testCase->assertEquals($hppRequestExpected->getAutoSettleFlag(), 234 | $hppRequestConverted->getAutoSettleFlag(), "Json conversion incorrect Auto Settle Flag"); 235 | $testCase->assertEquals($hppRequestExpected->getBillingCode(), $hppRequestConverted->getBillingCode(), "Json conversion incorrect Billing Code"); 236 | $testCase->assertEquals($hppRequestExpected->getBillingCountry(), 237 | $hppRequestConverted->getBillingCountry(), "Json conversion incorrect Billing Country"); 238 | $testCase->assertEquals($hppRequestExpected->getCardPaymentButtonText(), 239 | $hppRequestConverted->getCardPaymentButtonText(), "Json conversion incorrect Card Payment Button Text"); 240 | 241 | $testCase->assertEquals($hppRequestExpected->getCardStorageEnable(), 242 | $hppRequestConverted->getCardStorageEnable(),"Json conversion incorrect Card Storage Enable"); 243 | $testCase->assertEquals($hppRequestExpected->getCommentOne(), $hppRequestConverted->getCommentOne(), "Json conversion incorrect Comment One"); 244 | $testCase->assertEquals($hppRequestExpected->getCommentTwo(), $hppRequestConverted->getCommentTwo(), "Json conversion incorrect Comment Two"); 245 | $testCase->assertEquals($hppRequestExpected->getCurrency(), $hppRequestConverted->getCurrency(), "Json conversion incorrect Currency"); 246 | $testCase->assertEquals($hppRequestExpected->getCustomerNumber(), 247 | $hppRequestConverted->getCustomerNumber(), "Json conversion incorrect Customer Number"); 248 | $testCase->assertEquals($hppRequestExpected->getLanguage(), $hppRequestConverted->getLanguage(), "Json conversion incorrect HPP Language"); 249 | $testCase->assertEquals($hppRequestExpected->getMerchantId(), $hppRequestConverted->getMerchantId(), "Json conversion incorrect Merchant ID"); 250 | 251 | $testCase->assertEquals($hppRequestExpected->getOfferSaveCard(), 252 | $hppRequestConverted->getOfferSaveCard(),"Json conversion incorrect Offer Save Card"); 253 | $testCase->assertEquals( $hppRequestExpected->getPayerExists(), $hppRequestConverted->getPayerExists(),"Json conversion incorrect Payer Exists"); 254 | $testCase->assertEquals($hppRequestExpected->getPayerReference(), 255 | $hppRequestConverted->getPayerReference(),"Json conversion incorrect Payer Reference"); 256 | $testCase->assertEquals( $hppRequestExpected->getPaymentReference(), 257 | $hppRequestConverted->getPaymentReference(),"Json conversion incorrect Payment Reference"); 258 | 259 | $testCase->assertEquals($hppRequestExpected->getProductId(), $hppRequestConverted->getProductId(), "Json conversion incorrect Product ID"); 260 | $testCase->assertEquals($hppRequestExpected->getReturnTss(), $hppRequestConverted->getReturnTss(), "Json conversion incorrect Return TSS"); 261 | $testCase->assertEquals($hppRequestExpected->getShippingCode(), $hppRequestConverted->getShippingCode(), "Json conversion incorrect Shipping Code"); 262 | $testCase->assertEquals($hppRequestExpected->getShippingCountry(), 263 | $hppRequestConverted->getShippingCountry(), "Json conversion incorrect Shipping Country"); 264 | $testCase->assertEquals($hppRequestExpected->getVariableReference(), 265 | $hppRequestConverted->getVariableReference(), "Json conversion incorrect Variable Reference"); 266 | 267 | if (!$defaultsGenerated) { 268 | $testCase->assertEquals($hppRequestExpected->getTimeStamp(), $hppRequestConverted->getTimeStamp(), "Json conversion incorrect Time Stamp"); 269 | $testCase->assertEquals($hppRequestExpected->getHash(), $hppRequestConverted->getHash(), "Json conversion incorrect Hash"); 270 | $testCase->assertEquals($hppRequestExpected->getOrderId(), $hppRequestConverted->getOrderId(), "Json conversion incorrect Order ID"); 271 | } else { 272 | $testCase->assertNotNull($hppRequestConverted->getTimeStamp(), "Time Stamp failed to generate"); 273 | $testCase->assertNotNull($hppRequestConverted->getHash(), "Hash failed to generate"); 274 | $testCase->assertNotNull($hppRequestConverted->getOrderId(), "Order ID failed to generate"); 275 | } 276 | 277 | $testCase->assertEquals($hppRequestExpected->getValidateCardOnly(), 278 | $hppRequestConverted->getValidateCardOnly(), "Json conversion incorrect Validate Card Only"); 279 | $testCase->assertEquals($hppRequestExpected->getDccEnable(), 280 | $hppRequestConverted->getDccEnable(), "Json conversion incorrect DCC Enable"); 281 | } 282 | 283 | /** 284 | * Checks request supplementary data matches expected values. 285 | * 286 | * @param HppRequest $hppRequestConverted 287 | * @param PHPUnit_Framework_TestCase $testCase 288 | */ 289 | public static function checkValidHppRequestSupplementaryData(HppRequest $hppRequestConverted, 290 | PHPUnit_Framework_TestCase $testCase) 291 | { 292 | 293 | $supplementaryData = $hppRequestConverted->getSupplementaryData(); 294 | 295 | $testCase->assertEquals(self::UNKNOWN_ONE_VALUE, 296 | $supplementaryData[self::UNKNOWN_ONE_KEY], "Json conversion incorrect Unknown one"); 297 | $testCase->assertEquals(self::UNKNOWN_TWO_VALUE, 298 | $supplementaryData[self::UNKNOWN_TWO_KEY], "Json conversion incorrect Unknown one"); 299 | $testCase->assertEquals(self::UNKNOWN_THREE_VALUE, 300 | $supplementaryData[self::UNKNOWN_THREE_KEY], "Json conversion incorrect Unknown one"); 301 | $testCase->assertEquals(self::UNKNOWN_FOUR_VALUE, 302 | $supplementaryData[self::UNKNOWN_FOUR_KEY], "Json conversion incorrect Unknown one"); 303 | 304 | $testCase->assertEquals(sizeof(self::$SUPPLEMENTARY_DATA), 305 | sizeof($supplementaryData), "Json conversion incorrect size"); 306 | } 307 | 308 | /** 309 | * Generates valid {@link HppResponse} object. 310 | * 311 | * @return HppResponse 312 | */ 313 | public static function generateValidHppResponse() 314 | { 315 | $hppResponse = new HppResponse(); 316 | 317 | $hppResponse->setAccount(self::ACCOUNT); 318 | $hppResponse->setAmount(self::AMOUNT); 319 | $hppResponse->setAuthCode(self::AUTH_CODE); 320 | $hppResponse->setBatchId(self::BATCH_ID); 321 | $hppResponse->setCavv(self::CAVV); 322 | $hppResponse->setCommentOne(self::COMMENT_ONE); 323 | $hppResponse->setCommentTwo(self::COMMENT_TWO); 324 | $hppResponse->setCvnResult(self::CVN_RESULT); 325 | $hppResponse->setEci(self::ECI); 326 | $hppResponse->setHash(self::HASH_RESPONSE); 327 | $hppResponse->setMerchantId(self::MERCHANT_ID_RESPONSE); 328 | $hppResponse->setMessage(self::MESSAGE); 329 | $hppResponse->setOrderId(self::ORDER_ID_RESPONSE); 330 | $hppResponse->setPasRef(self::PAS_REF); 331 | $hppResponse->setResult(self::RESULT); 332 | $hppResponse->setTimeStamp(self::TIMESTAMP_RESPONSE); 333 | $hppResponse->setTss(self::$TSS); 334 | $hppResponse->setXid(self::XID); 335 | $hppResponse->setAVSAddressResult(self::AVS_ADDRESS); 336 | $hppResponse->setAVSPostCodeResult(self::AVS_POSTCODE); 337 | 338 | foreach (self::$SUPPLEMENTARY_DATA as $key => $value) { 339 | $hppResponse->setSupplementaryDataValue($key, $value); 340 | } 341 | 342 | return $hppResponse; 343 | } 344 | 345 | /** 346 | * @param HppResponse $hppResponseExpected 347 | * @param HppResponse $hppResponseConverted 348 | * @param PHPUnit_Framework_TestCase $testCase 349 | */ 350 | public static function checkValidHppResponse(HppResponse $hppResponseExpected, HppResponse $hppResponseConverted, 351 | PHPUnit_Framework_TestCase $testCase) 352 | { 353 | $testCase->assertEquals($hppResponseExpected->getAccount(), $hppResponseConverted->getAccount(), "Json conversion incorrect Account"); 354 | $testCase->assertEquals($hppResponseExpected->getAmount(), $hppResponseConverted->getAmount(), "Json conversion incorrect Amount"); 355 | $testCase->assertEquals($hppResponseExpected->getCommentOne(), $hppResponseConverted->getCommentOne(), "Json conversion incorrect Comment One"); 356 | $testCase->assertEquals($hppResponseExpected->getCommentTwo(), $hppResponseConverted->getCommentTwo(), "Json conversion incorrect Comment Two"); 357 | $testCase->assertEquals($hppResponseExpected->getMerchantId(), $hppResponseConverted->getMerchantId(), "Json conversion incorrect Merchant ID"); 358 | $testCase->assertEquals($hppResponseExpected->getTimeStamp(), $hppResponseConverted->getTimeStamp(), "Json conversion incorrect Time Stamp"); 359 | $testCase->assertEquals($hppResponseExpected->getHash(), $hppResponseConverted->getHash(), "Json conversion incorrect Hash"); 360 | $testCase->assertEquals($hppResponseExpected->getOrderId(), $hppResponseConverted->getOrderId(), "Json conversion incorrect Order ID"); 361 | $testCase->assertEquals($hppResponseExpected->getAuthCode(), $hppResponseConverted->getAuthCode(), "Json conversion incorrect Auth Code"); 362 | $testCase->assertEquals($hppResponseExpected->getBatchId(), $hppResponseConverted->getBatchId(), "Json conversion incorrect Batch ID"); 363 | $testCase->assertEquals($hppResponseExpected->getCavv(), $hppResponseConverted->getCavv(), "Json conversion incorrect CAVV"); 364 | $testCase->assertEquals($hppResponseExpected->getCvnResult(), $hppResponseConverted->getCvnResult(), "Json conversion incorrect CVN Result"); 365 | $testCase->assertEquals($hppResponseExpected->getEci(), $hppResponseConverted->getEci(), "Json conversion incorrect ECI"); 366 | $testCase->assertEquals($hppResponseExpected->getMessage(), $hppResponseConverted->getMessage(), "Json conversion incorrect Message"); 367 | $testCase->assertEquals($hppResponseExpected->getPasRef(), $hppResponseConverted->getPasRef(), "Json conversion incorrect Pas Ref"); 368 | $testCase->assertEquals($hppResponseExpected->getResult(), $hppResponseConverted->getResult(), "Json conversion incorrect Result"); 369 | $testCase->assertEquals($hppResponseExpected->getXid(), $hppResponseConverted->getXid(), "Json conversion incorrect XID"); 370 | 371 | $testCase->assertEquals($hppResponseExpected->getAVSAddressResult(), $hppResponseConverted->getAVSAddressResult(), "Json conversion incorrect AVS Address Result"); 372 | $testCase->assertEquals($hppResponseExpected->getAVSPostCodeResult(), $hppResponseConverted->getAVSPostCodeResult(), "Json conversion incorrect AVS Address Postcode"); 373 | 374 | $tss = $hppResponseExpected->getTss(); 375 | $convertedTss = $hppResponseConverted->getTss(); 376 | $testCase->assertEquals($tss[self::TSS_ONE_KEY], 377 | $convertedTss[self::TSS_ONE_KEY], "Json conversion incorrect TSS Entry"); 378 | $testCase->assertEquals($tss[self::TSS_TWO_KEY], 379 | $convertedTss[self::TSS_TWO_KEY], "Json conversion incorrect TSS Entry"); 380 | 381 | $testCase->assertEquals(sizeof(self::$TSS), 382 | sizeof($convertedTss), "Json conversion incorrect size"); 383 | 384 | $testCase->assertEquals(sizeof($tss), 385 | sizeof($convertedTss), "Json conversion incorrect size"); 386 | } 387 | 388 | /** 389 | * Checks request supplementary data matches expected values. 390 | * 391 | * @param HppResponse $hppResponse 392 | * @param PHPUnit_Framework_TestCase $testCase 393 | */ 394 | public static function checkValidHppResponseSupplementaryData(HppResponse $hppResponse, 395 | PHPUnit_Framework_TestCase $testCase) 396 | { 397 | $supplementaryData = $hppResponse->getSupplementaryData(); 398 | 399 | $testCase->assertEquals(self::UNKNOWN_ONE_VALUE, 400 | $supplementaryData[self::UNKNOWN_ONE_KEY], "Json conversion incorrect Unknown one"); 401 | $testCase->assertEquals(self::UNKNOWN_TWO_VALUE, 402 | $supplementaryData[self::UNKNOWN_TWO_KEY], "Json conversion incorrect Unknown one"); 403 | $testCase->assertEquals(self::UNKNOWN_THREE_VALUE, 404 | $supplementaryData[self::UNKNOWN_THREE_KEY], "Json conversion incorrect Unknown one"); 405 | $testCase->assertEquals(self::UNKNOWN_FOUR_VALUE, 406 | $supplementaryData[self::UNKNOWN_FOUR_KEY], "Json conversion incorrect Unknown one"); 407 | 408 | $testCase->assertEquals(sizeof(self::$SUPPLEMENTARY_DATA), 409 | sizeof($supplementaryData), "Json conversion incorrect size"); 410 | } 411 | 412 | 413 | 414 | /** 415 | * Checks request post dimensions matches expected values. 416 | * 417 | * @param HppRequest $hppRequestConverted 418 | * @param PHPUnit_Framework_TestCase $testCase 419 | */ 420 | public static function checkValidHppRequestPostDimensions(HppRequest $hppRequestConverted, PHPUnit_Framework_TestCase $testCase){ 421 | 422 | $postDimensions = $hppRequestConverted->getPostDimensions(); 423 | 424 | $testCase->assertEquals(self::POST_DIMENSIONS, $postDimensions, "Json conversion incorrect "); 425 | $testCase->assertEquals(strlen(self::POST_DIMENSIONS), strlen($postDimensions), "Json conversion incorrect size"); 426 | 427 | $hppRequestConverted = $hppRequestConverted->encode(RealexHpp::ENCODING_CHARSET); 428 | $hppRequestConverted = $hppRequestConverted->decode(RealexHpp::ENCODING_CHARSET); 429 | 430 | $postDimensions = $hppRequestConverted->getPostDimensions(); 431 | $testCase->assertEquals(self::POST_DIMENSIONS, $postDimensions, "Json conversion incorrect "); 432 | 433 | 434 | } 435 | 436 | 437 | 438 | 439 | } 440 | 441 | SampleJsonData::Init(); -------------------------------------------------------------------------------- /test/main/php/com-realexpayments-hpp-sdk/domain/HppRequestTest.php: -------------------------------------------------------------------------------- 1 | setTimeStamp(self::TIMESTAMP); 28 | $hppRequest->setMerchantId(self::MERCHANT_ID); 29 | $hppRequest->setOrderId(self::ORDER_ID); 30 | $hppRequest->setAmount(self::AMOUNT); 31 | $hppRequest->setCurrency(self::CURRENCY); 32 | 33 | $expectedHash = "e96eed4869a6d682e8fdbb88703ed81faa58f4df"; 34 | $actualHash = $hppRequest->hash("mysecret")->getHash(); 35 | 36 | $this->assertEquals($expectedHash, $actualHash,"Card storage hash does not match expected."); 37 | } 38 | 39 | 40 | public function testHashHppSelectCard() 41 | { 42 | $hppRequest = new HppRequest(); 43 | $hppRequest = $hppRequest->addTimeStamp(self::TIMESTAMP) 44 | ->addMerchantId(self::MERCHANT_ID) 45 | ->addOrderId(self::ORDER_ID) 46 | ->addAmount(self::AMOUNT) 47 | ->addCurrency(self::CURRENCY) 48 | ->addHppSelectStoredCard(self::SELECT_STORED_CARD); 49 | 50 | $expectedHash = "099b6ef236391d8bdc642488fc5e9c54ac31cd80"; 51 | $actualHash = $hppRequest->hash("mysecret")->getHash(); 52 | 53 | $this->assertEquals($expectedHash, $actualHash,"Card storage hash does not match expected."); 54 | } 55 | 56 | public function testHashHppSelectCardAndPaymentReference() 57 | { 58 | $hppRequest = new HppRequest(); 59 | $hppRequest = $hppRequest->addTimeStamp(self::TIMESTAMP) 60 | ->addMerchantId(self::MERCHANT_ID) 61 | ->addOrderId(self::ORDER_ID) 62 | ->addAmount(self::AMOUNT) 63 | ->addCurrency(self::CURRENCY) 64 | ->addHppSelectStoredCard(self::SELECT_STORED_CARD) 65 | ->addPaymentReference(self::PAYMENT_REFERENCE); 66 | 67 | $expectedHash = "4106afc4666c6145b623089b1ad4098846badba2"; 68 | $actualHash = $hppRequest->hash("mysecret")->getHash(); 69 | 70 | $this->assertEquals($expectedHash, $actualHash,"Card storage hash does not match expected."); 71 | } 72 | 73 | } 74 | 75 | 76 | -------------------------------------------------------------------------------- /test/main/php/com-realexpayments-hpp-sdk/utils/GenerationUtilsTest.php: -------------------------------------------------------------------------------- 1 | assertTrue( $expectedResult == $result, "Expected and resultant Hash do not match. expected: " . $expectedResult . " result: " . $result ); 24 | 25 | } 26 | 27 | /** 28 | * Test timestamp generation. Hard to test this in a meaningful way. Checking length and valid characters. 29 | */ 30 | public function testGenerateTimestamp() { 31 | 32 | 33 | $result = GenerationUtils::generateTimestamp(); 34 | 35 | $count = preg_match( "/[0-9]{14}/", $result, $matches ); 36 | 37 | $this->assertTrue( $count == 1, "Timestamp should be 14 digits: " . $result ); 38 | } 39 | 40 | /** 41 | * Test order Id generation. Hard to test this in a meaningful way. Checking length and valid characters. 42 | */ 43 | public function testGenerateOrderId() { 44 | $result = GenerationUtils::generateOrderId(); 45 | 46 | $this->assertEquals( 22, 47 | strlen( $result ), "OrderId " . $result . " should be 22 characters, is " . strlen( $result ) . " characters: " . $result ); 48 | 49 | $this->assertTrue( preg_match( "/[A-Za-z0-9-_]{22}/", $result ) == 1, "OrderId " . $result . " - Regexp doesn't match [A-Za-z0-9-_]{22}" ); 50 | } 51 | 52 | 53 | 54 | } 55 | -------------------------------------------------------------------------------- /test/main/php/com-realexpayments-hpp-sdk/utils/JsonUtilsTest.php: -------------------------------------------------------------------------------- 1 | assertEquals( "", $hppResponseConverted->getEci() ); 116 | } 117 | 118 | /** 119 | * Test converting JSON with empty ECI to {@link HppResponse}. 120 | */ 121 | public function testFromJsonHppResponseNoECIField() { 122 | $path = SampleJsonData::VALID_HPP_RESPONSE_NO_ECI_FIELD_JSON_PATH; 123 | $prefix = __DIR__ . '/../../../resources'; 124 | $json = file_get_contents( $prefix . $path ); 125 | 126 | 127 | $hppResponseConverted = JsonUtils::fromJsonHppResponse( $json ); 128 | 129 | $this->assertEquals( "", $hppResponseConverted->getEci() ); 130 | } 131 | 132 | /** 133 | * Test converting JSON with empty ECI to {@link HppResponse}. 134 | */ 135 | public function testFromJsonHppResponseNoECIFieldEncoded() { 136 | $path = SampleJsonData::VALID_HPP_RESPONSE_NO_ECI_FIELD_ENCODED_JSON_PATH; 137 | $prefix = __DIR__ . '/../../../resources'; 138 | $json = file_get_contents( $prefix . $path ); 139 | 140 | 141 | $hppResponseConverted = JsonUtils::fromJsonHppResponse( $json ); 142 | $hppResponseConverted = $hppResponseConverted->decode(RealexHpp::ENCODING_CHARSET); 143 | 144 | $this->assertEquals( "", $hppResponseConverted->getEci() ); 145 | } 146 | 147 | /** 148 | * Test converting JSON with no TSS Information to {@link HppResponse}. 149 | */ 150 | public function testFromJsonHppResponseNoTSS() { 151 | $path = SampleJsonData::VALID_HPP_RESPONSE_NO_TSS_JSON_PATH; 152 | $prefix = __DIR__ . '/../../../resources'; 153 | $json = file_get_contents( $prefix . $path ); 154 | 155 | 156 | $hppResponseConverted = JsonUtils::fromJsonHppResponse( $json ); 157 | 158 | $this->assertEquals( "", $hppResponseConverted->getTss() ); 159 | } 160 | 161 | /** 162 | * Test converting JSON with no TSS Information to {@link HppResponse}. 163 | */ 164 | public function testFromJsonHppResponseNoTSSEncoded() { 165 | $path = SampleJsonData::VALID_HPP_RESPONSE_NO_TSS_JSON_PATH; 166 | $prefix = __DIR__ . '/../../../resources'; 167 | $json = file_get_contents( $prefix . $path ); 168 | 169 | 170 | $hppResponseConverted = JsonUtils::fromJsonHppResponse( $json ); 171 | $hppResponseConverted = $hppResponseConverted->decode(RealexHpp::ENCODING_CHARSET); 172 | 173 | $this->assertEquals( "", $hppResponseConverted->getTss() ); 174 | } 175 | 176 | /** 177 | * Test converting {@link HppRequest} to JSON. 178 | * Testing import from json, decode and encode 179 | */ 180 | public function testToJsonHppRequestWithHppVersion() { 181 | 182 | $path = SampleJsonData::VALID_HPP_REQUEST_HPP_VERSION_JSON_PATH; 183 | $prefix = __DIR__ . '/../../../resources'; 184 | $json = file_get_contents( $prefix . $path ); 185 | 186 | 187 | /** 188 | * @var HppRequest $hppRequestConverted 189 | */ 190 | $hppRequestConverted = JsonUtils::fromJsonHppRequest( $json ); 191 | 192 | $this->assertEquals( SampleJsonData::HPP_VERSION, $hppRequestConverted->getHppVersion() ); 193 | $this->assertEquals( SampleJsonData::HPP_SELECT_STORED_CARD, $hppRequestConverted->getHppSelectStoredCard() ); 194 | 195 | $hppRequestConverted = $hppRequestConverted->encode(RealexHpp::ENCODING_CHARSET); 196 | $hppRequestConverted = $hppRequestConverted->decode(RealexHpp::ENCODING_CHARSET); 197 | 198 | $this->assertEquals( SampleJsonData::HPP_VERSION, $hppRequestConverted->getHppVersion() ); 199 | $this->assertEquals( SampleJsonData::HPP_SELECT_STORED_CARD, $hppRequestConverted->getHppSelectStoredCard() ); 200 | 201 | } 202 | 203 | 204 | 205 | 206 | } 207 | -------------------------------------------------------------------------------- /test/main/resources/sample-json/hpp-request-card-storage.json: -------------------------------------------------------------------------------- 1 | { 2 | "MERCHANT_ID":"MerchantID", 3 | "ACCOUNT":"myAccount", 4 | "ORDER_ID":"OrderID", 5 | "AMOUNT":"100", 6 | "CURRENCY":"EUR", 7 | "TIMESTAMP":"20990101120000", 8 | "SHA1HASH":"5d8f05abd618e50db4861a61cc940112786474cf", 9 | "AUTO_SETTLE_FLAG":"1", 10 | "COMMENT1":"a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | = ;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥", 11 | "COMMENT2":"Comment Two", 12 | "RETURN_TSS":"0", 13 | "SHIPPING_CODE":"56|987", 14 | "SHIPPING_CO":"IRELAND", 15 | "BILLING_CODE":"123|56", 16 | "BILLING_CO":"IRELAND", 17 | "CUST_NUM":"123456", 18 | "VAR_REF":"VariableRef", 19 | "PROD_ID":"ProductID", 20 | "HPP_LANG":"EN", 21 | "CARD_PAYMENT_BUTTON":"Submit Payment", 22 | "CARD_STORAGE_ENABLE":"1", 23 | "OFFER_SAVE_CARD":"1", 24 | "PAYER_REF":"PayerRef", 25 | "PMT_REF":"PaymentRef", 26 | "PAYER_EXIST":"0", 27 | "VALIDATE_CARD_ONLY":"0", 28 | "DCC_ENABLE":"0" 29 | } -------------------------------------------------------------------------------- /test/main/resources/sample-json/hpp-request-encoded-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "MERCHANT_ID":"TWVyY2hhbnRJRA==", 3 | "ACCOUNT":"bXlBY2NvdW50", 4 | "ORDER_ID":"T3JkZXJJRA==", 5 | "AMOUNT":"MTAw", 6 | "CURRENCY":"RVVS", 7 | "TIMESTAMP":"MjA5OTAxMDExMjAwMDA=", 8 | "SHA1HASH":"NWQ4ZjA1YWJkNjE4ZTUwZGI0ODYxYTYxY2M5NDAxMTI3ODY0NzRjZg==", 9 | "AUTO_SETTLE_FLAG":"MQ==", 10 | "COMMENT1":"YS16IEEtWiAwLTkgJyAiLCArIOKAnOKAnSAuXyAtICYgXCAvIEAgISA/ICUgKCApKiA6IMKjICQgJiDigqwgIyBbIF0gfCA9IDvDgMOBw4LDg8OEw4XDhsOHw4jDicOKw4vDjMONw47Dj8OQw5HDksOTw5TDlcOWw5fDmMOZw5rDm8Ocw53DnsOfw6DDocOiw6PDpMOlw6bDp8Oow6nDqsOrw6zDrcOuw6/DsMOxw7LDs8O0w7XDtsO3w7jCpMO5w7rDu8O8w73DvsO/xZLFvcWhxZPFvsW4wqU=", 11 | "COMMENT2":"Q29tbWVudCBUd28=", 12 | "RETURN_TSS":"MA==", 13 | "SHIPPING_CODE":"NTZ8OTg3", 14 | "SHIPPING_CO":"SVJFTEFORA==", 15 | "BILLING_CODE":"MTIzfDU2", 16 | "BILLING_CO":"SVJFTEFORA==", 17 | "CUST_NUM":"MTIzNDU2", 18 | "VAR_REF":"VmFyaWFibGVSZWY=", 19 | "PROD_ID":"UHJvZHVjdElE", 20 | "HPP_LANG":"RU4=", 21 | "CARD_PAYMENT_BUTTON":"U3VibWl0IFBheW1lbnQ=", 22 | "CARD_STORAGE_ENABLE":"MA==", 23 | "OFFER_SAVE_CARD":"MA==", 24 | "PAYER_REF":"UGF5ZXJSZWY=", 25 | "PMT_REF":"UGF5bWVudFJlZg==", 26 | "PAYER_EXIST":"MA==", 27 | "VALIDATE_CARD_ONLY":"MA==", 28 | "DCC_ENABLE":"MA==" 29 | } -------------------------------------------------------------------------------- /test/main/resources/sample-json/hpp-request-hpp-version-fail.json: -------------------------------------------------------------------------------- 1 | { 2 | "MERCHANT_ID":"MerchantID", 3 | "ACCOUNT":"myAccount", 4 | "ORDER_ID":"OrderID", 5 | "AMOUNT":"100", 6 | "CURRENCY":"EUR", 7 | "TIMESTAMP":"20990101120000", 8 | "SHA1HASH":"5d8f05abd618e50db4861a61cc940112786474cf", 9 | "AUTO_SETTLE_FLAG":"1", 10 | "COMMENT1":"a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | = ;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥", 11 | "COMMENT2":"Comment Two", 12 | "RETURN_TSS":"0", 13 | "SHIPPING_CODE":"56|987", 14 | "SHIPPING_CO":"IRELAND", 15 | "BILLING_CODE":"123|56", 16 | "BILLING_CO":"IRELAND", 17 | "CUST_NUM":"123456", 18 | "VAR_REF":"VariableRef", 19 | "PROD_ID":"ProductID", 20 | "HPP_LANG":"EN", 21 | "CARD_PAYMENT_BUTTON":"Submit Payment", 22 | "CARD_STORAGE_ENABLE":"0", 23 | "OFFER_SAVE_CARD":"0", 24 | "PAYER_REF":"PayerRef", 25 | "PMT_REF":"PaymentRef", 26 | "PAYER_EXIST":"0", 27 | "VALIDATE_CARD_ONLY":"0", 28 | "DCC_ENABLE":"0", 29 | "HPP_VERSION":"5", 30 | "HPP_SELECT_STORED_CARD":"kslkjfnskljfnskljfnskljfnbsklhfbslkhfbskhlbfsjklhbflkshbfskhlfbsjlhfbsjlhfbsjfuwyebaddbajhdbajhdbjahbdajkbdjahbf jhsd djhabjd baj" 31 | 32 | } -------------------------------------------------------------------------------- /test/main/resources/sample-json/hpp-request-hpp-version-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "MERCHANT_ID":"MerchantID", 3 | "ACCOUNT":"myAccount", 4 | "ORDER_ID":"OrderID", 5 | "AMOUNT":"100", 6 | "CURRENCY":"EUR", 7 | "TIMESTAMP":"20990101120000", 8 | "SHA1HASH":"5d8f05abd618e50db4861a61cc940112786474cf", 9 | "AUTO_SETTLE_FLAG":"1", 10 | "COMMENT1":"a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | = ;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥", 11 | "COMMENT2":"Comment Two", 12 | "RETURN_TSS":"0", 13 | "SHIPPING_CODE":"56|987", 14 | "SHIPPING_CO":"IRELAND", 15 | "BILLING_CODE":"123|56", 16 | "BILLING_CO":"IRELAND", 17 | "CUST_NUM":"123456", 18 | "VAR_REF":"VariableRef", 19 | "PROD_ID":"ProductID", 20 | "HPP_LANG":"EN", 21 | "CARD_PAYMENT_BUTTON":"Submit Payment", 22 | "CARD_STORAGE_ENABLE":"0", 23 | "OFFER_SAVE_CARD":"0", 24 | "PAYER_REF":"PayerRef", 25 | "PMT_REF":"PaymentRef", 26 | "PAYER_EXIST":"0", 27 | "VALIDATE_CARD_ONLY":"0", 28 | "DCC_ENABLE":"0", 29 | "HPP_VERSION":"1", 30 | "HPP_SELECT_STORED_CARD":"PayerRef" 31 | 32 | } -------------------------------------------------------------------------------- /test/main/resources/sample-json/hpp-request-hpp-version2.json: -------------------------------------------------------------------------------- 1 | { 2 | "MERCHANT_ID":"MerchantID", 3 | "ACCOUNT":"myAccount", 4 | "ORDER_ID":"OrderID", 5 | "AMOUNT":"100", 6 | "CURRENCY":"EUR", 7 | "TIMESTAMP":"20990101120000", 8 | "SHA1HASH":"5d8f05abd618e50db4861a61cc940112786474cf", 9 | "AUTO_SETTLE_FLAG":"1", 10 | "COMMENT1":"a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | = ;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥", 11 | "COMMENT2":"Comment Two", 12 | "RETURN_TSS":"0", 13 | "SHIPPING_CODE":"56|987", 14 | "SHIPPING_CO":"IRELAND", 15 | "BILLING_CODE":"123|56", 16 | "BILLING_CO":"IRELAND", 17 | "CUST_NUM":"123456", 18 | "VAR_REF":"VariableRef", 19 | "PROD_ID":"ProductID", 20 | "HPP_LANG":"EN", 21 | "CARD_PAYMENT_BUTTON":"Submit Payment", 22 | "CARD_STORAGE_ENABLE":"0", 23 | "OFFER_SAVE_CARD":"0", 24 | "PAYER_REF":"PayerRef", 25 | "PMT_REF":"PaymentRef", 26 | "PAYER_EXIST":"0", 27 | "VALIDATE_CARD_ONLY":"0", 28 | "DCC_ENABLE":"0", 29 | "HPP_SELECT_STORED_CARD":"PayerRef" 30 | 31 | } -------------------------------------------------------------------------------- /test/main/resources/sample-json/hpp-request-post-both-invalid-both.json: -------------------------------------------------------------------------------- 1 | { 2 | "MERCHANT_ID":"MerchantID", 3 | "ACCOUNT":"myAccount", 4 | "ORDER_ID":"OrderID", 5 | "AMOUNT":"100", 6 | "CURRENCY":"EUR", 7 | "TIMESTAMP":"20990101120000", 8 | "SHA1HASH":"5d8f05abd618e50db4861a61cc940112786474cf", 9 | "AUTO_SETTLE_FLAG":"1", 10 | "COMMENT1":"a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | = ;À", 11 | "COMMENT2":"Comment Two", 12 | "RETURN_TSS":"0", 13 | "SHIPPING_CODE":"56|987", 14 | "SHIPPING_CO":"IRELAND", 15 | "BILLING_CODE":"123|56", 16 | "BILLING_CO":"IRELAND", 17 | "CUST_NUM":"123456", 18 | "VAR_REF":"VariableRef", 19 | "PROD_ID":"ProductID", 20 | "HPP_LANG":"EN", 21 | "CARD_PAYMENT_BUTTON":"Submit Payment", 22 | "CARD_STORAGE_ENABLE":"0", 23 | "OFFER_SAVE_CARD":"0", 24 | "PAYER_REF":"PayerRef", 25 | "PMT_REF":"PaymentRef", 26 | "PAYER_EXIST":"0", 27 | "VALIDATE_CARD_ONLY":"0", 28 | "DCC_ENABLE":"0", 29 | "HPP_POST_DIMENSIONS":"width\":\"lwtaqzoqysgzcrfvqqldasxutaswhyqamfogquocmwzucsttgfmplgnejydkwpbgxbuswwhggnhbxoyrbbvdrmfvhfpxpvksvlpelanmihfbztllqqcxlzrqgwjzbsimnszxbrlkeurbpxkbtgenlxmhfbfuugqhqkdzhxsvkxemrtipxafotbbasafrpqnyyuwzrxcsycisqufjvlqzhsgwfaaqtscxkyqwoqdyrzseesymwqrgvludmqhwfzbqzmh", 30 | "HPP_POST_RESPONSE": "{\"DCCCOMMISSIONPERCENTAGE\": \"lwtaqzoqysgzcrfvqqldasxutaswhyqamfogquocmwzucsttgfmplgnejydkwpbgxbuswwhggnhbxoyrbbvdrmfvhfpxpvksvlpelanmihfbztllqqcxlzrqgwjzbsimnszxbrlkeurbpxkbtgenlxmhfbfuugqhqkdzhxsvkxemrtipxafotbbasafrpqnyyuwzrxcsycisqufjvlqzhsgwfaaqtscxkyqwoqdyrzseesymwqrgvludmqhwfzbqzmh\"}" 31 | 32 | } -------------------------------------------------------------------------------- /test/main/resources/sample-json/hpp-request-post-both-valid-both.json: -------------------------------------------------------------------------------- 1 | { 2 | "MERCHANT_ID":"MerchantID", 3 | "ACCOUNT":"myAccount", 4 | "ORDER_ID":"OrderID", 5 | "AMOUNT":"100", 6 | "CURRENCY":"EUR", 7 | "TIMESTAMP":"20990101120000", 8 | "SHA1HASH":"5d8f05abd618e50db4861a61cc940112786474cf", 9 | "AUTO_SETTLE_FLAG":"1", 10 | "COMMENT1":"a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | = ;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥", 11 | "COMMENT2":"Comment Two", 12 | "RETURN_TSS":"0", 13 | "SHIPPING_CODE":"56|987", 14 | "SHIPPING_CO":"IRELAND", 15 | "BILLING_CODE":"123|56", 16 | "BILLING_CO":"IRELAND", 17 | "CUST_NUM":"123456", 18 | "VAR_REF":"VariableRef", 19 | "PROD_ID":"ProductID", 20 | "HPP_LANG":"EN", 21 | "CARD_PAYMENT_BUTTON":"Submit Payment", 22 | "CARD_STORAGE_ENABLE":"0", 23 | "OFFER_SAVE_CARD":"0", 24 | "PAYER_REF":"PayerRef", 25 | "PMT_REF":"PaymentRef", 26 | "PAYER_EXIST":"0", 27 | "VALIDATE_CARD_ONLY":"0", 28 | "DCC_ENABLE":"0", 29 | "HPP_POST_DIMENSIONS":"{\"iframe\":{\"height\":\"544px\",\"width\":\"768px\"}}", 30 | "HPP_POST_RESPONSE": "{ \"DCCCOMMISSI1lbGlzdGVuZXIzRFM=\",\"AVSADDRESSRESULT\": \"VQ==\",\"CVNRESULT\": \"TQ==\",\"CARD_PAYMENT_BUTTON\": \"Q29tcGxldGUgUGF5bWVudA==\",\"MESSAGE\": \"QVVUSCBDT0RFIEFQMTIzNA==\"}", 31 | "HPP_VERSION":"1", 32 | "HPP_SELECT_STORED_CARD":"PayerRef" 33 | } -------------------------------------------------------------------------------- /test/main/resources/sample-json/hpp-request-post-dimensions-invalid-pattern.json: -------------------------------------------------------------------------------- 1 | { 2 | "MERCHANT_ID":"MerchantID", 3 | "ACCOUNT":"myAccount", 4 | "ORDER_ID":"OrderID", 5 | "AMOUNT":"100", 6 | "CURRENCY":"EUR", 7 | "TIMESTAMP":"20990101120000", 8 | "SHA1HASH":"5d8f05abd618e50db4861a61cc940112786474cf", 9 | "AUTO_SETTLE_FLAG":"1", 10 | "COMMENT1":"a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | = ;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥", 11 | "COMMENT2":"Comment Two", 12 | "RETURN_TSS":"0", 13 | "SHIPPING_CODE":"56|987", 14 | "SHIPPING_CO":"IRELAND", 15 | "BILLING_CODE":"123|56", 16 | "BILLING_CO":"IRELAND", 17 | "CUST_NUM":"123456", 18 | "VAR_REF":"VariableRef", 19 | "PROD_ID":"ProductID", 20 | "HPP_LANG":"EN", 21 | "CARD_PAYMENT_BUTTON":"Submit Payment", 22 | "CARD_STORAGE_ENABLE":"0", 23 | "OFFER_SAVE_CARD":"0", 24 | "PAYER_REF":"PayerRef", 25 | "PMT_REF":"PaymentRef", 26 | "PAYER_EXIST":"0", 27 | "VALIDATE_CARD_ONLY":"0", 28 | "DCC_ENABLE":"0", 29 | "HPP_POST_DIMENSIONS":"{\"height\":\"a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | = ;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥\"}" 30 | } -------------------------------------------------------------------------------- /test/main/resources/sample-json/hpp-request-post-dimensions-invalid-size.json: -------------------------------------------------------------------------------- 1 | { 2 | "MERCHANT_ID":"MerchantID", 3 | "ACCOUNT":"myAccount", 4 | "ORDER_ID":"OrderID", 5 | "AMOUNT":"100", 6 | "CURRENCY":"EUR", 7 | "TIMESTAMP":"20990101120000", 8 | "SHA1HASH":"5d8f05abd618e50db4861a61cc940112786474cf", 9 | "AUTO_SETTLE_FLAG":"1", 10 | "COMMENT1":"a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | = ;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥", 11 | "COMMENT2":"Comment Two", 12 | "RETURN_TSS":"0", 13 | "SHIPPING_CODE":"56|987", 14 | "SHIPPING_CO":"IRELAND", 15 | "BILLING_CODE":"123|56", 16 | "BILLING_CO":"IRELAND", 17 | "CUST_NUM":"123456", 18 | "VAR_REF":"VariableRef", 19 | "PROD_ID":"ProductID", 20 | "HPP_LANG":"EN", 21 | "CARD_PAYMENT_BUTTON":"Submit Payment", 22 | "CARD_STORAGE_ENABLE":"0", 23 | "OFFER_SAVE_CARD":"0", 24 | "PAYER_REF":"PayerRef", 25 | "PMT_REF":"PaymentRef", 26 | "PAYER_EXIST":"0", 27 | "VALIDATE_CARD_ONLY":"0", 28 | "DCC_ENABLE":"0", 29 | "HPP_POST_DIMENSIONS":"{\"width\":\"lwtaqzoqysgzcrfvqqlxutaswhyqamfogquocmwzucsttgfmplgnejydkwpbgxbuswwhggnhbxoyrbbvdrmfvhfpxpvksvlpelanmihfbztllqqcxlzrqgwjzbsimnszxbrlkeurbpxkbtgenlxmhfbfuugqhqkdzhxsvkxemrtipxafotbbasafrpqnyyuwzrxcsycisqufjvlqzhsgwfaaqtscxkyqwoqdyrzseesymwqrgvludmqhwfzbqzmh\"}" 30 | 31 | } -------------------------------------------------------------------------------- /test/main/resources/sample-json/hpp-request-post-dimensions-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "MERCHANT_ID":"MerchantID", 3 | "ACCOUNT":"myAccount", 4 | "ORDER_ID":"OrderID", 5 | "AMOUNT":"100", 6 | "CURRENCY":"EUR", 7 | "TIMESTAMP":"20990101120000", 8 | "SHA1HASH":"5d8f05abd618e50db4861a61cc940112786474cf", 9 | "AUTO_SETTLE_FLAG":"1", 10 | "COMMENT1":"a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | = ;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥", 11 | "COMMENT2":"Comment Two", 12 | "RETURN_TSS":"0", 13 | "SHIPPING_CODE":"56|987", 14 | "SHIPPING_CO":"IRELAND", 15 | "BILLING_CODE":"123|56", 16 | "BILLING_CO":"IRELAND", 17 | "CUST_NUM":"123456", 18 | "VAR_REF":"VariableRef", 19 | "PROD_ID":"ProductID", 20 | "HPP_LANG":"EN", 21 | "CARD_PAYMENT_BUTTON":"Submit Payment", 22 | "CARD_STORAGE_ENABLE":"0", 23 | "OFFER_SAVE_CARD":"0", 24 | "PAYER_REF":"PayerRef", 25 | "PMT_REF":"PaymentRef", 26 | "PAYER_EXIST":"0", 27 | "VALIDATE_CARD_ONLY":"0", 28 | "DCC_ENABLE":"0", 29 | "HPP_POST_DIMENSIONS":"{\"iframe\":{\"height\":\"544px\",\"width\":\"768px\"}}" 30 | } -------------------------------------------------------------------------------- /test/main/resources/sample-json/hpp-request-post-response-invalid-size.json: -------------------------------------------------------------------------------- 1 | { 2 | "MERCHANT_ID":"MerchantID", 3 | "ACCOUNT":"myAccount", 4 | "ORDER_ID":"OrderID", 5 | "AMOUNT":"100", 6 | "CURRENCY":"EUR", 7 | "TIMESTAMP":"20990101120000", 8 | "SHA1HASH":"5d8f05abd618e50db4861a61cc940112786474cf", 9 | "AUTO_SETTLE_FLAG":"1", 10 | "COMMENT1":"a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥", 11 | "COMMENT2":"Comment Two", 12 | "RETURN_TSS":"0", 13 | "SHIPPING_CODE":"56|987", 14 | "SHIPPING_CO":"IRELAND", 15 | "BILLING_CODE":"123|56", 16 | "BILLING_CO":"IRELAND", 17 | "CUST_NUM":"123456", 18 | "VAR_REF":"VariableRef", 19 | "PROD_ID":"ProductID", 20 | "HPP_LANG":"EN", 21 | "CARD_PAYMENT_BUTTON":"Submit Payment", 22 | "CARD_STORAGE_ENABLE":"0", 23 | "OFFER_SAVE_CARD":"0", 24 | "PAYER_REF":"PayerRef", 25 | "PMT_REF":"PaymentRef", 26 | "PAYER_EXIST":"0", 27 | "VALIDATE_CARD_ONLY":"0", 28 | "DCC_ENABLE":"0", 29 | "HPP_POST_DIMENSIONS":"{\"iframe\":{\"height\":\"544px\",\"width\":\"768px\"}}", 30 | "HPP_POST_RESPONSE": "{\"DCCCOMMISSIONPERCENTAGE\": \"lwtaqzoqysgzcrfvqqldasxutaswhyqamfogquocmwzucsttgfmplgnejydkwpbgxbuswwhggnhbxoyrbbvdrmfvhfpxpvksvlpelanmihfbztllqqcxlzrqgwjzbsimnszxbrlkeurbpxkbtgenlxmhfbfuugqhqkdzhxsvkxemrtipxafotbbasafrpqnyyuwzrxcsycisqufjvlqzhsgwfaaqtscxkyqwoqdyrzseesymwqrgvludmqhwfzbqzmh\"}" 31 | } -------------------------------------------------------------------------------- /test/main/resources/sample-json/hpp-request-post-response-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "MERCHANT_ID":"MerchantID", 3 | "ACCOUNT":"myAccount", 4 | "ORDER_ID":"OrderID", 5 | "AMOUNT":"100", 6 | "CURRENCY":"EUR", 7 | "TIMESTAMP":"20990101120000", 8 | "SHA1HASH":"5d8f05abd618e50db4861a61cc940112786474cf", 9 | "AUTO_SETTLE_FLAG":"1", 10 | "COMMENT1":"a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | = ;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥", 11 | "COMMENT2":"Comment Two", 12 | "RETURN_TSS":"0", 13 | "SHIPPING_CODE":"56|987", 14 | "SHIPPING_CO":"IRELAND", 15 | "BILLING_CODE":"123|56", 16 | "BILLING_CO":"IRELAND", 17 | "CUST_NUM":"123456", 18 | "VAR_REF":"VariableRef", 19 | "PROD_ID":"ProductID", 20 | "HPP_LANG":"EN", 21 | "CARD_PAYMENT_BUTTON":"Submit Payment", 22 | "CARD_STORAGE_ENABLE":"0", 23 | "OFFER_SAVE_CARD":"0", 24 | "PAYER_REF":"PayerRef", 25 | "PMT_REF":"PaymentRef", 26 | "PAYER_EXIST":"0", 27 | "VALIDATE_CARD_ONLY":"0", 28 | "DCC_ENABLE":"0", 29 | "HPP_POST_DIMENSIONS":"{\"iframe\":{\"height\":\"544px\",\"width\":\"768px\"}}", 30 | "HPP_POST_RESPONSE": "{ \"DCCCOMMISSIONPERCENTAGE\": MA==NRESULT\": \"TQ==\",\"CARD_PAYMENT_BUTTON\": \"Q29tcGxldGUgUGF5bWVudA==\",\"MESSAGE\": \"QVVUSCBDT0RFIEFQMTIzNA==\"}" 31 | } -------------------------------------------------------------------------------- /test/main/resources/sample-json/hpp-request-unknown-data.json: -------------------------------------------------------------------------------- 1 | { 2 | "MERCHANT_ID":"MerchantID", 3 | "ACCOUNT":"myAccount", 4 | "ORDER_ID":"OrderID", 5 | "AMOUNT":"100", 6 | "CURRENCY":"EUR", 7 | "TIMESTAMP":"20990101120000", 8 | "SHA1HASH":"5d8f05abd618e50db4861a61cc940112786474cf", 9 | "AUTO_SETTLE_FLAG":"1", 10 | "COMMENT1":"a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | = ;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥", 11 | "COMMENT2":"Comment Two", 12 | "RETURN_TSS":"0", 13 | "SHIPPING_CODE":"56|987", 14 | "SHIPPING_CO":"IRELAND", 15 | "BILLING_CODE":"123|56", 16 | "BILLING_CO":"IRELAND", 17 | "CUST_NUM":"123456", 18 | "VAR_REF":"VariableRef", 19 | "PROD_ID":"ProductID", 20 | "HPP_LANG":"EN", 21 | "CARD_PAYMENT_BUTTON":"Submit Payment", 22 | "CARD_STORAGE_ENABLE":"0", 23 | "OFFER_SAVE_CARD":"0", 24 | "PAYER_REF":"PayerRef", 25 | "PMT_REF":"PaymentRef", 26 | "UNKNOWN_1":"Unknown value 1", 27 | "UNKNOWN_2":"Unknown value 2", 28 | "UNKNOWN_3":"Unknown value 3", 29 | "UNKNOWN_4":"Unknown value 4", 30 | "PAYER_EXIST":"0", 31 | "VALIDATE_CARD_ONLY":"0", 32 | "DCC_ENABLE":"0" 33 | } -------------------------------------------------------------------------------- /test/main/resources/sample-json/hpp-request-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "MERCHANT_ID":"MerchantID", 3 | "ACCOUNT":"myAccount", 4 | "ORDER_ID":"OrderID", 5 | "AMOUNT":"100", 6 | "CURRENCY":"EUR", 7 | "TIMESTAMP":"20990101120000", 8 | "SHA1HASH":"5d8f05abd618e50db4861a61cc940112786474cf", 9 | "AUTO_SETTLE_FLAG":"1", 10 | "COMMENT1":"a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | = ;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥", 11 | "COMMENT2":"Comment Two", 12 | "RETURN_TSS":"0", 13 | "SHIPPING_CODE":"56|987", 14 | "SHIPPING_CO":"IRELAND", 15 | "BILLING_CODE":"123|56", 16 | "BILLING_CO":"IRELAND", 17 | "CUST_NUM":"123456", 18 | "VAR_REF":"VariableRef", 19 | "PROD_ID":"ProductID", 20 | "HPP_LANG":"EN", 21 | "CARD_PAYMENT_BUTTON":"Submit Payment", 22 | "CARD_STORAGE_ENABLE":"0", 23 | "OFFER_SAVE_CARD":"0", 24 | "PAYER_REF":"PayerRef", 25 | "PMT_REF":"PaymentRef", 26 | "PAYER_EXIST":"0", 27 | "VALIDATE_CARD_ONLY":"0", 28 | "DCC_ENABLE":"0" 29 | } -------------------------------------------------------------------------------- /test/main/resources/sample-json/hpp-response-empty-ECI.json: -------------------------------------------------------------------------------- 1 | { 2 | "MERCHANT_ID":"thestore", 3 | "ACCOUNT":"myAccount", 4 | "ORDER_ID":"ORD453-11", 5 | "AMOUNT":"100", 6 | "AUTHCODE":"79347", 7 | "TIMESTAMP":"20130814122239", 8 | "SHA1HASH":"f093a0b233daa15f2bf44888f4fe75cb652e7bf0", 9 | "RESULT":"00", 10 | "MESSAGE":"Successful", 11 | "CVNRESULT":"1", 12 | "PASREF":"3737468273643", 13 | "BATCHID":"654321", 14 | "ECI":"", 15 | "CAVV":"123", 16 | "XID":"654564564", 17 | "COMMENT1":"a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | = ;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥", 18 | "COMMENT2":"Comment Two", 19 | "TSS":{ 20 | "TSS_2":"TSS_2_VALUE", 21 | "TSS_1":"TSS_1_VALUE" 22 | }, 23 | "AVSADDRESSRESULT": "M", 24 | "AVSPOSTCODERESULT": "P" 25 | } -------------------------------------------------------------------------------- /test/main/resources/sample-json/hpp-response-encoded-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "MERCHANT_ID":"dGhlc3RvcmU=", 3 | "ACCOUNT":"bXlBY2NvdW50", 4 | "ORDER_ID":"T1JENDUzLTEx", 5 | "AMOUNT":"MTAw", 6 | "AUTHCODE":"NzkzNDc=", 7 | "TIMESTAMP":"MjAxMzA4MTQxMjIyMzk=", 8 | "SHA1HASH":"ZjA5M2EwYjIzM2RhYTE1ZjJiZjQ0ODg4ZjRmZTc1Y2I2NTJlN2JmMA==", 9 | "RESULT":"MDA=", 10 | "MESSAGE":"U3VjY2Vzc2Z1bA==", 11 | "CVNRESULT":"MQ==", 12 | "PASREF":"MzczNzQ2ODI3MzY0Mw==", 13 | "BATCHID":"NjU0MzIx", 14 | "ECI":"MQ==", 15 | "CAVV":"MTIz", 16 | "XID":"NjU0NTY0NTY0", 17 | "COMMENT1":"YS16IEEtWiAwLTkgJyAiLCArIOKAnOKAnSAuXyAtICYgXCAvIEAgISA/ICUgKCApKiA6IMKjICQgJiDigqwgIyBbIF0gfCA9IDvDgMOBw4LDg8OEw4XDhsOHw4jDicOKw4vDjMONw47Dj8OQw5HDksOTw5TDlcOWw5fDmMOZw5rDm8Ocw53DnsOfw6DDocOiw6PDpMOlw6bDp8Oow6nDqsOrw6zDrcOuw6/DsMOxw7LDs8O0w7XDtsO3w7jCpMO5w7rDu8O8w73DvsO/xZLFvcWhxZPFvsW4wqU=", 18 | "COMMENT2":"Q29tbWVudCBUd28=", 19 | "TSS":{ 20 | "TSS_2":"VFNTXzJfVkFMVUU=", 21 | "TSS_1":"VFNTXzFfVkFMVUU=" 22 | }, 23 | "UNKNOWN_4":"VW5rbm93biB2YWx1ZSA0", 24 | "UNKNOWN_3":"VW5rbm93biB2YWx1ZSAz", 25 | "UNKNOWN_2":"VW5rbm93biB2YWx1ZSAy", 26 | "UNKNOWN_1":"VW5rbm93biB2YWx1ZSAx", 27 | "AVSADDRESSRESULT": "TQ==", 28 | "AVSPOSTCODERESULT": "UA==" 29 | } -------------------------------------------------------------------------------- /test/main/resources/sample-json/hpp-response-no-ECI-field-encoded.json: -------------------------------------------------------------------------------- 1 | { 2 | "MERCHANT_ID":"dGhlc3RvcmU=", 3 | "ACCOUNT":"bXlBY2NvdW50", 4 | "ORDER_ID":"T1JENDUzLTEx", 5 | "AMOUNT":"MTAw", 6 | "AUTHCODE":"NzkzNDc=", 7 | "TIMESTAMP":"MjAxMzA4MTQxMjIyMzk=", 8 | "SHA1HASH":"ZjA5M2EwYjIzM2RhYTE1ZjJiZjQ0ODg4ZjRmZTc1Y2I2NTJlN2JmMA==", 9 | "RESULT":"MDA=", 10 | "MESSAGE":"U3VjY2Vzc2Z1bA==", 11 | "CVNRESULT":"MQ==", 12 | "PASREF":"MzczNzQ2ODI3MzY0Mw==", 13 | "BATCHID":"NjU0MzIx", 14 | "CAVV":"MTIz", 15 | "XID":"NjU0NTY0NTY0", 16 | "COMMENT1":"YS16IEEtWiAwLTkgJyAiLCArIOKAnOKAnSAuXyAtICYgXCAvIEAgISA/ICUgKCApKiA6IMKjICQgJiDigqwgIyBbIF0gfCA9IDvDgMOBw4LDg8OEw4XDhsOHw4jDicOKw4vDjMONw47Dj8OQw5HDksOTw5TDlcOWw5fDmMOZw5rDm8Ocw53DnsOfw6DDocOiw6PDpMOlw6bDp8Oow6nDqsOrw6zDrcOuw6/DsMOxw7LDs8O0w7XDtsO3w7jCpMO5w7rDu8O8w73DvsO/xZLFvcWhxZPFvsW4wqU=", 17 | "COMMENT2":"Q29tbWVudCBUd28=", 18 | "TSS":{ 19 | "TSS_2":"VFNTXzJfVkFMVUU=", 20 | "TSS_1":"VFNTXzFfVkFMVUU=" 21 | }, 22 | "UNKNOWN_4":"VW5rbm93biB2YWx1ZSA0", 23 | "UNKNOWN_3":"VW5rbm93biB2YWx1ZSAz", 24 | "UNKNOWN_2":"VW5rbm93biB2YWx1ZSAy", 25 | "UNKNOWN_1":"VW5rbm93biB2YWx1ZSAx", 26 | "AVSADDRESSRESULT": "TQ==", 27 | "AVSPOSTCODERESULT": "UA==" 28 | } -------------------------------------------------------------------------------- /test/main/resources/sample-json/hpp-response-no-ECI-field.json: -------------------------------------------------------------------------------- 1 | { 2 | "MERCHANT_ID":"thestore", 3 | "ACCOUNT":"myAccount", 4 | "ORDER_ID":"ORD453-11", 5 | "AMOUNT":"100", 6 | "AUTHCODE":"79347", 7 | "TIMESTAMP":"20130814122239", 8 | "SHA1HASH":"f093a0b233daa15f2bf44888f4fe75cb652e7bf0", 9 | "RESULT":"00", 10 | "MESSAGE":"Successful", 11 | "CVNRESULT":"1", 12 | "PASREF":"3737468273643", 13 | "BATCHID":"654321", 14 | "CAVV":"123", 15 | "XID":"654564564", 16 | "COMMENT1":"a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | = ;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥", 17 | "COMMENT2":"Comment Two", 18 | "TSS":{ 19 | "TSS_2":"TSS_2_VALUE", 20 | "TSS_1":"TSS_1_VALUE" 21 | }, 22 | "AVSADDRESSRESULT": "M", 23 | "AVSPOSTCODERESULT": "P" 24 | } -------------------------------------------------------------------------------- /test/main/resources/sample-json/hpp-response-no-TSS-encoded.json: -------------------------------------------------------------------------------- 1 | { 2 | "MERCHANT_ID":"dGhlc3RvcmU=", 3 | "ACCOUNT":"bXlBY2NvdW50", 4 | "ORDER_ID":"T1JENDUzLTEx", 5 | "AMOUNT":"MTAw", 6 | "AUTHCODE":"NzkzNDc=", 7 | "TIMESTAMP":"MjAxMzA4MTQxMjIyMzk=", 8 | "SHA1HASH":"ZjA5M2EwYjIzM2RhYTE1ZjJiZjQ0ODg4ZjRmZTc1Y2I2NTJlN2JmMA==", 9 | "RESULT":"MDA=", 10 | "MESSAGE":"U3VjY2Vzc2Z1bA==", 11 | "CVNRESULT":"MQ==", 12 | "PASREF":"MzczNzQ2ODI3MzY0Mw==", 13 | "BATCHID":"NjU0MzIx", 14 | "ECI":"MQ==", 15 | "CAVV":"MTIz", 16 | "XID":"NjU0NTY0NTY0", 17 | "COMMENT1":"YS16IEEtWiAwLTkgJyAiLCArIOKAnOKAnSAuXyAtICYgXCAvIEAgISA/ICUgKCApKiA6IMKjICQgJiDigqwgIyBbIF0gfCA9IDvDgMOBw4LDg8OEw4XDhsOHw4jDicOKw4vDjMONw47Dj8OQw5HDksOTw5TDlcOWw5fDmMOZw5rDm8Ocw53DnsOfw6DDocOiw6PDpMOlw6bDp8Oow6nDqsOrw6zDrcOuw6/DsMOxw7LDs8O0w7XDtsO3w7jCpMO5w7rDu8O8w73DvsO/xZLFvcWhxZPFvsW4wqU=", 18 | "COMMENT2":"Q29tbWVudCBUd28=", 19 | "AVSADDRESSRESULT": "TQ==", 20 | "AVSPOSTCODERESULT": "UA==" 21 | } -------------------------------------------------------------------------------- /test/main/resources/sample-json/hpp-response-no-TSS.json: -------------------------------------------------------------------------------- 1 | { 2 | "MERCHANT_ID":"thestore", 3 | "ACCOUNT":"myAccount", 4 | "ORDER_ID":"ORD453-11", 5 | "AMOUNT":"100", 6 | "AUTHCODE":"79347", 7 | "TIMESTAMP":"20130814122239", 8 | "SHA1HASH":"f093a0b233daa15f2bf44888f4fe75cb652e7bf0", 9 | "RESULT":"00", 10 | "MESSAGE":"Successful", 11 | "CVNRESULT":"1", 12 | "PASREF":"3737468273643", 13 | "BATCHID":"654321", 14 | "ECI":"1", 15 | "CAVV":"123", 16 | "XID":"654564564", 17 | "COMMENT1":"a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | = ;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥", 18 | "COMMENT2":"Comment Two", 19 | "AVSADDRESSRESULT": "M", 20 | "AVSPOSTCODERESULT": "P" 21 | } -------------------------------------------------------------------------------- /test/main/resources/sample-json/hpp-response-unknown-data.json: -------------------------------------------------------------------------------- 1 | { 2 | "MERCHANT_ID": "thestore", 3 | "ACCOUNT": "myAccount", 4 | "ORDER_ID": "ORD453-11", 5 | "AMOUNT": "100", 6 | "AUTHCODE": "79347", 7 | "TIMESTAMP": "20130814122239", 8 | "SHA1HASH": "f093a0b233daa15f2bf44888f4fe75cb652e7bf0", 9 | "RESULT": "00", 10 | "MESSAGE": "Successful", 11 | "CVNRESULT": "1", 12 | "PASREF": "3737468273643", 13 | "BATCHID": "654321", 14 | "ECI": "1", 15 | "CAVV": "123", 16 | "XID": "654564564", 17 | "COMMENT1": "a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | = ;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥", 18 | "COMMENT2": "Comment Two", 19 | "UNKNOWN_1": "Unknown value 1", 20 | "UNKNOWN_2": "Unknown value 2", 21 | "UNKNOWN_3": "Unknown value 3", 22 | "UNKNOWN_4": "Unknown value 4", 23 | "TSS": { 24 | "TSS_2": "TSS_2_VALUE", 25 | "TSS_1": "TSS_1_VALUE" 26 | }, 27 | "AVSADDRESSRESULT": "M", 28 | "AVSPOSTCODERESULT": "P" 29 | } -------------------------------------------------------------------------------- /test/main/resources/sample-json/hpp-response-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "MERCHANT_ID":"thestore", 3 | "ACCOUNT":"myAccount", 4 | "ORDER_ID":"ORD453-11", 5 | "AMOUNT":"100", 6 | "AUTHCODE":"79347", 7 | "TIMESTAMP":"20130814122239", 8 | "SHA1HASH":"f093a0b233daa15f2bf44888f4fe75cb652e7bf0", 9 | "RESULT":"00", 10 | "MESSAGE":"Successful", 11 | "CVNRESULT":"1", 12 | "PASREF":"3737468273643", 13 | "BATCHID":"654321", 14 | "ECI":"1", 15 | "CAVV":"123", 16 | "XID":"654564564", 17 | "COMMENT1":"a-z A-Z 0-9 ' \", + “” ._ - & \\ / @ ! ? % ( )* : £ $ & € # [ ] | = ;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷ø¤ùúûüýþÿŒŽšœžŸ¥", 18 | "COMMENT2":"Comment Two", 19 | "TSS":{ 20 | "TSS_2":"TSS_2_VALUE", 21 | "TSS_1":"TSS_1_VALUE" 22 | }, 23 | "AVSADDRESSRESULT": "M", 24 | "AVSPOSTCODERESULT": "P" 25 | } --------------------------------------------------------------------------------