Cashier で Laravel 4.2 を使用しており、その保護された関数 buildPayload() を変更する必要がありますが、Update を作成するときにコードを壊す可能性があるため、ベンダー ファイルで直接実行したくありません。この関数を自分のロジックでオーバーライドしますか?
現在、次のようにして、コントローラーの1つでキャッシャーを使用しています。
$user->subscription('testplan')
->create(Input::get('stripeToken'), [
'email' => 'email@email.com,
]);
しかし、 withTax() パラメータを追加したい...そのように:
$user->subscription('testplan')
->withTax(10)
->create(Input::get('stripeToken'), [
'email' => 'email@email.com,
]);
ファイルで直接行う方法はすでに知っていStripeGateway.php
ますが、それは悪い習慣です...
私は追加する必要があることを知っています:
protected $taxPercent = 0;
public function withTax($tax)
{
$this->taxPercent = $tax;
return $this;
}
protected function buildPayload()
{
$payload = [
'plan' => $this->plan, 'prorate' => $this->prorate,
'quantity' => $this->quantity, 'trial_end' => $this->getTrialEndForUpdate(),
'tax_percent' => $this->taxPercent,
];
return $payload;
}
私が知らないのは、Cashier Original ファイルに直接ではなく、このコードを追加する方法です。