I'm using Laravel Cashier with Stripe for my restaurant.
I want to use multiple payment methods that Stripe supports for my customers, but i couldn't find any information about using multiple payment methods with Stripe in the Laravel Cashier documentation.
The Accept a Payment document in Stripe's documentation is exactly what I need. Is there a way to implement the method described in this document with Laravel Cashier?
this requires to run both php and js script to stripe,
its reference here
you first need a setup intent, which you have to call using
return $user->createSetupIntent();
and access the value on the front-end. on your card/payment page, you have to set-up the stripe js card elements. then capture and process the card elements like example below (uses axios)
const { setupIntent, error } = await stripe.confirmCardSetup(your_SETUP_INTENT, {
payment_method: {
card: your_card_object,
billing_details: { name: 'Card Name' }
}
})
if (error) {
console.log(error)
} else {
const { data } = await axios.post('/api/payment-method', { card: setupIntent.payment_method })
}
once the request to stripe is successful, you'll get payment method id, which you can push back to your server like the example above, then attach the payment back that user by calling addPaymentMethod
$user->addPaymentMethod( $request->input('card) );