2017-01-05 4 views
0

braintree 업데이트 방법을 사용하여 프로젝트에서 사용자의 신용 카드 정보를 업데이트해야합니다.사용자의 카드 번호없이 braintree 업데이트 방법을 사용하여 신용 카드 정보를 업데이트 할 수 있습니까?

카드의 그 갱신에 대한 내 컨트롤러의 코드 세그먼트는 다음과 같습니다 -

case 'update': 
       $expirationMonth = $this->input->post('expiration_month'); 
       $expirationYear = $this->input->post('expiration_year'); 
       if (!empty($expirationMonth) && !empty($expirationYear)) { 
        if (date('Y') > $expirationYear) { 
         die('expired'); 
        } else if ($expirationYear == date('Y')) { 
         if (date('m') > $expirationMonth) 
          die('expired'); 
        } 
       } 
       $cardId = $this->input->post('cardId'); 
       $cardNumber = $this->input->post('card_num'); 
       $streetAddress = $this->input->post('street_add'); 
       $cardCity = $this->input->post('card_city'); 
       $cardState = $this->input->post('card_state'); 
       $postalCode = $this->input->post('postal_code'); 
       $customerId = $this->input->post('customer_id'); 
       $vaultToken = $this->input->post('vault_token'); 
       $cvvCode = $this->input->post('cvv_code'); 
       $data['default_status'] = $this->input->post('default_status'); 
       $data['card_type'] = $this->input->post('cardType'); 
       $this->load->library("braintreelib"); 
       $result = Braintree_Customer::update($customerId, array(
       //we can create a credit card at the same time 
       'creditCard' => array(
        //'cardholderName' => $this->input->post('cardholder_name'), 
        //'number' => $cardNumber, 
        'expirationMonth' => $expirationMonth, 
        'expirationYear' => $expirationYear, 
        'cvv' => $cvvCode, 
        'billingAddress' => array(
         /* Optional Information you can supply */ 
         'streetAddress' => $streetAddress, 
         'locality' => $cardCity, 
         'region' => getUsStateName($cardState)->abbrev, 
         'postalCode' => $postalCode, 
        ), 
        'options' => array('verifyCard' => true) 
       ) 
       )); 
       if (isset($cardId)) { 
        if($result->success){ 
        $this->load->model('updatedetails_model'); 
        if($data['default_status']){ 
         $this->common->saveDetails(TBL_RS_PAYMENTDETAILS, array('default_status' => 0, 'card_type' => $cardType), array('currentuserid' => $currentUserId, 'currentroleid' => $this->input->post('roleId'))); 
        }  
        $cardDetailId = $this->updatedetails_model->addedit_carddetails($data, $cardId); 
        if (!$cardDetailId) { 
         echo 'error'; 
         exit; 
        } 
        }else{ 
        foreach ($result->errors->deepAll() as $error) { 
         $errorFound = $error->message . "<br />"; 
        } 
        //echo $errorFound ; 
        echo $errorFound; 
        exit; 
        } 
       } else { 
        echo 'invalidcarddetails'; 
        exit; 
       } 
       $details['carddetails'] = $this->profile->getUserCardDetailsByUserId($currentUserId); 
       foreach($details['carddetails'] as $index => $value){ 
        $paymentMethod = Braintree_PaymentMethod::find(base64_decode($value->vault_token)); 
        $details['carddetails'][$index]->lastDigit = $paymentMethod->last4; 
        $details['carddetails'][$index]->cardType = $paymentMethod->cardType; 
        $details['carddetails'][$index]->cardholderName = ucfirst($paymentMethod->cardholderName); 
       } 
       $this->data['carddetails'] = $details['carddetails']; 
       echo $b = $this->load->view('operatorCardListing', $this->data, TRUE); 
       break; 

나는이 코드를 실행하려고, 난 오류가 무엇입니까 -

신용 카드 번호를 포함해야합니다 , paymentMethodNonce 또는 venmoSdkPaymentMethodCode.

내 요구 사항은 카드 번호를 입력하지 않고 신용 카드 정보를 업데이트하는 것입니다.

신용 카드 번호없이 카드를 업데이트 할 수 있습니까?

+0

구체적으로 업데이트하려는 특정 지불 방법은 무엇입니까? – ThinkAboutIt

+0

번호가없는 카드로 클라이언트 카드를 업데이트하려고합니까? 가능한 경우 생각하지 않으므로 장바구니를 추가하면 기본적으로 확인됩니다. 카드를 지우지 않는 이유는 무엇입니까? –

답변

1

전체 공개 : 저는 Braintree에서 일합니다. 더 궁금한 점이 있으시면 support으로 연락하십시오.

신용 카드 번호를 지정하지 않고도 신용 카드를 업데이트 할 수 있습니다. Braintree는 payment method functions instead of the credit card object으로이 작업을 수행하여 웹 사이트에서 원시 신용 카드 데이터를 처리하는 것을 피할 것을 권장합니다.

게시 한 코드에 신용 카드 업데이트 전화 대신 고객 업데이트 전화가 걸립니다. 고객 업데이트 전화를 걸면 일련의 신용 카드가 발송됩니다. Braintree는 해당 배열에있는 카드를 고객 기록에 추가하여 고객을 업데이트하려고 시도합니다. 고객 업데이트 호출은 고객의 카드를 업데이트해야한다는 것을 게이트웨이에 알리지 않습니다. 고객 업데이트 전화가 아니라 [결제 방법 업데이트 전화] [pm_upadte]를 사용하는 것이 좋습니다.

만료일 또는 CVV 만 변경하는 등 카드의 일부만 업데이트하려면 결제 방법을 사용하면됩니다. 지급 방법 일짜를 tokenizing only the details that you want to change으로 작성하십시오. 변경하려는 세부 정보 만 참조하는 nonce가 있으면 payment method update call으로 전달할 수 있습니다. 이것은 PHP에서 보이는 것입니다 :

$result = Braintree_PaymentMethod::update('the_token', [ 
    'paymentMethodNonce' => 'nonce_from_your_client' 
]);