php - 如何模拟订阅的逾期状态

标签 php subscriptions braintree

我在 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/

相关文章:

sql - 有没有办法查询将来的SSRS订阅时间表?

php - 在发送之前格式化文本区域(电子邮件)

PHP 正则表达式不匹配带有 s 修饰符的换行符

ios - CloudKit 的订阅不起作用

reporting-services - 有什么方法可以导出/导入 sql server 报告服务订阅?

java - Paypal REST API 中的 Braintree 计费协议(protocol) ID 查找

javascript - Cordova 和布伦特里 : PayPal login window is blank

php - 如何让 PHP Curl 请求不等待?

javascript - jQuery 验证有效,但如果条目不正确,仍然能够提交表单

braintree - 如何在 Braintree 销售交易前重新验证保险库中的信用卡