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

Target [Billow\Contracts\PaymentProcessor] is not instantiable. #7

Open
venkatavinash opened this issue Nov 11, 2017 · 4 comments
Open

Comments

@venkatavinash
Copy link

venkatavinash commented Nov 11, 2017

Hello,

I have included all as described but I am getting the following when I call the route onto PaymentContoller@confirmPayment

Target [Billow\Contracts\PaymentProcessor] is not instantiable.

/var/www/html/bidtend/bidtend/vendor/laravel/framework/src/Illuminate/Container/Container.php

/**
 * Throw an exception that the concrete is not instantiable.
 *
 * @param  string  $concrete
 * @return void
 *
 * @throws \Illuminate\Contracts\Container\BindingResolutionException
 */
protected function notInstantiable($concrete)
{
    if (! empty($this->buildStack)) {
        $previous = implode(', ', $this->buildStack);

        $message = "Target [$concrete] is not instantiable while building [$previous].";
    } else {
        $message = "Target [$concrete] is not instantiable.";
    }

    throw new BindingResolutionException($message);
}

/**
 * Throw an exception for an unresolvable primitive.
 *
 * @param  \ReflectionParameter  $parameter
 * @return void
 *
 * @throws \Illuminate\Contracts\Container\BindingResolutionException
 */
protected function unresolvablePrimitive(ReflectionParameter $parameter)
{
    $message = "Unresolvable dependency resolving [$parameter] in class {$parameter->getDeclaringClass()->getName()}";

    throw new BindingResolutionException($message);
}

/**
 * Register a new resolving callback.
 *

Arguments
"Target [Billow\Contracts\PaymentProcessor] is not instantiable."

any help would be appreciated.

Laravel 5.5 , php 7.0

@mikerockett
Copy link
Contributor

Contracts (that is, PHP interfaces) are not directly instantiable. Would you mind sharing your code for confirmPayment()?

@venkatavinash
Copy link
Author

true. i did not checked the code before posting here.

I have changed use Billow\Contracts\PaymentProcessor; to use Billow\Payfast and passed it using
public function somthing(Payfast $payfast).

Working fine now.

Is there a need to change the code ? I think so.

@mikerockett
Copy link
Contributor

Something would be going wrong on your side if the contract does not work. The service provider binds the contract to the Payfast class in the service container (which is why the class works when you pull it in directly). I’d still like to find out why binding the contract is not working on your side… I’ve tested on PHP 7.0/7.1 with L5.5, and it all works fine.

@venkatavinash
Copy link
Author

I have used the same code which was given in example.
public function confirmPayment(PaymentProcessor $payfast)
{
// Eloqunet example.
$cartTotal = 9999;
$order = Order::create([
'm_payment_id' => '001', // A unique reference for the order.
'amount' => $cartTotal
]);

    // Build up payment Paramaters.
    $payfast->setBuyer('first name', 'last name', 'email');
    $payfast->setAmount($order->amount);
    $payfast->setItem('item-title', 'item-description');
    $payfast->setMerchantReference($order->m_payment_id);

    // Return the payment form.
    return $payfast->paymentForm('Place Order');
}

But I have passed now Request $request and used Payfast $payfast which seems to be working.

Is it not right way to implement?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants