1
|
|
|
<?php |
2
|
|
|
namespace CultureKings\Afterpay\Model\Merchant; |
3
|
|
|
|
4
|
|
|
use CultureKings\Afterpay\Contacts\AuthorizationInterface; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* Class Authorization |
8
|
|
|
* |
9
|
|
|
* @package CultureKings\Afterpay |
10
|
|
|
*/ |
11
|
|
|
class Authorization implements AuthorizationInterface |
12
|
|
|
{ |
13
|
|
|
const PRODUCTION_URI = 'https://api.secure-afterpay.com.au/v1/'; |
14
|
|
|
const PRODUCTION_BASE_URI = 'https://api.secure-afterpay.com.au'; |
15
|
|
|
const SANDBOX_URI = 'https://api-sandbox.secure-afterpay.com.au/v1/'; |
16
|
|
|
const SANDBOX_BASE_URL = 'https://api-sandbox.secure-afterpay.com.au'; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
protected $endpoint; |
22
|
|
|
/** |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
protected $merchantId; |
26
|
|
|
/** |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
protected $secret; |
30
|
|
|
/** |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
protected $user_agent; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Authorization constructor. |
37
|
|
|
* @param string $endpoint |
38
|
|
|
* @param string|null $merchantId |
39
|
|
|
* @param string|null $secret |
40
|
|
|
*/ |
41
|
|
|
public function __construct($endpoint, $merchantId = null, $secret = null) |
42
|
|
|
{ |
43
|
|
|
$this->setEndpoint($endpoint); |
44
|
|
|
$this->setMerchantId($merchantId); |
45
|
|
|
$this->setSecret($secret); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return string |
50
|
|
|
*/ |
51
|
|
|
public function getEndpoint() |
52
|
|
|
{ |
53
|
|
|
return $this->endpoint; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param string $endpoint |
58
|
|
|
* @return $this |
59
|
|
|
*/ |
60
|
|
|
public function setEndpoint($endpoint) |
61
|
|
|
{ |
62
|
|
|
$this->endpoint = $endpoint; |
63
|
|
|
|
64
|
|
|
return $this; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return string |
69
|
|
|
*/ |
70
|
|
|
public function getMerchantId() |
71
|
|
|
{ |
72
|
|
|
return $this->merchantId; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param string $merchantId |
77
|
|
|
* @return $this |
78
|
|
|
*/ |
79
|
|
|
public function setMerchantId($merchantId) |
80
|
|
|
{ |
81
|
|
|
$this->merchantId = $merchantId; |
82
|
|
|
|
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return string |
88
|
|
|
*/ |
89
|
|
|
public function getSecret() |
90
|
|
|
{ |
91
|
|
|
return $this->secret; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param string $secret |
96
|
|
|
* @return $this |
97
|
|
|
*/ |
98
|
|
|
public function setSecret($secret) |
99
|
|
|
{ |
100
|
|
|
$this->secret = $secret; |
101
|
|
|
|
102
|
|
|
return $this; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @param string $user_agent |
108
|
|
|
* @return $this |
109
|
|
|
*/ |
110
|
|
|
public function setUserAgent($user_agent) |
111
|
|
|
{ |
112
|
|
|
$this->user_agent = $user_agent; |
113
|
|
|
|
114
|
|
|
return $this; |
115
|
|
|
} |
116
|
|
|
/** |
117
|
|
|
* @return string |
118
|
|
|
*/ |
119
|
|
|
public function getUserAgent() |
120
|
|
|
{ |
121
|
|
|
return $this->user_agent; |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
|