Skip to content

Commit

Permalink
config rework
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Jan 31, 2024
1 parent 58ed546 commit c189c9c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
14 changes: 6 additions & 8 deletions config/bazar.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,12 @@
'gateway' => [
'default' => env('BAZAR_GATEWAY_DRIVER', 'transfer'),
'drivers' => [
'cash' => [
'success_url' => '/?order={order}&status=success',
'failure_url' => '/?order={order}&status=failed',
],
'transfer' => [
'success_url' => '/?order={order}&status=success',
'failure_url' => '/?order={order}&status=failed',
],
'cash' => [],
'transfer' => [],
],
'urls' => [
'success' => '/?order={order}',
'failure' => '/?order={order}',
],
],

Expand Down
9 changes: 7 additions & 2 deletions src/Gateway/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Cone\Bazar\Support\Facades\Cart;
use Illuminate\Http\Request;
use Illuminate\Http\Response as HttpResponse;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\URL;
use Throwable;

Expand Down Expand Up @@ -62,15 +63,19 @@ public function getCaptureUrl(Order $order): string
*/
public function getSuccessUrl(Order $order): string
{
return URL::to(str_replace(['{order}'], [$order->uuid], $this->config['success_url'] ?? '/'));
$url = $this->config['success_url'] ?? Config::get('bazar.gateway.urls.success');

return URL::to(str_replace(['{order}'], [$order->uuid], $url ?? '/'));
}

/**
* Get the failure URL.
*/
public function getFailureUrl(Order $order): string
{
return URL::to(str_replace(['{order}'], [$order->uuid], $this->config['failure_url'] ?? '/'));
$url = $this->config['failure_url'] ?? Config::get('bazar.gateway.urls.failure');

return URL::to(str_replace(['{order}'], [$order->uuid], $url ?? '/'));
}

/**
Expand Down

0 comments on commit c189c9c

Please sign in to comment.