Catching Stripe errors with Try/Catch PHP method

后端 未结 6 852
独厮守ぢ
独厮守ぢ 2020-12-23 17:12

During my testing of STRIPE in a website, I built the code like this:

   try {
        $charge = Stripe_Charge::create(array(
          \"amount\" => $cli         


        
6条回答
  •  醉梦人生
    2020-12-23 17:58

    If you're using the Stripe PHP libraries and they have been namespaced (such as when they're installed via Composer) you can catch all Stripe exceptions with:

    getMessage());
    } catch (Exception $e) {
      // Catch any other non-Stripe exceptions
    }
    

提交回复
热议问题