1 | <?php |
||
9 | class MtnConfig |
||
10 | { |
||
11 | use AttributesMassAssignable; |
||
12 | |||
13 | /** |
||
14 | * @var string target environment |
||
15 | */ |
||
16 | public $baseUrl; |
||
17 | |||
18 | /** |
||
19 | * @var string the currency of http calls |
||
20 | */ |
||
21 | public $targetEnvironment; |
||
22 | |||
23 | /** |
||
24 | * @var string The MTN OpenApi currency |
||
25 | */ |
||
26 | public $currency; |
||
27 | |||
28 | /** |
||
29 | * @var string The MTN product suscribed to. |
||
30 | * collection|disbursement|remittance |
||
31 | */ |
||
32 | public $product; |
||
33 | |||
34 | const PRODUCTS = ['collection', 'disbursement', 'remittance']; |
||
35 | |||
36 | /** |
||
37 | * @var string The MTN OpenApi collections credentials |
||
38 | * - API Secret. |
||
39 | * - Primary Key |
||
40 | * - User Id |
||
41 | * - callback Url : can be overriden by a url set in the params array |
||
42 | */ |
||
43 | public $collectionApiSecret; |
||
44 | |||
45 | public $collectionPrimaryKey; |
||
46 | |||
47 | public $collectionUserId; |
||
48 | |||
49 | public $collectionCallbackUrl; |
||
50 | |||
51 | |||
52 | /** |
||
53 | * @var string The MTN OpenApi remittance credentials |
||
54 | * - API Secret. |
||
55 | * - Primary Key |
||
56 | * - User Id |
||
57 | * - callback Url : can be overriden by a url set in the params array |
||
58 | */ |
||
59 | public $remittanceApiSecret; |
||
60 | |||
61 | public $remittancePrimaryKey; |
||
62 | |||
63 | public $remittanceUserId; |
||
64 | |||
65 | public $remittanceCallbackUrl; |
||
66 | |||
67 | |||
68 | /** |
||
69 | * @var string The MTN OpenApi disbursements primary Key |
||
70 | * - API Secret. |
||
71 | * - Primary Key |
||
72 | * - User Id |
||
73 | * - callback Url : can be overriden by a url set in the params array |
||
74 | */ |
||
75 | public $disbursementApiSecret; |
||
76 | |||
77 | public $disbursementPrimaryKey; |
||
78 | |||
79 | public $disbursementUserId; |
||
80 | |||
81 | public $disbursementCallbackUrl; |
||
82 | |||
83 | |||
84 | /** |
||
85 | * Set values of configs |
||
86 | * |
||
87 | * @param array $configArray |
||
88 | */ |
||
89 | public function __construct($configArray) |
||
93 | |||
94 | /** |
||
95 | * Checck if all credentials are filled for the necessary |
||
96 | * product |
||
97 | * |
||
98 | * @param string $product disbursement | remittance | collection |
||
99 | * @throws \Exception |
||
100 | * @return void |
||
101 | */ |
||
102 | public function validate($product) |
||
123 | |||
124 | /** |
||
125 | * Get set of configs required according to the product being used. |
||
126 | * |
||
127 | * @param string $product disbursement | remittance | collection |
||
128 | * @return array |
||
129 | */ |
||
130 | protected function requiredConfigs($product) |
||
141 | |||
142 | /** |
||
143 | * Get specific config dynamicsally |
||
144 | * |
||
145 | * @param string $product 'collection'|'disbursement'|'remittance' |
||
146 | * @param string $configKey 'primaryKey' | 'ApiSecret' | 'UserId' |
||
147 | * $throws PatricPoba\MtnMomo\Exceptions\MtnConfigException\MtnConfigException |
||
148 | * @return string |
||
149 | */ |
||
150 | public function getValue($product, $configKey) |
||
161 | } |
||
162 |