Skip to content

Commit

Permalink
Merge pull request #7 from victorighalo/develop
Browse files Browse the repository at this point in the history
add mkdocs to repo
  • Loading branch information
seerbit-developers authored Feb 28, 2023
2 parents ff2f9c7 + c80d30e commit 1a89c1a
Show file tree
Hide file tree
Showing 5 changed files with 210 additions and 22 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
build
composer.lock
docs
vendor
coverage
.idea/workspace.xml
Expand Down
112 changes: 97 additions & 15 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
#Introduction

# This SDK enables direct and structured interction with SeerBit API

Once installed you can easily configure the SDK by providing your credentials in your environment file configuration.
<div align="center" >
<img width="200" valign="top" src="https://assets.seerbitapi.com/images/seerbit_logo_type.png">
</div>

For full documentation of SeerBit visit [mkdocs.org](https://www.docs.seerbit.com).

<h1 align="center">
<img width="60" valign="bottom" src="https://laravel.com/img/logomark.min.svg">
</h1>


# SeerBit's API SDK for Laravel

SeerBit PHP SDK for easy integration with SeerBit's API.

## Requirements
This package can be used with Laravel 5.8 or higher
PHP 7.1 or higher
PHP 8.0 or higher

## Installation

The preferred method is via [composer](https://getcomposer.org). Follow the composer
[installation instructions](https://getcomposer.org/doc/00-intro.md) if you do not already have
composer installed.


Once composer is installed, execute the following command in your project root to install this library:


```bash
composer require seerbit/seerbit-laravel
```
Expand All @@ -29,6 +38,7 @@ You can publish the config file with:
```bash
php artisan vendor:publish --provider="SeerbitLaravel\SeerbitServiceProvider" --tag="config"
```

This is the contents of the config file that will be published to your app's directory path `config/seerbit.php`:
```php
return [
Expand All @@ -41,23 +51,95 @@ return [
```

####
You can find both public and secret keys from your merchant dashboard.
You can find both public and secret keys from your merchant dashboard.

The token can be generated following the guides [here](https://doc.seerbit.com/getstarted/authentication)

Replace them by changes the key values in your **.env** file.

`SEERBIT_ENVIRONMENT="public_key"`
Open your .env file and add your public key, secret key and token:

###
Clear your config cache and restart the server after installation to ensure your config will be loaded. If you’ve been caching configurations locally, clear your config cache with either of these commands:
```php
SEERBIT_PUBLIC_KEY=xxxxxxxxxxxxx
SEERBIT_SECRET_KEY=xxxxxxxxxxxxx
SEERBIT_TOKEN=xxxxxxxxxxxxx
```

*If you are using a cloud hosting service such as lambda, etc, you may need to add the above details to your environment variables section.*

```bash
php artisan optimize:clear
# or
php artisan config:clear
```
ENSURE YOU DO NOT PUBLISH YOUR ENV FILE TO YOUR GIT REPOSITORY
```

## Usage

### Standard checkout
``` php
namespace App\Http\Controllers;

###Usage
Import the namespace:
use SeerbitLaravel\Facades\Seerbit;

class Standard
{
public function Checkout(){
try{
$uuid = bin2hex(random_bytes(6));
$transaction_ref = strtoupper(trim($uuid));

$payload = [
"amount" => "1000",
"callbackUrl" => "http:yourwebsite.com",
"country" => "NG",
"currency" => "NGN",
"email" => "[email protected]",
"paymentReference" => $transaction_ref,
"productDescription" => "product_description",
"productId" => "64310880-2708933-427"
];

$trans = seerbit()->Standard()->Initialize($payload);
//Or with Facade
$trans = SeerBit::Standard()->Initialize($payload);

}catch (\Exception $e){
;
}
}
```

Full documentation can be found [**here**](https://seerbit.github.io/seerbit-laravel)

<br>

## Configure Logger ##
````php
//Set Logger path in environment config file
SEERBIT_LOGGER_PATH = ""
````
<br>

## API Documentation ##
* https://doc.seerbit.com/

### Changelog

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

## Contributing
We strongly encourage you to join us in contributing to this repository so everyone can benefit from:
* New features and functionality
* Resolved bug fixes and issues
* Any general improvements

### Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

## Credits

- [Victor Osas Ighalo](https://github.com/victorighalo)

## License

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

9 changes: 3 additions & 6 deletions docs/standard.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ This service provides access to making secure transactions by generating a check
Add the NameSpace: **SeerbitLaravel\Facades\Seerbit** to your Class or Controller or Route in case you want to use the Facade.


###Initialize transaction
>
### Initialize transaction

```php
namespace App\Http\Controllers;

Expand Down Expand Up @@ -40,12 +40,10 @@ class Standard
}
}
```
>


###Validate transaction
### Validate transaction

>
```php
namespace App\Http\Controllers;

Expand All @@ -65,4 +63,3 @@ class Standard
}
}
```
>
110 changes: 110 additions & 0 deletions docs/tokenization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
The Card Tokenize and Charge API allows you to charge a tokenized payment.

Add the NameSpace: **SeerbitLaravel\Facades\Seerbit** to your Class or Controller or Route in case you want to use the Facade.

### Create Token

##### Tokenize a card


```php
try{
$uuid = bin2hex(random_bytes(6));
$transaction_ref = strtoupper(trim($uuid));

$payload = [
"amount": "100.00",
"fullName": "Anonymous Shopper",
"mobileNumber": "03447522256",
"currency": "NGN",
"country": "NG",
"email": "[email protected]",
"paymentType": "CARD",
"cardNumber": "6280511000000095",
"expiryMonth": "12",
"expiryYear": "26",
"cvv": "123",
"pin": "1234",
"tokenize": true,
"paymentReference" => $transaction_ref
];

$tokenization_result = SeerBit::Tokenization()->CreateToken($payload);

}catch (\Exception $e){
echo $e->getMessage();
}

```

### Get Token

##### Get details of tokenized card


```php
try{

//transaction reference used when creating a token
SeerBit::Tokenization()->GetToken($transaction_reference);

}catch (\Exception $e){
echo $e->getMessage();
}

```

### Charge a Token

##### Charge a card with its association token


```php
try{
$uuid = bin2hex(random_bytes(6));
$transaction_ref = strtoupper(trim($uuid));

//authorizationCode is a property in the response payload of GetToken
$payload = [
"paymentReference" => $transaction_ref,
"authorizationCode" => "authorizationCode",
"amount" => "100.00"
];

$tokenization_result = SeerBit::Tokenization()->ChargeToken($payload);

}catch (\Exception $e){
echo $e->getMessage();
}

```

### Charge a Token Bulk

##### Charge tokens in a batch



```php
try{
$uuid = bin2hex(random_bytes(6));
$transaction_ref = strtoupper(trim($uuid));

//authorizationCode is a property in the response payload of GetToken
//$transaction_ref should be unique for each record
$payload = [
(object)[
'authorizationCode' => $authorizationCode,
'paymentReference' => $transaction_ref,
'amount' => '100.00',
'publicKey' => 'MERCHANT_PUBLIC_KEY'
]
];

$tokenization_result = SeerBit::Tokenization()->ChargeTokenBulk($payload);

}catch (\Exception $e){
echo $e->getMessage();
}

```
Binary file modified site/sitemap.xml.gz
Binary file not shown.

0 comments on commit 1a89c1a

Please sign in to comment.