Search code examples
phplaravelstripe-payments

saving card information to stripe and charge customer later


I want my customers to fill the cc information through stripe without charging them initially but i would manually charge them later accordingly to the service i provide them. it

is it possible to simply save their card information on the stripe itself so i could manually go and charge them through stripe internally? i am new to stripe so i don't understand it all.

i came acrossed this

$intent = \Stripe\PaymentIntent::create([
                        'amount' => $request->amount * 100,
                        'currency' => 'usd',
                        'receipt_email' => $request->email,
                        'payment_method_types' => ["card"],
                        'setup_future_usage' => 'off_session'
                        )
                    ]);

but its always says The PaymentIntent requires a payment method which i don't seem to understand and don't see option of manually charging them after running PaymentIntent.

plus i am using one field to collect the cc information on which it collects cc number, month, expiry date and cvc which is provided from stripe website, i am not collecting them individually.

Thank you


Solution

  • Stripe has documentation about saving payment information for future use that covers this scenario.

    For PHP, the steps would basically be:

    1. Create a Customer
    2. Create a Setup Intent that specifies that Customer
    3. Collect payment details
    4. Confirm the Setup Intent

    That will create a Payment Method and attach it to the Customer. You can then use that Customer/Payment Method combination later to create a Payment Intent and collect a payment.