Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #3 from roelvanduijnhoven/improve-logging
Browse files Browse the repository at this point in the history
Improve logging for ELK
  • Loading branch information
Roel van Duijnhoven authored Jul 27, 2017
2 parents da70f83 + 2c8a1ac commit 8a816b1
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ public function create(
}

// make the call
$this->logger->info("Payment create: " . $paymentId, ['request' => $request->toArray()]);
$this->logger->info("Payment create: " . $paymentId, ['requestObject' => $request->toArray()]);
$response = $this->soap('create', [$request->toArray()]);
$this->logger->info("Payment create soap request: " . $paymentId, ['request' => (array) $this->soapClient->__getLastRequest()]);
$this->logger->info("Payment create soap response: " . $paymentId, ['response' => (array) $this->soapClient->__getLastResponse()]);
$this->logger->info("Payment create soap request: " . $paymentId, ['request' => $this->soapClient->__getLastRequest()]);
$this->logger->info("Payment create soap response: " . $paymentId, ['response' => $this->soapClient->__getLastResponse()]);

// validate response
if (isset($response->createError)) {
Expand All @@ -254,7 +254,7 @@ public function create(

$this->logger->error(
"Payment create: " . $paymentId,
['error' => (array) $response->createError->getError()->getExplanation()]
['error' => $response->createError->getError()->getExplanation()]
);

throw new \Exception($response->createError->getError()->getExplanation());
Expand All @@ -268,7 +268,7 @@ public function create(
*
* @param string $orderKey
* @param Type\PaymentRequestInput $payment
* @param Type\PaymentRequest $recurringPaymentRequest
* @param Type\PaymentRequest $recurringPaymentRequest
*
* @return Type\StartSuccess
*
Expand All @@ -280,29 +280,29 @@ public function start($orderKey, Type\PaymentRequestInput $payment = null, Type\
$request->setPaymentOrderKey($orderKey);
$request->setMerchant($this->merchant);
if($payment !== null){
$request->setPayment($payment);
$request->setPayment($payment);
}
if($recurringPaymentRequest !== null){
$request->setRecurringPaymentRequest($recurringPaymentRequest);
$request->setRecurringPaymentRequest($recurringPaymentRequest);
}

// make the call
$this->logger->info("Payment start: " . $orderKey, ['request' => $request->toArray()]);
$this->logger->info("Payment start: " . $orderKey, ['requestObject' => $request->toArray()]);
$response = $this->soap('start', [$request->toArray()]);
$this->logger->info("Payment start soap request: " . $orderKey, (array) $this->soapClient->__getLastRequest());
$this->logger->info("Payment start soap response: " . $orderKey, (array) $this->soapClient->__getLastResponse());
$this->logger->info("Payment start soap request: " . $orderKey, ['request' => $this->soapClient->__getLastRequest()]);
$this->logger->info("Payment start soap response: " . $orderKey, ['response' => $this->soapClient->__getLastResponse()]);

// validate response
if (isset($response->startError)) {
if ($this->test) {
var_dump($this->soapClient->__getLastRequest());
}
$this->logger->error("Payment start: " . $orderKey, (array) $response->startError->getError()->getExplanation());

$this->logger->error("Payment start: " . $orderKey, $response->startError->getError()->getExplanation());

throw new \Exception($response->startError->getError()->getExplanation());
}

return $response->startSuccess;
}

Expand All @@ -325,10 +325,10 @@ public function cancel($paymentOrderKey)

// make the call

$this->logger->info("Payment cancel: " . $paymentOrderKey, $request->toArray());
$this->logger->info("Payment cancel: " . $paymentOrderKey, ['requestObject' => $request->toArray()]);
$response = $this->soap('cancel', [$request->toArray()]);
$this->logger->info("Payment cancel soap request: " . $paymentOrderKey, ['request' => (array) $this->soapClient->__getLastRequest()]);
$this->logger->info("Payment cancel soap response: " . $paymentOrderKey, ['response' => (array) $this->soapClient->__getLastResponse()]);
$this->logger->info("Payment cancel soap request: " . $paymentOrderKey, ['request' => $this->soapClient->__getLastRequest()]);
$this->logger->info("Payment cancel soap response: " . $paymentOrderKey, ['response' => $this->soapClient->__getLastResponse()]);

// validate response
if (isset($response->cancelError)) {
Expand All @@ -338,7 +338,7 @@ public function cancel($paymentOrderKey)

$this->logger->error(
"Payment cancel: " . $paymentOrderKey,
['error' => (array) $response->cancelError->getError()->getExplanation()]
['error' => $response->cancelError->getError()->getExplanation()]
);

throw new \Exception($response->cancelError->getError()->getExplanation());
Expand Down Expand Up @@ -409,8 +409,8 @@ public function capture(

$this->logger->info("Payment capture: " . $merchantCaptureReference, ['request' => $request->toArray()]);
$response = $this->soap('capture', [$request->toArray()]);
$this->logger->info("Payment capture soap request: " . $merchantCaptureReference, ['request' => (array) $this->soapClient->__getLastRequest()]);
$this->logger->info("Payment capture soap response: " . $merchantCaptureReference, ['response' => (array) $this->soapClient->__getLastResponse()]);
$this->logger->info("Payment capture soap request: " . $merchantCaptureReference, ['request' => $this->soapClient->__getLastRequest()]);
$this->logger->info("Payment capture soap response: " . $merchantCaptureReference, ['response' => $this->soapClient->__getLastResponse()]);

// validate response
if (isset($response->captureError)) {
Expand All @@ -420,7 +420,7 @@ public function capture(

$this->logger->error(
"Payment capture: " . $merchantCaptureReference,
['error' => (array) $response->captureError->getError()->getExplanation()]
['error' => $response->captureError->getError()->getExplanation()]
);

throw new \Exception($response->captureError->getError()->getExplanation());
Expand Down Expand Up @@ -485,8 +485,8 @@ public function refund(
// make the call
$this->logger->info("Payment capture: " . $merchantRefundReference, ['request' => $request->toArray()]);
$response = $this->soap('refund', [$request->toArray()]);
$this->logger->info("Payment capture soap request: " . $merchantRefundReference, ['request' => (array) $this->soapClient->__getLastRequest()]);
$this->logger->info("Payment capture soap response: " . $merchantRefundReference, ['response' => (array) $this->soapClient->__getLastResponse()]);
$this->logger->info("Payment capture soap request: " . $merchantRefundReference, ['request' => $this->soapClient->__getLastRequest()]);
$this->logger->info("Payment capture soap response: " . $merchantRefundReference, ['response' => $this->soapClient->__getLastResponse()]);

// validate response
if (isset($response->refundError)) {
Expand All @@ -497,7 +497,7 @@ public function refund(

$this->logger->error(
"Payment capture: " . $merchantRefundReference,
['error' => (array) $response->refundError->getError()->getExplanation()]
['error' => $response->refundError->getError()->getExplanation()]
);

throw new \Exception(
Expand Down Expand Up @@ -526,12 +526,12 @@ public function status($paymentOrderKey)
$request->setPaymentOrderKey($paymentOrderKey);

// make the call
$this->logger->info("Payment status: " . $paymentOrderKey, ['request' => $request->toArray()]);
$this->logger->info("Payment status: " . $paymentOrderKey, ['requestObject' => $request->toArray()]);

/** @var StatusResponse $response */
$response = $this->soap('status', [$request->toArray()]);
$this->logger->info("Payment status soap request: " . $paymentOrderKey, ['request' => (array) $this->soapClient->__getLastRequest()]);
$this->logger->info("Payment status soap response: " . $paymentOrderKey, ['response' => (array) $this->soapClient->__getLastResponse()]);
$this->logger->info("Payment status soap request: " . $paymentOrderKey, ['request' => $this->soapClient->__getLastRequest()]);
$this->logger->info("Payment status soap response: " . $paymentOrderKey, ['response' => $this->soapClient->__getLastResponse()]);

// validate response
if ($response->getStatusError()) {
Expand All @@ -542,7 +542,7 @@ public function status($paymentOrderKey)

$this->logger->error(
"Payment status: " . $paymentOrderKey,
['error' => (array) $response->getStatusError()->getError()->getExplanation()]
['error' => $response->getStatusError()->getError()->getExplanation()]
);

throw new \Exception($response->getStatusError()->getError()->getExplanation());
Expand Down

0 comments on commit 8a816b1

Please sign in to comment.