2016-06-26 6 views
0

私たちはCashier/BraintreeでLaravel 5.2を使用しています。Braintreeが請求できませんでした:カスタムフィールドが無効です:説明

私たちは購読ベースのウェブサイトを持っています。これらは毎月定期的なメンバーシップパッケージのためのものでした。

ここでは、数日間の1回の料金で単価を追加しようとしています。最後のステップまで説明が無効であるとのエラーが表示されるまでは問題なく動作しているようです。ドキュメントとソースコードを見ると、なぜこれが機能していないのかわかりません。ブレインツリー(ちょうど参考のために使用して、編集されていない)から

Exception in Billable.php line 41: 
Braintree was unable to perform a charge: Custom field is invalid: description. 

ソースコード::私たちは次のエラーを取得する

$plan = $request->get('plan'); 
$coupon = $request->get('coupon'); 
$user = $this->user; 

if (false === $user->hasBraintreeId()){ 
    $customer = $user->createAsBraintreeCustomer($request->get('payment_method_nonce'), array()); 
    $user->setCustomerId($customer->id); 
    $user->save(); 
} else { 
    $customer = $user->asBraintreeCustomer(); 
} 

if ($plan == '5-day-taster'){ // One off payment 
    $this->user->invoiceFor('5-day-taster', 5.99); 
} elseif ($plan == '10-day-taster'){ // One off payment 
    $this->user->invoiceFor('10-day-taster', 9.99); 
} elseif ($plan == 'personal-standard'){ // Subscription(s) 
    if (isset($coupon) && !empty($coupon)) 
     $this->user->newSubscription($plan, $plan) 
      ->withCoupon($coupon) 
      ->create($request->get('payment_method_nonce'), [ 
       'email' => $this->user->email, 
      ]); 
    else 
     $this->user->newSubscription($plan, $plan) 
      ->create($request->get('payment_method_nonce'), [ 
       'email' => $this->user->email, 
      ]); 
} 

:ここ

はコードである

/** 
    * Make a "one off" charge on the customer for the given amount. 
    * 
    * @param int $amount 
    * @param array $options 
    * @return \Braintree\Transaction 
    */ 
    public function charge($amount, array $options = []) 
    { 
     $customer = $this->asBraintreeCustomer(); 

     $response = BraintreeTransaction::sale(array_merge([ 
      'amount' => $amount * (1 + ($this->taxPercentage()/100)), 
      'paymentMethodToken' => $customer->paymentMethods[0]->token, 
      'options' => [ 
       'submitForSettlement' => true, 
      ], 
      'recurring' => true, 
     ], $options)); 

     if (! $response->success) { 
      throw new Exception('Braintree was unable to perform a charge: '.$response->message); 
     } 

     return $response; 
    } 

    /** 
    * Invoice the customer for the given amount. 
    * 
    * @param string $description 
    * @param int $amount 
    * @param array $options 
    * @return \Braintree\Transaction 
    */ 
    public function invoiceFor($description, $amount, array $options = []) 
    { 
     return $this->charge($amount, array_merge($options, [ 
      'customFields' => [ 
       'description' => $description, 
      ], 
     ])); 
    } 

事前にアドバイスをいただきありがとうございます。

答えて

5

全開示:私はブレーントリーで働いています。ご不明な点がございましたら、supportまでお気軽にお問い合わせください。

Laravel \ Cashierには文書化されていない要件があります。setup a custom field in your Braintree control panelです。このカスタムフィールドがなく、データを格納するためにこのフィールドを使用しようとしているため、爆発しているようです。

私はLaravel\Cashier Documentation for Braintree configurationで何かを見つけようとしましたが、他の方法については、Braintree documentationの無関係な部分にリンクしていました。 Braintree Custom Fields docsが言うしかし:

  1. コントロールパネルにログインし
  2. 設定に移動>処理>カスタムフィールド
  3. フィールドに続いて、編集フォームで目的のフィールド
  4. をクリックすると、変更することができますフィールドの表示名またはストア切り替えるとバックパスし、クリックして
  5. パススルー・保存

それは過去のTHIを取得する必要がありますコントロールパネルにdescriptionというカスタムフィールドを追加したときにエラーが発生しました。Store and Pass Backが設定されています。

+0

これは私のために解決しました。 –

関連する問題