Skip to content

Commit

Permalink
15.5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
ebrasha committed Jun 20, 2024
1 parent d7d6929 commit eb590db
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,23 @@ use Abdal\AbdalZarinpalPg\Zarinpal;
return $response->referenceId();
}
```
اگر نمی خواهید در هر بار استفاده از پکیج کد درگاه و واحد پول را وارد کنید می توانید از فایل .env نیز استفاده کنید.
در فایل .env پروژه خود، مقادیر مربوط به ZARINPAL_MERCHANT_ID و ZARINPAL_CURRENCY را اضافه کنید:
مرچنت کد یا کد درگاه را اضافه کنید
```bash
ZARINPAL_MERCHANT_ID=00000000-0000-0000-0000-000000000000
```
برای تغییر واحد پول به تومان (پکیج پیشفرض از واحد تومان استفاده می کند)
```bash
ZARINPAL_CURRENCY=IRT
```
برای تغییر واحد پول به ریال
```bash
ZARINPAL_CURRENCY=IRR
```
## ❤️ کمک به پروژه
https://alphajet.ir/abdal-donation
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"homepage": "https://github.com/ebrasha/abdal-zarinpal-pg",
"license": "MIT",
"version": "15.5.3",
"version": "15.5.6",
"autoload": {
"psr-4": {
"Abdal\\AbdalZarinpalPg\\": "src/"
Expand Down
20 changes: 13 additions & 7 deletions src/Zarinpal.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Zarinpal
public function __construct()
{
$this->merchantId = config('zarinpal.merchant_id');
$this->currency = 'IRT';
$this->currency = config('zarinpal.currency');
}

public static function merchantId($merchantId)
Expand All @@ -29,12 +29,24 @@ public static function merchantId($merchantId)
return $instance->setMerchantId($merchantId);
}

public static function currency($currency)
{
$instance = new self();
return $instance->setCurrency($currency);
}

public function setMerchantId($merchantId)
{
$this->merchantId = $merchantId;
return $this;
}

public function setCurrency($currency)
{
$this->currency = $currency;
return $this;
}

public function amount($amount)
{
$this->amount = $amount;
Expand Down Expand Up @@ -65,12 +77,6 @@ public function mobile($mobile)
return $this;
}

public function currency($currency)
{
$this->currency = $currency;
return $this;
}

public function authority($authority)
{
$this->authority = $authority;
Expand Down
4 changes: 2 additions & 2 deletions src/config/zarinpal.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

return [
'merchant_id' => env('ZARINPAL_MERCHANT_ID', 'your-merchant-id'),
'sandbox' => env('ZARINPAL_SANDBOX_ENABLED', false),
'merchant_id' => env('ZARINPAL_MERCHANT_ID', '00000000-0000-0000-0000-000000000000'),
'currency' => env('ZARINPAL_CURRENCY', 'IRT'),
];

0 comments on commit eb590db

Please sign in to comment.