Casey

Full-Stack Developer

#php

Stripe PHP Basic Error Handling

<?php
// https://stackoverflow.com/questions/17750143/catching-stripe-errors-with-try-catch-php-method

try {
  // Use a Stripe PHP library method that may throw an exception....
  \Stripe\Customer::create($args);
} catch (\Stripe\Error\Base $e) {
  // Code to do something with the $e exception object when an error occurs
  echo($e->getMessage());
} catch (Exception $e) {
  // Catch any other non-Stripe exceptions
}

?>