Skip to content

Commit

Permalink
Merge pull request #11 from DrH97/dev-dr
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
DrH97 authored Jan 9, 2022
2 parents 0589a70 + d08c0ba commit aa3b7da
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Total Downloads](https://poser.pugx.org/DrH97/laravel-tanda/downloads)](https://packagist.org/packages/drh/laravel-tanda)
[![License](https://poser.pugx.org/DrH97/laravel-tanda/license)](https://github.com/DrH97/laravel-tanda/blob/master/LICENSE.md)

This is a <i>Laravel 8</i> package that interfaces with [Tanda](https://www.tanda.africa/) Payments Api.
This is a <i>Laravel</i> package that interfaces with [Tanda](https://www.tanda.africa/) Payments Api.
The API enables you to initiate mobile payments, disburse payments to mobile and bank, purchase airtime & bundles* and to pay for utility bills.

Check out their [api documentation](https://www.tanda.africa/api).
Expand Down
19 changes: 19 additions & 0 deletions src/Library/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

namespace DrH\Tanda\Library;

use DrH\Tanda\Events\TandaRequestFailedEvent;
use DrH\Tanda\Events\TandaRequestSuccessEvent;
use DrH\Tanda\Exceptions\TandaException;
use DrH\Tanda\Models\TandaRequest;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Support\Str;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -159,4 +162,20 @@ private function getReferenceParameters(): array
]
];
}

/**
* @param TandaRequest $request
* @return void
*/
protected function fireTandaEvent(TandaRequest $request): void
{
if ($request->status == 000001) {
return;
}
if ($request->status == 000000) {
event(new TandaRequestSuccessEvent($request));
} else {
event(new TandaRequestFailedEvent($request));
}
}
}
21 changes: 0 additions & 21 deletions src/Library/Utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace DrH\Tanda\Library;

use DrH\Tanda\Events\TandaRequestFailedEvent;
use DrH\Tanda\Events\TandaRequestSuccessEvent;
use DrH\Tanda\Exceptions\TandaException;
use DrH\Tanda\Models\TandaRequest;
use GuzzleHttp\Exception\GuzzleException;
Expand Down Expand Up @@ -195,30 +193,11 @@ private function saveRequest(array $response, int $relationId = null): TandaRequ
}
}

/**
* @param TandaRequest $request
* @return void
*/
private function fireTandaEvent(TandaRequest $request): void
{
// TODO: Check on proper status codes
if ($request->status == 000001) {
return;
}
if ($request->status == 000000) {
event(new TandaRequestSuccessEvent($request));
} else {
event(new TandaRequestFailedEvent($request));
}
}

/**
* @throws TandaException
*/
private function validate(string $validationType, int $amount): void
{
$min = 0;
$max = 0;

switch ($validationType) {
case "AIRTIME":
Expand Down

0 comments on commit aa3b7da

Please sign in to comment.