Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Yii2 如何在braintree付款方式中更新客户_Yii2_Braintree - Fatal编程技术网

Yii2 如何在braintree付款方式中更新客户

Yii2 如何在braintree付款方式中更新客户,yii2,braintree,Yii2,Braintree,我已经在yii2restapi中集成了braintree方法。我想更新客户,但出现以下错误: Braintree\Customer::update()缺少参数2 下面是我的代码: $braintree = Yii::$app->braintree; $response = $braintree->call('Customer', 'update','15552090',[

我已经在yii2restapi中集成了braintree方法。我想更新客户,但出现以下错误:

Braintree\Customer::update()缺少参数2

下面是我的代码:

 $braintree = Yii::$app->braintree;
       $response = $braintree->call('Customer', 'update','15552090',[                               

                                      'firstName' => 'test-1545',
                                      'lastName' => 'asdf',
                                      'company' => 'New Company',
                                      'email' => 'new.email@example.com',
                                      'phone' => 'new phone',
                                      'fax' => 'new fax',
                                      'website' => 'http://new.example.com'

                            ]);
                        print_r($response); die;

我在这里讨论如何传递参数?

这是这个特定扩展的问题。请参阅Github上的

问题OP建议使用此修复程序:

public function call($command, $method, $values, $values2 = null)
{
    $class = strtr("{class}_{command}", [
        '{class}' => $this->_prefix,
        '{command}' => $command,
    ));

    if ($values2) {
        return call_user_func(array($class, $method), $values, $values2);
    else {
        return call_user_func(array($class, $method), $values);
    }
}
扩展作者建议:

if (is_array($values)) {
   call_user_func_array(...);
} else {
   call_user_func(...);
}
无论哪种方式,您都需要使用自己的组件覆盖此组件并应用修补程序

请注意,应用程序中的代码量很小(一个文件中有64行),所以您可以创建自己的包装器或找到更好的包装器,因为这个问题仍然没有得到解决

直接使用比神奇的
call
更清晰的方法可能更好

更新:若要覆盖组件,请从bryglen的扩展创建自己的类,例如,如果使用高级应用程序,请将其放置在
common/components
文件夹中

namespace common\components;

class Braintree extends \bryglen\braintree\Braintree
{
    public function call($command, $method, $values)
    {
        // Override logic here
    }
}
然后在配置中将扩展类名替换为自定义的扩展类名:

'components' => [
    'braintree' => [
        'class' => 'common\components\Braintree',
        'environment' => 'sandbox',
        'merchantId' => 'your_merchant_id',
        'publicKey' => 'your_public_key',
        'privateKey' => 'your_private_key',
    ],
],

请提供您正在使用的扩展的参考。我正在使用以下内容。由于我是yii2的新手,请您指导我或提供如何覆盖此组件的任何提示。Thanks@Arunendra我更新了答案,更详细地说明了如何做到这一点。