@@ -9,6 +9,7 @@ This library makes it easy for PHP developers to integrate with One4All TPP onli
99
1010It's supported on PHP 5.5+
1111
12+ ## Using the Library
1213``` php
1314use MyOne4All\TppClient;
1415use MyOne4All\Exceptions\TppException;
@@ -17,16 +18,33 @@ use MyOne4All\NetworkCodes;
1718
1819$tppClient = new TppClient("apikey", "apisecret", "retailer");
1920
21+ ```
22+
23+ ## Get Balance
24+ ``` php
25+ # ecredit balance
2026echo $tppClient->getBalance(); # 0.0
2127
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
2237// send airtime implementation
2338$airtime_response = $tppClient->sendAirtime("0245667942", 1, "trans03423423", NetworkCodes::AUTO_DETECT);
2439if($airtime_response->isSuccessful()){
2540 echo "airtime sent";
2641}else{
2742 echo "Failed: ".$airtime_response->getErrorMessage();
2843}
44+ ```
2945
46+ ## Send Data Bundle
47+ ``` php
3048// send internet data implementation
3149$data_code = "DAILY_20MB";
3250$transaction_reference = "trans03423423";
@@ -36,7 +54,24 @@ if($bundle_response->isSuccessful()){
3654}else{
3755 echo "Failed: ".$bundle_response->getErrorMessage();
3856}
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+ ```
3972
73+ ## Send Mobile Money
74+ ``` php
4075
4176// send mobile money implementation
4277$transaction_reference = "trans03423423";
@@ -51,7 +86,10 @@ if($momo_response->isSuccessful()){
5186}else{
5287 echo "Failed: ".$momo_response->getErrorMessage();
5388}
89+ ```
5490
91+ ## Receive Mobile Money
92+ ``` php
5593// receive mobile money implementation
5694$transaction_reference = "trans03423423";
5795$amount = 1;
@@ -63,7 +101,27 @@ if($momo_response->isSuccessful()){
63101}else{
64102 echo "Failed: ".$momo_response->getErrorMessage();
65103}
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
66123
124+ ``` php
67125$sms_message = "hello world";
68126$sms_sender_id = "One4All";
69127$transaction_reference = "sms11";
@@ -74,7 +132,11 @@ if($sms_response->isSuccessful()){
74132 echo "Failed: ".$sms_response->getErrorMessage();
75133}
76134
135+ ```
77136
137+ ## Query Bundle List
138+ We recommend you cache this list for at least 24 hours to avoid unnecessary API calls.
139+ ``` php
78140
79141echo NetworkCodes::AUTO_DETECT; # 0
80142echo NetworkCodes::MTN_GH; # 4
0 commit comments