Jump to content

Knucklehead00

New Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by Knucklehead00

  1. 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); }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.