Skip to content

Commit

Permalink
Refactor Circle Dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
ovac committed Aug 13, 2017
1 parent 701c0e5 commit 77c943e
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions src/Api/Transaction/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,16 @@ public function setCustomer($data = [])
/**
* This method sests a single callback for both the success and Error
* @param string $primaryCallbackURL A url for callbacks from the hubtel server
* @return function
* @return self
*/
public function callback($primaryCallbackURL)
{
return $this->setPrimaryCallbackURL($primaryCallbackURL)
->setSecondaryCallbackURL($primaryCallbackURL);
if (is_string($primaryCallbackURL)) {
$this->setPrimaryCallbackURL($primaryCallbackURL)
->setSecondaryCallbackURL($primaryCallbackURL);
}

return $this;
}

/**
Expand All @@ -352,6 +356,7 @@ public function callback($primaryCallbackURL)
public function setCallback($data = [])
{
if (is_array($data)) {

if (array_key_exists('callbackOnFail', $data)) {
$this->setSecondaryCallbackURL($data['callbackOnFail']);
}
Expand All @@ -369,21 +374,11 @@ public function setCallback($data = [])
}

if (array_key_exists('callback', $data)) {
if (is_array($data['callback']) && array_key_exists('success', $data['callback'])) {
$this->setPrimaryCallbackURL($data['callback']['success']);
}

if (is_array($data['callback']) && array_key_exists('error', $data['callback'])) {
$this->setSecondaryCallbackURL($data['callback']['error']);
}

if (is_string($data['callback'])) {
$this->callback($data['callback']);
}
$this->setCallback($data['callback']);
}
}

return $this;
return $this->callback($data);
}
/**
* Sets the URL to call when the payment fails or is unsuccessfull
Expand Down

0 comments on commit 77c943e

Please sign in to comment.