代码之家  ›  专栏  ›  技术社区  ›  Prasad Patel

调用braintree退款时未找到类“Transaction”

  •  0
  • Prasad Patel  · 技术社区  · 7 年前

    我正在将braintree支付集成到我的应用程序中。我已经成功创建了事务,现在正在处理退款功能,return()方法在'transaction'类中,所以我尝试用'transaction::return()'调用它,但是没有被调用,而是显示了类'transaction'not found error

    require_once('../assets/plugins/braintree/includes/braintree_init.php');
    ---------
    ---------
    if(post('refund_mode') == 'braintree'){
      include_once '/var/www/vhosts/my_app_name/assets/plugins/braintree/vendor/braintree/braintree_php/lib/Braintree/Transaction.php'; 
      $result = Transaction::refund($braintree_transaction_id, $refund_amount);
      echo "<pre>"; print_r($result);exit;
    }
    

    这是调用return()方法的正确方法吗?如果不是,如何调用return()方法?有人能帮我一下吗?我犯了什么错?

    1 回复  |  直到 7 年前
        1
  •  1
  •   David    7 年前

    完全公开,我在Braintree工作。如果您还有任何问题,我建议您联系我们 support

    语法与您键入的非常接近,不过它确实取决于您使用的Braintree的phpsdk库的版本。在较新的版本中,您将需要使用实例方法而不是类方法来执行退款。如果您使用的是最新版本的SDK,则您的请求可能如下所示:

    $result = $gateway->transaction()->refund($braintree_transaction_id, $refund_amount);
    

    但是,如果您使用的是旧版本的SDK,您的请求将类似于以下内容:

    $result = Braintree_Transaction::refund($braintree_transaction_id, $refund_amount);
    

    class methods vs instance methods 了解不同之处。否则,参考 Braintree's developer documentation 可以证明有助于构造API请求。