Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.x] Update payavel/orchestration to v3. #62

Merged
merged 10 commits into from
Jul 1, 2024
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"test": "vendor/bin/phpunit"
},
"require": {
"payavel/orchestration": "^2.0"
"payavel/orchestration": "dev-master"
},
"require-dev": {
"orchestra/testbench": "^8.0|^9.0"
Expand Down
4 changes: 2 additions & 2 deletions database/factories/TransactionEventFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Payavel\Checkout\Models\Payment;
use Payavel\Checkout\Models\Refund;
use Payavel\Checkout\Models\TransactionEvent;
use Payavel\Orchestration\Support\ServiceConfig;
use Payavel\Orchestration\ServiceConfig;

class TransactionEventFactory extends Factory
{
Expand Down Expand Up @@ -38,7 +38,7 @@ public function definition()
*/
public function configure()
{
$this->model = ServiceConfig::get('checkout', 'models.' . $this->model, $this->model);
$this->model = ServiceConfig::find('checkout')->get('models.' . $this->model, $this->model);

return $this->afterMaking(function (TransactionEvent $transactionEvent) {
if (is_null($transactionEvent->payment_id)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Payavel\Orchestration\Support\ServiceConfig;
use Payavel\Orchestration\ServiceConfig;

return new class () extends Migration {
/**
Expand All @@ -13,7 +13,7 @@
*/
public function up()
{
$usingDatabaseDriver = ServiceConfig::get('checkout', 'defaults.driver') === 'database';
$usingDatabaseDriver = ServiceConfig::find('checkout')->get('defaults.driver') === 'database';

Schema::create('payment_types', function (Blueprint $table) {
$table->string('id')->primary();
Expand Down
20 changes: 20 additions & 0 deletions src/CheckoutGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,24 @@ public function __construct()
{
parent::__construct('checkout');
}

/**
* Get or set the service's config.
*
* @param string|array $key
* @param mixed $default
* @return mixed
*/
public function config($key, $default = null)
{
if (is_array($key)) {
foreach ($key as $key => $value) {
$this->config->set($key, $value);
}

return;
}

return $this->config->get($key, $default);
}
}
3 changes: 2 additions & 1 deletion src/Facades/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
use Payavel\Checkout\CheckoutGateway;

/**
* @method static mixed config($key, $default)
* @method static \Payavel\Checkout\CheckoutGateway provider($provider)
* @method static \Payavel\Orchestration\Contracts\Providable getProvider()
* @method static void setProvider($provider)
* @method static string|int|\Payavel\Orchestration\Contracts\Providable getDefaultProvider()
* @method static \Payavel\Checkout\CheckoutGateway account($account)
* @method static \Payavel\Orchestration\Contracts\Accountable getAccount()
* @method static void setAccount($account, $strict = true)
* @method static void reset()
* @method static string|int|\Payavel\Orchestration\Contracts\Accountable getDefaultAccount()
* @method static void reset()
* @method static \Payavel\Checkout\CheckoutResponse getWallet(\Payavel\Checkout\Models\Wallet $wallet)
* @method static \Payavel\Checkout\CheckoutResponse getPaymentInstrument(\Payavel\Checkout\Models\PaymentInstrument $paymentInstrument)
* @method static \Payavel\Checkout\CheckoutResponse tokenizePaymentInstrument(\Payavel\Checkout\Contracts\Billable $billable, $data)
Expand Down
6 changes: 3 additions & 3 deletions src/Models/Dispute.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Payavel\Checkout\Models;

use Illuminate\Database\Eloquent\Model;
use Payavel\Orchestration\Support\ServiceConfig;
use Payavel\Checkout\Facades\Checkout;
use Payavel\Orchestration\Traits\HasFactory;

class Dispute extends Model
Expand Down Expand Up @@ -52,7 +52,7 @@ protected static function getFactoryNamespace()
*/
public function payment()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . Payment::class, Payment::class));
return $this->belongsTo(Checkout::config('models.' . Payment::class, Payment::class));
}

/**
Expand All @@ -62,6 +62,6 @@ public function payment()
*/
public function transactionEvents()
{
return $this->morphMany(ServiceConfig::get('checkout', 'models.' . TransactionEvent::class, TransactionEvent::class), 'transactionable');
return $this->morphMany(Checkout::config('models.' . TransactionEvent::class, TransactionEvent::class), 'transactionable');
}
}
14 changes: 7 additions & 7 deletions src/Models/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace Payavel\Checkout\Models;

use Illuminate\Database\Eloquent\Model;
use Payavel\Checkout\Facades\Checkout;
use Payavel\Orchestration\Contracts\Orchestrable;
use Payavel\Orchestration\Models\Account;
use Payavel\Orchestration\Models\Provider;
use Payavel\Orchestration\Support\ServiceConfig;
use Payavel\Orchestration\Traits\OrchestratesService;
use Payavel\Orchestration\Traits\HasFactory;

Expand Down Expand Up @@ -64,7 +64,7 @@ protected static function getFactoryNamespace()
*/
public function provider()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . Provider::class, Provider::class));
return $this->belongsTo(Checkout::config('models.' . Provider::class, Provider::class));
}

/**
Expand All @@ -74,7 +74,7 @@ public function provider()
*/
public function account()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . Account::class, Account::class));
return $this->belongsTo(Checkout::config('models.' . Account::class, Account::class));
}

/**
Expand All @@ -84,7 +84,7 @@ public function account()
*/
public function rail()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . PaymentRail::class, PaymentRail::class));
return $this->belongsTo(Checkout::config('models.' . PaymentRail::class, PaymentRail::class));
}

/**
Expand All @@ -94,7 +94,7 @@ public function rail()
*/
public function instrument()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . PaymentInstrument::class, PaymentInstrument::class));
return $this->belongsTo(Checkout::config('models.' . PaymentInstrument::class, PaymentInstrument::class));
}

/**
Expand All @@ -104,7 +104,7 @@ public function instrument()
*/
public function events()
{
return $this->hasMany(ServiceConfig::get('checkout', 'models.' . TransactionEvent::class, TransactionEvent::class));
return $this->hasMany(Checkout::config('models.' . TransactionEvent::class, TransactionEvent::class));
}

/**
Expand All @@ -114,7 +114,7 @@ public function events()
*/
public function transactionEvents()
{
return $this->morphMany(ServiceConfig::get('checkout', 'models.' . TransactionEvent::class, TransactionEvent::class), 'transactionable');
return $this->morphMany(Checkout::config('models.' . TransactionEvent::class, TransactionEvent::class), 'transactionable');
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Models/PaymentInstrument.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Payavel\Checkout\Models;

use Illuminate\Database\Eloquent\Model;
use Payavel\Orchestration\Support\ServiceConfig;
use Payavel\Checkout\Facades\Checkout;
use Payavel\Orchestration\Traits\HasFactory;

class PaymentInstrument extends Model
Expand Down Expand Up @@ -53,7 +53,7 @@ protected static function getFactoryNamespace()
*/
public function wallet()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . Wallet::class, Wallet::class));
return $this->belongsTo(Checkout::config('models.' . Wallet::class, Wallet::class));
}

/**
Expand All @@ -63,7 +63,7 @@ public function wallet()
*/
public function type()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . PaymentType::class, PaymentType::class));
return $this->belongsTo(Checkout::config('models.' . PaymentType::class, PaymentType::class));
}

/**
Expand All @@ -73,7 +73,7 @@ public function type()
*/
public function payments()
{
return $this->hasMany(ServiceConfig::get('checkout', 'models.' . Payment::class, Payment::class), 'instrument_id');
return $this->hasMany(Checkout::config('models.' . Payment::class, Payment::class), 'instrument_id');
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Models/PaymentRail.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Payavel\Checkout\Models;

use Illuminate\Database\Eloquent\Model;
use Payavel\Orchestration\Support\ServiceConfig;
use Payavel\Checkout\Facades\Checkout;
use Payavel\Orchestration\Traits\HasFactory;

class PaymentRail extends Model
Expand Down Expand Up @@ -54,7 +54,7 @@ protected static function getFactoryNamespace()
*/
public function parentType()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . PaymentType::class, PaymentType::class));
return $this->belongsTo(Checkout::config('models.' . PaymentType::class, PaymentType::class));
}

/**
Expand All @@ -64,7 +64,7 @@ public function parentType()
*/
public function type()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . PaymentType::class, PaymentType::class));
return $this->belongsTo(Checkout::config('models.' . PaymentType::class, PaymentType::class));
}

/**
Expand All @@ -74,6 +74,6 @@ public function type()
*/
public function payments()
{
return $this->hasMany(ServiceConfig::get('checkout', 'models.' . Payment::class, Payment::class), 'rail_id');
return $this->hasMany(Checkout::config('models.' . Payment::class, Payment::class), 'rail_id');
}
}
6 changes: 3 additions & 3 deletions src/Models/PaymentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Payavel\Checkout\Models;

use Illuminate\Database\Eloquent\Model;
use Payavel\Orchestration\Support\ServiceConfig;
use Payavel\Checkout\Facades\Checkout;
use Payavel\Orchestration\Traits\HasFactory;

class PaymentType extends Model
Expand Down Expand Up @@ -41,7 +41,7 @@ protected static function getFactoryNamespace()
*/
public function rails()
{
return $this->hasMany(ServiceConfig::get('checkout', 'models.' . PaymentRail::class, PaymentRail::class), 'parent_type_id');
return $this->hasMany(Checkout::config('models.' . PaymentRail::class, PaymentRail::class), 'parent_type_id');
}

/**
Expand All @@ -51,6 +51,6 @@ public function rails()
*/
public function instruments()
{
return $this->hasMany(ServiceConfig::get('checkout', 'models.' . PaymentInstrument::class, PaymentInstrument::class), 'type_id');
return $this->hasMany(Checkout::config('models.' . PaymentInstrument::class, PaymentInstrument::class), 'type_id');
}
}
6 changes: 3 additions & 3 deletions src/Models/Refund.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Payavel\Checkout\Models;

use Illuminate\Database\Eloquent\Model;
use Payavel\Orchestration\Support\ServiceConfig;
use Payavel\Checkout\Facades\Checkout;
use Payavel\Orchestration\Traits\HasFactory;

class Refund extends Model
Expand Down Expand Up @@ -52,7 +52,7 @@ protected static function getFactoryNamespace()
*/
public function payment()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . Payment::class, Payment::class));
return $this->belongsTo(Checkout::config('models.' . Payment::class, Payment::class));
}

/**
Expand All @@ -62,6 +62,6 @@ public function payment()
*/
public function transactionEvents()
{
return $this->morphMany(ServiceConfig::get('checkout', 'models.' . TransactionEvent::class, TransactionEvent::class), 'transactionable');
return $this->morphMany(Checkout::config('models.' . TransactionEvent::class, TransactionEvent::class), 'transactionable');
}
}
4 changes: 2 additions & 2 deletions src/Models/TransactionEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Payavel\Checkout\Models;

use Illuminate\Database\Eloquent\Model;
use Payavel\Orchestration\Support\ServiceConfig;
use Payavel\Checkout\Facades\Checkout;
use Payavel\Orchestration\Traits\HasFactory;

class TransactionEvent extends Model
Expand Down Expand Up @@ -52,7 +52,7 @@ protected static function getFactoryNamespace()
*/
public function payment()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . Payment::class, Payment::class));
return $this->belongsTo(Checkout::config('models.' . Payment::class, Payment::class));
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Models/Wallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace Payavel\Checkout\Models;

use Illuminate\Database\Eloquent\Model;
use Payavel\Checkout\Facades\Checkout;
use Payavel\Orchestration\Contracts\Orchestrable;
use Payavel\Orchestration\Traits\OrchestratesService;
use Payavel\Orchestration\Models\Account;
use Payavel\Orchestration\Models\Provider;
use Payavel\Orchestration\Support\ServiceConfig;
use Payavel\Orchestration\Traits\HasFactory;

class Wallet extends Model implements Orchestrable
Expand Down Expand Up @@ -63,7 +63,7 @@ public function billable()
*/
public function provider()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . Provider::class, Provider::class));
return $this->belongsTo(Checkout::config('models.' . Provider::class, Provider::class));
}

/**
Expand All @@ -73,7 +73,7 @@ public function provider()
*/
public function account()
{
return $this->belongsTo(ServiceConfig::get('checkout', 'models.' . Account::class, Account::class));
return $this->belongsTo(Checkout::config('models.' . Account::class, Account::class));
}

/**
Expand All @@ -83,7 +83,7 @@ public function account()
*/
public function paymentInstruments()
{
return $this->hasMany(ServiceConfig::get('checkout', 'models.' . PaymentInstrument::class, PaymentInstrument::class));
return $this->hasMany(Checkout::config('models.' . PaymentInstrument::class, PaymentInstrument::class));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Traits/Billable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Payavel\Checkout\Traits;

use Payavel\Checkout\Facades\Checkout;
use Payavel\Checkout\Models\Wallet;
use Payavel\Orchestration\Support\ServiceConfig;

trait Billable
{
Expand All @@ -14,6 +14,6 @@ trait Billable
*/
public function wallets()
{
return $this->morphMany(ServiceConfig::get('checkout', 'models.' . Wallet::class, Wallet::class), 'billable');
return $this->morphMany(Checkout::config('models.' . Wallet::class, Wallet::class), 'billable');
}
}

This file was deleted.

Loading
Loading