Skip to content

Commit 9b0ba31

Browse files
authored
Merge pull request #168 from ashtru/future
Allow setLogLevel. Added dependency, unit testing updates, default credentials for unit tests.
2 parents 839a953 + 683c4c3 commit 9b0ba31

5 files changed

Lines changed: 31 additions & 13 deletions

File tree

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
"ext-json": "*",
1212
"ext-simplexml": "*",
1313
"ext-xmlwriter": "*",
14+
"goetas/xsd2php": "^2.0",
1415
"goetas-webservices/xsd2php-runtime":"^0.2",
1516
"goetas-webservices/xsd-reader": "^0.1",
16-
"jms/serializer": "serializer-master-dev as 1.0"
17+
"jms/serializer": "serializer-master-dev as 1.0",
18+
"symfony/yaml": "^3.1"
1719
},
1820
"require-dev": {
1921
"phpunit/phpunit": "~4.0",

lib/AuthorizeNetAIM.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ public function __construct($response, $delimiter, $encap_char, $custom_fields)
475475

476476
// Set custom fields
477477
if ($count = count($custom_fields)) {
478-
$custom_fields_response = array_slice($this->_response_array, -$count, $count);
478+
$custom_fields_response = array_slice($this->_response_array, -$count-1, $count);
479479
$i = 0;
480480
foreach ($custom_fields as $key => $value) {
481481
$this->$key = $custom_fields_response[$i];

lib/net/authorize/util/Log.php

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class Log
3030
{
3131
private $sensitiveXmlTags = NULL;
3232
private $logFile = '';
33+
private $logLevel = ANET_LOG_LEVEL;
3334

3435
/**
3536
* Takes a regex pattern (string) as argument and adds the forward slash delimiter.
@@ -270,25 +271,25 @@ private function log($logLevelPrefix, $logMessage, $flags){
270271

271272
public function debug($logMessage, $flags=FILE_APPEND)
272273
{
273-
if(ANET_LOG_DEBUG >= ANET_LOG_LEVEL){
274+
if(ANET_LOG_DEBUG >= $this->logLevel){
274275
$this->log(ANET_LOG_DEBUG_PREFIX, $logMessage,$flags);
275276
}
276277
}
277278

278279
public function info($logMessage, $flags=FILE_APPEND){
279-
if(ANET_LOG_INFO >= ANET_LOG_LEVEL) {
280+
if(ANET_LOG_INFO >= $this->logLevel) {
280281
$this->log(ANET_LOG_INFO_PREFIX, $logMessage,$flags);
281282
}
282283
}
283284

284285
public function warn($logMessage, $flags=FILE_APPEND){
285-
if(ANET_LOG_WARN >= ANET_LOG_LEVEL) {
286+
if(ANET_LOG_WARN >= $this->logLevel) {
286287
$this->log(ANET_LOG_WARN_PREFIX, $logMessage,$flags);
287288
}
288289
}
289290

290291
public function error($logMessage, $flags=FILE_APPEND){
291-
if(ANET_LOG_ERROR >= ANET_LOG_LEVEL) {
292+
if(ANET_LOG_ERROR >= $this->logLevel) {
292293
$this->log(ANET_LOG_ERROR_PREFIX, $logMessage,$flags);
293294
}
294295
}
@@ -308,29 +309,44 @@ private function logFormat($logLevelPrefix, $format, $objects, $flags){
308309

309310
public function debugFormat($format, $args=array(), $flags=FILE_APPEND)
310311
{
311-
if(ANET_LOG_DEBUG >= ANET_LOG_LEVEL){
312+
if(ANET_LOG_DEBUG >= $this->logLevel){
312313
$this->logFormat(ANET_LOG_DEBUG_PREFIX, $format, $args , $flags);
313314
}
314315
}
315316

316317
public function infoFormat($format, $args=array(), $flags=FILE_APPEND){
317-
if(ANET_LOG_INFO >= ANET_LOG_LEVEL) {
318+
if(ANET_LOG_INFO >= $this->logLevel) {
318319
$this->logFormat(ANET_LOG_INFO_PREFIX, $format, $args , $flags);
319320
}
320321
}
321322

322323
public function warnFormat($format, $args=array(), $flags=FILE_APPEND){
323-
if(ANET_LOG_WARN >= ANET_LOG_LEVEL) {
324+
if(ANET_LOG_WARN >= $this->logLevel) {
324325
$this->logFormat(ANET_LOG_WARN_PREFIX, $format, $args , $flags);
325326
}
326327
}
327328

328329
public function errorFormat($format, $args=array(), $flags=FILE_APPEND){
329-
if(ANET_LOG_ERROR >= ANET_LOG_LEVEL) {
330+
if(ANET_LOG_ERROR >= $this->logLevel) {
330331
$this->logFormat(ANET_LOG_ERROR_PREFIX, $format, $args , $flags);
331332
}
332333
}
333334

335+
/**
336+
* @param string $logLevel
337+
* possible values = ANET_LOG_DEBUG, ANET_LOG_INFO, ANET_LOG_WARN, ANET_LOG_ERROR
338+
*/
339+
public function setLogLevel($logLevel){
340+
$this->logLevel = $logLevel;
341+
}
342+
343+
/**
344+
* @return string
345+
*/
346+
public function getLogLevel(){
347+
return $this->logLevel;
348+
}
349+
334350
/**
335351
* @param string $logFile
336352
*/
@@ -350,4 +366,4 @@ public function __construct(){
350366
$this->sensitiveStringRegexes = ANetSensitiveFields::getSensitiveStringRegexes();
351367
}
352368
}
353-
?>
369+
?>

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
<!-- Enter your test account credentials to run tests against sandbox. -->
3434
<const name="AUTHORIZENET_API_LOGIN_ID" value="5KP3u95bQpv" />
35-
<const name="AUTHORIZENET_TRANSACTION_KEY" value="4Ktq966gC55GAX7S" />
35+
<const name="AUTHORIZENET_TRANSACTION_KEY" value="346HZ32z3fP4hTG2" />
3636
<const name="AUTHORIZENET_MD5_SETTING" value="" />
3737

3838
<!-- Enter your live account credentials to run tests against production gateway. -->

tests/AuthorizeNetCIM_Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ public function testGetCustomerProfileIds()
448448
{
449449
// A valid response should be received when a merchant has zero customer profiles...
450450
// Hence, first testing using specific credentials for a merchant which has zero customer profiles...
451-
$request = new AuthorizeNetCIM('5KP3u95bQpv','4Ktq966gC55GAX7S');
451+
$request = new AuthorizeNetCIM('5KP3u95bQpv','346HZ32z3fP4hTG2');
452452
$response = $request->getCustomerProfileIds();
453453

454454

0 commit comments

Comments
 (0)