Skip to content

Commit

Permalink
Update README file and composer file & compress socialcard
Browse files Browse the repository at this point in the history
  • Loading branch information
alkhatibdev committed Jul 15, 2022
1 parent 2213f4b commit 1bb75a3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 20 deletions.
44 changes: 25 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,29 @@
# Zain DSP API integration with Laravel

[![Latest Version](https://img.shields.io/github/release/alkhatibdev/laravel-zain.svg?style=flat-square)](https://github.com/alkhatibdev/laravel-zain/releases)
[![MIT Licensed](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![MIT Licensed](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)

## Introduction
Laravel Zain is Zain DSP API integration with Laravel, made to simplify the the process and API calls and let developers focus on other integration parts and logic.
# Introduction
Laravel Zain is Zain DSP API integration with Laravel, made to simplify the the process and API calls and let developers focus on other integration parts and logic.

# Installation

## Installation

### Requirements
## Requirements

- PHP >= `7.4.x`
- Laravel >= `7.x`

### install via composer
## install via composer

```shell
composer require alkhatibdev/laravel-zain
```

### Publish Configs
## Publish Configs
```shell
php artisan vendor:publish --tag=laravel-zain-config
```
`laravel-zain.php` config file will be published on your `configs` directory, with following content:
A `laravel-zain.php` config file will be published on your `configs` directory, with the following content:

```php
<?php
Expand Down Expand Up @@ -58,9 +57,9 @@ ZAIN_REMEMBER_TOKEN=false
```


## Usage
# Usage

### Initial Payment/Subscription
## Initial Payment/Subscription

```php
use AlkhatibDev\LaravelZain\Facades\Zain;
Expand All @@ -70,25 +69,25 @@ $response = Zain::initiate($phone)

```

When `initial` request payment send successfully, a `OTP` code will be send to `$phone`, and `$response` will contain a `request_id` you should save to the next step `verify`.
When `initiate` payment request successfully sent, a SMS with `OTP` code will be send to the `$phone` number, and `$response` will contain a `subscribe_request_id` and you should save it to the next step `verify`.

### Verify Payment/Subscription
## Verify Payment/Subscription

```php

$response = Zain::verify($otp, $requestId)

```

### Check Subscription
## Check Subscription

```php

$response = Zain::checkSubscription($phone)

```

### Unsubscribe
## Unsubscribe

```php

Expand All @@ -98,16 +97,20 @@ $response = Zain::unsubscribe($phone)

```

### Login and Cache DSP token
## Login and Cache DSP token


Out of the box the package will login automatically and get the `token` and use it for each action `initiate`, `verify` ..etc per request.

If you want cache the token and use it for furthor requests of whole day, you request `token` like this:

```php
$token = Zain::token()
```
And you can cache it and use for next requests for the next 24 hours.
If you set `ZAIN_REMEMBER_TOKEN=true` token will be expired after 30 days.

And you can cach it and use for next requests for the next 24 hours if you set `ZAIN_REMEMBER_TOKEN=true`, example :
Example of using cached token:

```php
// $token = getCachedToken()
Expand All @@ -117,12 +120,15 @@ $response = Zain::withToken($token)->verify($phone)
...
```

### Logging
## Logging
You can enable logging from package config file
```
'enable_logging' => true,
```

## License
# Other Packages
- ### [Laravel Sudani](https://github.com/alkhatibdev/laravel-sudani) SPay API Integration

# License

Laravel Zain is open-sourced software licensed under the [MIT license](LICENSE).
11 changes: 10 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
{
"name": "alkhatibdev/laravel-zain",
"description": "Zain DSP API integration",
"homepage": "https://github.com/alkhatibdev/laravel-zain",
"keywords": [
"zain",
"dsp",
"integration",
"laravel"
],
"type": "package",
"license": "MIT",
"authors": [
{
"name": "AlkhatibHamad",
"email": "alkhatib.hamad@gmail.com"
"email": "me@alkhatib.dev",
"homepage": "https://github.com/alkhatibdev",
"role": "Developer"
}
],
"minimum-stability": "dev",
Expand Down
Binary file modified socialcard.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1bb75a3

Please sign in to comment.