Knucklehead00 Posted October 27, 2012 Share Posted October 27, 2012 I am trying to finish up the programming work for my site's integration with a payment processor called Stripe. The last step is catching HTTP error response codes that happen during the customer creation process. In the code below, the exception will get throw when "Stripe_Customer::create" is reached if the credit card is declined or a sleuth of other things. What I want to do is take the Exception message and pass it to Smarty. Can I not do this in the Exception block? Right now, the code in the Exception block is throwing a Server Error. If I take out the code and just do a "echo $e->getMessage;", then it works just fine. Any help would be appreciated! try { $customer = Stripe_Customer::create(array( "description" => es($_POST['fname']) . " " . es($_POST['lname']), "email" => es($_POST['e-mail_add']), "card" => es($_POST['stripeToken']) )); // Validation information for card that was entered. $cvcCheck = $customer->active_card->cvc_check; $addressCheck = $customer->active_card->address_line1_check; $zipCheck = $customer->active_card->address_zip_check; // Validation checks for the card that was entered. if($cvcCheck == 'fail'){ $error = true; $smarty->assign("cvcError", true); } //If both the address and zip check failed or are left unchecked, //then the card cannot be charged properly and an error should be //displayed to the user. //If only one of them fails, then the charge can still process through //as long as the CvC is correct. if(!$error && $addressCheck != 'pass' && $zipCheck != 'pass'){ $error = true; $smarty->assign("addressError", true); } //Deleting the temporary customer. $cu = Stripe_Customer::retrieve($customer->id); $cu->delete(); } catch (Exception $e){ $errorMessage = $e->getMessage(); $smarty->assign("cardError", true); $smarty->assign("cardErrorMessage", $errorMessage); } Quote Link to comment https://forums.phpfreaks.com/topic/269964-exception-handling-issue/ Share on other sites More sharing options...
requinix Posted October 27, 2012 Share Posted October 27, 2012 The reason behind that 500 was recorded somewhere. See if you can't find it in the server logs. a sleuth of other things "slew" Quote Link to comment https://forums.phpfreaks.com/topic/269964-exception-handling-issue/#findComment-1388070 Share on other sites More sharing options...
ManiacDan Posted October 27, 2012 Share Posted October 27, 2012 "Throwing a server error" describes an infinite number of things. Be more specific. if you can't, go find the log file which contains the actual error, or just...do what you say already works. Quote Link to comment https://forums.phpfreaks.com/topic/269964-exception-handling-issue/#findComment-1388071 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.