I am finishing up getting Stripe set up to go live on a website, however seeing as users are going to be subscribing I want to protect myself from cards being declined during the subscription period (i.e. anytime after the first payment) and be notified when they are. There isn't much in depth discussion on this error handling on the Stripe site so I would just like to know if the following would execute when the card declines during the subscription seeing as I don't know of any way to test this with Stripe.
try
{
// Try to charge the customers card here, subscription
}
//In the event of a card error
catch (Stripe_CardError $e)
{
// Card was declined.
$e_json = $e->getJsonBody();
$error = $e_json['error'];
print ($error['message']);
//Send the email to notify both parties that the payment declined.
$to = $_POST['email'];
$subject = 'Your card ending in'.['last4'].'has declined';
$message = 'Please remedy the situtaion at your earliest convience, there will be another attempt to charge your card in three days';
wordwrap($message, $width=75, "
");
mail($to, $subject, $message);
}
I'm just unsure as to whether or not this would send and if not what should I add to get it to send. Thanks very much.