在PHP中更新Braintree的CC信息


Update CC info of Braintree in PHP

我正在尝试更新braintree的CC信息,但在文档中提供的功能不起作用。我无法找出原因。

下面是我的函数:

public function updateCC(){
        $fname      =   $this->input->get_post('fname');
        $lname      =   $this->input->get_post('lname');
        $expirationYear   =   $this->input->get_post('expirationYear');
        $expirationMonth   =   $this->input->get_post('expirationMonth');
        $cardholderName =   $this->input->get_post('cardholderName');
        $cvv        =   $this->input->get_post('cvv');
        $cc_no      =   $this->input->get_post('cc_no');
        $token      =   $this->input->get_post('token');
        $BTCustomerID   =   $this->input->get_post('BTCustomerID ');

     $result = Braintree_Customer::update(
                $BTCustomerID,
                (
            'firstName' => $fname,
            'lastName' => $lname,
            'creditCard' => (
                      'paymentMethodNonce' => 'fake-valid-nonce',
                'options' => (
             'updateExistingToken' => $token,
                  'verifyCard' => true
                )
             )           
        ));
    echo json_encode(array('error'=>-1));
 }

由于这段代码,我的应用程序崩溃了。

 $result = Braintree_Customer::update(
            $BTCustomerID,
            (
        'firstName' => $fname,
        'lastName' => $lname,
        'creditCard' => (
                  'paymentMethodNonce' => 'fake-valid-nonce',
            'options' => (
         'updateExistingToken' => $token,
              'verifyCard' => true,
            )
         )           
    ));

我是Braintree的开发人员。在呼叫Braintree_Customer::update()时,paymentMethodNonce必须在creditCard内部传递,与options同级。在你的代码中,你正在传递options内部的it。参考代码示例