Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
amandio committed Jan 6, 2019
1 parent 13c6988 commit 9c63502
Showing 1 changed file with 55 additions and 2 deletions.
57 changes: 55 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,55 @@
### Install using composer
```composer require codeonweekends/mpesa-php-sdk```
# Install using Composer
```composer require codeonweekends/mpesa-php-sdk```

# Usage
The easiest way to use the API is by calling ``Codeonweekends\Mpesa\Mpesa`` and accessing
the available transaction methods.

- Create an instance of ``Codeonweekends\Mpesa\Mpesa``
- Get the api context using the ``getApiContext()`` method
- Set the public key and the api key on the context using ``setPublicKey(YOUR_PUBLIC_KEY)`` and ``setApiKey(YOUR_API_KEY)`` respectively

Example:
```php
$mpesa = new Codeonweekends\Mpesa\Mpesa();
$context = $mpesa->getApiContext();

$context->setPublicKey(YOUR_PUBLIC_KEY);
$context->setApiKey(YOUR_API_KEY);
```


## Create a C2B Transaction

```php
$thirdPartyReference = 11114;
$amount = 10;
$customerMSISDN = 258843330333;
$serviceProviderCode = 171717;
$transactionReference = 'T12344C';

$c2b = $mpesa->c2b($thirdPartyReference, $amount, $customerMSISDN, $serviceProviderCode, $transactionReference);
```

## View a Transaction Status

```php
$queryReference = '5C1400CVRO';
$serviceProviderCode = '171717';
$securityCredential = 'Mpesa2019';
$initiatorIdentifier = 'Mpesa2018';

$status = $mpesa->transactionStatus($queryReference, $serviceProviderCode, $securityCredential, $initiatorIdentifier);
```

## Transaction Reversal

```php
$amount = 10;
$serviceProviderCode = 171717;
$transactionID = '49XCDF6';
$securityCredential = 'Mpesa2019';
$initiatorIdentifier = 'Mpesa2018';

$reversal = $mpesa->transactionReversal($amount, $serviceProviderCode, $transactionID, $securityCredential, $initiatorIdentifier);
```

0 comments on commit 9c63502

Please sign in to comment.