2017-07-16 52 views
0

我使用Laravel 5.3,並試圖在WebhookControllerLaravel 5.3如何使用布倫特裏 WebhookNotification

這裏添加新的網絡掛接事件處理程序是我的控制器

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) 
 
    { 
 
\t \t if(isset($_POST["bt_signature"]) && isset($_POST["bt_payload"])) 
 
\t \t { 
 
\t \t \t $notification = Braintree_WebhookNotification::parse($_POST["bt_signature"], $_POST["bt_payload"]); 
 
\t \t \t 
 
\t \t \t $notification->kind == Braintree_WebhookNotification::SUB_MERCHANT_ACCOUNT_APPROVED; 
 
\t \t \t // true 
 
\t \t \t $notification->merchantAccount->status; 
 
\t \t \t // "active" 
 
\t \t \t $notification->merchantAccount->id; 
 
\t \t \t // "blue_ladders_store" 
 
\t \t \t $notification->merchantAccount->masterMerchantAccount->id; 
 
\t \t \t // "14ladders_marketplace" 
 
\t \t \t $notification->merchantAccount->masterMerchantAccount->status; 
 
\t \t } 
 
    } 
 
}

,但得到的以下錯誤消息: Container.php中的BindingResolutionException行763: 目標[Braintree \ WebhookNotification]不可實例化。

+0

你有沒有在像[這一個](https://stackoverflow.com/questions/28595862/target-is-not-instantiable-laravel-一些類似Laravel問題採取一看5應用結合服務提供商)?有一些共識認爲,這個特定的錯誤結構「Target [x]不是無法滿足的」可能來自compiled.php文件沒有更新。 –

回答

0

我找到了答案。這是如何實施Braintree webhook控制器。

<?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) 
 
    { 
 
\t \t $notification = WebhookNotification::parse($request->bt_signature, $request->bt_payload); 
 
\t 
 
\t \t \t $merchantId = $notification->merchantAccount->id; 
 
\t \t \t $result_merchant_status = $notification->merchantAccount->status; 
 
    } 
 
\t 
 
}