Skip to content

Commit

Permalink
initial commit🎉🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
pro-cms committed Oct 21, 2021
0 parents commit 4bac29a
Show file tree
Hide file tree
Showing 20 changed files with 750 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2
13 changes: 13 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Ignore all test and documentation with "export-ignore".
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
/.editorconfig export-ignore
/.php_cs.dist export-ignore
/psalm.xml export-ignore
/psalm.xml.dist export-ignore
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.idea
.php_cs
.php_cs.cache
.phpunit.result.cache
build
composer.lock
coverage
docs
phpunit.xml
psalm.xml
vendor
43 changes: 43 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

$finder = Symfony\Component\Finder\Finder::create()
->notPath('bootstrap/*')
->notPath('storage/*')
->notPath('resources/view/mail/*')
->in([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);

return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'trailing_comma_in_multiline_array' => true,
'phpdoc_scalar' => true,
'unary_operator_spaces' => true,
'binary_operator_spaces' => true,
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
],
'phpdoc_single_line_var_spacing' => true,
'phpdoc_var_without_name' => true,
'class_attributes_separation' => [
'elements' => [
'method',
],
],
'method_argument_space' => [
'on_multiline' => 'ensure_fully_multiline',
'keep_multiple_spaces_after_comma' => true,
],
'single_trait_insert_per_statement' => true,
])
->setFinder($finder);
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

All notable changes to `dpo-laravel` will be documented in this file.

## 1.0.0 - 202X-XX-XX

- initial release
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) zepson <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
138 changes: 138 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# DPO (Direct Pay Online) Laravel Package
## _The best DPO Laravel package, simple Ever_


[![Build Status](https://travis-ci.org/joemccann/dillinger.svg?branch=master)](https://travis-ci.org/joemccann/dillinger)

This is the package that will help you add DPO Payment API to your Laravel Application, We are open to contribution and support to make it better.

## Features

- Create Payment Token (Initiate order at DPO servers)
- Verify Payment Token (Check Transaction status)
- Make Direct payment(Redirects order direct to DPO payment page)
- Fetch Payment Token
- Database migrations to save transaction details
- Much easy to use
- Constantly updated

## How It works
1. Create payment token
2. Verify token
3. Redirect to DPO payment page
4. Fetch response
5. Done

#### The package does all this for you behind the scenes😂
Basic Usage Example.

```php
<?php
use Zepson\Dpo\Dpo;
........

$dpo = new Dpo();
$order = [
'paymentAmount'=>"10000",
'paymentCurrency'=> "TZS",
'customerFirstName'=> "Novath",
'customerLastName'=> "Thomas",
'customerAddress'=> "Tanzania",
'customerCity'=>"Dodoma",
'customerPhone'=> "0752771650",
'customerEmail'=> "[email protected]",
'companyRef'=> "34TESTREFF"
];
//Now make payment
$dpo->directPayment($data);
//Its done! Simple right!😂

```

## Installation

Install the package Via Composer
```sh
composer require zepson/dpo-laravel
```
Now You can Publish the configuration File and Migration
```sh
php artisan vendor:publish --provider="Spatie\Skeleton\SkeletonServiceProvider" --tag=":package_name-migrations"
```

Migrate The Database table[OPTIONAL]
```php
php artisan migrate
```

#### Configuration File'

```php
<?php

return [
"company_token"=>env("DPO_COMPANY_TOKEN","9F416C11-127B-4DE2-AC7F-D5710E4C5E0A"),
"account_type"=>env("DPO_ACCOUNT_TYPE","3854"),
'is_test_mode'=>env("DPO_IS_TEST_MODE",true),
"back_url"=>env("DPO_BACK_URL"),
"redirect_url"=>env("DPO_REDIRECT_URL")
];
```
The above Details are for Test/Sandbox environment taken from DPO public documentation
#### Update .env File with Correct Informations
```
DPO_COMPANY_TOKEN = "YOUR_DPO_COMPANY_TOKEN"
DPO_ACCOUNT_TYPE = "YOUR_DPO_ACCONT_TYPE"
DPO_IS_TEST_MODE = "true/false"
DPO_BACK_URL ="YOUR APPLICATION_BACK_URL"
DPO_REDIRECT_URL = "YAPPLICATION_REDIRECT_URL_AFTER_RESPONSE_FROM_DPO"
```
## USAGE
- create array of your order which match parrameters in the following exaple
```php
$order = [
'paymentAmount'=>"10000",
'paymentCurrency'=> "TZS",
'customerFirstName'=> "Novath",
'customerLastName'=> "Thomas",
'customerAddress'=> "Tanzania",
'customerCity'=>"Dodoma",
'customerPhone'=> "0752771650",
'customerEmail'=> "[email protected]",
'companyRef'=> "34TESTREFF"
];
```
- Now you can choose to make direct payment or createToken First and then make payment
- Starting with Direct Payment
```php
$dpo = new Dpo;
return $dpo->directPayment($data); //this will redirect user to DPO Payment page
```
- If you preffer to save details then this is the ideal step to follow [Generate Token, Make payment]
- Get Token
```php
$token = $dpo->createToken($data); //return array of response with transaction code
//you can save or do what ever you want with the response
```
- Get payment Url
```php
$dpo->getPaymentUrl($token);
```
- Redirect User to payment page
```php
return Redirect::to($payment_url);
```

As [Novath Thomas] always says

> There is a huge difference between sysem security and
>complications, Complication hurts, API should'nt be complicated
>Thats one of the primary AIM of the introduction of APIs

#### We would like more contributions to make the package more secure and readable.

## License

MIT

59 changes: 59 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "zepson/dpo-laravel",
"description": "A simple package to add DPO API to your laravel application and make payment processing much easy",
"keywords": [
"zepson",
"dpo-laravel"
],
"homepage": "https://github.com/zepson/dpo-laravel",
"license": "MIT",
"authors": [
{
"name": "Zepson Technologies",
"email": "[email protected]",
"role": "Developer"
}
],
"require": {
"php": "^7.4|^8.0",
"spatie/laravel-package-tools": "^1.1",
"illuminate/contracts": "^8.0"
},
"require-dev": {
"orchestra/testbench": "^6.0",
"phpunit/phpunit": "^9.3",
"spatie/laravel-ray": "^1.9",
"vimeo/psalm": "^4.4"
},
"autoload": {
"psr-4": {
"Zepson\\Dpo\\": "src",
"Zepson\\Dpo\\Database\\Factories\\": "database/factories"
}
},
"autoload-dev": {
"psr-4": {
"Zepson\\Dpo\\Tests\\": "tests"
}
},
"scripts": {
"psalm": "vendor/bin/psalm",
"test": "vendor/bin/phpunit --colors=always",
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
},
"config": {
"sort-packages": true
},
"extra": {
"laravel": {
"providers": [
"Zepson\\Dpo\\DpoServiceProvider"
],
"aliases": {
"Dpo": "Zepson\\Dpo\\DpoFacade"
}
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
9 changes: 9 additions & 0 deletions config/dpo-laravel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

return [
"company_token"=>env("DPO_COMPANY_TOKEN","9F416C11-127B-4DE2-AC7F-D5710E4C5E0A"),
"account_type"=>env("DPO_ACCOUNT_TYPE","3854"),
'is_test_mode'=>env("DPO_IS_TEST_MODE",true),
"back_url"=>env("DPO_BACK_URL"),
"redirect_url"=>env("DPO_REDIRECT_URL")
];
19 changes: 19 additions & 0 deletions database/factories/ModelFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Zepson\Dpo\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/*
class ModelFactory extends Factory
{
protected $model = YourModel::class;
public function definition()
{
return [
];
}
}
*/
35 changes: 35 additions & 0 deletions database/migrations/2021_10_20_222228_create_direct_pays_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateDirectPaysTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('direct_pays', function (Blueprint $table) {
$table->id();
$table->string("transToken");
$table->string("model");
$table->string("model_id");
$table->string("transRef");
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('direct_pays');
}
}
Loading

0 comments on commit 4bac29a

Please sign in to comment.