0

I want to build the process below

  1. 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

  1. Within these 7 days, I call another API to complete the charge, to cancel the hold, or just let the hold expire.

  2. 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?

screenshot

screenshot1

  • I would start by working with https://stripe.com/docs/payments/capture-later and https://stripe.com/docs/payments/save-during-payment , hard to say more if you don't share the code you're having specific trouble with. – karllekko Sep 02 '21 at 11:57
  • Thanks for your reply. So I try this, I will share the code snip so tell me what I missing. – Alejandro Díaz Sep 02 '21 at 12:03
  • 1
    There's nothing wrong with your code. It's just the money doesn't appear in your balance for a few days (https://stripe.com/docs/payouts#standard-payout-timing) and that's how Stripe's dashboard shows it, it can be a bit confusing. Anyway if you use the API instead of the dashboard to check your `pending` balance you'll see it there. https://stripe.com/docs/api/balance/balance_retrieve – karllekko Sep 02 '21 at 13:51
  • Oh~ I got it. By the way. If I want to release this payment using another api, how to do it? Within these 7 days, I call another API to complete the charge, to cancel the hold, or just let the hold expire. – Alejandro Díaz Sep 02 '21 at 14:18
  • and then I am using the test credit card for this. so the current balance of the card is $0.00. If the card balance is $0.00, what happens to do? – Alejandro Díaz Sep 02 '21 at 14:19
  • 1
    Your first question is covered at https://stripe.com/docs/payments/capture-later#cancel-authorization . Your second question, I don't know what a "card balance" is or follow exactly what you're trying to say. – karllekko Sep 02 '21 at 14:23
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/236690/discussion-between-alejandro-diaz-and-karllekko). – Alejandro Díaz Sep 02 '21 at 15:03
  • So you mean if I do 'Canceling a PaymentIntent', the balance status is 'available'? – Alejandro Díaz Sep 02 '21 at 16:28
  • No you don't get to keep the money if you refund the payment(which is what cancelling does). If you cancel the paymentintent before capturing it you never actually had the money in your account balance(it was just being held by the customer's bank). I'd suggest asking Stripe's support team instead! – karllekko Sep 02 '21 at 16:37

0 Answers0