17
17
* throughout the Omnipay system. It enforces implementation of
18
18
* the GatewayInterface interface and defines various common attibutes
19
19
* and methods that all gateways should have.
20
+ *
21
+ * Example:
22
+ *
23
+ * <code>
24
+ * // Initialise the gateway
25
+ * $gateway->initialize(...);
26
+ *
27
+ * // Get the gateway parameters.
28
+ * $parameters = $gateway->getParameters();
29
+ *
30
+ * // Create a credit card object
31
+ * $card = new CreditCard(...);
32
+ *
33
+ * // Do an authorisation transaction on the gateway
34
+ * if ($gateway->supportsAuthorize()) {
35
+ * $gateway->authorize(...);
36
+ * } else {
37
+ * throw new \Exception('Gateway does not support authorize()');
38
+ * }
39
+ * </code>
40
+ *
41
+ * For further code examples see the *omnipay-example* repository on github.
42
+ *
43
+ * @see GatewayInterface
20
44
*/
21
45
abstract class AbstractGateway implements GatewayInterface
22
46
{
@@ -214,7 +238,30 @@ public function supportsUpdateCard()
214
238
}
215
239
216
240
/**
217
- * Create and initialize a request object using existing parameters from this gateway
241
+ * Create and initialize a request object
242
+ *
243
+ * This function is usually used to create objects of type
244
+ * Omnipay\Common\Message\AbstractRequest (or a non-abstract subclass of it)
245
+ * and initialise them with using existing parameters from this gateway.
246
+ *
247
+ * Example:
248
+ *
249
+ * <code>
250
+ * class myRequest extends \Omnipay\Common\Message\AbstractRequest {};
251
+ *
252
+ * class myGateway extends \Omnipay\Common\AbstractGateway {
253
+ * function myRequest($parameters) {
254
+ * $this->createRequest('myRequest', $parameters);
255
+ * }
256
+ * }
257
+ *
258
+ * $myRequest = myGateway->myRequest($someParameters);
259
+ * </code>
260
+ *
261
+ * @see \Omnipay\Common\Message\AbstractRequest
262
+ * @param string $class The request class name
263
+ * @param array $parameters
264
+ * @return \Omnipay\Common\Message\AbstractRequest
218
265
*/
219
266
protected function createRequest ($ class , array $ parameters )
220
267
{
@@ -223,6 +270,11 @@ protected function createRequest($class, array $parameters)
223
270
return $ obj ->initialize (array_replace ($ this ->getParameters (), $ parameters ));
224
271
}
225
272
273
+ /**
274
+ * Get the global default HTTP client.
275
+ *
276
+ * @return HttpClient
277
+ */
226
278
protected function getDefaultHttpClient ()
227
279
{
228
280
return new HttpClient (
@@ -233,6 +285,11 @@ protected function getDefaultHttpClient()
233
285
);
234
286
}
235
287
288
+ /**
289
+ * Get the global default HTTP request.
290
+ *
291
+ * @return HttpRequest
292
+ */
236
293
protected function getDefaultHttpRequest ()
237
294
{
238
295
return HttpRequest::createFromGlobals ();
0 commit comments