diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..6537ca4
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,15 @@
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+insert_final_newline = true
+indent_style = space
+indent_size = 4
+trim_trailing_whitespace = true
+
+[*.md]
+trim_trailing_whitespace = false
+
+[*.{yml,yaml}]
+indent_size = 2
diff --git a/.gitignore b/.gitignore
index 35923b4..40c5728 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@ phpunit.xml
coverage
coverage.xml
.phpunit.result.cache
+docker-compose.yml
diff --git a/.styleci.yml b/.styleci.yml
index 6cf98dc..0285f17 100644
--- a/.styleci.yml
+++ b/.styleci.yml
@@ -1,5 +1 @@
preset: laravel
-
-finder:
- exclude:
- - "tests"
diff --git a/.travis.yml b/.travis.yml
index 3e211a0..fc48cf3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,34 +7,37 @@ cache:
matrix:
fast_finish: true
include:
- - php: 7.2
- env: LARAVEL='5.8.*' TESTBENCH='3.8.*' COMPOSER_FLAGS='--prefer-lowest'
- - php: 7.2
- env: LARAVEL='5.8.*' TESTBENCH='3.8.*' COMPOSER_FLAGS='--prefer-stable'
+ # Laravel 7
- php: 7.3
- env: LARAVEL='5.8.*' TESTBENCH='3.8.*' COMPOSER_FLAGS='--prefer-lowest'
- - php: 7.3
- env: LARAVEL='5.8.*' TESTBENCH='3.8.*' COMPOSER_FLAGS='--prefer-stable'
- - php: 7.2
- env: LARAVEL='6.*' TESTBENCH='4.*' COMPOSER_FLAGS='--prefer-lowest'
- - php: 7.2
- env: LARAVEL='6.*' TESTBENCH='4.*' COMPOSER_FLAGS='--prefer-stable'
- - php: 7.3
- env: LARAVEL='6.*' TESTBENCH='4.*' COMPOSER_FLAGS='--prefer-lowest'
+ env: LARAVEL='7.*' TESTBENCH='5.*' COMPOSER_FLAGS='--prefer-lowest'
- php: 7.3
- env: LARAVEL='6.*' TESTBENCH='4.*' COMPOSER_FLAGS='--prefer-stable'
- - php: 7.2
+ env: LARAVEL='7.*' TESTBENCH='5.*' COMPOSER_FLAGS='--prefer-stable'
+
+ - php: 7.4
env: LARAVEL='7.*' TESTBENCH='5.*' COMPOSER_FLAGS='--prefer-lowest'
- - php: 7.2
+ - php: 7.4
env: LARAVEL='7.*' TESTBENCH='5.*' COMPOSER_FLAGS='--prefer-stable'
- - php: 7.3
+
+ - php: 8.0
env: LARAVEL='7.*' TESTBENCH='5.*' COMPOSER_FLAGS='--prefer-lowest'
- - php: 7.3
+ - php: 8.0
env: LARAVEL='7.*' TESTBENCH='5.*' COMPOSER_FLAGS='--prefer-stable'
+
+ # Laravel 8
+ - php: 7.3
+ env: LARAVEL='8.*' TESTBENCH='6.*' COMPOSER_FLAGS='--prefer-lowest'
+ - php: 7.3
+ env: LARAVEL='8.*' TESTBENCH='6.*' COMPOSER_FLAGS='--prefer-stable'
+
- php: 7.4
- env: LARAVEL='7.*' TESTBENCH='5.*' COMPOSER_FLAGS='--prefer-lowest'
+ env: LARAVEL='8.*' TESTBENCH='6.*' COMPOSER_FLAGS='--prefer-lowest'
- php: 7.4
- env: LARAVEL='7.*' TESTBENCH='5.*' COMPOSER_FLAGS='--prefer-stable' COVERAGE=true
+ env: LARAVEL='8.*' TESTBENCH='6.*' COMPOSER_FLAGS='--prefer-stable' COVERAGE=true
+
+ - php: 8.0
+ env: LARAVEL='8.*' TESTBENCH='6.*' COMPOSER_FLAGS='--prefer-lowest'
+ - php: 8.0
+ env: LARAVEL='8.*' TESTBENCH='6.*' COMPOSER_FLAGS='--prefer-stable'
before_install:
- travis_retry composer self-update
diff --git a/docs/changelog.md b/CHANGELOG.md
similarity index 67%
rename from docs/changelog.md
rename to CHANGELOG.md
index 9ca3a5a..1fd6ae4 100644
--- a/docs/changelog.md
+++ b/CHANGELOG.md
@@ -2,6 +2,11 @@
All notable changes to Laravel Toman will be documented in this file.
+## Version 2.0
+
+### Change
+- Package interfaces are significantly changed
+
## Version 1.0
### Added
diff --git a/docs/contributing.md b/CONTRIBUTING.md
similarity index 65%
rename from docs/contributing.md
rename to CONTRIBUTING.md
index de35553..436bd6b 100644
--- a/docs/contributing.md
+++ b/CONTRIBUTING.md
@@ -1,25 +1,23 @@
# Contributing
-Contributions are welcome and will be fully credited.
+Contributions are welcome and will be fully credited. They are accepted via Pull Requests on [Laravel Toman](https://github.com/evryn/laravel-toman) repository.
-Contributions are accepted via Pull Requests on [Github](https://github.com/amirrezanasiri/laraveltoman).
-
-# Things you could do
+# Things you can do
If you want to contribute but do not know where to start, this list provides some starting points.
- * Add callback fakers to simulate actual gateway callbacks.
* Add a new Payment Gateway:
* [YekPay.com](https://yekpay.com/)
* [Pay.ir](https://pay.ir/)
* [PayPing.ir](https://www.payping.ir/)
* Refactor if you think there are better approach to do things.
+ * Improve documents and comments; Fix grammatical errors, typos, etc.
## Pull Requests
-- **Add tests!** - Your patch won't be accepted if it doesn't have comprehensive tests.
+- **Add tests** - We need to have tests for the features.
- **Document any change in behaviour** - Make sure documents in `docs/` directory are kept up-to-date.
-- **Consider our release cycle** - We're following [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
+- **Consider our release cycle** - We're following [SemVer v2.0.0](http://semver.org/).
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
diff --git a/license.md b/LICENSE.md
similarity index 96%
rename from license.md
rename to LICENSE.md
index 8e5c378..5e3a940 100644
--- a/license.md
+++ b/LICENSE.md
@@ -1,6 +1,6 @@
# MIT License
-Copyright (c) 2019 Amirreza Nasiri
+Copyright (c) Amirreza Nasiri
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:
diff --git a/readme.md b/README.md
similarity index 80%
rename from readme.md
rename to README.md
index 75ecf80..e88588c 100644
--- a/readme.md
+++ b/README.md
@@ -11,7 +11,7 @@
-
+
@@ -22,12 +22,19 @@
and start using in <5m
+
+ داکیومنت فارسی
+ رو بخونین و تو 5 دقیقه استفادهاش کنین
+ 📚
+
+
# About Toman (تومَن)
Toman is a Laravel package which makes working with popular payment gateways much easier.
## Supported Gateways
✅ [Zarinpal.com](https://zarinpal.com)
+✅ [IDPay.ir](https://idpay.ir)
🔘 [YekPay.com](https://yekpay.com/)
🔘 [Pay.ir](https://pay.ir/)
🔘 [PayPing.ir](https://www.payping.ir/)
@@ -35,17 +42,17 @@ Toman is a Laravel package which makes working with popular payment gateways muc
## Simple to use
-Request new payment as easy as:
+Request a new payment:
diff --git a/composer.json b/composer.json
index 85f14bc..e0df7b6 100644
--- a/composer.json
+++ b/composer.json
@@ -1,6 +1,6 @@
{
"name": "evryn/laravel-toman",
- "description": "A simple stable Laravel package to handle popular payment gateways in Iran including Zarinpal.",
+ "description": "A simple stable Laravel package to handle popular payment gateways in Iran including ZarinPal and IDPay.",
"license": "MIT",
"authors": [
{
@@ -11,19 +11,20 @@
],
"homepage": "https://github.com/evryn/laravel-toman",
"keywords": [
+ "zarinpal", "زرین پال",
+ "idpay", "آیدی پی",
"laravel", "laraveltoman", "laravel-toman",
- "toman", "zarinpal", "زرین پال", "payment",
- "gateway", "درگاه", "پرداخت"
+ "toman", "payment", "gateway", "درگاه", "پرداخت"
],
"require": {
- "php": "^7.2",
- "illuminate/support": "~5.8.0|^6.0|^7.0",
- "guzzlehttp/guzzle": "^6.3"
+ "php": "^7.3|^8.0",
+ "illuminate/support": "^7.0|^8.0",
+ "guzzlehttp/guzzle": "^6.3|^7.0"
},
"require-dev": {
"phpunit/phpunit": "^8.0",
- "mockery/mockery": "^1.1",
- "orchestra/testbench": "~3.8.0|^4.0|^5.0",
+ "mockery/mockery": "^1.3.3",
+ "orchestra/testbench": "~3.8.0|^4.0|^5.0|^6.0",
"sempro/phpunit-pretty-print": "^1.0"
},
"autoload": {
@@ -48,7 +49,7 @@
},
"scripts": {
"test": "vendor/bin/phpunit --exclude-group external",
- "test-coverage": "vendor/bin/phpunit --exclude-group external --coverage-clover=coverage.xml",
- "test-dev": "vendor/bin/phpunit --configuration=phpunit.xml --coverage-html=coverage --coverage-text"
+ "test-coverage": "vendor/bin/phpunit --coverage-clover coverage.xml",
+ "test-dev": "vendor/bin/phpunit --coverage-html coverage --coverage-text"
}
}
diff --git a/config/toman.php b/config/toman.php
index f59b9ed..db66dc5 100644
--- a/config/toman.php
+++ b/config/toman.php
@@ -27,8 +27,8 @@
'gateways' => [
'zarinpal' => [
- // Use sandbox.zarinpal.com instead of zarinpal.com for testing
- // purpose. Set it to false on production to receive real payments.
+ // Setting to true makes all payments happen in a testing environment to fake transactions.
+ // Set it to false on production to receive real payments.
'sandbox' => env('ZARINPAL_SANDBOX', false),
// Merchant ID of your gateway provided by Zarinpal for your gateway
@@ -36,8 +36,35 @@
'merchant_id' => env('ZARINPAL_MERCHANT_ID'),
],
+ 'idpay' => [
+ // Setting to true makes all payments happen in a testing environment to fake transactions.
+ // Set it to false on production to receive real payments.
+ 'sandbox' => env('IDPAY_SANDBOX', false),
+
+ // API Key of your gateway provided by IDPay in your dashboard
+ // only. Looks like this: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
+ 'api_key' => env('IDPAY_API_KEY'),
+ ],
+
],
+ /*
+ |--------------------------------------------------------------------------
+ | Default Currency
+ |--------------------------------------------------------------------------
+ |
+ Gateways accept different currencies; So in order to avoid confusion
+ | when switching between gateways, you can specify your intended currency
+ | here, and Toman will convert to proper one automatically.
+ | You can of course override it and specify another currency during making
+ | requests using Money object too.
+ |
+ | Supported currencies: "toman", "rial"
+ |
+ */
+
+ 'currency' => 'toman',
+
/*
|--------------------------------------------------------------------------
| Default Description
diff --git a/docker-compose.yml.example b/docker-compose.yml.example
new file mode 100644
index 0000000..b2c1361
--- /dev/null
+++ b/docker-compose.yml.example
@@ -0,0 +1,19 @@
+version: "3.4"
+
+services:
+ php:
+ image: php:7.3-alpine
+ volumes:
+ - .:/var/www/html
+
+ composer:
+ image: composer:2
+ volumes:
+ - .:/app
+ - composer-cache:/tmp/cache
+ working_dir: /app
+ command: '-V'
+
+volumes:
+ composer-cache:
+ name: composer-cache
diff --git a/docs/README.md b/docs/README.md
new file mode 100644
index 0000000..7d82a33
--- /dev/null
+++ b/docs/README.md
@@ -0,0 +1,40 @@
+# About Toman (تومَن)
+Toman is a Laravel package that makes working with popular payment gateways much easier.
+
+There are dozens of gateway handlers; Here is why you may choose Laravel Toman:
+
+## Heavily Tested
+
+
+
+
+
+
+
+Payment is a critical topic, and its handlers must be tested from all aspects. Laravel Toman has an automated test suit with 100% coverage. On every released build, we're forced to pass all tests so you can add a payment to your code with confidence.
+
+## Elegant API
+
+APIs are pretty much easy to use! Requesting a new payment and verifying it will add ~10 lines to your codebase! 😎
+
+## Supports Multiple Gateways
+
+We are planning to add new gateway providers. They'll require minimum possible changes in your code.
+Currently, following gateways are available to use:
+✅ [Zarinpal.com](https://zarinpal.com)
+✅ [IDPay.ir](https://idpay.ir)
+🔘 [YekPay.com](https://yekpay.com/)
+🔘 [Pay.ir](https://pay.ir/)
+🔘 [PayPing.ir](https://www.payping.ir/)
+🔘 ...
+
+## Easy to Test
+
+Writing a test for your application and want to see if you're using the package correctly? No problem at all!
+
+See our testing instructions in your payment gateway section!
+
+
+➡ Why don't you see yourself? [Quick Start](getting-started.md)
+
+➡ Looking for old documents? V1 Docs
diff --git a/docs/_coverpage.md b/docs/_coverpage.md
index 35781de..20ddf75 100644
--- a/docs/_coverpage.md
+++ b/docs/_coverpage.md
@@ -1,7 +1,6 @@
-
![logo](_media/logo.png)
-# Laravel Toman 1.0
+# Laravel Toman 2.0
> A painless payment handler!
@@ -13,8 +12,8 @@ Elegant API • Heavily Tested • Multiple Gateways
-
-
+
+
@@ -25,3 +24,7 @@ Elegant API • Heavily Tested • Multiple Gateways
[GitHub](https://github.com/evryn/laravel-toman)
[Get Started](#quickstart)
+
+
+
+![color](#b3ffe9)
diff --git a/docs/_media/logo.png b/docs/_media/logo.png
index 9dad305..874bf0b 100644
Binary files a/docs/_media/logo.png and b/docs/_media/logo.png differ
diff --git a/docs/_media/payment-request.png b/docs/_media/payment-request.png
new file mode 100644
index 0000000..8f691d0
Binary files /dev/null and b/docs/_media/payment-request.png differ
diff --git a/docs/_media/payment-verification.png b/docs/_media/payment-verification.png
new file mode 100644
index 0000000..7a5a1ba
Binary files /dev/null and b/docs/_media/payment-verification.png differ
diff --git a/docs/_navbar.md b/docs/_navbar.md
new file mode 100644
index 0000000..7531ae5
--- /dev/null
+++ b/docs/_navbar.md
@@ -0,0 +1,2 @@
+* [English](/)
+* [فارسی](/fa/)
diff --git a/docs/_sidebar.md b/docs/_sidebar.md
index d476b9c..489891a 100644
--- a/docs/_sidebar.md
+++ b/docs/_sidebar.md
@@ -1,18 +1,13 @@
-* [Introduction](introduction.md)
+* [Introduction](README.md)
-* Getting started
-
- * [Quick Start](quickstart.md)
- * [Configuration](configuration.md)
- * [Translations](translations.md)
+* [Getting Started](getting-started.md)
-* Available Gateways
+* Payment Gateways
- * [Zarinpal](gateways/zarinpal.md)
-
-* [Testing](testing.md)
+ * [💳 Zarinpal](gateways/zarinpal.md)
+ * [💳 IDPay](gateways/idpay.md)
-* [Contributing](contributing.md)
-* [Changelog](changelog.md)
-* [Support 💜](support.md)
+* [Contributing](../CONTRIBUTING.md)
+* [Changelog](../CHANGELOG.md)
+* [💜 Support](support.md)
diff --git a/docs/fa/README.md b/docs/fa/README.md
new file mode 100644
index 0000000..623f285
--- /dev/null
+++ b/docs/fa/README.md
@@ -0,0 +1,41 @@
+# درباره Toman (تومَن)
+تومَن یه پکیج لاراوله که کار کردن با درگاههای پرداخت رو خیلی راحتتر میکنه.
+کلی پکیج دیگه واسه هندل کردن درگاهها وجود داره اما این پکیج ممکنه واستون مناسبتر باشه، چون:
+
+## قابل اطمینان
+
+
+
+
+
+
+
+پرداخت موضوع مهمیه و هندلرها باید از جنبههاش مختلف تست شده باشن.
+Laravel Toman یه تست سوئیت کامل داره. قبل از ریلیز کردن هر نسخهای، مجبوریم که همه تستهای خودکار رو پاس کنیم تا به دست شما برسه
+و بتونین با خیال راحت تو کدهاتون استفاده کنین.
+
+## رابطهای خوشگل
+
+رابطهای این پکیج خیلی سادهتر از اونی هست که فکر میکنین. ایجاد پرداخت جدید و راستیآزماییش فقط 10 خط به کدبیستون اضافه میکنه 😎
+
+## پشتیبانی از چندین درگاه
+
+برنامه داریم که درگاههای جدید رو هم به تومن اضافه کنیم. قول میدیم که سوئیچ کردن رو درگاههای مختلف، کمترین تغییرات رو توی کدهاتون داشته باشه.
+فعلاً این درگاهها قابل استفاده هستن:
+
+✅ [Zarinpal.com](https://zarinpal.com)
+✅ [IDPay.ir](https://idpay.ir)
+🔘 [YekPay.com](https://yekpay.com/)
+🔘 [Pay.ir](https://pay.ir/)
+🔘 [PayPing.ir](https://www.payping.ir/)
+🔘 ...
+
+## سادگی در تست کردن
+
+دارین برای کدهاتون تست سوئیت خودکار ایجاد میکنین و میخواین ببینین که از این پکیج هم درست استفاده میکنین یا نه؟
+مشکلی نیست! تو صفحه راهنمای درگاهها، میتونین ببینین چطور به راحتی میشه تست کرد این جنبه از نرمافزارتون رو.
+
+
+➡ [بریم سراغ نصب!](getting-started.md)
+
+➡ دنبال داکیومنت قدیمی هستین؟ داکیومنتهای نسخه 1
diff --git a/docs/fa/_coverpage.md b/docs/fa/_coverpage.md
new file mode 100644
index 0000000..3a0cd96
--- /dev/null
+++ b/docs/fa/_coverpage.md
@@ -0,0 +1,30 @@
+![logo](../_media/logo.png)
+
+# Laravel Toman 2.0
+
+> درگاه پرداخت - مثل آب خوردن!
+
+استفاده آسان • تست شده • پشتیبانی از چندین درگاه
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+[گیتهاب](https://github.com/evryn/laravel-toman)
+[شروع به کار](#quickstart)
+
+
+
+![color](#b3ffe9)
diff --git a/docs/fa/_navbar.md b/docs/fa/_navbar.md
new file mode 100644
index 0000000..36e4749
--- /dev/null
+++ b/docs/fa/_navbar.md
@@ -0,0 +1,2 @@
+* [فارسی](/fa/)
+* [English](/)
diff --git a/docs/fa/_sidebar.md b/docs/fa/_sidebar.md
new file mode 100644
index 0000000..c7f9afb
--- /dev/null
+++ b/docs/fa/_sidebar.md
@@ -0,0 +1,13 @@
+* [معرفی](fa/README.md)
+
+* [شروع به کار](fa/getting-started.md)
+
+* درگاههای پرداخت
+
+ * [💳 زرینپال](fa/gateways/zarinpal.md)
+ * [💳 آیدی پِی](fa/gateways/idpay.md)
+
+* [مشارکت](../CONTRIBUTING.md)
+* [لیست تغییرات](../CHANGELOG.md)
+* [💜 حمایت از ما](fa/support.md)
+
diff --git a/docs/fa/gateways/idpay.md b/docs/fa/gateways/idpay.md
new file mode 100644
index 0000000..e211950
--- /dev/null
+++ b/docs/fa/gateways/idpay.md
@@ -0,0 +1,268 @@
+# استفاده از درگاه IDPay
+
+تومن درگاه [IDPay.ir](https://idpay.ir) رو بر اساس نسخه 1.1 [داکیومنت رسمیشون](https://idpay.ir/web-service/v1.1/) ساخته.
+
+## شروع به کار
+### تنظیمات
+
+درگاه آیدی پِی نیاز به تغییر این مقادیر تو فایل `.env` داره:
+
+| متغیر محیطی | توضیحات |
+|---------------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `TOMAN_GATEWAY` | (**اجباری**) باید `idpay` باشه. |
+| `IDPAY_API_KEY` | (**اجباری**) API Key درگاه پرداخت که میتونین از پنل ارائهدهنده بگیرین. نمونه: `0bcf346fc-3a79-4b36-b936-5ccbc2be0696` |
+| `IDPAY_SANDBOX` | (اختیاری. مقدار پیشفرض: `false`) اگه تنظیم شه به `true`، همه درخواستها تو محیط تست این درگاه بدون پرداخت واقعی انجام میشه. این شرایط تو محیط توسعه لوکال به درد میخوره.
+
+نمونه:
+```dotenv
+...
+
+TOMAN_GATEWAY=idpay
+IDPAY_API_KEY=0bcf346fc-3a79-4b36-b936-5ccbc2be0696
+```
+
+#### واحد پولی
+
+واحد پولی رو میتونین به دو صورت معین کنین:
+
+**استفاده از فایل تنظیمات (کانفیگ):**
+
+| متد | تنظیم | یعنی |
+|------------------|----------------------------|--------------|
+| `amount(10000)` | `toman.currency = 'toman'` | 10,000 تومان |
+| `amount(10000)` | `toman.currency = 'rial'` | 1,000 تومان |
+
+**صریحاً مشخص کردن:**
+```php
+use Evryn\LaravelToman\Money;
+
+...->amount(Money::Rial(10000));
+...->amount(Money::Toman(1000));
+```
+
+## ⚡ درخواست پرداخت جدید
+
+```php
+use Evryn\LaravelToman\Facades\Toman;
+
+// ...
+
+$request = Toman::orderId('order_1500')
+ ->amount(15000)
+ // ->description('Subscribing to Plan A')
+ // ->callback(route('payment.callback'))
+ // ->mobile('09350000000')
+ // ->email('amirreza@example.com')
+ // ->name('Amirreza Nasiri')
+ ->request();
+
+if ($request->successful()) {
+ $transactionId = $request->transactionId();
+ // Store created transaction details for verification
+
+ return $request->pay(); // Redirect to payment URL
+}
+
+if ($request->failed()) {
+ // Handle transaction request failure; Probably showing proper error to user.
+}
+```
+
+متدهای قابل استفاده برای ایجاد درخواست پرداخت جدید با کلاس نمایهای `Toman`:
+
+| متد | توضیحات |
+|------------- |--------------------------------------------------------------------------------------------------------------------------------- |
+| `amount($amount)` | **(الزامی)** تنظیم مبلغ قابل پرداخت. این درگاه واحد پولیش ریاله. |
+| `orderId($orderId)` | **(الزامی)** تنظیم شناسه سفارش. این شناسه یه رشته هست که سمت شما به صورت یکتا باید ساخته بشه و موقع تایید پرداخت ازش استفاده بشه. |
+| `callback($url)` | تنظیم یک آدرس URL کامل به عنوان Callback URL. بر کانفیگ `callback_route` اولویت داره. |
+| `description($string)` | تنظیم توضیحات پرداخت. بر کانفیگ `description` اولویت داره. |
+| `mobile($mobile)` | تنظیم شماره موبایل پرداختکننده. |
+| `email($email)` | تنظیم ایمیل پرداختکننده. |
+| `name($name)` | تنظیم نام پرداختکننده. |
+| `request()` | ارسال درخواست پرداخت جدید و بازگردوندن یک آبجکت از نوع `RequestedPayment`. |
+
+
+استفاده از `RequestedPayment` برگردونده شده:
+
+|
متد
| توضیحات |
+|-------------------- |--------------------------------------------------------------------------------------------------------------------------------- |
+| `successful()` | درخواست پرداخت موفق بوده؛ شناسه تراکنش در دسترسه و میشه کاربر رو به صفحه پرداخت هدایت کرد. |
+| `transactionId()` | [در صورت موفقیت] دریافت شناسه تراکنش. |
+| `pay($options = [])` | [در صورت موفقیت] ریدایرکت کردن کاربر به صفحه پرداخت از کنترلر. یه آبجکت `RedirectResponse` برمیگردونه. |
+| `paymentUrl($options = [])` | [در صورت موفقیت] دریافت آدرس پراخت نهایی. |
+| `failed()` | درخواست پرداخت شکست خورد؛ پیامهای مناسب و Exception در دسترس هستن. |
+| `messages()` | [در صورت شکست] دریافت آرایهای از پیامهای خطا |
+| `message()` | [در صورت شکست] دریافت اولین پیام خطا. |
+| `throw()` | [در صورت شکست] پرت کردن Exception متناسب با خطا. |
+
+
+
+## ⚡ تایید پرداخت
+
+مکانیزم تایید پرداخت باید در مسیر مربوط به Callback ارسال شده پیاده شود. این کنترلر رو در نظر بگیرین:
+
+```php
+transactionId() and $request->orderId() to match the
+ // non-paid payment. Take care of Double Spending.
+
+ $payment = $request->verify();
+
+ if ($payment->successful()) {
+ // Store the successful transaction details
+ $referenceId = $payment->referenceId();
+ }
+
+ if ($payment->alreadyVerified()) {
+ // ...
+ }
+
+ if ($payment->failed()) {
+ // ...
+ }
+ }
+}
+```
+
+متدهای قابل استفاده برای تایید پرداخت با `CallbackRequest` یا کلاس نمایهای `Toman`:
+
+| متد | توضیحات |
+|------------- |--------------------------------------------------------------------------------------------------------------------------------- |
+| `orderId($orderId)` | تنظیم شناسه سفارش. `CallbackRequest` اینو خودش پر میکنه. |
+| `transactionId($id)` | تنظیم شناسه تراکنش برای بررسی تایید پرداخت. `CallbackRequest` اینو خودش پر میکنه.|
+| `verify()` |ارسال درخواست بررسی و تایید پرداخت. یه آبجکت `CheckedPayment` برمیگردونه. |
+
+
+استفاده از `CheckedPayment` برگردونده شده:
+
+| متد | توضیحات |
+|-------------------- |--------------------------------------------------------------------------------------------------------------------------------- |
+| `orderId()` | دریافت شناسه سفارشی که تو درخواست ارسال شده بود. |
+| `transactionId()` | دریافت شناسه تراکنشی که تو درخواست ارسال شده بود. |
+| `successful()` | پرداخت موفق بوده و شناسه ارجاع در دسترسه. |
+| `transactionId()` | [در صورت موفقیت] دریافت شناسه ارجاع. |
+| `alreadyVerified()` | پرداخت قبلاً یه بار بررسی و تایید شده بود. شناسه ارجاع همچنان در دسترسه. |
+| `failed()` | پرداخت شکست خورده؛ پیامهای مناسب و Exception در دسترس هستن. |
+| `messages()` | [در صورت شکست] دریافت آرایهای از پیامهای خطا |
+| `message()` | [در صورت شکست] دریافت اولین پیام خطا. |
+| `throw()` | [در صورت شکست] پرت کردن Exception متناسب با خطا. |
+
+
+
+## بیشتر
+
+### تایید پرداخت به صورت دستی
+اگه نیاز داشتین بدون استفاده از `CallbackRequest` تایید یه پرداخت رو بررسی کنین، میتونین از `Toman` استفاده کنین:
+
+```php
+use Evryn\LaravelToman\Facades\Toman;
+
+// ...
+
+$payment = Toman::transactionId('tid_123')
+ ->orderId('order_1000')
+ ->verify();
+
+if ($payment->successful()) {
+ // Store the successful transaction details
+ $referenceId = $payment->referenceId();
+}
+
+if ($payment->alreadyVerified()) {
+ // ...
+}
+
+if ($payment->failed()) {
+ // ...
+}
+```
+
+### تست کردن درگاه IDPay
+اگه که برای نرمافزارتون تست سوئیت خودکار مینویسین و میخواین ببینین که با پکیج به درستی تعامل داره یا نه، ادامه بدین.
+
+#### 🧪 تست درخواست پرداخت
+
+از `Toman::fakeRequest()` استفاده کنین تا یه نتیجه درخواست ایجاد پرداخت رو شبیهسازی کنین و بعد محتوای درخواست رو با `Toman::assertRequested()` مورد بررسی قرار بدین.
+
+```php
+use Evryn\LaravelToman\Facades\Toman;
+use Evryn\LaravelToman\Money;
+
+final class PaymentTest extends TestCase
+{
+ /** @test */
+ public function requests_new_payment_with_proper_data()
+ {
+ // Stub a successful or failed payment request result
+ Toman::fakeRequest()->successful()->withTransactionId('tid_123');
+
+ // Toman::fakeRequest()->failed();
+
+ // Act with your app ...
+
+ // Assert that you've correctly requested payment
+ Toman::assertRequested(function ($request) {
+ return $request->merchantId() === 'your-idpay-api-key'
+ && $request->callback() === route('callback-route')
+ && $request->amount()->is(Money::Toman(50000));
+ });
+ }
+}
+```
+
+#### 🧪 تست بررسی و تایید پرداخت
+
+از `Toman::fakeVerification()` استفاده کنین تا یه نتیجه درخواست بررسی و تایید رو شبیهسازی کنین و بعد محتوای درخواست رو با `Toman::assertCheckedForVerification()` مورد بررسی قرار بدین.
+
+```php
+use Evryn\LaravelToman\Facades\Toman;
+use Evryn\LaravelToman\Money;
+
+final class PaymentTest extends TestCase
+{
+ /** @test */
+ public function verifies_payment_with_proper_data()
+ {
+ // Stub a successful, already verified or failed payment verification result
+ Toman::fakeVerification()
+ ->successful()
+ ->withOrderId('order_100')
+ ->withTransactionId('tid_123')
+ ->withReferenceId('ref_123');
+
+ // Toman::fakeVerification()
+ // ->alreadyVerified()
+ // ->withOrderId('order_100')
+ // ->withTransactionId('tid_123')
+ // ->withReferenceId('ref_123');
+
+ // Toman::fakeVerification()
+ // ->failed()
+ // ->withOrderId('order_100')
+ // ->withTransactionId('tid_123');
+
+ // Act with your app ...
+
+ // Assert that you've correctly verified payment
+ Toman::assertCheckedForVerification(function ($request) {
+ return $request->merchantId() === 'your-idpay-api-id'
+ && $request->orderId() === 'order_100'
+ && $request->transactionId() === 'tid_123'
+ && $request->amount()->is(Money::Toman(50000));
+ });
+ }
+}
+```
diff --git a/docs/fa/gateways/zarinpal.md b/docs/fa/gateways/zarinpal.md
new file mode 100644
index 0000000..c379d81
--- /dev/null
+++ b/docs/fa/gateways/zarinpal.md
@@ -0,0 +1,260 @@
+# استفاده از درگاه زرینپال
+
+تومن درگاه [Zarinpal.com](https://www.zarinpal.com) رو بر اساس نسخه 1.3 [داکیومنت رسمیشون](https://github.com/ZarinPal-Lab/Documentation-PaymentGateway/) ساخته.
+
+## شروع به کار
+### تنظیمات
+
+درگاه زرینپال نیاز به تغییر این مقادیر تو فایل `.env` داره:
+
+| متغیر محیطی | توضیحات |
+|---------------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `TOMAN_GATEWAY` | (**اجباری**) باید `zarinpal` باشه. |
+| `ZARINPAL_MERCHANT_ID` | (**اجباری**) کد درگاه پرداخت که میتونین از پنل ارائهدهنده بگیرین. نمونه: `0bcf346fc-3a79-4b36-b936-5ccbc2be0696` |
+| `ZARINPAL_SANDBOX` | (اختیاری. مقدار پیشفرض: `false`) اگه تنظیم شه به `true`، همه درخواستها تو محیط تست این درگاه بدون پرداخت واقعی انجام میشه. این شرایط تو محیط توسعه لوکال به درد میخوره.
+
+نمونه:
+```dotenv
+...
+
+TOMAN_GATEWAY=zarinpal
+ZARINPAL_MERCHANT_ID=0bcf346fc-3a79-4b36-b936-5ccbc2be0696
+```
+
+#### واحد پولی
+
+واحد پولی رو میتونین به دو صورت معین کنین:
+
+**استفاده از فایل تنظیمات (کانفیگ):**
+
+| متد | تنظیم | یعنی |
+|------------------|----------------------------|--------------|
+| `amount(10000)` | `toman.currency = 'toman'` | 10,000 تومان |
+| `amount(10000)` | `toman.currency = 'rial'` | 1,000 تومان |
+
+**صریحاً مشخص کردن:**
+```php
+use Evryn\LaravelToman\Money;
+
+...->amount(Money::Rial(10000));
+...->amount(Money::Toman(1000));
+```
+
+## ⚡ درخواست پرداخت جدید
+
+```php
+use Evryn\LaravelToman\Facades\Toman;
+
+// ...
+
+$request = Toman::amount(1000)
+ // ->description('Subscribing to Plan A')
+ // ->callback(route('payment.callback'))
+ // ->mobile('09350000000')
+ // ->email('amirreza@example.com')
+ ->request();
+
+if ($request->successful()) {
+ $transactionId = $request->transactionId();
+ // Store created transaction details for verification
+
+ return $request->pay(); // Redirect to payment URL
+}
+
+if ($request->failed()) {
+ // Handle transaction request failure; Probably showing proper error to user.
+}
+```
+
+متدهای قابل استفاده برای ایجاد درخواست پرداخت جدید با کلاس نمایهای `Toman`:
+
+| متد | توضیحات |
+|------------- |--------------------------------------------------------------------------------------------------------------------------------- |
+| `amount($amount)` | **(الزامی)** تنظیم مبلغ قابل پرداخت. |
+| `callback($url)` | تنظیم یک آدرس URL کامل به عنوان Callback URL. بر کانفیگ `callback_route` اولویت داره. |
+| `description($string)` | تنظیم توضیحات پرداخت. بر کانفیگ `description` اولویت داره. |
+| `mobile($mobile)` | تنظیم شماره موبایل پرداختکننده. |
+| `email($email)` | تنظیم ایمیل پرداختکننده. |
+| `request()` | ارسال درخواست پرداخت جدید و بازگردوندن یک آبجکت از نوع `RequestedPayment`. |
+
+
+استفاده از `RequestedPayment` برگردونده شده:
+
+|
متد
| توضیحات |
+|-------------------- |--------------------------------------------------------------------------------------------------------------------------------- |
+| `successful()` | درخواست پرداخت موفق بوده؛ شناسه تراکنش در دسترسه و میشه کاربر رو به صفحه پرداخت هدایت کرد. |
+| `transactionId()` | [در صورت موفقیت] دریافت شناسه تراکنش. |
+| `pay($options = [])` | [در صورت موفقیت] ریدایرکت کردن کاربر به صفحه پرداخت از کنترلر. یه آبجکت `RedirectResponse` برمیگردونه. یه آپشن اختیاری هم میشه برای ارسال کرد که مشخص کننده درگاه بانکی خاص برای پرداخت هست: `['gateway' => 'Sep']`. برای استفاده، باید با زرینپال صحبت کنین. |
+| `paymentUrl($options = [])` | [در صورت موفقیت] دریافت آدرس پراخت نهایی. آپشن اختیاریش هم مثل مورد بالا هست. |
+| `failed()` | درخواست پرداخت شکست خورد؛ پیامهای مناسب و Exception در دسترس هستن. |
+| `messages()` | [در صورت شکست] دریافت آرایهای از پیامهای خطا |
+| `message()` | [در صورت شکست] دریافت اولین پیام خطا. |
+| `throw()` | [در صورت شکست] پرت کردن Exception متناسب با خطا. |
+
+
+
+## ⚡ تایید پرداخت
+
+مکانیزم تایید پرداخت باید در مسیر مربوط به Callback ارسال شده پیاده شود. این کنترلر رو در نظر بگیرین:
+
+```php
+transactionId() to match the payment record stored
+ // in your persistence database and get expected amount, which is required
+ // for verification.
+
+ $payment = $request->amount(1000)->verify();
+
+ if ($payment->successful()) {
+ // Store the successful transaction details
+ $referenceId = $payment->referenceId();
+ }
+
+ if ($payment->alreadyVerified()) {
+ // ...
+ }
+
+ if ($payment->failed()) {
+ // ...
+ }
+ }
+}
+```
+
+متدهای قابل استفاده برای تایید پرداخت با `CallbackRequest` یا کلاس نمایهای `Toman`:
+
+| متد | توضیحات |
+|------------- |--------------------------------------------------------------------------------------------------------------------------------- |
+| `amount($amount)` | **(اجباری)** تنظیم مبلغی که کاربر باید پرداخت کرده باشد. |
+| `transactionId($id)` | تنظیم شناسه تراکنش برای بررسی تایید پرداخت. `CallbackRequest` اینو خودش پر میکنه.|
+| `verify()` |ارسال درخواست بررسی و تایید پرداخت. یه آبجکت `CheckedPayment` برمیگردونه. |
+
+
+استفاده از `CheckedPayment` برگردونده شده:
+
+| متد | توضیحات |
+|-------------------- |--------------------------------------------------------------------------------------------------------------------------------- |
+| `transactionId()` | دریافت شناسه تراکنشی که تو درخواست ارسال شده بود. |
+| `successful()` | پرداخت موفق بوده و شناسه ارجاع در دسترسه. |
+| `transactionId()` | [در صورت موفقیت] دریافت شناسه ارجاع. |
+| `alreadyVerified()` | پرداخت قبلاً یه بار بررسی و تایید شده بود. شناسه ارجاع همچنان در دسترسه. |
+| `failed()` | پرداخت شکست خورده؛ پیامهای مناسب و Exception در دسترس هستن. |
+| `messages()` | [در صورت شکست] دریافت آرایهای از پیامهای خطا |
+| `message()` | [در صورت شکست] دریافت اولین پیام خطا. |
+| `throw()` | [در صورت شکست] پرت کردن Exception متناسب با خطا. |
+
+
+
+## بیشتر
+
+### تایید پرداخت به صورت دستی
+اگه نیاز داشتین بدون استفاده از `CallbackRequest` تایید یه پرداخت رو بررسی کنین، میتونین از `Toman` استفاده کنین:
+
+```php
+use Evryn\LaravelToman\Facades\Toman;
+
+// ...
+
+$payment = Toman::transactionId('A00001234')
+ ->amount(1000)
+ ->verify();
+
+if ($payment->successful()) {
+ // Store the successful transaction details
+ $referenceId = $payment->referenceId();
+}
+
+if ($payment->alreadyVerified()) {
+ // ...
+}
+
+if ($payment->failed()) {
+ // ...
+}
+```
+
+### تست کردن درگاه IDPay
+اگه که برای نرمافزارتون تست سوئیت خودکار مینویسین و میخواین ببینین که با پکیج به درستی تعامل داره یا نه، ادامه بدین.
+
+#### 🧪 تست درخواست پرداخت
+
+از `Toman::fakeRequest()` استفاده کنین تا یه نتیجه درخواست ایجاد پرداخت رو شبیهسازی کنین و بعد محتوای درخواست رو با `Toman::assertRequested()` مورد بررسی قرار بدین.
+
+```php
+use Evryn\LaravelToman\Facades\Toman;
+use Evryn\LaravelToman\Money;
+
+final class PaymentTest extends TestCase
+{
+ /** @test */
+ public function requests_new_payment_with_proper_data()
+ {
+ // Stub a successful or failed payment request result
+ Toman::fakeRequest()->successful()->withTransactionId('A123');
+
+ // Toman::fakeRequest()->failed();
+
+ // Act with your app ...
+
+ // Assert that you've correctly requested payment
+ Toman::assertRequested(function ($request) {
+ return $request->merchantId() === 'your-merchant-id'
+ && $request->callback() === route('callback-route')
+ && $request->amount()->is(Money::Toman(50000));
+ });
+ }
+}
+```
+
+#### 🧪 تست بررسی و تایید پرداخت
+
+از `Toman::fakeVerification()` استفاده کنین تا یه نتیجه درخواست بررسی و تایید رو شبیهسازی کنین و بعد محتوای درخواست رو با `Toman::assertCheckedForVerification()` مورد بررسی قرار بدین.
+
+```php
+use Evryn\LaravelToman\Facades\Toman;
+use Evryn\LaravelToman\Money;
+
+final class PaymentTest extends TestCase
+{
+ /** @test */
+ public function verifies_payment_with_proper_data()
+ {
+ // Stub a successful, already verified or failed payment verification result
+ Toman::fakeVerification()
+ ->successful()
+ ->withTransactionId('A123')
+ ->withReferenceId('R123');
+
+ // Toman::fakeVerification()
+ // ->alreadyVerified()
+ // ->withTransactionId('A123')
+ // ->withReferenceId('R123');
+
+ // Toman::fakeVerification()
+ // ->failed()
+ // ->withTransactionId('A123');
+
+ // Act with your app ...
+
+ // Assert that you've correctly verified payment
+ Toman::assertCheckedForVerification(function ($request) {
+ return $request->merchantId() === 'your-merchant-id'
+ && $request->transactionId() === 'A123'
+ && $request->amount()->is(Money::Toman(50000));
+ });
+ }
+}
+```
diff --git a/docs/fa/getting-started.md b/docs/fa/getting-started.md
new file mode 100644
index 0000000..d288eea
--- /dev/null
+++ b/docs/fa/getting-started.md
@@ -0,0 +1,43 @@
+> اگه نیاز شد، توی [evryn/laravel-toman-example](https://github.com/evryn/laravel-toman-example) میتونین یه نمونه پروژه کامل با این پکیج رو ببینین.
+
+## پیشنیازها
+
+| پکیج | فریمورک Laravel | PHP | وضعیت |
+| ------------- |:-------------:|:-----:| ---:|
+| 2.x | 8.x, 7.x | >= 7.3 | فعال 🚀 |
+| 1.x | 6.x, 5.8.x | >= 7.2 | |
+
+## نصب
+
+پکیج رو با Composer نصب کنین:
+```bash
+composer require evryn/laravel-toman
+```
+
+## تنظیمات
+یه سری تنظیمات در نظر گرفتیم که باعث میشه کدهای کمتری استفاده کنین.
+
+با دستور زیر، فایل کانفیگ پکیج رو منتشر کنین:
+```bash
+php artisan vendor:publish --provider=Evryn\LaravelToman\LaravelTomanServiceProvider --tag=config
+```
+
+حالا میتونین تو فایل `config/toman.php` این تنظیمات رو انجام بدین.
+
+## شخصیسازی متنها (اختیاری)
+درگاهها ممکنه پاسخ رو در وضعیتهای مختلفی برگردونن که هر کدوم معنی خاصی داره. تومن این متنها رو هم نوشته تا کارتون راحتتر باشه.
+
+با دستور زیر، فایل مربوط به متنها رو منتشر کنین:
+```bash
+php artisan vendor:publish --provider=Evryn\LaravelToman\LaravelTomanServiceProvider --tag=lang
+```
+
+فایلها تو مسیر `/resource/lang/vendor/toman` قابل ویرایش هستن.
+
+
+## قدم بعدی
+یکی از درگاهها رو راه بندازین:
+ * [💳 زرینپال](fa/gateways/zarinpal.md)
+ * [💳 آیدی پِی](fa/gateways/idpay.md)
+
+
diff --git a/docs/fa/support.md b/docs/fa/support.md
new file mode 100644
index 0000000..a909893
--- /dev/null
+++ b/docs/fa/support.md
@@ -0,0 +1,40 @@
+# حمایت از ما
+
+این پکیج رو دوست دارین؟ ❤ـتون رو لطفاً بهمون نشون بدین:
+
+## کمک مالی
+
+یه حالی بهمون بدین :) واحد پولیتون رو انتخاب کنین:
+ * [€, £](https://dashboard.yekpay.com/en/user/AmirrezaNasiri)
+ * [تومان](https://zarinp.al/@amirrezan)
+
+
+## ارسال کارت پستال
+
+کارت پستال مربوط به خودتون یا شرکتتون رو بهمون ارسال کنین تا بسی کیف کنیم :) بعداً نشونشون هم خواهیم داد. بهم یه پیام بفرستین تا زودی پاسخ بدم: `nasiri.amirreza.96@gmail.com` یا [@Amirreza_Nasiri](https://twitter.com/amirreza_nasiri).
+
+
+## حمایت تو گیتهاب
+
+با فالو کردن ما، ستاره دادن به این پروژه و چنگال زدن بهش، کمک کنین تا پکیج بیشتر دیده بشه. بیشتر از 11 ثانیه طول نمیکشه. کافیه برین به صفحه [evryn/laravel-toman](https://github.com/evryn/laravel-toman) و دکمههای زیر رو توش پیدا کنین:
+
+
+
+## مشارکت
+
+آشنا به لاراول و توسعه پکیج هستین؟ عالی میشه اگه بتونین تو توسعه تومن بهمون کمک کنین. واسه این کار، [Contribution Guide](../CONTRIBUTING.md) رو بخونین.
+
+## بهاشتراک بذارین
+
+اگه کسی رو میشناسین که این پکیج کارهاش رو یکم راحتتر میکنه، لطفاً لینک این داکیومنت رو باهاش بهاشتراک بذارین یا روی لینکهای زیر کلیک کنین:
+
+* [بهاشتراکگذاری در توئیتر](https://twitter.com/share?url=https://github.com/evryn/laravel-toman)
+* [بهاشتراکگذاری در تلگرام](https://t.me/share/url?url=https://github.com/evryn/laravel-toman)
+
+## هیچ کدومش قابل انجام نیست؟
+
+ اصلاً اشکال نـــــــــداره! کافیه **امروز** لبخند رو لبهای یکی بیارین 😊
diff --git a/docs/gateways/idpay.md b/docs/gateways/idpay.md
new file mode 100644
index 0000000..247250c
--- /dev/null
+++ b/docs/gateways/idpay.md
@@ -0,0 +1,267 @@
+# Using IDPay Gateway
+
+Implementation of [IDPay.ir](https://idpay.ir) gateway is based on version 1.1 of their [official document](https://idpay.ir/web-service/v1.1/).
+
+## Getting Started
+### Setup
+
+IDPay gateway requires the following variables in `.env` file to work:
+
+| Environment Variable | Description |
+|---------------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `TOMAN_GATEWAY` | (**Required**) Must equal `idpay` in order to use this gateway provider. |
+| `IDPAY_API_KEY` | (**Required**) Your gateway's API Key which can be gotten from your panel. Example: `0bcf346fc-3a79-4b36-b936-5ccbc2be0696` |
+| `IDPAY_SANDBOX` | (Optional. Default: `false`) Set it to `true` in your development environment to make test calls in a simulated environment provided by the gateway without real payments.
+
+Example:
+```dotenv
+...
+
+TOMAN_GATEWAY=idpay
+IDPAY_API_KEY=0bcf346fc-3a79-4b36-b936-5ccbc2be0696
+```
+
+### Currency
+
+You can specify your intended currency in a few ways:
+
+**Using config:**
+
+| Method | Config | Means |
+|------------------|----------------------------|--------------|
+| `amount(10000)` | `toman.currency = 'toman'` | 10,000 Toman |
+| `amount(10000)` | `toman.currency = 'rial'` | 1,000 Toman |
+
+**Specifying explicitly:**
+```php
+use Evryn\LaravelToman\Money;
+
+...->amount(Money::Rial(10000));
+...->amount(Money::Toman(1000));
+```
+
+## ⚡ Request New Payment
+
+```php
+use Evryn\LaravelToman\Facades\Toman;
+
+// ...
+
+$request = Toman::orderId('order_1500')
+ ->amount(15000)
+ // ->description('Subscribing to Plan A')
+ // ->callback(route('payment.callback'))
+ // ->mobile('09350000000')
+ // ->email('amirreza@example.com')
+ // ->name('Amirreza Nasiri')
+ ->request();
+
+if ($request->successful()) {
+ $transactionId = $request->transactionId();
+ // Store created transaction details for verification
+
+ return $request->pay(); // Redirect to payment URL
+}
+
+if ($request->failed()) {
+ // Handle transaction request failure; Probably showing proper error to user.
+}
+```
+
+For requesting payment using `Toman` facade:
+
+| Method | Description |
+|------------- |--------------------------------------------------------------------------------------------------------------------------------- |
+| `amount($amount)` | **(Required)** Set amount for payment. |
+| `orderId($orderId)` | **(Required)** Set order ID for payment. Order ID is a unique your-side generated string that will be used for verification. |
+| `callback($url)` | Set an absolute callback URL. Overrides `callback_route` config. |
+| `description($string)` | Set description. Overrides `description` config. |
+| `mobile($mobile)` | Set mobile. |
+| `email($email)` | Set email. |
+| `name($name)` | Set payer name. |
+| `request()` | Request payment and return `RequestedPayment` object |
+
+
+Using returned `RequestedPayment`:
+
+|
Method
| Description |
+|-------------------- |--------------------------------------------------------------------------------------------------------------------------------- |
+| `successful()` | Payment request was successful, its transaction ID is available and can be redirected for payment. |
+| `transactionId()` | [On Success] Get transaction ID. |
+| `pay()` | [On Success] Redirect to payment URL from your controller. Returns a `RedirectResponse` object. |
+| `paymentUrl()` | [On Success] Get payment URL. |
+| `failed()` | Payment request was failed and proper messages and exception are available. |
+| `messages()` | [On Failure] Get list of error messages. |
+| `message()` | [On Failure] Get first error message. |
+| `throw()` | [On Failure] Throw exception related to the failure. |
+
+
+
+## ⚡ Verify Payment
+
+Verification must be implemented in the callback route. Consider the following controller method:
+
+```php
+transactionId() and $request->orderId() to match the
+ // non-paid payment. Take care of Double Spending.
+
+ $payment = $request->verify();
+
+ if ($payment->successful()) {
+ // Store the successful transaction details
+ $referenceId = $payment->referenceId();
+ }
+
+ if ($payment->alreadyVerified()) {
+ // ...
+ }
+
+ if ($payment->failed()) {
+ // ...
+ }
+ }
+}
+```
+
+For requesting payment using `CallbackRequest` or `Toman` facade:
+
+| Method | Description |
+|------------- |--------------------------------------------------------------------------------------------------------------------------------- |
+| `orderId($orderId)` | Set the order ID you've generated when requesting the payment. `CallbackRequest` sets it automatically. |
+| `transactionId($id)` | Set transaction ID to verify. `CallbackRequest` sets it automatically. |
+| `verify()` | Verify payment and return `CheckedPayment` object |
+
+
+Using returned `CheckedPayment`:
+
+| Method | Description |
+|-------------------- |--------------------------------------------------------------------------------------------------------------------------------- |
+| `orderId()` | Get order ID. |
+| `transactionId()` | Get transaction ID. |
+| `successful()` | Payment is newly verified and its reference ID is available. |
+| `transactionId()` | [On Success] Get reference ID. |
+| `alreadyVerified()` | Payment was once verified before. Reference ID is available too. |
+| `failed()` | Payment was failed and proper messages and exception are available. |
+| `messages()` | [On Failure] Get list of error messages. |
+| `message()` | [On Failure] Get first error message. |
+| `throw()` | [On Failure] Throw exception related to the failure. |
+
+
+
+## More
+
+### Manual Payment Verification
+If you want to verify a payment manually (instead of using intended `CallbackRequest`), you just need to use `Toman` facade:
+```php
+use Evryn\LaravelToman\Facades\Toman;
+
+// ...
+
+$payment = Toman::transactionId('tid_123')
+ ->orderId('order_1000')
+ ->verify();
+
+if ($payment->successful()) {
+ // Store the successful transaction details
+ $referenceId = $payment->referenceId();
+}
+
+if ($payment->alreadyVerified()) {
+ // ...
+}
+
+if ($payment->failed()) {
+ // ...
+}
+```
+
+### Testing IDPay Gateway
+If you're making automated tests for your application and want to see if you're interacting with Laravel Toman properly, go on.
+
+#### 🧪 Test Payment Request
+
+Use `Toman::fakeRequest()` to stub request result and assert expected request data with `Toman::assertRequested()` method by a truth test.
+
+```php
+use Evryn\LaravelToman\Facades\Toman;
+use Evryn\LaravelToman\Money;
+
+final class PaymentTest extends TestCase
+{
+ /** @test */
+ public function requests_new_payment_with_proper_data()
+ {
+ // Stub a successful or failed payment request result
+ Toman::fakeRequest()->successful()->withTransactionId('tid_123');
+
+ // Toman::fakeRequest()->failed();
+
+ // Act with your app ...
+
+ // Assert that you've correctly requested payment
+ Toman::assertRequested(function ($request) {
+ return $request->merchantId() === 'your-idpay-api-key'
+ && $request->callback() === route('callback-route')
+ && $request->amount()->is(Money::Toman(50000));
+ });
+ }
+}
+```
+
+#### 🧪 Test Payment Verification
+
+Use `Toman::fakeVerification()` to stub verification result and assert its expected data with `Toman::assertCheckedForVerification()` method by a truth test.
+
+```php
+use Evryn\LaravelToman\Facades\Toman;
+use Evryn\LaravelToman\Money;
+
+final class PaymentTest extends TestCase
+{
+ /** @test */
+ public function verifies_payment_with_proper_data()
+ {
+ // Stub a successful, already verified or failed payment verification result
+ Toman::fakeVerification()
+ ->successful()
+ ->withOrderId('order_100')
+ ->withTransactionId('tid_123')
+ ->withReferenceId('ref_123');
+
+ // Toman::fakeVerification()
+ // ->alreadyVerified()
+ // ->withOrderId('order_100')
+ // ->withTransactionId('tid_123')
+ // ->withReferenceId('ref_123');
+
+ // Toman::fakeVerification()
+ // ->failed()
+ // ->withOrderId('order_100')
+ // ->withTransactionId('tid_123');
+
+ // Act with your app ...
+
+ // Assert that you've correctly verified payment
+ Toman::assertCheckedForVerification(function ($request) {
+ return $request->merchantId() === 'your-idpay-api-id'
+ && $request->orderId() === 'order_100'
+ && $request->transactionId() === 'tid_123'
+ && $request->amount()->is(Money::Toman(50000));
+ });
+ }
+}
+```
diff --git a/docs/gateways/zarinpal.md b/docs/gateways/zarinpal.md
index 3091097..3fbeee7 100644
--- a/docs/gateways/zarinpal.md
+++ b/docs/gateways/zarinpal.md
@@ -1,16 +1,17 @@
-# Zarinpal Gateway
+# Using Zarinpal Gateway
-[Zarinpal.com](https://www.zarinpal.com) gateway was added in version 1.0 and implementation of it is based on version 1.3 of their [official document](https://github.com/ZarinPal-Lab/Documentation-PaymentGateway/).
+Implementation of [Zarinpal.com](https://www.zarinpal.com) gateway is based on version 1.3 of their [official document](https://github.com/ZarinPal-Lab/Documentation-PaymentGateway/).
-## Config
+## Getting Started
+### Setup
-Zarinpal gateway requires following variables in `.env` file to work:
+Zarinpal gateway requires the following variables in `.env` file to work:
| Environment Variable | Description |
|---------------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| TOMAN_GATEWAY | (**Required**) Must equal `zarinpal` in order to use this gateway provider. |
-| ZARINPAL_MERCHANT_ID | (**Required**) Your gateway's merchant ID which can be gotten from your Zarinpal panel. Example: 0bcf346fc-3a79-4b36-b936-5ccbc2be0696 |
-| ZARINPAL_SANDBOX | (Optional. Default: false) Set it to `true` to make test calls in a simulated environment provided by Zarinpal without actual payments. Delete the key or set it to `false` to make calls in production environment and receive actual payments. |
+| `TOMAN_GATEWAY` | (**Required**) Must equal `zarinpal` in order to use this gateway provider. |
+| `ZARINPAL_MERCHANT_ID` | (**Required**) Your gateway's merchant ID which can be gotten from your panel. Example: `0bcf346fc-3a79-4b36-b936-5ccbc2be0696` |
+| `ZARINPAL_SANDBOX` | (Optional. Default: `false`) Set it to `true` in your development environment to make test calls in a simulated environment provided by the gateway without real payments.
Example:
```dotenv
@@ -20,76 +21,239 @@ TOMAN_GATEWAY=zarinpal
ZARINPAL_MERCHANT_ID=0bcf346fc-3a79-4b36-b936-5ccbc2be0696
```
-## Payment Request
+### Currency
+
+You can specify your intended currency in a few ways:
+
+**Using config:**
+
+| Method | Config | Means |
+|------------------|----------------------------|--------------|
+| `amount(10000)` | `toman.currency = 'toman'` | 10,000 Toman |
+| `amount(10000)` | `toman.currency = 'rial'` | 1,000 Toman |
+
+**Specifying explicitly:**
+```php
+use Evryn\LaravelToman\Money;
+
+...->amount(Money::Rial(10000));
+...->amount(Money::Toman(1000));
+```
+
+## ⚡ Request New Payment
-In short, you can request a new payment with the following methods and catches:
```php
-use Evryn\LaravelToman\Facades\PaymentRequest;
-use Evryn\LaravelToman\Gateways\Zarinpal\Status;
+use Evryn\LaravelToman\Facades\Toman;
// ...
-try {
- $requestedPayment = PaymentRequest::amount(1000)
- ->description('Subscrbing to Plan A')
- ->callback('https://example.com/callback')
- ->mobile('09350000000')
- ->email('amirreza@example.com')
- ->request();
-} catch (GatewayException $gatewayException) {
- if ($gatewayException->getCode() === Status::SHAPARAK_LIMITED) {
- // there might be a problem with 'Amount' data.
- }
-} catch (InvalidConfigException $exception) {
- // Woops! wrong merchant_id or sandbox option is configurated.
+$request = Toman::amount(1000)
+ // ->description('Subscribing to Plan A')
+ // ->callback(route('payment.callback'))
+ // ->mobile('09350000000')
+ // ->email('amirreza@example.com')
+ ->request();
+
+if ($request->successful()) {
+ $transactionId = $request->transactionId();
+ // Store created transaction details for verification
+
+ return $request->pay(); // Redirect to payment URL
}
-// Use $requestedPayment...
+if ($request->failed()) {
+ // Handle transaction request failure; Probably showing proper error to user.
+}
```
+For requesting payment using `Toman` facade:
+
| Method | Description |
|------------- |--------------------------------------------------------------------------------------------------------------------------------- |
-| callback | Sets `CallbackURL` data and overrides `callback_route` config. |
-| description | Sets `Description` data and overrides `description` config. |
-| mobile | Sets `Mobile` data. |
-| email | Sets `Email` data. |
-| amount | Sets `Amount` data. |
-| request | Calls `PaymentRequest` Zarinpal endpoint and returns a `RequestedPayment` object with available transaction ID and payment URL. Might throw `GatewayException` if the request was rejected by Zarinpal. `GatewayException` is filled with user-friendly message that can be translated (see [Translations](#translations) section) and status code constants in `Evryn\LaravelToman\Gateways\Zarinpal\Status`. Might throw an `InvalidConfigException` if gateway-specific configs are not set correctly (see [Config](#config) section above). |
+| `amount($amount)` | **(Required)** Set amount for payment. |
+| `callback($url)` | Set an absolute callback URL. Overrides `callback_route` config. |
+| `description($string)` | Set description. Overrides `description` config. |
+| `mobile($mobile)` | Set mobile. |
+| `email($email)` | Set email. |
+| `request()` | Request payment and return `RequestedPayment` object |
+
+
+Using returned `RequestedPayment`:
+
+|
Method
| Description |
+|-------------------- |--------------------------------------------------------------------------------------------------------------------------------- |
+| `successful()` | Payment request was successful, its transaction ID is available and can be redirected for payment. |
+| `transactionId()` | [On Success] Get transaction ID. |
+| `pay($options = [])` | [On Success] Redirect to payment URL from your controller. Returns a `RedirectResponse` object. An option can be optionally passed in to explicitly select final gateway: `['gateway' => 'Sep']` . You can contact ZarinPal to make them available. |
+| `paymentUrl($options = [])` | [On Success] Get payment URL. `$options` is optional and same as above. |
+| `failed()` | Payment request was failed and proper messages and exception are available. |
+| `messages()` | [On Failure] Get list of error messages. |
+| `message()` | [On Failure] Get first error message. |
+| `throw()` | [On Failure] Throw exception related to the failure. |
+
-## Payment Verification
+## ⚡ Verify Payment
+
+Verification must be implemented in the callback route. Consider the following controller method:
-In short, you can verify a payment callback with the following methods and catches:
```php
-use Evryn\LaravelToman\Facades\PaymentVerification;
-use Evryn\LaravelToman\Gateways\Zarinpal\Status;
+verify(request()); // or $request in your Controller
-} catch (GatewayException $gatewayException) {
- if ($gatewayException->getCode() === Status::NOT_PAID) {
- // the payment has been cancelled
- } elseif ($gatewayException->getCode() === Status::ALREADY_VERIFIED) {
- // the payment has already been verified before
+class PaymentController extends Controller
+{
+ /**
+ * Handle payment callback
+ */
+ public function callback(CallbackRequest $request)
+ {
+ // Use $request->transactionId() to match the payment record stored
+ // in your persistence database and get expected amount, which is required
+ // for verification.
+
+ $payment = $request->amount(1000)->verify();
+
+ if ($payment->successful()) {
+ // Store the successful transaction details
+ $referenceId = $payment->referenceId();
+ }
+
+ if ($payment->alreadyVerified()) {
+ // ...
+ }
+
+ if ($payment->failed()) {
+ // ...
+ }
}
-} catch (InvalidConfigException $exception) {
- // Woops! wrong merchant_id or sandbox option is configurated.
}
-
-// Use $verifiedPayment...
```
+For requesting payment using `CallbackRequest` or `Toman` facade:
+
| Method | Description |
|------------- |--------------------------------------------------------------------------------------------------------------------------------- |
-| amount | Sets `Amount` data. It should equal to the amount that payment request was created with. |
-| verify | Calls `PaymentVerification` Zarinpal endpoint with callback queries gotten from request and returns a `VerifiedPayment` object with available reference ID. Might throw a `GatewayException` if the request was rejected by Zarinpal. `GatewayException` is filled with user-friendly message that can be translated (see [Translations](#translations) section) and status code constants in `Evryn\LaravelToman\Gateways\Zarinpal\Status`. Might throw an `InvalidConfigException` if gateway-specific configs are not set correctly (see [Config](#config) section above) |
-
+| `amount($amount)` | **(Required)** Set amount that is expected to be paid. |
+| `transactionId($id)` | Set transaction ID to verify. `CallbackRequest` sets it automatically. |
+| `verify()` | Verify payment and return `CheckedPayment` object |
+
+
+Using returned `CheckedPayment`:
+
+| Method | Description |
+|-------------------- |--------------------------------------------------------------------------------------------------------------------------------- |
+| `transactionId()` | Get transaction ID. |
+| `successful()` | Payment is newly verified and its reference ID is available. |
+| `transactionId()` | [On Success] Get reference ID. |
+| `alreadyVerified()` | Payment was once verified before. Reference ID is available too. |
+| `failed()` | Payment was failed and proper messages and exception are available. |
+| `messages()` | [On Failure] Get list of error messages. |
+| `message()` | [On Failure] Get first error message. |
+| `throw()` | [On Failure] Throw exception related to the failure. |
-## Translations
+
-Currently, two `fa` (Persian) and `en` (English) languages are added to display payment status (in `GatewayException` especially).
+## More
+
+### Manual Payment Verification
+If you want to verify a payment manually (instead of using intended `CallbackRequest`), you just need to use `Toman` facade:
+```php
+use Evryn\LaravelToman\Facades\Toman;
+
+// ...
-See [Getting Started/Translations](../translations.md) to find out how to set application locale or customize these messages.
+$payment = Toman::transactionId('A00001234')
+ ->amount(1000)
+ ->verify();
+
+if ($payment->successful()) {
+ // Store the successful transaction details
+ $referenceId = $payment->referenceId();
+}
+
+if ($payment->alreadyVerified()) {
+ // ...
+}
+
+if ($payment->failed()) {
+ // ...
+}
+```
+
+### Testing Zarinpal Gateway
+If you're making automated tests for your application and want to see if you're interacting with Laravel Toman properly, go on.
+
+#### 🧪 Test Payment Request
+
+Use `Toman::fakeRequest()` to stub request result and assert expected request data with `Toman::assertRequested()` method by a truth test.
+
+```php
+use Evryn\LaravelToman\Facades\Toman;
+use Evryn\LaravelToman\Money;
+
+final class PaymentTest extends TestCase
+{
+ /** @test */
+ public function requests_new_payment_with_proper_data()
+ {
+ // Stub a successful or failed payment request result
+ Toman::fakeRequest()->successful()->withTransactionId('A123');
+
+ // Toman::fakeRequest()->failed();
+
+ // Act with your app ...
+
+ // Assert that you've correctly requested payment
+ Toman::assertRequested(function ($request) {
+ return $request->merchantId() === 'your-merchant-id'
+ && $request->callback() === route('callback-route')
+ && $request->amount()->is(Money::Toman(50000));
+ });
+ }
+}
+```
+
+#### 🧪 Test Payment Verification
+
+Use `Toman::fakeVerification()` to stub verification result and assert its expected data with `Toman::assertCheckedForVerification()` method by a truth test.
+
+```php
+use Evryn\LaravelToman\Facades\Toman;
+use Evryn\LaravelToman\Money;
+
+final class PaymentTest extends TestCase
+{
+ /** @test */
+ public function verifies_payment_with_proper_data()
+ {
+ // Stub a successful, already verified or failed payment verification result
+ Toman::fakeVerification()
+ ->successful()
+ ->withTransactionId('A123')
+ ->withReferenceId('R123');
+
+ // Toman::fakeVerification()
+ // ->alreadyVerified()
+ // ->withTransactionId('A123')
+ // ->withReferenceId('R123');
+
+ // Toman::fakeVerification()
+ // ->failed()
+ // ->withTransactionId('A123');
+
+ // Act with your app ...
+
+ // Assert that you've correctly verified payment
+ Toman::assertCheckedForVerification(function ($request) {
+ return $request->merchantId() === 'your-merchant-id'
+ && $request->transactionId() === 'A123'
+ && $request->amount()->is(Money::Toman(50000));
+ });
+ }
+}
+```
diff --git a/docs/getting-started.md b/docs/getting-started.md
new file mode 100644
index 0000000..26acdf8
--- /dev/null
+++ b/docs/getting-started.md
@@ -0,0 +1,42 @@
+> There is an example project using Laravel Toman you can find at [evryn/laravel-toman-example](https://github.com/evryn/laravel-toman-example). It contains a payment implementation and few critical tests.
+
+## Requirements
+
+| Package | Laravel Framework | PHP | Status |
+| ------------- |:-------------:|:-----:| ---:|
+| 2.x | 8.x, 7.x | >= 7.3 | Active 🚀 |
+| 1.x | 6.x, 5.8.x | >= 7.2 | |
+
+## Installation
+
+Install the package using Composer:
+```bash
+composer require evryn/laravel-toman
+```
+
+## Configuration
+
+There are few configurable options to make your code cleaner.
+
+Use the following command to publish package config:
+```bash
+php artisan vendor:publish --provider=Evryn\LaravelToman\LaravelTomanServiceProvider --tag=config
+```
+
+Now, a config file will be available to edit at `config/toman.php`. See available options there.
+
+## Customizing Messages (Optional)
+
+Gateways requests might result in different states, and each of them is meaningful. This package also contains those messages, so you don't need to write them again.
+
+Use the following command to publish package translation files:
+```bash
+php artisan vendor:publish --provider=Evryn\LaravelToman\LaravelTomanServiceProvider --tag=lang
+```
+
+Now, translation files are ready to be modified in `/resource/lang/vendor/toman`.
+
+## Next Step
+See how to use a gateway:
+ * [💳 Zarinpal](gateways/zarinpal.md)
+ * [💳 IDPay](gateways/idpay.md)
diff --git a/docs/index.html b/docs/index.html
index 92c2851..094768c 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -7,22 +7,82 @@
+
+
-
+
Opening wallet ...
+
diff --git a/docs/support.md b/docs/support.md
index eb46f0e..bfe82d4 100644
--- a/docs/support.md
+++ b/docs/support.md
@@ -4,27 +4,28 @@ Do you like this project? Here are some ways to show us your ❤:
### Donation
-Donations are very welcome. You can send us some money using one of the following links:
- * [YekPay Personal Gateway (€, £)](https://dashboard.yekpay.com/en/user/AmirrezaNasiri)
- * [Zarinpal Personal Gateway (تومان)](https://zarinp.al/@amirrezan)
-
-### Send us a Postcard
+Donations are very welcome. Select your currency:
+ * [€, £](https://dashboard.yekpay.com/en/user/AmirrezaNasiri)
+ * [تومان](https://zarinp.al/@amirrezan)
+
+
+### Send Us a Postcard
-We appreciate to receive a physical postcard from you or your company. We'll soon display all of them. Just leave me a message and I'll reply soon: `nasiri.amirreza.96@gmail.com` or [@Amirreza_Nasiri](https://twitter.com/amirreza_nasiri).
+We appreciate to receive a postcard from you or your company. We'll soon display all of them. Just leave me a message and I'll reply soon: `nasiri.amirreza.96@gmail.com` or [@Amirreza_Nasiri](https://twitter.com/amirreza_nasiri).
### Follow, Star and Fork
By following us, giving a star and forking this repository, you'll make this package more visible to people. It'll take ~11s, just hit these buttons on [the repository](https://github.com/evryn/laravel-toman):
-Follow @Evryn
+FollowStarFork
### Contribute
-Knowing Laravel and package development? It would be great if you could help us extend this project. See [Contribution Guide](contributing.md).
+Knowing about Laravel and package development? It would be great if you could help us extend this project. See [Contribution Guide](../CONTRIBUTING.md).
### Share it
@@ -32,8 +33,8 @@ Let people know about this package by simply sharing current URL or clicking her
* [Share on Twitter](https://twitter.com/share?url=https://github.com/evryn/laravel-toman)
* [Share on Telegram](https://t.me/share/url?url=https://github.com/evryn/laravel-toman)
-
-
+
+
### Not a suitable one yet?
-Don't worry at all! You can help us by making someone very very happy **today** 😊. We believe in Butterfly Effect.
+Don't worry at all! You can help us by making someone happy **today** 😊
diff --git a/docs/todo.md b/docs/todo.md
deleted file mode 100644
index e2b9a4d..0000000
--- a/docs/todo.md
+++ /dev/null
@@ -1,3 +0,0 @@
- * Add a callback request form validator with access to payment transaction id
- * Add a method to continue unexpired transaction
- * Add a feature to request gateway to expire specific transaction(s)
diff --git a/docs/v1/_media/icon.png b/docs/v1/_media/icon.png
new file mode 100644
index 0000000..6165180
Binary files /dev/null and b/docs/v1/_media/icon.png differ
diff --git a/docs/v1/_media/logo.png b/docs/v1/_media/logo.png
new file mode 100644
index 0000000..9dad305
Binary files /dev/null and b/docs/v1/_media/logo.png differ
diff --git a/docs/_media/payment-request-canvas.png b/docs/v1/_media/payment-request-canvas.png
similarity index 100%
rename from docs/_media/payment-request-canvas.png
rename to docs/v1/_media/payment-request-canvas.png
diff --git a/docs/_media/payment-verification-canvas.png b/docs/v1/_media/payment-verification-canvas.png
similarity index 100%
rename from docs/_media/payment-verification-canvas.png
rename to docs/v1/_media/payment-verification-canvas.png
diff --git a/docs/v1/_sidebar.md b/docs/v1/_sidebar.md
new file mode 100644
index 0000000..726a00f
--- /dev/null
+++ b/docs/v1/_sidebar.md
@@ -0,0 +1,18 @@
+* [Introduction](introduction.md)
+
+* Getting started
+
+ * [Quick Start](quickstart.md)
+ * [Configuration](configuration.md)
+ * [Translations](translations.md)
+
+* Available Gateways
+
+ * [Zarinpal](gateways/zarinpal.md)
+
+* [Testing](testing.md)
+
+* Contributing
+* Changelog
+* Support 💜
+
diff --git a/docs/configuration.md b/docs/v1/configuration.md
similarity index 100%
rename from docs/configuration.md
rename to docs/v1/configuration.md
diff --git a/docs/v1/gateways/zarinpal.md b/docs/v1/gateways/zarinpal.md
new file mode 100644
index 0000000..3091097
--- /dev/null
+++ b/docs/v1/gateways/zarinpal.md
@@ -0,0 +1,95 @@
+# Zarinpal Gateway
+
+[Zarinpal.com](https://www.zarinpal.com) gateway was added in version 1.0 and implementation of it is based on version 1.3 of their [official document](https://github.com/ZarinPal-Lab/Documentation-PaymentGateway/).
+
+## Config
+
+Zarinpal gateway requires following variables in `.env` file to work:
+
+| Environment Variable | Description |
+|---------------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| TOMAN_GATEWAY | (**Required**) Must equal `zarinpal` in order to use this gateway provider. |
+| ZARINPAL_MERCHANT_ID | (**Required**) Your gateway's merchant ID which can be gotten from your Zarinpal panel. Example: 0bcf346fc-3a79-4b36-b936-5ccbc2be0696 |
+| ZARINPAL_SANDBOX | (Optional. Default: false) Set it to `true` to make test calls in a simulated environment provided by Zarinpal without actual payments. Delete the key or set it to `false` to make calls in production environment and receive actual payments. |
+
+Example:
+```dotenv
+...
+
+TOMAN_GATEWAY=zarinpal
+ZARINPAL_MERCHANT_ID=0bcf346fc-3a79-4b36-b936-5ccbc2be0696
+```
+
+## Payment Request
+
+In short, you can request a new payment with the following methods and catches:
+```php
+use Evryn\LaravelToman\Facades\PaymentRequest;
+use Evryn\LaravelToman\Gateways\Zarinpal\Status;
+
+// ...
+
+try {
+ $requestedPayment = PaymentRequest::amount(1000)
+ ->description('Subscrbing to Plan A')
+ ->callback('https://example.com/callback')
+ ->mobile('09350000000')
+ ->email('amirreza@example.com')
+ ->request();
+} catch (GatewayException $gatewayException) {
+ if ($gatewayException->getCode() === Status::SHAPARAK_LIMITED) {
+ // there might be a problem with 'Amount' data.
+ }
+} catch (InvalidConfigException $exception) {
+ // Woops! wrong merchant_id or sandbox option is configurated.
+}
+
+// Use $requestedPayment...
+```
+
+| Method | Description |
+|------------- |--------------------------------------------------------------------------------------------------------------------------------- |
+| callback | Sets `CallbackURL` data and overrides `callback_route` config. |
+| description | Sets `Description` data and overrides `description` config. |
+| mobile | Sets `Mobile` data. |
+| email | Sets `Email` data. |
+| amount | Sets `Amount` data. |
+| request | Calls `PaymentRequest` Zarinpal endpoint and returns a `RequestedPayment` object with available transaction ID and payment URL. Might throw `GatewayException` if the request was rejected by Zarinpal. `GatewayException` is filled with user-friendly message that can be translated (see [Translations](#translations) section) and status code constants in `Evryn\LaravelToman\Gateways\Zarinpal\Status`. Might throw an `InvalidConfigException` if gateway-specific configs are not set correctly (see [Config](#config) section above). |
+
+
+## Payment Verification
+
+In short, you can verify a payment callback with the following methods and catches:
+```php
+use Evryn\LaravelToman\Facades\PaymentVerification;
+use Evryn\LaravelToman\Gateways\Zarinpal\Status;
+
+// ...
+
+try {
+ $verifiedPayment = PaymentVerification::amount(1000)
+ ->verify(request()); // or $request in your Controller
+} catch (GatewayException $gatewayException) {
+ if ($gatewayException->getCode() === Status::NOT_PAID) {
+ // the payment has been cancelled
+ } elseif ($gatewayException->getCode() === Status::ALREADY_VERIFIED) {
+ // the payment has already been verified before
+ }
+} catch (InvalidConfigException $exception) {
+ // Woops! wrong merchant_id or sandbox option is configurated.
+}
+
+// Use $verifiedPayment...
+```
+
+| Method | Description |
+|------------- |--------------------------------------------------------------------------------------------------------------------------------- |
+| amount | Sets `Amount` data. It should equal to the amount that payment request was created with. |
+| verify | Calls `PaymentVerification` Zarinpal endpoint with callback queries gotten from request and returns a `VerifiedPayment` object with available reference ID. Might throw a `GatewayException` if the request was rejected by Zarinpal. `GatewayException` is filled with user-friendly message that can be translated (see [Translations](#translations) section) and status code constants in `Evryn\LaravelToman\Gateways\Zarinpal\Status`. Might throw an `InvalidConfigException` if gateway-specific configs are not set correctly (see [Config](#config) section above) |
+
+
+## Translations
+
+Currently, two `fa` (Persian) and `en` (English) languages are added to display payment status (in `GatewayException` especially).
+
+See [Getting Started/Translations](../translations.md) to find out how to set application locale or customize these messages.
diff --git a/docs/v1/index.html b/docs/v1/index.html
new file mode 100644
index 0000000..4c89b6e
--- /dev/null
+++ b/docs/v1/index.html
@@ -0,0 +1,62 @@
+
+
+
+ Laravel Toman
+
+
+
+
+
+
+
+
+
+