当前位置: 首页>>代码示例>>PHP>>正文


PHP Braintree_Customer::update方法代码示例

本文整理汇总了PHP中Braintree_Customer::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Braintree_Customer::update方法的具体用法?PHP Braintree_Customer::update怎么用?PHP Braintree_Customer::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Braintree_Customer的用法示例。


在下文中一共展示了Braintree_Customer::update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: payment

 public function payment()
 {
     $this->request->allowMethod('post');
     if (!isset($this->request->data['amount']) || empty($this->request->data['amount'])) {
         $this->redirect($this->referer());
     }
     $firstName = $lastName = '';
     $name = explode(' ', $this->currUser['User']['full_name']);
     if (count($name) > 0) {
         $firstName = array_shift($name);
         $lastName = implode(' ', $name);
     }
     $customerData = array('firstName' => $firstName, 'lastName' => $lastName, 'email' => $this->currUser['User']['username'], 'phone' => $this->currUser['User']['phone']);
     try {
         $customer = Braintree_Customer::find('konstruktor-' . $this->currUser['User']['id']);
         $customer = Braintree_Customer::update('konstruktor-' . $this->currUser['User']['id'], $customerData);
     } catch (Exception $e) {
         $customer = Braintree_Customer::create(Hash::merge(array('id' => 'konstruktor-' . $this->currUser['User']['id']), $customerData));
     }
     if ($customer->success) {
         $customer = $customer->customer;
     } else {
         throw new NotFoundException(__d('billing', 'Invalid billing group'));
     }
     $this->Session->write('Billing', array('amount' => $this->request->data['amount']));
     $this->layout = 'profile_new';
     $clientToken = Braintree_ClientToken::generate();
     $this->set('clientToken', $clientToken);
     $this->set('customer', $customer);
 }
开发者ID:nilBora,项目名称:konstruktor,代码行数:30,代码来源:BillingUserController.php

示例2: check

 public function check($customer)
 {
     if (empty($customer)) {
         $customer = $this->_controller->currUser;
     }
     $firstName = $lastName = '';
     $name = explode(' ', $customer['User']['full_name']);
     if (count($name) > 0) {
         $firstName = array_shift($name);
         $lastName = implode(' ', $name);
     }
     $customerData = array('firstName' => $firstName, 'lastName' => $lastName, 'email' => $customer['User']['username'], 'phone' => $customer['User']['phone']);
     try {
         $_customer = Braintree_Customer::find('konstruktor-' . $customer['User']['id']);
         $_customer = Braintree_Customer::update('konstruktor-' . $customer['User']['id'], $customerData);
     } catch (Exception $e) {
         $_customer = Braintree_Customer::create(Hash::merge(array('id' => 'konstruktor-' . $customer['User']['id']), $customerData));
     }
     if ($_customer->success) {
         return $_customer->customer;
     }
     return array();
 }
开发者ID:nilBora,项目名称:konstruktor,代码行数:23,代码来源:BraintreeCustomerComponent.php

示例3: getCustomer

 function getCustomer(&$order, $force = false)
 {
     global $current_user;
     //already have it?
     if (!empty($this->customer) && !$force) {
         return $this->customer;
     }
     //try based on user id
     if (!empty($order->user_id)) {
         $user_id = $order->user_id;
     }
     //if no id passed, check the current user
     if (empty($user_id) && !empty($current_user->ID)) {
         $user_id = $current_user->ID;
     }
     //check for a braintree customer id
     if (!empty($user_id)) {
         $customer_id = get_user_meta($user_id, "pmpro_braintree_customerid", true);
     }
     //check for an existing stripe customer
     if (!empty($customer_id)) {
         try {
             $this->customer = Braintree_Customer::find($customer_id);
             //update the customer address, description and card
             if (!empty($order->accountnumber)) {
                 //put data in array for Braintree API calls
                 $update_array = array('firstName' => $order->FirstName, 'lastName' => $order->LastName, 'creditCard' => array('number' => $order->braintree->number, 'expirationDate' => $order->braintree->expiration_date, 'cardholderName' => trim($order->FirstName . " " . $order->LastName), 'options' => array('updateExistingToken' => $this->customer->creditCards[0]->token)));
                 //address too?
                 if (!empty($order->billing)) {
                     //make sure Address2 is set
                     if (!isset($order->Address2)) {
                         $order->Address2 = '';
                     }
                 }
                 //add billing address to array
                 $update_array['creditCard']['billingAddress'] = array('firstName' => $order->FirstName, 'lastName' => $order->LastName, 'streetAddress' => $order->Address1, 'extendedAddress' => $order->Address2, 'locality' => $order->billing->city, 'region' => $order->billing->state, 'postalCode' => $order->billing->zip, 'countryCodeAlpha2' => $order->billing->country, 'options' => array('updateExisting' => true));
                 //update
                 $response = Braintree_Customer::update($customer_id, $update_array);
                 if ($response->success) {
                     $this->customer = $response->customer;
                     return $this->customer;
                 } else {
                     $order->error = __("Failed to update customer.", "pmpro") . " " . $response->message;
                     $order->shorterror = $order->error;
                     return false;
                 }
             }
             return $this->customer;
         } catch (Exception $e) {
             //assume no customer found
         }
     }
     //no customer id, create one
     if (!empty($order->accountnumber)) {
         try {
             $result = Braintree_Customer::create(array('firstName' => $order->FirstName, 'lastName' => $order->LastName, 'email' => $order->Email, 'phone' => $order->billing->phone, 'creditCard' => array('number' => $order->braintree->number, 'expirationDate' => $order->braintree->expiration_date, 'cvv' => $order->braintree->cvv, 'cardholderName' => trim($order->FirstName . " " . $order->LastName), 'billingAddress' => array('firstName' => $order->FirstName, 'lastName' => $order->LastName, 'streetAddress' => $order->Address1, 'extendedAddress' => $order->Address2, 'locality' => $order->billing->city, 'region' => $order->billing->state, 'postalCode' => $order->billing->zip, 'countryCodeAlpha2' => $order->billing->country))));
             if ($result->success) {
                 $this->customer = $result->customer;
             } else {
                 $order->error = __("Failed to create customer.", "pmpro") . " " . $result->message;
                 $order->shorterror = $order->error;
                 return false;
             }
         } catch (Exception $e) {
             $order->error = __("Error creating customer record with Braintree:", "pmpro") . " " . $e->getMessage();
             $order->shorterror = $order->error;
             return false;
         }
         //if we have no user id, we need to set the customer id after the user is created
         if (empty($user_id)) {
             global $pmpro_braintree_customerid;
             $pmpro_braintree_customerid = $this->customer->id;
             add_action('user_register', array('PMProGateway_braintree', 'user_register'));
         } else {
             update_user_meta($user_id, "pmpro_braintree_customerid", $this->customer->id);
         }
         return $this->customer;
     }
     return false;
 }
开发者ID:AmpleTech,项目名称:paid-memberships-pro,代码行数:80,代码来源:class.pmprogateway_braintree.php

示例4: updateCustomerId

 /**
  * Updates customer ID
  * 
  * @param string $customerId
  * @param string $newId
  */
 public function updateCustomerId($customerId, $newId)
 {
     if ($this->exists($customerId)) {
         $this->_debug("Updating customer ID {$customerId} to {$newId}");
         try {
             $result = Braintree_Customer::update($customerId, array('id' => $newId));
         } catch (Exception $e) {
             Mage::logException($e);
             $result = 'Update failed';
         }
         $this->_debug($result);
     }
 }
开发者ID:portchris,项目名称:NaturalRemedyCompany,代码行数:19,代码来源:Creditcard.php

示例5: file_put_contents

     //[ADD Customer ID to text file]
     $customer = $result->customer->id . "\r\n";
     // Write the contents to the file,
     // using the FILE_APPEND flag to append the content to the end of the file
     // and the LOCK_EX flag to prevent anyone else writing to the file at the same time
     file_put_contents($file, $customer, FILE_APPEND | LOCK_EX);
     echo "</br>";
     echo "<div> <h3>API response</h3>";
     //echo json_encode($result, JSON_PRETTY_PRINT);
     //echo json_encode($result);
     echo "<pre>";
     print_r($result);
     echo "</div>";
 } else {
     if ($_POST['_act'] == 'updateCustomer') {
         $updateResult = Braintree_Customer::update($_POST['customer_id'], array('firstName' => $_POST['firstName'], 'lastName' => $_POST['lastName'], 'company' => $_POST['company'], 'email' => $_POST['email'], 'phone' => $_POST['phone'], 'fax' => $_POST['fax'], 'website' => $_POST['website']));
         $updateResult->success;
         print_r($updateResult);
     } else {
         if ($_POST['_act'] == 'findCustomer') {
             //echo $_POST['customer_id'];
             //$_POST['customer_id'] = '57306224';
             $findResult = Braintree_Customer::find((string) $_POST['customer_id']);
             print_r($findResult);
         } else {
             if ($_POST['_act'] == 'deleteCustomer') {
                 $search = (string) $_POST['customer_id'];
                 $file = './data/customerID.txt';
                 $contents = file_get_contents($file);
                 echo $contents = str_replace($_POST['customer_id'], trim((string) $_POST['customer_id'] . "_DELETED\r\n"), $contents);
                 file_put_contents($file, $contents);
开发者ID:KLBombaStick,项目名称:BrainTree,代码行数:31,代码来源:createTrans.php

示例6: getCustomer

 function getCustomer(&$order, $force = false)
 {
     global $current_user;
     //already have it?
     if (!empty($this->customer) && !$force) {
         return $this->customer;
     }
     //try based on user id
     if (!empty($order->user_id)) {
         $user_id = $order->user_id;
     }
     //if no id passed, check the current user
     if (empty($user_id) && !empty($current_user->ID)) {
         $user_id = $current_user->ID;
     }
     //check for a braintree customer id
     if (!empty($user_id)) {
         $customer_id = get_user_meta($user_id, "pmpro_braintree_customerid", true);
     }
     //check for an existing stripe customer
     if (!empty($customer_id)) {
         try {
             $this->customer = Braintree_Customer::find($customer_id);
             //update the customer description and card
             if (!empty($order->accountnumber)) {
                 $response = Braintree_Customer::update($customer_id, array('firstName' => $order->FirstName, 'lastName' => $order->LastName, 'creditCard' => array('number' => $order->braintree->number, 'expirationDate' => $order->braintree->expiration_date, 'cardholderName' => trim($order->FirstName . " " . $order->LastName), 'options' => array('updateExistingToken' => $customer_id))));
                 if ($response->success) {
                     $this->customer = $result->customer;
                 } else {
                     $order->error = __("Failed to update customer.", "pmpro");
                     $order->shorterror = $order->error;
                     return false;
                 }
             }
             return $this->customer;
         } catch (Exception $e) {
             //assume no customer found
         }
     }
     //no customer id, create one
     if (!empty($order->accountnumber)) {
         try {
             $result = Braintree_Customer::create(array('firstName' => $order->FirstName, 'lastName' => $order->LastName, 'email' => $order->Email, 'phone' => $order->billing->phone, 'creditCard' => array('number' => $order->braintree->number, 'expirationDate' => $order->braintree->expiration_date, 'cvv' => $order->braintree->cvv, 'cardholderName' => trim($order->FirstName . " " . $order->LastName), 'billingAddress' => array('firstName' => $order->FirstName, 'lastName' => $order->LastName, 'streetAddress' => $order->Address1, 'extendedAddress' => $order->Address2, 'locality' => $order->billing->city, 'region' => $order->billing->state, 'postalCode' => $order->billing->zip, 'countryCodeAlpha2' => $order->billing->country))));
             if ($result->success) {
                 $this->customer = $result->customer;
             } else {
                 $order->error = __("Failed to create customer.", "pmpro");
                 $order->shorterror = $order->error;
                 return false;
             }
         } catch (Exception $e) {
             $order->error = __("Error creating customer record with Braintree:", "pmpro") . " " . $e->getMessage();
             $order->shorterror = $order->error;
             return false;
         }
         update_user_meta($user_id, "pmpro_braintree_customerid", $this->customer->id);
         return $this->customer;
     }
     return false;
 }
开发者ID:Willislahav,项目名称:paid-memberships-pro,代码行数:60,代码来源:class.pmprogateway_braintree.php

示例7: update

 /**
  * Updates an existing record via the API
  *
  * @param   object  $model
  * @param   array   $fields
  * @param   array   $values
  * @return  bool
  */
 public function update(Model $model, $fields = null, $values = null, $conditions = null)
 {
     $to_save = $this->_createSaveArray($fields, $values);
     if (!empty($to_save['id'])) {
         $model->id = $to_save['id'];
         unset($to_save['id']);
     }
     if (empty($model->id)) {
         false;
     }
     $entity = $this->_getModelEntity($model);
     try {
         switch ($entity) {
             case 'Customer':
                 $result = Braintree_Customer::update($model->id, $to_save);
                 break;
             case 'Transaction':
                 $transaction = $this->read($model, array('conditions' => array($model->alias . '.' . $model->primaryKey => $model->id)));
                 if (empty($transaction)) {
                     return false;
                 }
                 $exploded = explode('|', $model->id);
                 $braintree_transaction_id = isset($exploded[1]) ? $exploded[1] : $model->id;
                 if (!empty($to_save['status']) && $to_save['status'] == 'voided') {
                     if ($transaction[0][$model->alias]['status'] != 'authorized' && $transaction[0][$model->alias]['status'] != 'submitted_for_settlement') {
                         $this->showError(__('A transaction can only be VOIDED when the status is AUTHORIZED or SUBMITTED FOR SETTLEMENT.', true));
                         return false;
                     }
                     $result = Braintree_Transaction::void($braintree_transaction_id);
                     if (!$result->success) {
                         $this->showError($result->message);
                         return false;
                     }
                 } elseif (!empty($to_save['status']) && $to_save['status'] == 'submitted_for_settlement') {
                     if ($transaction[0][$model->alias]['status'] != 'authorized') {
                         $this->showError(__('A transaction can only be SUBMITTED FOR SETTLEMENT when the status is AUTHORIZED.', true));
                         return false;
                     }
                     if (!empty($to_save['amount'])) {
                         $result = Braintree_Transaction::submitForSettlement($braintree_transaction_id, $to_save['amount']);
                     } else {
                         $result = Braintree_Transaction::submitForSettlement($braintree_transaction_id);
                     }
                     if (!$result->success) {
                         $this->showError($result->message);
                         return false;
                     }
                 } else {
                     $this->showError(__('The only update that can be made to a transaction is a VOID.', true));
                     return false;
                 }
                 break;
             case 'CreditCard':
                 return false;
                 break;
             case 'Address':
                 return false;
                 break;
             default:
                 $result = false;
                 break;
         }
     } catch (Exception $e) {
         $this->showError(print_r($e, true));
         return false;
     }
     $success = $result->success;
     if (!$success) {
         return false;
     }
     return $success;
 }
开发者ID:sime,项目名称:cakephp-braintree-plugin,代码行数:80,代码来源:BraintreeSource.php

示例8: _updateCustomer

 /**
  * Updates customer id
  * 
  * @param string $customerId
  * @param string $email
  */
 protected function _updateCustomer($customerId, $email, $newId = false)
 {
     if (!$newId) {
         $newId = Mage::helper('braintree_payments')->generateCustomerId($customerId, $email);
     }
     try {
         Braintree_Customer::update($customerId, array('id' => $newId));
     } catch (Exception $e) {
         Mage::logException($e);
     }
 }
开发者ID:portchris,项目名称:NaturalRemedyCompany,代码行数:17,代码来源:braintreeIds.php

示例9: do_process

    function do_process()
    {
        $action = ym_request('action');
        if ($action == 'js') {
            header('Content-Type: text/javascript');
            ?>
jQuery(document).ready(function() {
	jQuery('.ym_braintree_button').click(function(event) {
		event.preventDefault();

		jQuery('.ym_form').slideUp();
		jQuery('#<?php 
            echo $this->code;
            ?>
_cc_form_unique_' + jQuery(this).attr('data-unique')).slideDown();
	});

	var braintree = Braintree.create("<?php 
            echo $this->encryptionkey;
            ?>
");
	jQuery('.<?php 
            echo $this->code;
            ?>
_cc_form').submit(function(e) {
		e.preventDefault();

		jQuery('.ym_braintree_icon').addClass('ym_ajax_loading_image');

		var target = jQuery(this);
		target.find('.error').remove();

		var data = jQuery(this).clone();
		data.find('#braintree_credit_card_number').val(braintree.encrypt(jQuery(this).find('#braintree_credit_card_number').val()));
		data.find('#braintree_credit_card_ccv').val(braintree.encrypt(jQuery(this).find('#braintree_credit_card_ccv').val()));
		data.find('#braintree_credit_card_exp').val(braintree.encrypt(jQuery(this).find('#braintree_credit_card_exp').val()));

		target.find('input').attr('disabled', 'disabled');

		jQuery.post('<?php 
            echo $this->action_url;
            ?>
&action=ajax', data.serialize(), function(resp) {
			jQuery('.ym_braintree_icon').removeClass('ym_ajax_loading_image');

			resp = jQuery.parseJSON(resp);
			if (resp['ok']) {
				target.find('#braintree_credit_card_number').val('');
				target.find('#braintree_credit_card_ccv').val('');
				target.find('#braintree_credit_card_exp').val('');

				jQuery('<div class="success"><p>' + resp['message'] + '</p></div>').prependTo(target);

				document.location = resp['url'];
			} else {
				target.find('input').removeAttr('disabled');
				jQuery('<div class="error"><p>' + resp['message'] + '</p></div>').prependTo(target);
			}
		});
	});
});
<?php 
            exit;
        } else {
            if ($action == 'ajax') {
                ob_start();
                $this->_braintree();
                // issue sale or subscribe
                $code = $_POST['code'];
                list($buy, $what, $pack_id, $user_id) = explode('_', $code);
                // credit card update
                $result = Braintree_Customer::update('ym_' . $user_id, array('creditCard' => array('number' => $_POST['customer']['credit_card']['number'], 'cvv' => $_POST['customer']['credit_card']['cvv'], 'expirationDate' => $_POST['customer']['credit_card']['expiration_date'])));
                if ($result->success) {
                    // grab token and subscribe
                    //				if ($pack['num_cycles'] == 1 || $planId) {
                    if ($what == 'subscription') {
                        // above catches both kinds of package/subscription
                        $pack = ym_get_pack_by_id($pack_id);
                        $planId = isset($pack['braintree_plan_id']) ? $pack['braintree_plan_id'] : false;
                        // initiate charge against just added credit card
                        if ($planId) {
                            $result = Braintree_Subscription::create(array('planId' => $planId, 'paymentMethodToken' => $result->customer->creditCards[0]->token));
                            $amount = $result->subscription->transactions[0]->amount;
                        } else {
                            $result = Braintree_Transaction::sale(array('amount' => $pack['cost'], 'options' => array('submitForSettlement' => true), 'customerId' => $result->customer->id, 'paymentMethodToken' => $result->customer->creditCards[0]->token));
                            $amount = $result->transaction->amount;
                        }
                        if ($result->success) {
                            // common
                            $this->common_process($code, $amount, true, false);
                            // thanks
                            $url = $this->redirectlogic($pack);
                            $r = array('ok' => true, 'url' => $url, 'message' => __('Payment Complete', 'ym'));
                        } else {
                            $r = $this->_failedBraintree($result, true);
                        }
                    } else {
                        if ($what == 'bundle' || $what == 'post') {
                            // post or bundle purchase
                            if ($what == 'post') {
//.........这里部分代码省略.........
开发者ID:AdultStack,项目名称:ap-members,代码行数:101,代码来源:ym_braintree.php

示例10: testUpdate_withNewCreditCardAndExistingBillingAddress

 function testUpdate_withNewCreditCardAndExistingBillingAddress()
 {
     $customer = Braintree_Customer::create()->customer;
     $address = Braintree_Address::create(array('customerId' => $customer->id, 'firstName' => 'Dan'))->address;
     $result = Braintree_Customer::update($customer->id, array('creditCard' => array('number' => '4111111111111111', 'expirationDate' => '11/14', 'billingAddressId' => $address->id)));
     $billingAddress = $result->customer->creditCards[0]->billingAddress;
     $this->assertEquals($address->id, $billingAddress->id);
     $this->assertEquals('Dan', $billingAddress->firstName);
 }
开发者ID:robelkin,项目名称:braintree_php,代码行数:9,代码来源:CustomerTest.php

示例11: update

 public function update()
 {
     $updateResult = Braintree_Customer::update('2', ['firstName' => 'New First', 'lastName' => 'New Last', 'company' => 'New Company', 'email' => 'new.email@example.com', 'phone' => 'new phone', 'fax' => 'new fax', 'website' => 'http://new.example.com']);
     $updateResult->success;
     pr($updateResult);
 }
开发者ID:CapsuleCorpIndonesia,项目名称:martabak_revolution,代码行数:6,代码来源:Payment.php

示例12: updateCustomer

 public function updateCustomer($id, $data)
 {
     $result = Braintree_Customer::update($id, $data);
     echo "<pre>";
     print_r($result);
     echo "</pre>";
     if ($result->success) {
         return array('success' => 1, 'customer_id' => $result->customer->id);
     } else {
         return array('success' => 0, 'validation_errors' => $errors);
     }
 }
开发者ID:anmolview,项目名称:yiidemos,代码行数:12,代码来源:YiiBraintree.php

示例13: testUpdate_forBillingAddressAndExistingCreditCardAndCustomerDetailsTogether

 function testUpdate_forBillingAddressAndExistingCreditCardAndCustomerDetailsTogether()
 {
     $create_result = Braintree_Customer::create(array('firstName' => 'Old First', 'lastName' => 'Old Last', 'creditCard' => array('number' => '5105105105105100', 'expirationDate' => '05/12', 'cvv' => '123', 'cardholderName' => 'Old Cardholder', 'billingAddress' => array('firstName' => 'Drew', 'lastName' => 'Smith'))));
     $this->assertEquals(true, $create_result->success);
     $customer = $create_result->customer;
     $creditCard = $customer->creditCards[0];
     $result = Braintree_Customer::update($customer->id, array('firstName' => 'New Customer First', 'lastName' => 'New Customer Last', 'creditCard' => array('number' => '4111111111111111', 'expirationDate' => '11/14', 'options' => array('updateExistingToken' => $creditCard->token), 'billingAddress' => array('firstName' => 'New Billing First', 'lastName' => 'New Billing Last', 'options' => array('updateExisting' => true)))));
     $this->assertEquals(true, $result->success);
     $this->assertEquals('New Customer First', $result->customer->firstName);
     $this->assertEquals('New Customer Last', $result->customer->lastName);
     $this->assertEquals(1, sizeof($result->customer->creditCards));
     $this->assertEquals(1, sizeof($result->customer->addresses));
     $creditCard = $result->customer->creditCards[0];
     $this->assertEquals('411111', $creditCard->bin);
     $this->assertEquals('11/2014', $creditCard->expirationDate);
     $billingAddress = $creditCard->billingAddress;
     $this->assertEquals('New Billing First', $billingAddress->firstName);
     $this->assertEquals('New Billing Last', $billingAddress->lastName);
 }
开发者ID:kingsolmn,项目名称:CakePHP-Braintree-Plugin,代码行数:19,代码来源:CustomerTest.php

示例14: testUpdate_doesNotWorkWithOnetimePayPalNonce

 function testUpdate_doesNotWorkWithOnetimePayPalNonce()
 {
     $customerResult = Braintree_Customer::create(array('creditCard' => array('number' => '5105105105105100', 'expirationDate' => '05/12', 'options' => array('makeDefault' => true))));
     $paypalAccountToken = 'PAYPALToken-' . strval(rand());
     $http = new Braintree_HttpClientApi(Braintree_Configuration::$global);
     $nonce = $http->nonceForPayPalAccount(array('paypal_account' => array('access_token' => 'PAYPAL_ACCESS_TOKEN', 'token' => $paypalAccountToken, 'options' => array('makeDefault' => true))));
     $result = Braintree_Customer::update($customerResult->customer->id, array('paymentMethodNonce' => $nonce));
     $this->assertFalse($result->success);
     $errors = $result->errors->forKey('customer')->forKey('paypalAccount')->errors;
     $this->assertEquals(Braintree_Error_Codes::PAYPAL_ACCOUNT_CANNOT_VAULT_ONE_TIME_USE_PAYPAL_ACCOUNT, $errors[0]->code);
 }
开发者ID:beevo,项目名称:disruptivestrong,代码行数:11,代码来源:CustomerTest.php

示例15: filter_var

 $phone = filter_var($phone, FILTER_VALIDATE_REGEXP, array("options" => array("regexp" => "/^\\(?(\\d{3})\\)?[-\\. ]?(\\d{3})[-\\. ]?(\\d{4})\$/")));
 if (!filter_var($phone, FILTER_VALIDATE_REGEXP, array("options" => array("regexp" => "/^\\(?(\\d{3})\\)?[-\\. ]?(\\d{3})[-\\. ]?(\\d{4})\$/")))) {
     // Not a valid US phone number
     echo 'The phone number you entered is not a valid US phone number<br><br><input type="button" value="Submit" onClick="doChangeBill();">';
     exit;
 }
 $expd = filter_input(INPUT_POST, 'expd', FILTER_SANITIZE_STRING);
 $cardn = "";
 // Verify Zip with Braintree first
 $customer = Braintree_Customer::find($un . "_FITNESS");
 $successful = false;
 if ($customer->id !== "") {
     $payToken = $customer->creditCards[0]->token;
     if (@isset($_POST['nonce'])) {
         $nonce = filter_input(INPUT_POST, 'nonce', FILTER_SANITIZE_STRING);
         $result = Braintree_Customer::update($un . "_FITNESS", array('creditCard' => array('paymentMethodNonce' => $nonce, 'options' => array('updateExistingToken' => $payToken))));
         if ($result->success) {
             $successful = true;
             $cardn = $result->customer->creditCards[0]->maskedNumber;
             $expd = $result->customer->creditCards[0]->expirationDate;
         } else {
             $error_msg = 'Update failed:';
             foreach ($result->errors->deepAll() as $error) {
                 $error_msg .= $error->code . ": " . $error->message . '<br>';
             }
             echo $error_msg . '<br><br><input type="button" value="Submit" onClick="doChangeBill();">';
             exit;
         }
     } else {
         $result = Braintree_PaymentMethod::update($payToken, array('billingAddress' => array('postalCode' => $zip, 'options' => array('updateExisting' => true)), 'expirationDate' => $expd));
         if ($result->success) {
开发者ID:beevo,项目名称:disruptivestrong,代码行数:31,代码来源:account-features.php


注:本文中的Braintree_Customer::update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。