laravel / cashier-stripe

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.
https://laravel.com/docs/billing
MIT License
2.37k stars 670 forks source link

Braintree payment method chosen wrong #348

Closed norbert-berenyi closed 5 years ago

norbert-berenyi commented 7 years ago

If a customer has more than one payment method the Billable->charge() method is not working as expected. It charges the first payment method, not the default one.

$customer->paymentMethods[0]->token

I have fixed it by creating a method: (I hope correctly...)

$this->defaultPaymentMethod()->token,

/**
 * Choose the default payment method.
 *
 * @return \Braintree\PaymentMethod
 */
private function defaultPaymentMethod()
{
    $customer = $this->asBraintreeCustomer();

    foreach ($customer->paymentMethods as $paymentMethod) {
        if($paymentMethod->default) { return $paymentMethod;}
    }
}
driesvints commented 5 years ago

Heya, we just enabled issues for the Braintree repo. If this is still an issue can you report the issue there? Thanks! https://github.com/laravel/cashier-braintree/issues