Laravel - 用户注册以及try catch块中的条带支付

时间:2016-12-30 10:02:30

标签: php laravel laravel-5.3

我使用Laravel Cashier以及一种形式的身份验证注册,并使用try catch块对其进行处理。

try {
    // Process the credit card through Stripe
    // Register the user in the system
} catch (\Exception $e) {
    // Throw exception with error message
}

这很好用,但我想知道如果卡的处理工作会发生什么,但注册失败。

他们会收取费用而且没有帐户。

如果出现问题,您如何撤销所采取的措施?

2 个答案:

答案 0 :(得分:1)

您应该为每个进程使用不同的try / catch:

try {
  // Process the credit card through Stripe
} catch (\Exception $e) {
  // Throw exception with error message
}

第二个是注册:

try {
  // Register the user in the system
} catch (\Exception $e) {
  // Throw exception with error message
}

这样你就知道失败了。

答案 1 :(得分:0)

您应首先尝试注册过程,因为如果出现任何问题,我们可以将其恢复原状

df2 %>% View