Skip to content

Commit

Permalink
add support for sepa_debit
Browse files Browse the repository at this point in the history
  • Loading branch information
lsmith77 committed Mar 21, 2020
1 parent 527b435 commit 7163fef
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/Billable.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,17 +430,28 @@ public function paymentMethods($parameters = [])
return collect();
}

$parameters = array_merge(['limit' => 24], $parameters);
$parameters = array_merge(['limit' => 24, 'customer' => $this->stripe_id], $parameters);

// "type" is temporarily required by Stripe...
$paymentMethods = StripePaymentMethod::all(
['customer' => $this->stripe_id, 'type' => 'card'] + $parameters,
['type' => 'card'] + $parameters,
$this->stripeOptions()
);

return collect($paymentMethods->data)->map(function ($paymentMethod) {
$cards = collect($paymentMethods->data)->map(function ($paymentMethod) {
return new PaymentMethod($this, $paymentMethod);
});

$paymentMethods = StripePaymentMethod::all(
['type' => 'sepa_debit'] + $parameters,
$this->stripeOptions()
);

$sepa = collect($paymentMethods->data)->map(function ($paymentMethod) {
return new PaymentMethod($this, $paymentMethod);
});

return $cards->merge($sepa);
}

/**
Expand Down Expand Up @@ -594,9 +605,15 @@ public function updateDefaultPaymentMethodFromStripe()
*/
protected function fillPaymentMethodDetails($paymentMethod)
{
if ($paymentMethod->type === 'card') {
$this->card_brand = $paymentMethod->card->brand;
$this->card_last_four = $paymentMethod->card->last4;
switch ($paymentMethod->type) {
case 'card':
$this->card_brand = $paymentMethod->card->brand;
$this->card_last_four = $paymentMethod->card->last4;
break;
case 'sepa_debit':
$this->card_brand = 'SEPA Debit';
$this->card_last_four = $paymentMethod->sepa_debit->last4;
break;
}

return $this;
Expand Down

0 comments on commit 7163fef

Please sign in to comment.