Skip to content

Commit 8229255

Browse files
committed
Initial Commit
0 parents  commit 8229255

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2548
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/dist
2+
/vendor
3+
composer.lock

.prettierrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"trailingComma": "es5",
3+
"tabWidth": 4,
4+
"semi": false,
5+
"singleQuote": false,
6+
"endOfLine": "auto",
7+
"bracketSameLine": true,
8+
"html.format.wrapAttributes": "auto",
9+
"html.format.wrapLineLength": 0,
10+
"printWidth": 1000
11+
}

LICENCE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 MOHAMMED BOUBAZINE
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Introduction
2+
3+
Package supports multi payments gateways (All in one Package) for PHP
4+
5+
# Instalation
6+
7+
- you can install the package via composer
8+
9+
```bash
10+
composer require medboubazine/pay
11+
```
12+
13+
# Documentation
14+
15+
[Documentation](./docs/index.md)

composer.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "medboubazine/pay",
3+
"type": "library",
4+
"description": "All In One . PHP Library for Payment Gateways",
5+
"keywords": [
6+
"php",
7+
"payment-gateway",
8+
"paypal-checkout",
9+
"paysera-checkout",
10+
"chargily-pay",
11+
"binance-pay"
12+
],
13+
"license": "MIT",
14+
"authors": [
15+
{
16+
"name": "Medboubazine",
17+
"email": "mohamedtorino161@gmail.com",
18+
"role": "Developer"
19+
}
20+
],
21+
"require": {
22+
"php": "^8.1",
23+
"paypal/rest-api-sdk-php": "^1.14",
24+
"illuminate/support": "^10.3",
25+
"rakit/validation": "^1.4",
26+
"webtopay/libwebtopay": "^1.8",
27+
"medboubazine/chargily-checkout": "^1.1",
28+
"medboubazine/binance-pay": "^1.0",
29+
"nesbot/carbon": "^2.66"
30+
},
31+
"autoload": {
32+
"psr-4": {
33+
"Medboubazine\\Pay\\": "src/"
34+
}
35+
},
36+
"require-dev": {
37+
"symfony/var-dumper": "^6.2",
38+
"symfony/error-handler": "^6.2"
39+
}
40+
}

docs/index.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Supported Payment methods
2+
3+
The package supports the following gateways
4+
5+
- Paypal
6+
- Paysera
7+
- Chargily Pay (EDAHABIA , CIB)
8+
- Binance Pay (Crypto Currencies)
9+
10+
# Documentation
11+
12+
- [Paypal](./payment_methods/paypal.md)
13+
- [Paysera](./payment_methods/paysera.md)
14+
- [Chargily Pay](./payment_methods/chargily_pay.md)
15+
- [Binance Pay](./payment_methods/binance_pay.md)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Payment Method: Binance Pay
2+
3+
## Create payment
4+
5+
```php
6+
$pay = new Pay();
7+
8+
$credentials = new Credentials();
9+
10+
$credentials->setEnv("");//'sandbox' for testing OR 'live' for production
11+
$credentials->setApiKey("");// Api Key
12+
$credentials->setSecretKey("");//Secret Key
13+
$credentials->setPaymentExpirationTime(60 * 30); //Paymen Expiration in seconds
14+
15+
$attributes = new Attributes();
16+
17+
$attributes->setOrderId("");//Order ID Must Be UNIQUE
18+
$attributes->setAmount("");//Amount
19+
$attributes->setCurrency("");//BUSD or USDT
20+
$attributes->setDescription("");//Order Description
21+
$attributes->setBackUrl("");//Back Url (Must be Active Url)
22+
$attributes->setProcessUrl("");//Payment Processing Url (Must be Active Url)
23+
24+
25+
$payment = Pay::createPayment(Pay::PM_BINANCE_PAY, $credentials, $attributes);
26+
27+
28+
if ($payment) {
29+
$payment_id = $payment->getId();
30+
$url = $payment->getId();
31+
//redirect to url
32+
} else {
33+
// "Payment creation failed
34+
}
35+
36+
```
37+
38+
## Process payment
39+
40+
```php
41+
42+
$pay = new Pay();
43+
44+
$credentials = new Credentials();
45+
46+
$credentials->setApiKey("");
47+
$credentials->setSecretKey("");
48+
49+
$attributes = new Attributes();
50+
51+
52+
$payment = Pay::processPayment(Pay::PM_BINANCE_PAY, $credentials, $attributes);
53+
54+
if($payment){
55+
if($payment->getStatus() === "approved"){
56+
//payment is confirmed
57+
}elseif($payment->getStatus() === "canceled"){
58+
//payment is canceled
59+
}else($payment->getStatus() === "failed"){
60+
//payment is failed
61+
}
62+
}
63+
64+
```
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Payment Method: Chargily Pay
2+
3+
## Create payment
4+
5+
```php
6+
7+
$credentials = new Credentials();
8+
9+
$credentials->setApiKey("");// Api Key
10+
$credentials->setSecretKey("");// Secret Key
11+
12+
$attributes = new Attributes();
13+
14+
$attributes->setOrderId("");//Order/Invoice ID
15+
$attributes->setClientFullName("");//Client Fullname/username
16+
$attributes->setClientEmail("");//client email
17+
$attributes->setAmount("");//Amount
18+
$attributes->setDiscount("");//Discount
19+
$attributes->setMethod("");//DAHABIA or CIB
20+
$attributes->setDescription("");//Order Description
21+
$attributes->setBackUrl("");//Back Url (Must be Active Url)
22+
$attributes->setProcessUrl("");//Payment Processing Url (Must be Active Url)
23+
24+
25+
$payment = Pay::createPayment(Pay::PM_CHARGILY_PAY, $credentials, $attributes);
26+
27+
28+
29+
if ($payment) {
30+
$payment_id = $payment->getId();
31+
$url = $payment->getId();
32+
//redirect to url
33+
} else {
34+
// "Payment creation failed
35+
}
36+
37+
```
38+
39+
## Process payment
40+
41+
```php
42+
43+
$pay = new Pay();
44+
45+
$credentials = new Credentials();
46+
47+
$credentials->setApiKey("");
48+
$credentials->setSecretKey("");
49+
50+
$attributes = new Attributes();
51+
52+
$payment = Pay::processPayment(Pay::PM_CHARGILY_PAY, $credentials, $attributes);
53+
54+
if($payment){
55+
if($payment->getStatus() === "approved"){
56+
//payment is confirmed
57+
}elseif($payment->getStatus() === "canceled"){
58+
//payment is canceled
59+
}else($payment->getStatus() === "failed"){
60+
//payment is failed
61+
}
62+
}
63+
64+
```

docs/payment_methods/paypal.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Payment Method: Paypal
2+
3+
## Create payment
4+
5+
```php
6+
7+
$credentials = new Credentials();
8+
9+
$credentials->setEnv("sandbox"); //sandbox OR live
10+
$credentials->setApiKey(""); //Your paypal Api Key
11+
$credentials->setSecretKey(""); //Your paypal Api Key
12+
$credentials->setLogEnabled(false);
13+
//if logEnabled set is true uncoment next line
14+
//$credentials->setLogPath(__DIR__ . "/log/paypal_log.log");
15+
16+
$attributes = new Attributes();
17+
18+
$attributes->setAmount("10");
19+
$attributes->setCurrency("USD");
20+
$attributes->setDescription("Order Amount");
21+
$attributes->setProcessUrl("/dist/process.php"); // Payment process page
22+
$attributes->setBackUrl("/back.php");
23+
24+
$payment = Pay::createPayment(Pay::PM_PAYPAL, $credentials, $attributes);
25+
26+
if ($payment) {
27+
$payment_id = $payment->getId();
28+
$url = $payment->getId();
29+
//redirect to url
30+
} else {
31+
// "Payment creation failed
32+
}
33+
34+
```
35+
36+
## Process payment
37+
38+
```php
39+
$pay = new Pay();
40+
41+
$credentials = new Credentials();
42+
43+
$credentials->setEnv("");
44+
$credentials->setApiKey("");
45+
$credentials->setSecretKey("");
46+
$credentials->setLogEnabled(false);
47+
$credentials->setLogPath(__DIR__ . "/log/paypal_log.log");
48+
49+
$attributes = new Attributes();
50+
$attributes->setAcceptOnlyVerifiedAccounts(false);
51+
52+
$payment = Pay::processPayment(Pay::PM_PAYPAL, $credentials, $attributes);
53+
54+
if($payment){
55+
if($payment->getStatus() === "approved"){
56+
//payment is confirmed
57+
}elseif($payment->getStatus() === "canceled"){
58+
//payment is canceled
59+
}else($payment->getStatus() === "failed"){
60+
//payment is failed
61+
}
62+
}
63+
64+
```

docs/payment_methods/paysera.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Payment Method: Paysera
2+
3+
## Create payment
4+
5+
```php
6+
$pay = new Pay();
7+
8+
$credentials = new Credentials();
9+
10+
$credentials->setEnv("");//'sandbox' for testing Or 'live' for production
11+
$credentials->setProjectId("");//Project Id
12+
$credentials->setSignPassword("");//Sign password
13+
14+
$attributes = new Attributes();
15+
16+
$attributes->setOrderId("");//Order/Invoice Number
17+
$attributes->setAmount("");//Amount
18+
$attributes->setCurrency("");//Currency
19+
$attributes->setCountry("");//Country
20+
$attributes->setBackUrl("");//Back Url
21+
$attributes->setProcessUrl("");//Payment Processing url
22+
23+
24+
$payment = Pay::createPayment(Pay::PM_PAYSERA, $credentials, $attributes);
25+
26+
if ($payment) {
27+
$payment_id = $payment->getId();
28+
$url = $payment->getId();
29+
//redirect to url
30+
} else {
31+
// "Payment creation failed
32+
}
33+
34+
```
35+
36+
## Process payment
37+
38+
```php
39+
$pay = new Pay();
40+
41+
$credentials = new Credentials();
42+
43+
$credentials->setProjectId("");
44+
$credentials->setSignPassword("");
45+
46+
$attributes = new Attributes();
47+
48+
$attributes->setAllowTestPayments(false);
49+
$attributes->setAcceptOnlyMacroPayments(true);
50+
51+
$payment = Pay::processPayment(Pay::PM_PAYSERA, $credentials, $attributes);
52+
53+
54+
if($payment){
55+
if($payment->getStatus() === "approved"){
56+
//payment is confirmed
57+
}elseif($payment->getStatus() === "canceled"){
58+
//payment is canceled
59+
}else($payment->getStatus() === "failed"){
60+
//payment is failed
61+
}
62+
}
63+
64+
```

0 commit comments

Comments
 (0)