Skip to content

Commit 769d8ab

Browse files
authored
Merge pull request #107 from phpguru/issue/106-outcome-details
Adding a getOutcome method to Message\Response to solve Issue 106
2 parents 9241dc4 + 946b585 commit 769d8ab

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/Message/Response.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,29 @@ public function isSuccessful()
5555
*/
5656
public function getChargeReference()
5757
{
58-
if (isset($this->data['object']) && $this->data['object'] == 'charge') {
58+
if (isset($this->data['object']) && 'charge' === $this->data['object']) {
5959
return $this->data['id'];
6060
}
6161

6262
return null;
6363
}
6464

65+
/**
66+
* Get the outcome of a charge from the response
67+
*
68+
* @return array|null
69+
*/
70+
public function getOutcome()
71+
{
72+
if (isset($this->data['object']) && 'charge' === $this->data['object']) {
73+
if (isset($this->data['outcome']) && !empty($this->data['outcome'])) {
74+
return $this->data['outcome'];
75+
}
76+
}
77+
78+
return null;
79+
}
80+
6581
/**
6682
* Get the transaction reference.
6783
*

0 commit comments

Comments
 (0)