Skip to content

Commit fe05ddd

Browse files
committed
Merge pull request #44 from delatbabel/implement-getcode
Implement getCode method in Response class
2 parents eb42edb + d0b5e4e commit fe05ddd

File tree

1 file changed

+31
-15
lines changed

1 file changed

+31
-15
lines changed

src/Message/Response.php

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getTransactionReference()
4040
return $this->data['error']['charge'];
4141
}
4242

43-
return;
43+
return null;
4444
}
4545

4646
/**
@@ -79,7 +79,7 @@ public function getCustomerReference()
7979
}
8080
}
8181

82-
return;
82+
return null;
8383
}
8484

8585
/**
@@ -110,7 +110,7 @@ public function getCardReference()
110110
}
111111
}
112112

113-
return;
113+
return null;
114114
}
115115

116116
/**
@@ -124,7 +124,7 @@ public function getToken()
124124
return $this->data['id'];
125125
}
126126

127-
return;
127+
return null;
128128
}
129129

130130
/**
@@ -138,7 +138,7 @@ public function getCard()
138138
return $this->data['card'];
139139
}
140140

141-
return;
141+
return null;
142142
}
143143

144144
/**
@@ -150,9 +150,9 @@ public function getSource()
150150
{
151151
if (isset($this->data['source']) && $this->data['source']['object'] == 'card') {
152152
return $this->data['source'];
153-
} else {
154-
return;
155153
}
154+
155+
return null;
156156
}
157157

158158
/**
@@ -166,7 +166,7 @@ public function getSubscriptionReference()
166166
return $this->data['id'];
167167
}
168168

169-
return;
169+
return null;
170170
}
171171

172172
/**
@@ -180,7 +180,7 @@ public function getEventReference()
180180
return $this->data['id'];
181181
}
182182

183-
return;
183+
return null;
184184
}
185185

186186
/**
@@ -194,7 +194,7 @@ public function getInvoiceReference()
194194
return $this->data['id'];
195195
}
196196

197-
return;
197+
return null;
198198
}
199199

200200
/**
@@ -208,7 +208,7 @@ public function getList()
208208
return $this->data['data'];
209209
}
210210

211-
return;
211+
return null;
212212
}
213213

214214
/**
@@ -224,7 +224,7 @@ public function getPlan()
224224
return $this->data;
225225
}
226226

227-
return;
227+
return null;
228228
}
229229

230230
/**
@@ -239,7 +239,7 @@ public function getPlanId()
239239
return $plan['id'];
240240
}
241241

242-
return;
242+
return null;
243243
}
244244

245245
/**
@@ -253,7 +253,7 @@ public function getInvoiceItemReference()
253253
return $this->data['id'];
254254
}
255255

256-
return;
256+
return null;
257257
}
258258

259259
/**
@@ -269,6 +269,22 @@ public function getMessage()
269269
return $this->data['error']['message'];
270270
}
271271

272-
return;
272+
return null;
273+
}
274+
275+
/**
276+
* Get the error message from the response.
277+
*
278+
* Returns null if the request was successful.
279+
*
280+
* @return string|null
281+
*/
282+
public function getCode()
283+
{
284+
if (!$this->isSuccessful()) {
285+
return $this->data['error']['code'];
286+
}
287+
288+
return null;
273289
}
274290
}

0 commit comments

Comments
 (0)