79314287

Date: 2024-12-28 17:52:51
Score: 1
Natty:
Report link

Fired when a payment session is completed, successfully or not.

This event can be used to receive interesting information for internal use, via a parameter added to your payment link. The parameter should be called "client_reference_id". For example https://buy.stripe.com/test_fZe8AdgMFewR6sM9AA?client_reference_id=10

The interesting thing you ask in the comments is: how do I know if it has finished successfully without having to listen to the payment_intent.succeeded event?

Yes, you can. If you want to be absolutely sure that the payment has been completed successfully, simply see the value .getPaymentStatus() of com.stripe.model.checkout.Session object, and check that it has the value "paid":

EventDataObjectDeserializer dataObjectDeserializer = event.getDataObjectDeserializer();
            
            
            StripeObject stripeObject = null;
            
           
            com.stripe.model.checkout.Session checkoutSession;
            
            
            if (dataObjectDeserializer.getObject().isPresent()) {
                stripeObject = dataObjectDeserializer.getObject().get();
               
                

                        // Handle the event
                  switch (event.getType()) {
                          
                        case "checkout.session.completed":
                          checkoutSession = (com.stripe.model.checkout.Session) stripeObject;


                          if(checkoutSession!=null){
                             
                               if(checkoutSession.getPaymentStatus().equals("paid")){
                                    ...
                                }


                           
Reasons:
  • Blacklisted phrase (1): how do I
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Manuel