2017-02-03 7 views
2

私はLaravel docsに従ってキャッシャーを実装しましたが、動作させることができません。要するにLaravel 5.3、Cashier - Braintree - Single Chargees

  • 製と移行移行
  • は、私の.envに私のUser.phpモデルに
  • 追加キーを課金対象を追加しました私のconfig/services.phpでそれらに言及し、私のAppServiceProvider.php
  • にSDKの呼び出しを追加しました

必要に応じて、コードを貼り付けることができますが、文書の場合と同じです(チェックしたことはありますがわかりません)。

InvalidArgumentException in CustomerGateway.php line 567: 
    expected customer id to be set 

--- 

in CustomerGateway.php line 567 
at CustomerGateway->_validateId(null) in CustomerGateway.php line 198 
at CustomerGateway->find(null) in Customer.php line 106 
at Customer::find(null) in Billable.php line 440 
at User->asBraintreeCustomer() in Billable.php line 29 
at User->charge('15') in MyController.php line 787 

エラーがここにあるように私には思える:

at Customer::find(null) in Billable.php line 440 

は今、私は私のコントローラで

$user = User::find(2); 
$response = $user->charge(15); 
dd($response); 

を実行しようとする場合、私はエラーを取得しますCustomerGatewayの場合はnullとなります。だからここに感謝Billable.php

$customer = $this->asBraintreeCustomer(); 
public function asBraintreeCustomer() 
{ 
    return BraintreeCustomer::find($this->braintree_id); 
} 

の29行目に呼び出されるコードがあります!

UPDATE

私はasBraintreeCustomer()方法でdd($this)を行なったし、私のユーザーを得ました。ただし、braintree_id属性はnullです。 これらはどのように設定しますか? 手動で行う必要がありますか?

答えて

1

これはBillable特性のバグでした。あなたはバグと修正について読むことができ、7月15日'17上に固定されています:https://github.com/laravel/cashier-braintree/commit/f0c133860d175a30676eedbab8d2345a59432910

あなたは道にいる:問題は$this->paymentMethod()を呼び出すときbraintree_id属性がnullされていました。

あなたのプロジェクトにちょうどcomposer updateを起動してください。

+0

ありがとうございます。私はこれから進んできましたが、しばらく前に私がこれをどのように修正したかを知るためには、私のコードに戻っていく必要があります。 – dbr