1 | <?php |
||
8 | class Mpesa |
||
9 | { |
||
10 | |||
11 | private $base_uri = 'https://api.sandbox.vm.co.mz'; |
||
12 | private $public_key; |
||
13 | private $api_key; |
||
14 | |||
15 | public function __construct($config = null) |
||
23 | |||
24 | public function setPublicKey($public_key) |
||
28 | |||
29 | public function setApiKey($api_key) |
||
33 | |||
34 | public function setEnv($env) |
||
40 | |||
41 | |||
42 | /* Standard customer-to-business transaction |
||
43 | * |
||
44 | * @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. |
||
45 | * @param string $customerMSISDN MSISDN of the customer for the transaction |
||
46 | * @param string $amount The amount for the transaction. |
||
47 | * @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. |
||
48 | * @param string $serviceCode Shortcode of the business where funds will be credited to. |
||
49 | * @return \stdClass |
||
50 | */ |
||
51 | function c2b($transactionReference, $customerMSISDN, $amount, $thirdPartReferece, $serviceCode) |
||
64 | |||
65 | /** |
||
66 | * @param $transactionID |
||
67 | * @param $securityCredential |
||
68 | * @param $initiatorIdentifier |
||
69 | * @param $thirdPartyReference |
||
70 | * @param $serviceProviderCode |
||
71 | * @param $reversalAmount |
||
72 | * @return \stdClass |
||
73 | */ |
||
74 | public function transactionReversal($transactionID, $securityCredential, $initiatorIdentifier, $thirdPartyReference, $serviceProviderCode, $reversalAmount) |
||
86 | |||
87 | /** |
||
88 | * @param $thirdPartyReference |
||
89 | * @param $queryReference |
||
90 | * @param $serviceProviderCode |
||
91 | * @return \stdClass |
||
92 | */ |
||
93 | public function status($thirdPartyReference, $queryReference, $serviceProviderCode) |
||
106 | |||
107 | /** |
||
108 | * Generates a base64 encoded token |
||
109 | */ |
||
110 | public function getToken() |
||
124 | |||
125 | /** |
||
126 | * @param string $url |
||
127 | * @param string $method |
||
128 | * @param array $fields |
||
129 | * @return \stdClass |
||
130 | */ |
||
131 | private function makeRequest(string $url, int $port, string $method, array $fields = []) |
||
164 | |||
165 | /** |
||
166 | * @return array |
||
167 | */ |
||
168 | private function getHeaders() |
||
178 | } |
||
179 |
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.