-
Notifications
You must be signed in to change notification settings - Fork 2
/
CieloServiceProvider.php
39 lines (31 loc) · 1.02 KB
/
CieloServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace SMartins\Cielo;
use Illuminate\Support\ServiceProvider;
use Cielo\API30\Merchant;
use Cielo\API30\Ecommerce\Environment;
use Cielo\API30\Ecommerce\CieloEcommerce;
class CieloServiceProvider extends ServiceProvider
{
public function boot()
{
$source = realpath(__DIR__.'/../config/cielo.php');
$this->publishes([$source => config_path('cielo.php')]);
$this->mergeConfigFrom($source, 'cielo');
}
public function register()
{
$this->app->singleton('Cielo', function ($app) {
$merchant = new Merchant(
$app->config->get('cielo.merchant_id'),
$app->config->get('cielo.merchant_key')
);
$env = $app->config->get('cielo.environment');
if ($env === 'production') {
$environment = Environment::production();
} else {
$environment = Environment::sandbox();
}
return new CieloEcommerce($merchant, $environment);
});
}
}