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,34 @@ 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
+ * // Create the gateway object
259
+ * $gw = Omnipay::create('MyGateway');
260
+ *
261
+ * // Create the request object
262
+ * $myRequest = $gw->myRequest($someParameters);
263
+ * </code>
264
+ *
265
+ * @see \Omnipay\Common\Message\AbstractRequest
266
+ * @param string $class The request class name
267
+ * @param array $parameters
268
+ * @return \Omnipay\Common\Message\AbstractRequest
218
269
*/
219
270
protected function createRequest ($ class , array $ parameters )
220
271
{
@@ -223,6 +274,11 @@ protected function createRequest($class, array $parameters)
223
274
return $ obj ->initialize (array_replace ($ this ->getParameters (), $ parameters ));
224
275
}
225
276
277
+ /**
278
+ * Get the global default HTTP client.
279
+ *
280
+ * @return HttpClient
281
+ */
226
282
protected function getDefaultHttpClient ()
227
283
{
228
284
return new HttpClient (
@@ -233,6 +289,11 @@ protected function getDefaultHttpClient()
233
289
);
234
290
}
235
291
292
+ /**
293
+ * Get the global default HTTP request.
294
+ *
295
+ * @return HttpRequest
296
+ */
236
297
protected function getDefaultHttpRequest ()
237
298
{
238
299
return HttpRequest::createFromGlobals ();
0 commit comments