@@ -9,6 +9,7 @@ This library makes it easy for PHP developers to integrate with One4All TPP onli
9
9
10
10
It's supported on PHP 5.5+
11
11
12
+ ## Using the Library
12
13
``` php
13
14
use MyOne4All\TppClient;
14
15
use MyOne4All\Exceptions\TppException;
@@ -17,16 +18,33 @@ use MyOne4All\NetworkCodes;
17
18
18
19
$tppClient = new TppClient("apikey", "apisecret", "retailer");
19
20
21
+ ```
22
+
23
+ ## Get Balance
24
+ ``` php
25
+ # ecredit balance
20
26
echo $tppClient->getBalance(); # 0.0
21
27
28
+ # mobile money collection balance
29
+ echo $tppClient->getBalance(TppClient::WALLET_TYPE_MOBILE_MONEY_COLLECTION); # 0.0
30
+
31
+ # mobile money credit balance
32
+ echo $tppClient->getBalance(TppClient::WALLET_TYPE_MOBILE_MONEY_CREDIT); # 0.0
33
+ ```
34
+
35
+ ## Send Airtime
36
+ ``` php
22
37
// send airtime implementation
23
38
$airtime_response = $tppClient->sendAirtime("0245667942", 1, "trans03423423", NetworkCodes::AUTO_DETECT);
24
39
if($airtime_response->isSuccessful()){
25
40
echo "airtime sent";
26
41
}else{
27
42
echo "Failed: ".$airtime_response->getErrorMessage();
28
43
}
44
+ ```
29
45
46
+ ## Send Data Bundle
47
+ ``` php
30
48
// send internet data implementation
31
49
$data_code = "DAILY_20MB";
32
50
$transaction_reference = "trans03423423";
@@ -36,7 +54,24 @@ if($bundle_response->isSuccessful()){
36
54
}else{
37
55
echo "Failed: ".$bundle_response->getErrorMessage();
38
56
}
57
+ ```
58
+
59
+ ## Send Flexi Data Bundle
60
+ ``` php
61
+ // send internet data implementation
62
+ $data_code = "flexi_data_bundle";
63
+ $transaction_reference = "trans03423423";
64
+ $amount = 10;
65
+ $bundle_response = $tppClient->sendFlexiDataBundle("0245667942", $amount, $data_code, $transaction_reference, NetworkCodes::MTN_GH);
66
+ if($bundle_response->isSuccessful()){
67
+ echo "internet bundle sent";
68
+ }else{
69
+ echo "Failed: ".$bundle_response->getErrorMessage();
70
+ }
71
+ ```
39
72
73
+ ## Send Mobile Money
74
+ ``` php
40
75
41
76
// send mobile money implementation
42
77
$transaction_reference = "trans03423423";
@@ -51,7 +86,10 @@ if($momo_response->isSuccessful()){
51
86
}else{
52
87
echo "Failed: ".$momo_response->getErrorMessage();
53
88
}
89
+ ```
54
90
91
+ ## Receive Mobile Money
92
+ ``` php
55
93
// receive mobile money implementation
56
94
$transaction_reference = "trans03423423";
57
95
$amount = 1;
@@ -63,7 +101,27 @@ if($momo_response->isSuccessful()){
63
101
}else{
64
102
echo "Failed: ".$momo_response->getErrorMessage();
65
103
}
104
+ ```
105
+ ## Receive Mobile Money on USSD
106
+ When working with USSD sessions, it is important there is a delay between the closing of the current session and the payment prompt. Use the delay parameter to specify the number of seconds to delay the payment prompt after the current USSD session ends.
107
+ ``` php
108
+ // receive mobile money implementation
109
+ $transaction_reference = "trans03423423";
110
+ $amount = 1;
111
+ $payer_number = "0245667XXX";
112
+ // the last parameter represents the number of seconds to delay the payment prompt
113
+ $momo_response = $tppClient->receiveMobileMoney($payer_number, $amount, $transaction_reference, 5);
114
+ if($momo_response->isSuccessful()){
115
+ // check transaction status later to confirm receipt
116
+ echo "mobile money payment request initiated";
117
+ }else{
118
+ echo "Failed: ".$momo_response->getErrorMessage();
119
+ }
120
+ ```
121
+
122
+ ## Send SMS
66
123
124
+ ``` php
67
125
$sms_message = "hello world";
68
126
$sms_sender_id = "One4All";
69
127
$transaction_reference = "sms11";
@@ -74,7 +132,11 @@ if($sms_response->isSuccessful()){
74
132
echo "Failed: ".$sms_response->getErrorMessage();
75
133
}
76
134
135
+ ```
77
136
137
+ ## Query Bundle List
138
+ We recommend you cache this list for at least 24 hours to avoid unnecessary API calls.
139
+ ``` php
78
140
79
141
echo NetworkCodes::AUTO_DETECT; # 0
80
142
echo NetworkCodes::MTN_GH; # 4
0 commit comments