Skip to content

Commit a2c87e9

Browse files
committed
wip
1 parent ce5ac54 commit a2c87e9

File tree

12 files changed

+269
-0
lines changed

12 files changed

+269
-0
lines changed

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.idea
2+
.php_cs
3+
.php_cs.cache
4+
.phpunit.result.cache
5+
build
6+
composer.lock
7+
coverage
8+
phpunit.xml
9+
phpstan.neon
10+
testbench.yaml
11+
vendor
12+
node_modules
13+
.php-cs-fixer.cache
14+
.DS_Store

LICENSE

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
MIT License
2+
3+
Copyright (c) 2025
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+
[Full License Text...]

composer.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "thejano/zaincash-laravel",
3+
"description": "A Laravel SDK for integrating with ZainCash payment gateway",
4+
"type": "library",
5+
"require": {
6+
"php": ">=8.1",
7+
"illuminate/support": "^8.0|^9.0|^10.0|^11.0",
8+
"firebase/php-jwt": "^6.0",
9+
"guzzlehttp/guzzle": "^7.0"
10+
},
11+
"autoload": {
12+
"psr-4": {
13+
"TheJano\\ZainCash\\": "src/"
14+
}
15+
},
16+
"extra": {
17+
"laravel": {
18+
"providers": [
19+
"TheJano\\ZainCash\\Providers\\ZainCashPaymentServiceProvider"
20+
]
21+
}
22+
},
23+
"minimum-stability": "stable"
24+
}

config/zaincash.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
return [
3+
'msisdn' => env('ZAINCASH_MSISDN', '9647835077893'),
4+
'merchant_id' => env('ZAINCASH_MERCHANT_ID', '5ffacf6612b5777c6d44266f'),
5+
'secret' => env('ZAINCASH_SECRET', '$2y$10$hBbAZo2GfSSvyqAyV2SaqOfYewgYpfR1O19gIh4SqyGWdmySZYPuS'),
6+
'environment' => env('ZAINCASH_ENVIRONMENT', 'staging'),
7+
'staging_url' => env('ZAINCASH_STAGING_URL', 'https://test.zaincash.iq'),
8+
'production_url' => env('ZAINCASH_PRODUCTION_URL', 'https://api.zaincash.iq'),
9+
'language' => env('ZAINCASH_LANGUAGE', 'ar'),
10+
'prefix_order_id' => env('ZAINCASH_PREFIX_ORDER_ID', 'myshop_'),
11+
'should_redirect' => env('ZAINCASH_SHOULD_REDIRECT', true),
12+
'redirect_url' => env('ZAINCASH_REDIRECT_URL', 'https://yourwebsite.com/payment/callback'),
13+
];

editorconfig.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_size = 4
6+
indent_style = space
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2

gitattributes.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Path-based git attributes
2+
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
3+
4+
# Ignore all test and documentation with "export-ignore".
5+
/.github export-ignore
6+
/.gitattributes export-ignore
7+
/.gitignore export-ignore
8+
/phpunit.xml.dist export-ignore
9+
/art export-ignore
10+
/docs export-ignore
11+
/tests export-ignore
12+
/.editorconfig export-ignore
13+
/.php_cs.dist.php export-ignore
14+
/psalm.xml export-ignore
15+
/psalm.xml.dist export-ignore
16+
/testbench.yaml export-ignore
17+
/UPGRADING.md export-ignore
18+
/phpstan.neon.dist export-ignore
19+
/phpstan-baseline.neon export-ignore

src/Contracts/PaymentGateway.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
namespace TheJano\ZainCash\Contracts;
3+
4+
interface PaymentGateway {
5+
public function initiatePayment(string $orderId, float $amount, string $serviceType, ?string $redirectUrl = null): array;
6+
public function verifyPayment(string $token): ?array;
7+
public function checkTransaction(string $transactionId): array;
8+
}

src/Facades/ZainCashPayment.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
namespace TheJano\ZainCash\Facades;
3+
4+
use Illuminate\Support\Facades\Facade;
5+
6+
class ZainCashPayment extends Facade {
7+
protected static function getFacadeAccessor() {
8+
return 'zaincashPayment';
9+
}
10+
}

src/Http/HttpClient.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
namespace TheJano\ZainCash\Http;
3+
4+
interface HttpClient {
5+
public function post(string $url, array $data): array;
6+
}

src/Http/LaravelHttpClient.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
namespace TheJano\ZainCash\Http;
3+
4+
use Illuminate\Support\Facades\Http;
5+
use Exception;
6+
7+
class LaravelHttpClient implements HttpClient {
8+
public function post(string $url, array $data): array {
9+
$response = Http::asForm()->post($url, $data);
10+
if ($response->failed()) {
11+
throw new Exception('Request failed: ' . $response->body());
12+
}
13+
return $response->json();
14+
}
15+
}

0 commit comments

Comments
 (0)