我正在完成将Stripe设置为在网站上生效,但是看到用户将要订阅时我想保护自己免受在订阅期间被拒绝的卡期间(即第一次付款后的任何时间),并在他们到达时得到通知。关于Stripe站点上的这个错误处理没有太多深入的讨论,所以我只想知道在订阅期间卡片拒绝时是否会执行以下操作,因为我不知道有什么方法可以用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, "\n");
mail($to, $subject, $message);
}
我只是不确定这是否会发送,如果不是我应该添加什么来让它发送。非常感谢。