Updates to LIPP & Future Payments

- Updated LIPP Sample code
- Updated Future Payments to have helper functions for retrieving access token
- Updated Logging Syntax to include timestamp and response json
This commit is contained in:
japatel
2014-10-20 12:04:41 -05:00
parent dcc147ac7e
commit 84660cbb2a
42 changed files with 1156 additions and 789 deletions

View File

@@ -79,8 +79,7 @@ class PPHttpConnection
public function execute($data)
{
//Initialize the logger
$this->logger->fine("Connecting to " . $this->httpConfig->getUrl());
$this->logger->fine("Payload " . $data);
$this->logger->info($this->httpConfig->getMethod() . ' ' . $this->httpConfig->getUrl());
//Initialize Curl Options
$ch = curl_init($this->httpConfig->getUrl());
@@ -100,18 +99,19 @@ class PPHttpConnection
//Default Option if Method not of given types in switch case
if ($this->httpConfig->getMethod() != NULL) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->httpConfig->getMethod());
$this->logger->info("Method : " . $this->httpConfig->getMethod());
}
//Logging Each Headers for debugging purposes
foreach ($this->getHttpHeaders() as $header) {
//TODO: Strip out credentials and other secure info when logging.
$this->logger->info("Adding header $header");
$this->logger->fine($header);
}
$this->logger->fine("Payload : " . $data . "\n");
//Execute Curl Request
$result = curl_exec($ch);
//Retry if Certificate Exception
if (curl_errno($ch) == 60) {
$this->logger->info("Invalid or no certificate authority found - Retrying using bundled CA certs file");
@@ -151,6 +151,7 @@ class PPHttpConnection
"Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}. " .
"Retried $retries times."
);
$this->logger->fine("Response : " . $result . "\n\n");
$ex->setData($result);
throw $ex;
} else if ($httpStatus < 200 || $httpStatus >= 300) {
@@ -159,10 +160,13 @@ class PPHttpConnection
"Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}.",
$httpStatus
);
$this->logger->fine("Response : " . $result . "\n\n");
$ex->setData($result);
throw $ex;
}
$this->logger->fine("Response : " . $result . "\n\n");
//Return result object
return $result;
}