createAmazonPayIpnHandler()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Apache OSL-2
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\AmazonPay\Business\Api\Adapter\Sdk;
9
10
use AmazonPay\Client;
11
use AmazonPay\IpnHandler;
12
use SprykerEco\Shared\AmazonPay\AmazonPayConfigInterface;
13
14
class AmazonPaySdkAdapterFactory implements AmazonPaySdkAdapterFactoryInterface
15
{
16
    public const MERCHANT_ID = 'merchant_id';
17
    public const PLATFORM_ID = 'platform_id';
18
    public const ACCESS_KEY = 'access_key';
19
    public const SECRET_KEY = 'secret_key';
20
    public const CLIENT_ID = 'client_id';
21
    public const REGION = 'region';
22
    public const CURRENCY_CODE = 'currency_code';
23
    public const SANDBOX = 'sandbox';
24
25
    /**
26
     * @param \SprykerEco\Shared\AmazonPay\AmazonPayConfigInterface $config
27
     *
28
     * @return \AmazonPay\ClientInterface
29
     */
30
    public function createAmazonPayClient(AmazonPayConfigInterface $config)
31
    {
32
        $aConfig = [
33
            static::MERCHANT_ID => $config->getSellerId(),
34
            static::PLATFORM_ID => $config->getSellerId(),
35
            static::ACCESS_KEY => $config->getAccessKeyId(),
36
            static::SECRET_KEY => $config->getSecretAccessKey(),
37
            static::CLIENT_ID => $config->getClientId(),
38
            static::REGION => $config->getRegion(),
39
            static::CURRENCY_CODE => $config->getCurrencyIsoCode(),
40
            static::SANDBOX => $config->isSandbox(),
41
        ];
42
43
        return new Client($aConfig);
44
    }
45
46
    /**
47
     * @param array $headers
48
     * @param string $body
49
     *
50
     * @return \AmazonPay\IpnHandlerInterface
51
     */
52
    public function createAmazonPayIpnHandler(array $headers, $body)
53
    {
54
        return new IpnHandler($headers, $body);
55
    }
56
}
57