如何测试 Braintree 交易退款?
我正在尝试对 Braintree 交易退款进行测试,但遇到了问题.Braintree 的 API 仅允许您为已结算的交易发出退款.但是,在沙盒环境中创建的交易仅每 24 小时结算"一次.因此,当我尝试在测试套件中退款时,退款总是被拒绝,因为原始交易是submitted_for_settlement"而不是settled".
I'm trying to run tests on Braintree transaction refunding, but I'm running into a problem. Braintree's API only allows you to issue refunds for transactions that have settled. However, transactions created in the sandbox environment only "settle" once every 24 hours. So, when I try to refund them in the test suite, the refunds are always rejected because the original transaction is "submitted_for_settlement" and not "settled".
有什么办法吗?
推荐答案
我在 Braintree 工作.如果您还有其他问题,可以随时与我们的支持团队联系.
Braintree PHP 库中的 TestHelper 有一种在沙盒中结算交易的方法:
The TestHelper in the Braintree PHP library has a method to settle a transaction in sandbox:
class Braintree_TestHelper
{
. . .
public static function settle($transactionId)
{
$http = new Braintree_Http(Braintree_Configuration::$global);
$path = Braintree_Configuration::$global->merchantPath() . '/transactions/' . $transactionId . '/settle';
$http->put($path);
}
. . .
}
我们支持的其他语言也有类似的方法.
Similar methods exist for our other supported languages.
相关文章