@@ -46,18 +46,15 @@ Below is a basic example on how to set up. Check full example in your [Laravel p
4646 use IntaSend\IntaSendPHP\Customer;
4747
4848 $credentials = [
49- 'publishable_key' => 'INTASEND_PUBLISHABLE_KEY'
49+ 'publishable_key' => env('INTASEND_PUBLISHABLE_KEY'),
50+ 'test' => env('INTASEND_TEST_ENVIRONMENT', true),
5051 ];
5152
5253 $customer = new Customer();
5354 $customer->first_name = "Joe";
5455 $customer->last_name = "Doe";
5556 $customer->email = "joe@doe.com";
5657 $customer->country = "KE";
57- $customer->city = "Nairobi";
58- $customer->address = "Apt 123, Westland road";
59- $customer->zipcode = "0100";
60- $customer->state = "Nairobi";
6158
6259 $amount = 10;
6360 $currency = "KES";
@@ -71,30 +68,24 @@ Below is a basic example on how to set up. Check full example in your [Laravel p
7168 $checkout->init($credentials);
7269 $resp = $checkout->create($amount = $amount, $currency = $currency, $customer = $customer, $host=$host, $redirect_url = $redirect_url, $api_ref = $ref_order_number, $comment = null, $method = null);
7370
71+ // Redirect the user to the URL to complete payment
7472 print_r($resp->url);
7573
7674## Send M-Pesa STK-Push
7775
7876Checkout API generates a URL that enables you to do M-Pesa collection and other payment methods. In case you want to leverage only the M-Pesa STK-Push option, you might want to consider this the ` collection->mpesa_stk_push() ` option.
7977
8078 use IntaSend\IntaSendPHP\Collection;
81-
8279 $credentials = [
83- 'publishable_key' => 'INTASEND_PUBLISHABLE_KEY'
80+ 'publishable_key' => env('INTASEND_PUBLISHABLE_KEY'),
81+ 'test' => env('INTASEND_TEST_ENVIRONMENT', true),
8482 ];
8583
84+
8685 $collection = new Collection();
8786 $collection->init($credentials);
8887
89- $amount = 10;
90- $phone_number = "254720000000";
91- $api_ref = "ORDER-1";
92- $response = $collection->mpesa_stk_push($amount, $phone_number, $api_ref);
93- print_r($response);
94-
95- $invoice = $response->invoice;
96- $invoice_id = $invoice->invoice_id;
97- $response = $collection->status($invoice_id);
88+ $response = $collection->create($amount=10, $phone_number="2547...", $currency="KES", $method="MPESA_STK_PUSH", $api_ref="Your API Ref", $name="", $email="john@example.com");
9889 print_r($response);
9990
10091## How to create Payment links
@@ -145,13 +136,13 @@ Payment links are free forms that you can share with your customers on email and
145136 ];
146137
147138 $transactions = [
148- ['account'=>'254723890353','amount'=>'2000', 'narrative'=>'Salary '],
149- ['account'=>'254723890260','amount'=>'15000', 'narrative'=>'Dividends ']
139+ ['account'=>'254723890353','amount'=>'20 '],
140+ ['account'=>'254723890260','amount'=>'15 ']
150141 ];
151142
152143 $transfer = new Transfer();
153144 $transfer->init($credentials);
154-
145+
155146 $response=$transfer->mpesa("KES", $transactions);
156147
157148 //call approve method for approving last transaction
@@ -186,7 +177,7 @@ To send money to M-Pesa PayBills, specify business number under account and an a
186177 $response = $transfer->approve($response);
187178 print_r($response);
188179
189- ## How to Send Money to M-Pesa Till Number
180+ ## How to Send Money to M-Pesa Till Number or PayBill
190181
191182To send money to Till Numbers, simply specify the account number. No account reference is requred.
192183
@@ -198,13 +189,14 @@ To send money to Till Numbers, simply specify the account number. No account ref
198189 ];
199190
200191 $transactions = [
201- ['account'=>'5002901', 'account_type'=>'TillNumber', 'amount'=>'2000', 'narrative'=>'Trip']
192+ ['name' => 'Business A','account'=>'524311','amount'=>'200', 'account_type'=>'PayBill', 'account_reference'=>'29822182', 'narrative'=> 'Bill Payment'],
193+ ['name' => 'Business B','account'=>'17626','amount'=>'150', 'account_type'=>'TillNumber', 'narrative'=> 'Purchase']
202194 ];
203195
204196 $transfer = new Transfer();
205197 $transfer->init($credentials);
206-
207- $response=$transfer->mpesa ("KES", $transactions);
198+
199+ $response=$transfer->mpesa_b2b ("KES", $transactions);
208200
209201 //call approve method for approving last transaction
210202 $response = $transfer->approve($response);
@@ -222,13 +214,13 @@ You'll need a bank code and account numbers to send bank payments. Here is a [li
222214 ];
223215
224216 $transactions = [
225- ['account'=>'12910000111', 'name '=>'Joe Doe', 'bank_code' => 2 , 'amount '=>'2000 ', 'narrative'=>'Salary '],
226- ['account'=>'23332112222', 'name '=>'Mary Doe', 'bank_code' => 4 , 'amount '=>'1500 ', 'narrative'=>'Salary ']
217+ ['name' => 'Joe Doe','account '=>'0129292920202','amount'=>'200' , 'bank_code '=>'2 ', 'narrative'=> 'Bill Payment '],
218+ ['name' => 'Mary Doe','account '=>'525623632321','amount'=>'150' , 'bank_code '=>'11 ', 'narrative'=> 'Purchase ']
227219 ];
228220
229221 $transfer = new Transfer();
230222 $transfer->init($credentials);
231-
223+
232224 $response=$transfer->bank("KES", $transactions);
233225
234226 //call approve method for approving last transaction
@@ -275,10 +267,8 @@ Example on how to create a new wallet, list wallets and other details
275267 $wallet = new Wallet();
276268 $wallet->init($credentials);
277269
278- $currency = "KES";
279- $label = "WALLET-1";
280- $response = $wallet->create($currency, $label);
281- print_r($response);
270+ $response = $wallet->create($currency='KES', $label='MY-WALLET-ID', $can_disburse=true);
271+ print_r($response);
282272
283273### List all wallets in your account
284274
@@ -287,22 +277,35 @@ Example on how to create a new wallet, list wallets and other details
287277
288278### View wallet details and its transactions
289279
290- $wallet_id = "KASPWO1";
291- $response = $wallet->details($wallet_id);
280+ $response = $wallet->transactions('<wallet_id>');
292281 print_r($response);
293282
294283 $response = $wallet->transactions($wallet_id);
295284 print_r($response);
296285
297286### Direct deposit to wallet using M-Pesa STK Push
298287
299- $phone_number = "254723890353";
300- $email = "john.doe@gmail.com";
301- $amount = 10;
302-
303- $response = $wallet->fund($phone_number=$phone_number, $email=$email, $amount=$amount);
288+ $response = $wallet->fund_mpesa_stk_push($wallet_id="<wallet_id>", $phone_number='2547...',$email='john@doe.com', $amount=10, $api_ref="API Request");
304289 print_r($response);
305290
291+ ### Direct deposit to wallet with Checkout Method
292+
293+ use IntaSend\IntaSendPHP\Customer;
294+
295+ $customer = new Customer();
296+ $customer->first_name = "Joe";
297+ $customer->last_name = "Doe";
298+ $customer->email = "joe@doe.com";
299+ $customer->country = "KE";
300+
301+ $host = "https://example.com";
302+ $redirect_url = "https://example.com";
303+
304+ $ref_order_number = "fund-wallet-10";
305+
306+ $response = $wallet->fund_checkout($wallet_id="<wallet_id>", $phone_number='2547..', $currency='USD', $customer=$customer, $amount=10, $host=$host, $redirect_url=$redirect_url, $api_ref=$ref_order_number, $card_tarrif = "BUSINESS-PAYS", $mobile_tarrif = "BUSINESS-PAYS");
307+ print_r($response->url);
308+
306309### Wallet to wallet transfers (Intra-transfer)
307310
308311Transfer funds between wallets in your account
@@ -314,6 +317,19 @@ Transfer funds between wallets in your account
314317
315318 $response = $wallet->intra_transfer($origin_wallet_id, $destination_wallet_id, $amount, $narrative);
316319 print_r($response);
320+
321+ ### External Wallet Transfer to M-PESA
322+ use IntaSend\IntaSendPHP\Transfer;
323+
324+ $transactions = [
325+ ['account'=>'254...','amount'=>'20'],
326+ ['account'=>'254...','amount'=>'15']
327+ ];
328+
329+ $response=$transfer->mpesa("KES", $transactions=$transactions, $callback_url=null, $wallet_id='<wallet_id>');
330+ print_r($response);
331+
332+ Like all other Send Money APIs, the above request is also a two step. Please go through the send money examples on full implementation for M-Pesa B2C, M-Pesa B2B, Bank Payouts and IntaSend P2P.
317333
318334## Chargebacks Management
319335
0 commit comments