2

I am using Laravel 5.3 and trying to add new webhook event handler in WebhookController

Here is my controller

namespace App\Http\Controllers;

use Braintree\WebhookNotification;
use Laravel\Cashier\Http\Controllers\WebhookController as CashierController;

use Log;
use App\Models\BraintreeMerchant;

class WebhookController extends CashierController
{
    public function handleSubMerchantAccountApproved(WebhookNotification $notification)
    {
  if( isset($_POST["bt_signature"]) && isset($_POST["bt_payload"]))
  {
   $notification = Braintree_WebhookNotification::parse($_POST["bt_signature"], $_POST["bt_payload"]);
   
   $notification->kind == Braintree_WebhookNotification::SUB_MERCHANT_ACCOUNT_APPROVED;
   // true
   $notification->merchantAccount->status;
   // "active"
   $notification->merchantAccount->id;
   // "blue_ladders_store"
   $notification->merchantAccount->masterMerchantAccount->id;
   // "14ladders_marketplace"
   $notification->merchantAccount->masterMerchantAccount->status;
  }
    }
}

but getting the following error message: BindingResolutionException in Container.php line 763: Target [Braintree\WebhookNotification] is not instantiable.

Shoaib Rehan
  • 526
  • 6
  • 16
  • Have you taken a look at some similar Laravel issues like [this one](https://stackoverflow.com/questions/28595862/target-is-not-instantiable-laravel-5-app-binding-service-provider)? There's some consensus that this specific error structure "Target [x] is not insatiable" might be from the compiled.php file not updating. – Ryan Regan Jul 18 '17 at 18:19

1 Answers1

1

I've found the answer. this is how to implement Braintree webhook controller.

<?php

namespace App\Http\Controllers;

use Braintree\WebhookNotification;
use Laravel\Cashier\Http\Controllers\WebhookController as CashierController;
use Illuminate\Http\Request;

class WebhookController extends CashierController
{
    public function handleSubMerchantAccountApproved(Request $request)
    {
  $notification = WebhookNotification::parse($request->bt_signature, $request->bt_payload);
 
   $merchantId = $notification->merchantAccount->id;
   $result_merchant_status = $notification->merchantAccount->status;
    }
 
}
Shoaib Rehan
  • 526
  • 6
  • 16