我在 cron 上设置了一个 PHP 脚本,它通过 API 联系 Braintree 以查找我们存档的每个订阅的状态。然后我们根据客户的订阅状态更新我们的本地记录。因为我可以从 Braintree 控制面板手动取消订阅,所以我能够测试我的脚本可以检测到已取消的订阅。
但是,除了等待计费周期结束外,我找不到任何方法来测试逾期状态。因为 Braintree 中的计费周期最短为一个月,这使得调试我的脚本非常困难。
我知道理论上我应该只看到一个不同的订阅状态字符串,但我正在寻找一种可重现的方式来模拟逾期状态,以及正余额和 daysPastDue 的值。
有人能帮忙吗?
$BT_subscription = Braintree_Subscription::find($BT_subscription_id);
if ($BT_subscription && $BT_subscription instanceof Braintree_Subscription) {
if ($BT_subscription->status == 'Past Due' && $BT_subscription->balance > 0) {
// ...
最佳答案
我从 Braintree 支持部门收到了关于此问题的以下回复:
Because our sandbox environment is meant to replicate our production environment there is no way to force a subscription to past due. However here is a little work around that might make this testing easier:
To put a subscription in the Past Due status in the Sandbox, you can create a subscription with a trial period of one day and a price of $2000. Then, when the one day trial expires, it will trigger a transaction create that will fail because of the dollar amount.
Test Amounts for Unsuccessful Transactions 的价格可能为 2000 美元触发信用卡支付失败。我已经设置了一个测试,如果测试证明不成功,我将对此进行编辑。
关于php - 如何模拟订阅的逾期状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17666761/