saveFirstDataNotification()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 16
rs 9.7998
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Glue\FirstData\Processor\Saver;
9
10
use Generated\Shared\Transfer\FirstDataNotificationTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ataNotificationTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use SprykerEco\Client\FirstData\FirstDataClientInterface;
12
13
class FirstDataNotificationSaver implements FirstDataNotificationSaverInterface
14
{
15
    protected const KEY_ID_TRANSACTION = 'ipgTransactionId';
16
    protected const KEY_PAYMENT_TOKEN = 'hosteddataid';
17
    protected const KEY_STATUS = 'status';
18
    protected const KEY_TXN_DATE_TIME = 'txndatetime';
19
    protected const KEY_TXN_TYPE = 'txntype';
20
    protected const KEY_REF_NUMBER = 'refnumber';
21
    protected const KEY_ID_SCHEME_TRANSACTION = 'schemeTransactionId';
22
    protected const KEY_APPROVAL_CODE = 'approval_code';
23
    protected const KEY_CHARGE_TOTAL = 'chargetotal';
24
    protected const KEY_CURRENCY = 'currency';
25
    protected const KEY_ID_ORDER = 'oid';
26
    protected const KEY_TIMEZONE = 'timezone';
27
28
    /**
29
     * @var \SprykerEco\Client\FirstData\FirstDataClientInterface
30
     */
31
    protected $firstDataClient;
32
33
    /**
34
     * @param \SprykerEco\Client\FirstData\FirstDataClientInterface $firstDataClient
35
     */
36
    public function __construct(FirstDataClientInterface $firstDataClient)
37
    {
38
        $this->firstDataClient = $firstDataClient;
39
    }
40
41
    /**
42
     * @param array $postData
43
     *
44
     * @return void
45
     */
46
    public function saveFirstDataNotification(array $postData): void
47
    {
48
        $firstDataNotificationRequestTransfer = (new FirstDataNotificationTransfer())
49
            ->setTransactionId($postData[static::KEY_ID_TRANSACTION] ?? '')
50
            ->setPaymentToken($postData[static::KEY_PAYMENT_TOKEN] ?? '')
51
            ->setStatus($postData[static::KEY_STATUS] ?? '')
52
            ->setTxnDateTime($postData[static::KEY_TXN_DATE_TIME] ?? '')
53
            ->setTxnType($postData[static::KEY_TXN_TYPE] ?? '')
54
            ->setRefNumber($postData[static::KEY_REF_NUMBER] ?? '')
55
            ->setIdSchemeTransaction($postData[static::KEY_ID_SCHEME_TRANSACTION] ?? '')
56
            ->setApprovalCode($postData[static::KEY_APPROVAL_CODE] ?? '')
57
            ->setChargeTotal($postData[static::KEY_CHARGE_TOTAL] ?? '')
58
            ->setCurrency($postData[static::KEY_CURRENCY] ?? '')
59
            ->setOid($postData[static::KEY_ID_ORDER] ?? '')
60
            ->setTimezone($postData[static::KEY_TIMEZONE] ?? '');
61
        $this->firstDataClient->processNotification($firstDataNotificationRequestTransfer);
62
    }
63
}
64