<commit_before># The architecture

The code snippets presented below are only for demonstration purposes (pseudo code). Their goal is to illustrate the general approach to various tasks. To see real life examples please follow the links provided when appropriate.
In general, you have to create a _[request][base-request]_ , implement _[action][action-interface]_ in order to know what to do with such request.
And use _gateway_ that implements _[gateway interface][gateway-interface]_.
This is where things get processed.
This interface forces us to specify route to possible actions and can execute the request.
So, gateway is the place where a request and an action meet together.

_**Note**: If you'd like to see real world examples we have provided you with a sandbox: [online][sandbox-online], [code][sandbox-code]._

```php
<?php
$gateway = new Gateway;
$gateway->addAction(new CaptureAction));

//CaptureAction does its job.
$gateway->execute($capture = new Capture(array(
    'amount' => 100,
    'currency' => 'USD'
));

var_export($capture->getModel());
```

```php
<?php
class CaptureAction implements ActionInterface
{
    public function execute($request)
    {
       $model = $request->getModel();

       //capture payment logic here

       $model['status'] = 'success';
       $model['transaction_id'] = 'an_id';
    }

    public function supports($request)
    {
        return $request instanceof Capture;
    }
}
```<commit_msg>fix typo<commit_after># The architecture

The code snippets presented below are only for demonstration purposes (pseudo code). Their goal is to illustrate the general approach to various tasks. To see real life examples please follow the links provided when appropriate.
In general, you have to create a _[request][base-request]_ , implement _[action][action-interface]_ in order to know what to do with such request.
And use _gateway_ that implements _[gateway interface][gateway-interface]_.
This is where things get processed.
This interface forces us to specify route to possible actions and can execute the request.
So, gateway is the place where a request and an action meet together.

_**Note**: If you'd like to see real world examples we have provided you with a sandbox: [online][sandbox-online], [code][sandbox-code]._

```php
<?php
$gateway = new Gateway;
$gateway->addAction(new CaptureAction);

//CaptureAction does its job.
$gateway->execute($capture = new Capture(array(
    'amount' => 100,
    'currency' => 'USD'
));

var_export($capture->getModel());
```

```php
<?php
class CaptureAction implements ActionInterface
{
    public function execute($request)
    {
       $model = $request->getModel();

       //capture payment logic here

       $model['status'] = 'success';
       $model['transaction_id'] = 'an_id';
    }

    public function supports($request)
    {
        return $request instanceof Capture;
    }
}
```
{'fraction_non_alphanumeric': 0.10462707182320442, 'fraction_numerical': 0.0020718232044198894, 'mean_word_length': 4.191756272401434, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '928610', 'n_tokens_mistral': 805, 'n_tokens_neox': 762, 'n_words': 325}