Skip to content

Commit

Permalink
Change config file format
Browse files Browse the repository at this point in the history
  • Loading branch information
litvinjuan committed Aug 10, 2019
1 parent 7959d22 commit 6a02cc6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
15 changes: 13 additions & 2 deletions config/laravel-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,19 @@
'currency' => 'USD',

'gateways' => [
'default' => ''
// 'another' => Another\Gateway\Implementation::class,
'default' => [
'gateway' => 'Gateway\Class',
'params' => [
'key1' => 'value1',
],
],

// 'another' => [
// 'gateway' => 'Gateway\Class',
// 'params' => [
// 'key1' => 'value1',
// ],
// ],
],

];
3 changes: 2 additions & 1 deletion src/Gateways/GatewayFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class GatewayFactory
public static function make(Payment $payment = null): AbstractGateway
{
// Get the Gateway Class from the config file using the payment's gateway_name attribute, or the default gateway if none was set.
$gatewayClass = config('laravel-payments.gateways')[optional($payment)->gateway_name ?? config('laravel-payments.default_gateway')];
$gateway = optional($payment)->gateway_name ?? config('laravel-payments.default_gateway');
$gatewayClass = config('laravel-payments.gateways')[$gateway]['gateway'];

// Check the Gateway Class exists
if (! class_exists($gatewayClass)) {
Expand Down

0 comments on commit 6a02cc6

Please sign in to comment.