Skip to content

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
  • Loading branch information
Medboubazine committed Feb 7, 2024
0 parents commit 6dff01a
Show file tree
Hide file tree
Showing 61 changed files with 2,793 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/dist
/vendor
composer.lock
11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"trailingComma": "es5",
"tabWidth": 4,
"semi": false,
"singleQuote": false,
"endOfLine": "auto",
"bracketSameLine": true,
"html.format.wrapAttributes": "auto",
"html.format.wrapLineLength": 0,
"printWidth": 1000
}
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 MOHAMMED BOUBAZINE

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.
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Chargily Pay V2

PHP Library for Chargily Pay™ Gateway - V2.

The easiest and free way to integrate payment API through EDAHABIA of Algerie Poste and CIB of SATIM in your PHP project.

# Requirements

- PHP >= 8.1.10

# Installation

- Via Composer (Recomended)

```bash
composer require chargily/chargily-pay
```

# Getting Started

- Replace **test** by **live** if you are in production mode
- Replace **public_key_here** with your public key shown in the Chargily Pay dashboard in the developer section
- Replace **secret_key_here** with your secret key shown in the Chargily Pay dashboard in the developer section

```php

use Chargily\ChargilyPay\Auth\Credentials;
use Chargily\ChargilyPay\ChargilyPay;

require "path-to-vendor/autoload.php";

$credentials = new Credentials([
"mode" => "test",
"public" => "public_key_here",
"secret" => "secret_key_here",
]);

$chargily_pay = new ChargilyPay($credentials);

$chargily_pay->balance()->get(),
$chargily_pay->checkouts()->all(),
$chargily_pay->customers()->all(),
$chargily_pay->payment_links()->all(),
$chargily_pay->prices()->all(),
$chargily_pay->products()->all(),
//validate and get Webhook details
$chargily_pay->webhook()->get()

```

# Documentation

- [Balance](./blob/main/docs/Balance.md)
- [Checkouts](./blob/main/docs/Checkouts.md)
- [Customers](./blob/main/docs/Customers.md)
- [Payment Links](./blob/main/docs/PaymentLinks.md)
- [Prices](./blob/main/docs/Prices.md)
- [Products](./blob/main/docs/Products.md)
- [Webhook](./blob/main/docs/Webhook.md)
42 changes: 42 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "chargily/chargily-pay",
"type": "library",
"description": "PHP Library for Chargily Pay V2",
"keywords": [
"Chargily-Pay-Gateway",
"Pay",
"epaiment",
"pay.chargily.com",
"chargily",
"satim",
"cib",
"cibweb",
"php"
],
"license": "MIT",
"authors": [
{
"name": "ChargilyDev",
"role": "Developer"
},
{
"name": "Boubazine mohammed",
"email": "mohamedtorino161@gmail.com",
"role": "Developer"
}
],
"require": {
"php": ">=8.1.10",
"guzzlehttp/guzzle": "^7.0",
"symfony/var-dumper": "^6.4",
"rakit/validation": "^1.4",
"illuminate/support": "^10.39",
"medboubazine/number_format": "^1.1",
"nesbot/carbon": "^2.72"
},
"autoload": {
"psr-4": {
"Chargily\\ChargilyPay\\": "src/"
}
}
}
45 changes: 45 additions & 0 deletions docs/Balance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
## Balance

### Retrieve Balance

```php
/**
* @var Chargily\ChargilyPay\Core\Helpers\Collection|null
*/
$balance = $chargily_pay->balance()->get();

/**
* @var \Chargily\ChargilyPay\Elements\WalletElement|null
*/
$dzd_wallet = $balance->first(fn ($wallet) => $wallet->getCurrency() === "dzd");
/**
* @var \Chargily\ChargilyPay\Elements\WalletElement|null
*/
$eur_wallet = $balance->first(fn ($wallet) => $wallet->getCurrency() === "eur");
/**
* @var \Chargily\ChargilyPay\Elements\WalletElement|null
*/
$usd_wallet = $balance->first(fn ($wallet) => $wallet->getCurrency() === "usd");

/////////
///////// Available Methods
/////////
/**
* @method \Chargily\ChargilyPay\Elements\WalletElement getBalance()
* @method \Chargily\ChargilyPay\Elements\WalletElement getReadyForPayout()
* @method \Chargily\ChargilyPay\Elements\WalletElement getOnHold()
* @method \Chargily\ChargilyPay\Elements\WalletElement getCurrency()
*
*/
/////////
///////// Example
/////////
$dzd_wallet->getBalance();
//The balance you can withdraw
$dzd_wallet->getReadyForPayout();
//The balance on hold
$dzd_wallet->getOnHold();
//The currency
$dzd_wallet->getCurrency();

```
77 changes: 77 additions & 0 deletions docs/Checkouts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
## Checkouts

### List of All

```php
/**
* @var Chargily\ChargilyPay\Elements\PaginationElement|null
*/
$items = $chargily_pay->checkouts()->all();

```

### Retrieve

```php
/**
* @var Chargily\ChargilyPay\Elements\CheckoutElement|null
*/
$checkout = $chargily_pay->checkouts()->get("checkout_id");

```

### Create

```php
/**
* @var Chargily\ChargilyPay\Elements\CheckoutElement|null
*/
$checkout = $chargily_pay->checkouts()->create([
"locale" => "en",//this is language en,ar,fr
"description" => "This description for checkout",
"items" => [
[
"price" => "price_id",
"quantity" => 1,
],
],
"metadata" => [],
"success_url" => "Redirect URL after payment completed",
"failure_url" => "Redirect URL after payment failure",
"webhook_endpoint" => "Webhook URL TO Recieve payment status",
]);

```

### Expire

- Change checkout status to expired

```php
/**
* @var Chargily\ChargilyPay\Elements\CheckoutElement|null
*/
$checkout = $chargily_pay->checkouts()->expire("checkout_id");
```

### Retrieve Prices

```php
/**
* @var Chargily\ChargilyPay\Elements\PaginationElement|null
*/
$prices = $chargily_pay->checkouts()->prices("checkout_id");

```

### `Chargily\ChargilyPay\Elements\CheckoutElement` Relations

- You can access the checkout prices list directly from `Chargily\ChargilyPay\Elements\CheckoutElement`

```php

$checkout = $chargily_pay->checkouts()->get("checkout_id");

$prices = $checkout->prices()->all();

```
63 changes: 63 additions & 0 deletions docs/Customers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
## Customers

### List of All

```php
/**
* @var Chargily\ChargilyPay\Elements\PaginationElement|null
*/
$items = $chargily_pay->customers()->all();

```

### Retrieve

```php
/**
* @var Chargily\ChargilyPay\Elements\CustomerElement|null
*/
$customer = $chargily_pay->customers()->get("customer_id");

```

### Create

```php
/**
* @var Chargily\ChargilyPay\Elements\CustomerElement|null
*/
$customer = $chargily_pay->customers()->create([
"name" => "Customer Name",
"email" => "customer@mail.com",
"phone" => "0990909090",
"address" => [
"country" => "DZ",
"state" => "18",
"address" => "100 Logs",
],
"metadata" => [],
]);

```

### Update

```php
/**
* @var Chargily\ChargilyPay\Elements\CustomerElement|null
*/
$customer = $chargily_pay->customers()->update("cuctomer_id",[
"name" => "New Customer Name",
]);

```

### Delete

```php
/**
* @var bool
*/
$deleted = $chargily_pay->customers()->delete("cuctomer_id");

```
54 changes: 54 additions & 0 deletions docs/PaymentLinks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
## Payment Links

### List of All

```php
/**
* @var Chargily\ChargilyPay\Elements\PaginationElement|null
*/
$items = $chargily_pay->payment_links()->all();

```

### Retrieve

```php
/**
* @var Chargily\ChargilyPay\Elements\PaymentLinkElement|null
*/
$link = $chargily_pay->payment_links()->get("payment_link_id");

```

### Create

```php
/**
* @var Chargily\ChargilyPay\Elements\PaymentLinkElement|null
*/
$link = $chargily_pay->payment_links()->create([
"name" => "Payment Link for Facebook page.",
"active" => true,
"after_completion_message" => "The product will arrive in 03 days.",
"locale" => "en",
"pass_fees_to_customer" => false,
"metadata" => [],
"items" => [
[
"price" => "price_id",
"quantity" => 1,
],
],
]);

```

### Retrieve Prices

```php
/**
* @var Chargily\ChargilyPay\Elements\PaginationElement|null
*/
$prices = $chargily_pay->payment_links()->prices("payment_link_id");

```
Loading

0 comments on commit 6dff01a

Please sign in to comment.