Skip to content

Commit 4306b4a

Browse files
committedOct 26, 2017
move laravel configs to services.php
1 parent 804aa23 commit 4306b4a

File tree

2 files changed

+18
-34
lines changed

2 files changed

+18
-34
lines changed
 

‎README.md

+15-29
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,24 @@
66

77
transaction request library for zarinpal
88

9-
##laravel ready
9+
## laravel ready
1010
this package is going to work with all kinds of projects, but for laravel i add provider to make it as easy as possible.
1111
just add :
1212
```php
13-
'providers' => array(
13+
'providers' => [
1414
...
1515
Zarinpal\Laravel\ZarinpalServiceProvider::class
1616
...
17-
)
17+
]
1818
```
19-
to providers list in "config/app.php". and run
20-
'`php artisan vendor:publish --provider="Zarinpal\Laravel\ZarinpalServiceProvider"`'
21-
to add config file to laravel configs directory config it and you are good to go
19+
to providers list in "config/app.php". then add this to `config/services.php`
20+
```php
21+
'zarinpal' => [
22+
'merchantID' => 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
23+
'driver' => 'Rest',
24+
],
25+
```
26+
and you are good to go (legacy config still works)
2227
now you can access the zarinpal lib like this:
2328
```php
2429
use Zarinpal\Laravel\Facade\Zarinpal;
@@ -28,8 +33,8 @@ Zarinpal::verify('OK',1000,$answer['Authority']);
2833
```
2934

3035

31-
##usage
32-
###installation
36+
## usage
37+
### installation
3338
``composer require zarinpal/zarinpal``
3439
or
3540
```json
@@ -40,7 +45,7 @@ or
4045
},
4146
```
4247

43-
###request
48+
### request
4449
```php
4550
use Zarinpal\Zarinpal;
4651

@@ -54,7 +59,7 @@ if(isset($answer['Authority'])) {
5459
//$answer['Authority'] must save somewhere to do the verification
5560
```
5661

57-
###verify
62+
### verify
5863
```php
5964
use Zarinpal\Zarinpal;
6065

@@ -63,22 +68,3 @@ $answer['Authority'] = file_get_contents('Authority');
6368
echo json_encode($test->verify('OK',1000,$answer['Authority']));
6469
//'Status'(index) going to be 'success', 'error' or 'canceled'
6570
```
66-
##change driver
67-
driver can be changed between restAPI , soap and NuSoap with using:
68-
69-
restAPI (recommended):
70-
```php
71-
$test = new Zarinpal('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX');
72-
```
73-
or soap:
74-
```php
75-
use Zarinpal\Drivers\SoapDriver;
76-
$test = new Zarinpal('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',new soapDriver());
77-
```
78-
or nuSoap:
79-
```php
80-
use Zarinpal\Drivers\NuSoapDriver;
81-
$test = new Zarinpal('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',new NuSoapDriver());
82-
```
83-
84-

‎src/Laravel/ZarinpalServiceProvider.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class ZarinpalServiceProvider extends ServiceProvider
2020
public function register()
2121
{
2222
$this->app->singleton('Zarinpal', function () {
23-
$merchantID = config('Zarinpal.merchantID', 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX');
24-
$driver = config('Zarinpal.driver', 'Rest');
23+
$merchantID = config('services.zarinpal.merchantID', config('Zarinpal.merchantID', 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'));
24+
$driver = config('services.zarinpal.driver', config('Zarinpal.driver', 'Rest'));
2525
switch ($driver) {
2626
case 'Soap':
2727
$driver = new SoapDriver();
@@ -43,8 +43,6 @@ public function register()
4343
*/
4444
public function boot()
4545
{
46-
$this->publishes([
47-
__DIR__.'/config/Zarinpal.php' => config_path('Zarinpal.php'),
48-
]);
46+
//
4947
}
5048
}

0 commit comments

Comments
 (0)
Please sign in to comment.