I want to build the process below
- When a client presses the Book button, we need to place a hold on the credit card for the amount of the transaction
I think the hold does not charge the card, ie the money does not leave the card The hold just checks that the money is available and reserves it for a few days
Within these 7 days, I call another API to complete the charge, to cancel the hold, or just let the hold expire.
If a client books an appointment, the money goes on hold and then, after a day or so, he cancels, the hold should be released I checked the Stripe API doc, but I am not sure how to do this process. I think it must to using the paymentIntent API. Please explain to me what process I must do.
$stripe = new \Stripe\StripeClient(env('STRIPE_SECRET_KEY')); $getPaymentMethod = $stripe->paymentMethods->all([ 'customer' => $request->customerId, 'type' => 'card', ]); $createIntent = $stripe->paymentIntents->create([ 'amount' => $request->price * 100, 'currency' => 'usd', 'payment_method' => $getPaymentMethod->data[0]->id, 'payment_method_types' => [$request->paymentType], 'customer' => $request->customerId, 'capture_method' => 'manual', 'description' => 'The payment of the appointment', ]); $confirmPaymentIntent = $stripe->paymentIntents->confirm( $createIntent->id, ['payment_method' => $getPaymentMethod->data[0]->id] ); $captureIntent = $stripe->paymentIntents->retrieve($confirmPaymentIntent->id); $results = $captureIntent->capture($confirmPaymentIntent->id); return $results;
I tried this code so it is working and the payment capture. But it didn't charge the money on the stripe and the balance is $0.00. I am not sure it is correct and how to do next step for complete. Please help me. what should I?