2

Select card from saved cards, if not create a new card Before Payment in Laravel Cashier.

Note: Just Charging the $N amount, N can be different for next time checkout.

Step 1: List of Saved Cards, if not create a new one.

Step 2: Choose Card

Step 3: Checkout the payment.

2 Answers2

0

Find Billable.php trait in laravel/cashier/scr/ and search word like card then you find all methods related to card i.e.

  • hasCardOnFile()
  • fillCardDetails()
  • updateCard()
  • updateCardFromStripe()
  • deleteCards()
  • cards()
  • defaultCard()

Use them according to your requirements

Afraz Ahmad
  • 5,193
  • 28
  • 38
0
$defaultCard = $user->defaultCard();  // Default Card

$cards = $user->cards();   //List of Cards


//Make current source as default
$customer = \Stripe\Customer::retrieve(($request->stripe_id));
$customer->default_source = $request->card_token;
$customer->save();

// Now charge customer
$charge = \Stripe\Charge::create([
                'amount'   => $amount,
                'currency' => 'usd',
                'customer' => $customer->id,
            ]);