|
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 PayWithAmazon\Client; |
|
11
|
|
|
use PayWithAmazon\IpnHandler; |
|
12
|
|
|
use SprykerEco\Shared\Amazonpay\AmazonpayConfigInterface; |
|
13
|
|
|
|
|
14
|
|
|
class AmazonpaySdkAdapterFactory implements AmazonpaySdkAdapterFactoryInterface |
|
15
|
|
|
{ |
|
16
|
|
|
|
|
17
|
|
|
const MERCHANT_ID = 'merchant_id'; |
|
18
|
|
|
const PLATFORM_ID = 'platform_id'; |
|
19
|
|
|
const ACCESS_KEY = 'access_key'; |
|
20
|
|
|
const SECRET_KEY = 'secret_key'; |
|
21
|
|
|
const CLIENT_ID = 'client_id'; |
|
22
|
|
|
const REGION = 'region'; |
|
23
|
|
|
const CURRENCY_CODE = 'currency_code'; |
|
24
|
|
|
const SANDBOX = 'sandbox'; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @param \SprykerEco\Shared\Amazonpay\AmazonpayConfigInterface $config |
|
28
|
|
|
* |
|
29
|
|
|
* @return \PayWithAmazon\ClientInterface |
|
30
|
|
|
*/ |
|
31
|
|
|
public function createAmazonpayClient(AmazonpayConfigInterface $config) |
|
32
|
|
|
{ |
|
33
|
|
|
$aConfig = [ |
|
34
|
|
|
static::MERCHANT_ID => $config->getSellerId(), |
|
35
|
|
|
static::PLATFORM_ID => $config->getSellerId(), |
|
36
|
|
|
static::ACCESS_KEY => $config->getAccessKeyId(), |
|
37
|
|
|
static::SECRET_KEY => $config->getSecretAccessKey(), |
|
38
|
|
|
static::CLIENT_ID => $config->getClientId(), |
|
39
|
|
|
static::REGION => $config->getRegion(), |
|
40
|
|
|
static::CURRENCY_CODE => $config->getCurrencyIsoCode(), |
|
41
|
|
|
static::SANDBOX => $config->isSandbox(), |
|
42
|
|
|
]; |
|
43
|
|
|
|
|
44
|
|
|
return new Client($aConfig); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @param array $headers |
|
49
|
|
|
* @param string $body |
|
50
|
|
|
* |
|
51
|
|
|
* @return \PayWithAmazon\IpnHandlerInterface |
|
52
|
|
|
*/ |
|
53
|
|
|
public function createAmazonpayIpnHandler(array $headers, $body) |
|
54
|
|
|
{ |
|
55
|
|
|
return new IpnHandler($headers, $body); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
|