У меня проблема при попытке привязать StripePaymentGateway
к PaymentGatewayInteface
namespace App\Billing;
interface PaymentGatewayInteface
{
public function charge($amount, $token);
}
namespace App\Billing;
use Stripe\Charge;
class StripePaymentGateway
{
private $apiKey;
public function __construct($apiKey)
{
$this->apiKey = $apiKey;
}
public function charge($amount, $token)
{
// code
}
}
Мой AppServiceProvider:
namespace App\Providers;
use App\Billing\StripePaymentGateway;
use App\Billing\PaymentGatewayInteface;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
public function register()
{
$this->app->bind(StripePaymentGateway::class, function () {
return new StripePaymentGateway(config('services.stripe.secret'));
});
$this->app->bind(PaymentGatewayInteface::class, StripePaymentGateway::class);
}
}
namespace App\Http\Controllers;
use App\Billing\PaymentGatewayInteface;
class ConcertsOrdersController extends Controller
{
private $paymentGateway;
public function __construct(PaymentGatewayInteface $paymentGateway)
{
$this->paymentGateway = $paymentGateway;
}
}
Эта ошибка показывает:
Symfony\Component\Debug\Exception\FatalThrowableError : Argument 1 passed to App\Http\Controllers\ConcertsOrdersController::__construct() must implement interface App\Billing\PaymentGatewayInteface, instance of App\Billing\StripePaymentGateway given