Skip to content

Commit

Permalink
Merge pull request #17 from levizwannah/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
levizwannah authored Oct 16, 2024
2 parents 3c715b0 + d303920 commit b89fb1e
Show file tree
Hide file tree
Showing 11 changed files with 659 additions and 208 deletions.
39 changes: 39 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# _config.yml

# Site settings
title: M-Pesa SDK for PHP
description: A lightweight SDK for seamless M-Pesa integrations in PHP applications
baseurl: "/mpesa-sdk-php"
url: "https://levizwannah.github.io"

# Author details
author:
name: Levi Kamara Zwannah
email: [email protected]

# Theme setup
theme: jekyll-theme-cayman

# Plugins
plugins:
- jekyll-feed
- jekyll-seo-tag
- jekyll-sitemap
- jemoji

# Features
markdown: kramdown
highlighter: rouge

# SEO settings
seo:
title: "M-Pesa SDK PHP"
description: "Simple, lightweight SDK for integrating M-Pesa in PHP applications."

# Footer
footer:
message: "Developed by Levi Kamara Zwannah"
powered_by: "Powered by GitHub Pages"
links:
- title: "GitHub"
url: "https://github.com/levizwannah/mpesa-sdk-php"
1 change: 1 addition & 0 deletions index.md
50 changes: 50 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,56 @@ $conversationId = $response->ConversationID;

//... save to db, etc
```

## Mpesa Ratiba (Subscription)
This API enables you to create Mpesa Standing Orders. Take it as a subscription API for Mpesa

### Requirements
Ensure these values were set as shown in the setup section:
- Consumer Key (`key`)
- Consumer Secret(`secret`)
- Business Short Code (`code`);

### Usage
```php
// ...setup...
$subscription = $mpesa->subscription(); // same as $mpesa->ratiba();

$subscription->amount(100)
->plan("Gold Plan") // Standing order Name (same as $sub->name('Gold Plan'))
->phone('0740958756')
->startDate(10, 10, 2024) // month, day, year
->endDate(10, 11, 2024) // month, day, year
->frequency(Constant::FREQ_DAILY)
->callback('https://my.url/path/to/result');

# if your code is paybill number
$subscription->paybill() // if paybill number
->account('account-number');

# if using a till till number
$subscription->buygoods()
->till(1234567); // if till number

# optional
$subscription->description('optional description');

# create subscription
$subscription->create();

if(!$subscription->accepted()) {
$error = $subscription->error();
echo "$error->code $error->message";
// exit;
}

$response = $subscription->response();
$refId = $response->responseRefID;
//...

//... save to db, etc
```

# Quick Note
If you are confused on how to handle the results in the callback, please read the earlier sections of this README file.

Expand Down
2 changes: 1 addition & 1 deletion src/Helpers/AccountBalance.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AccountBalance extends MpesaWithInitiator {
protected string $type = Constant::ACCOUNT_BALANCE;

/**
* You should not call this directly. Use $mpesa->b2c()
* You should not call this directly. Use $mpesa->balance()
* @param array $config
*/
public function __construct(array $config)
Expand Down
2 changes: 1 addition & 1 deletion src/Helpers/BusinessToBulk.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class BusinessToBulk extends MpesaWithInitiator
protected $receiverIdentifierType = 4;

/**
* You should not call this directly. Use $mpesa->b2c()
* You should not call this directly. Use $mpesa->btb()
* @param array $config
*/
public function __construct(array $config)
Expand Down
2 changes: 1 addition & 1 deletion src/Helpers/BusinessToBusiness.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class BusinessToBusiness extends MpesaWithInitiator {
protected $identifierType = 4;

/**
* You should not call this directly. Use $mpesa->b2c()
* You should not call this directly. Use $mpesa->b2b()
* @param array $config
*/
public function __construct(array $config)
Expand Down
14 changes: 14 additions & 0 deletions src/Helpers/Constant.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ private function __construct(){}
// Business To Bulk
const BUSINESS_TO_BULK = "BusinessPayToBulk";
const BUSINESS_MMF_UTILITY = "BusinessTransferFromMMFToUtility";

// Standing Orders
const STANDING_ORDERS_PAYBILL = "Standing Order Customer Pay Bill";
const STANDING_ORDERS_TILL = "Standing Order Customer Pay Merchant";

// Standing Orders
const FREQ_ONE_OFF = 1;
const FREQ_DAILY = 2;
const FREQ_WEEKLY = 3;
const FREQ_MONTHLY = 4;
const FREQ_BI_MONTHLY = 5;
const FREQ_QUARTERLY = 6;
const FREQ_HALF_YEARLY = 7;
const FREQ_YEARLY = 8;
}

?>
Loading

0 comments on commit b89fb1e

Please sign in to comment.