Skip to content

Commit

Permalink
Merge pull request #1 from openpesa/develop
Browse files Browse the repository at this point in the history
add main features
  • Loading branch information
leyluj committed Oct 16, 2020
2 parents 02291d0 + 4550b69 commit f4b8a4f
Show file tree
Hide file tree
Showing 39 changed files with 1,138 additions and 61 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
/phpunit.xml.dist export-ignore
/.scrutinizer.yml export-ignore
/tests export-ignore
/docs export-ignore
/.editorconfig export-ignore
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
build
composer.lock
docs

vendor
coverage
coverage

.idea
/examples/http-client.private.env.json
/examples/my-simple.php
45 changes: 33 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,42 @@
language: php

php:
- 7.1
- 7.2
- 7.3
# - 7.1
# - 7.2
- 7.3

env:
matrix:
- COMPOSER_FLAGS="--prefer-lowest"
- COMPOSER_FLAGS=""
# env:
# matrix:
# - COMPOSER_FLAGS="--prefer-lowest"
# - COMPOSER_FLAGS=""

# cache:
# directories:
# - $HOME/.composer/cache

before_install:
- nvm install stable
- nvm use stable

before_script:
- travis_retry composer self-update
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source
# - travis_retry composer self-update
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source
- cd docs && npm install && cd ..

script:
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
# - ./vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
- ./vendor/bin/phpunit --coverage-clover coverage.xml
- cd docs && npm run build && cd ..

after_success:
- bash <(curl -s https://codecov.io/bash)

after_script:
- php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover
deploy:
provider: pages
strategy: git
skip_cleanup: true
local_dir: ./docs/src/.vuepress/dist
token: $GITHUB_TOKEN
keep_history: true
on:
branch: develop
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

All notable changes to `pesa` will be documented in this file

## 1.0.0 - 201X-XX-XX
## 0.0.1 - 2020-10-12

- initial release
- Support for C2B, B2C, REVERSAL
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) Alpha Olomi
Copyright (c) Openpesa

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
102 changes: 73 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,110 @@
# Pesa SDK
# Pesa SDK for PHP

[![Latest Version on Packagist](https://img.shields.io/packagist/v/openpesa/pesa.svg?style=flat-square)](https://packagist.org/packages/openpesa/pesa)
[![Build Status](https://img.shields.io/travis/openpesa/pesa/master.svg?style=flat-square)](https://travis-ci.org/openpesa/pesa)
[![Quality Score](https://img.shields.io/scrutinizer/g/openpesa/pesa.svg?style=flat-square)](https://scrutinizer-ci.com/g/openpesa/pesa)
[![Latest Version on Packagist](https://img.shields.io/packagist/v/openpesa/pesa.svg?style=flat-square&?include_prereleases)](https://packagist.org/packages/openpesa/pesa)
[![Build Status](https://img.shields.io/travis/openpesa/php-pesa/develop.svg?style=flat-square)](https://travis-ci.org/openpesa/php-pesa)
[![codecov.io](https://codecov.io/github/openpesa/php-pesa/coverage.svg)](https://codecov.io/github/openpesa/php-pesa)
[![Total Downloads](https://img.shields.io/packagist/dt/openpesa/pesa.svg?style=flat-square)](https://packagist.org/packages/openpesa/pesa)

This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what PSRs you support to avoid any confusion with users and contributors.
The **Pesa SDK for PHP** makes it easy for developers to access [OpenAPI](https://openapiportal.m-pesa.com/) in their PHP code, and build robust applications and software using services like Customber 2 Bussiness, Query etc.

## Installation
## Documentation

You can install the package via composer:
Take a look at the [API docs here](https://php-pesa.netlify.app/).

## Getting Started

1. **Sign up for OpenAPI Portal** – Before you begin, you need to
sign up for an account and retrieve your credentials.

1. **Minimum requirements** – To run the SDK, your system will need to meet the
[minimum requirements](https://php-pesa.netlify.app/docs/requirements.html), including having **PHP >= 7.1**.
<!-- We highly recommend having it compiled with the cURL extension and cURL
7.16.2+ compiled with a TLS backend (e.g., NSS or OpenSSL). -->
1. **Install the SDK** – Using [Composer] is the recommended way to install the
Pesa SDK for PHP. The SDK is available via [Packagist] under the
[`openpesa/php-pesa`](https://packagist.org/packages/openpesa/pesa) package. If Composer is installed globally on your system, you can run the following in the base directory of your project to add the SDK as a dependency:
```sh
composer require openpesa/pesa
```
Please see the
[Installation section of the User Guide](https://php-pesa.netlify.app/docs/installation.html) for more
detailed information about installing the SDK through Composer and other
means.
1. **Using the SDK** – The best way to become familiar with how to use the SDK
is to read the [User Guide](https://php-pesa.netlify.app/docs/guide.html).

<!-- The [Getting Started Guide](#) will help you become familiar with
the basic concepts. -->

```bash
composer require openpesa/pesa
```

## Usage

``` php
use Openpesa\SDK\Pesa;
### Quick Examples

```php

require 'vendor/autoload.php';

use Openpesa\SDK\Forodha;

// Set the consumer key and consumer secret as follows
$username = 'YOUR_USERNAME'; // use 'sandbox' for development in the test environment
$apiKey = 'YOUR_API_KEY'; // use your sandbox app API key for development in the test environment
// Intiate with credntials
$forodha = new Forodha([
'api_key' => 'YOUR_API_KEY',
'public_key' => 'PUBLIC_KEY',
'client_options' => [],
]);

// Get one of the services
$pesa = new Pesa($public_key, $apiKey);
// Setup the transaction
$data = [
'input_Amount' => '10000',
'input_Country' => 'TZN',
'input_Currency' => 'TZS',
'input_CustomerMSISDN' => '255766303775',
'input_ServiceProviderCode' => '000000',
'input_ThirdPartyConversationID' => 'rerekf',
'input_TransactionReference' => rand(),
'input_PurchasedItemsDesc' => 'Test Two Item'
];

// Use the service
$result = $pesa->c2b($invoice_id, $phone_number, $amount, $reference_id, $shortcode);
// Execute
$result = $forodha->transact('c2b', $data);

// Print results
var_dump($result);

print_r($result);
```

For more example check [pesa-demo-example](https://github.com/openpesa/php-pesa/tree/develop/examples).

### Testing

``` bash
```bash
composer test
```

## Opening Issues

If you have a feature requrest or you encounter a bug, please file an issue on [our issue tracker on GitHub](https://github.com/openpesa/php-pesa/issues).

### Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

## Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
Please review our [CONTRIBUTING](CONTRIBUTING.md) for details.


### Security

If you discover any security related issues, please email alphaolomi@gmail.com instead of using the issue tracker.

## Credits

- [Alpha Olomi](https://github.com/openpesa)
- [Ley](https://github.com/leyluj)
- [All Contributors](../../contributors)
- [Alpha Olomi](https://github.com/openpesa)
- [Ley](https://github.com/leyluj)
- [All Contributors](../../contributors)

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

## PHP Package Boilerplate

This package was generated using the [PHP Package Boilerplate](https://laravelpackageboilerplate.com).
22 changes: 16 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "openpesa/pesa",
"description": "pesa",
"description": "Pesa PHP SDK",
"keywords": [
"api",
"openpesa",
"pesa"
],
Expand All @@ -13,28 +14,37 @@
"name": "Alpha Olomi",
"email": "alphaolomi@gmail.com",
"role": "Developer"
},
{
"name": "Leylow Lujuo",
"email": "leyluj21@gmail.com",
"role": "Developer"
}
],
"require": {
"php": "^7.1"
"php": "^7.1",
"guzzlehttp/guzzle": "^6.0",
"phpseclib/phpseclib": "^2.0",
"ext-json": "*",
"ext-openssl": "*"
},
"require-dev": {
"phpunit/phpunit": "^7.0"
"phpunit/phpunit": "^7.0",
"scrutinizer/ocular": "^1.7"
},
"autoload": {
"psr-4": {
"Openpesa\\Pesa\\": "src"
"Openpesa\\SDK\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Openpesa\\Pesa\\Tests\\": "tests"
"Openpesa\\SDK\\Tests\\": "tests"
}
},
"scripts": {
"test": "vendor/bin/phpunit",
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"

},
"config": {
"sort-packages": true
Expand Down
12 changes: 12 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pids
logs
node_modules
npm-debug.log
coverage/
run
dist
.DS_Store
.nyc_output
.basement
config.local.js
basement_dist
18 changes: 18 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "php-pesa-docs",
"version": "0.0.1",
"description": "Pesa SDK for PHP",
"authors": {
"name": "Alpha Olomi",
"email": "alphaolomi@gmail.com"
},
"repository": "https://github.com/openpesa/php-pesa",
"scripts": {
"dev": "vuepress dev src",
"build": "vuepress build src"
},
"license": "MIT",
"devDependencies": {
"vuepress": "^1.5.3"
}
}
15 changes: 15 additions & 0 deletions docs/src/.vuepress/components/Foo/Bar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<template>
<p class="demo">
{{ msg }}
</p>
</template>

<script>
export default {
data () {
return {
msg: 'Hello this is <Foo-Bar>'
}
}
}
</script>
3 changes: 3 additions & 0 deletions docs/src/.vuepress/components/OtherComponent.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<p class="demo">This is another component</p>
</template>
15 changes: 15 additions & 0 deletions docs/src/.vuepress/components/demo-component.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<template>
<p class="demo">
{{ msg }}
</p>
</template>

<script>
export default {
data() {
return {
msg: 'Hello this is <demo-component>'
}
}
}
</script>
Loading

0 comments on commit f4b8a4f

Please sign in to comment.