1 | <?php |
||
5 | class Mpesa { |
||
6 | |||
7 | private $api_url = 'https://api.sandbox.vm.co.mz'; |
||
8 | private $api_port; |
||
9 | public $public_key; |
||
10 | public $api_key; |
||
11 | |||
12 | public function __construct($config = []) |
||
20 | |||
21 | public function setPublicKey($public_key){ |
||
24 | |||
25 | public function setApiKey($api_key){ |
||
28 | |||
29 | public function setEnv($env){ |
||
34 | |||
35 | |||
36 | /* Standard customer-to-business transaction |
||
37 | * |
||
38 | * @param string $transactionReference This is the reference of the transaction for the customer or business making the * transaction. This can be a smartcard number for a TV subscription or a reference number of a utility bill. |
||
39 | * @param string $customerMSISDN MSISDN of the customer for the transaction |
||
40 | * @param string $amount The amount for the transaction. |
||
41 | * @param string $thirdPartReferece This is the unique reference of the third party system. When there are queries about transactions, this will usually be used to track a transaction. |
||
42 | * @param string $serviceCode Shortcode of the business where funds will be credited to. |
||
43 | * @return \stdClass |
||
44 | */ |
||
45 | function c2b($transactionReference, $customerMSISDN, $amount, $thirdPartReferece, $serviceCode){ |
||
58 | |||
59 | /** |
||
60 | * @param $transactionID |
||
61 | * @param $securityCredential |
||
62 | * @param $initiatorIdentifier |
||
63 | * @param $thirdPartyReference |
||
64 | * @param $serviceProviderCode |
||
65 | * @param $reversalAmount |
||
66 | * @return \stdClass |
||
67 | */ |
||
68 | public function transactionReversal($transactionID, $securityCredential, $initiatorIdentifier, $thirdPartyReference, $serviceProviderCode, $reversalAmount) |
||
82 | |||
83 | /** |
||
84 | * @param $thirdPartyReference |
||
85 | * @param $queryReference |
||
86 | * @param $serviceProviderCode |
||
87 | * @return \stdClass |
||
88 | */ |
||
89 | public function status($thirdPartyReference, $queryReference, $serviceProviderCode) |
||
103 | |||
104 | /** |
||
105 | * Generates a base64 encoded token |
||
106 | */ |
||
107 | public function getToken() |
||
122 | |||
123 | /** |
||
124 | * @param string $url |
||
125 | * @param string $method |
||
126 | * @param array $fields |
||
127 | * @return \stdClass |
||
128 | */ |
||
129 | private function makeRequest(string $url,string $method, array $fields = []) |
||
169 | |||
170 | /** |
||
171 | * @return array |
||
172 | */ |
||
173 | private function getHeader() |
||
183 | |||
184 | |||
185 | } |
||
186 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.