lib/pay/braintree/billable.rb
# Handles Billable#customer
#
# Returns Braintree::Customer
Handles Billable#customer
Returns Braintree::Customer
Handles Billable#customer Returns Braintree :: Customer
def braintree_customer
        if processor_id?
          gateway.customer.find(processor_id)
        else
          result = gateway.customer.create(
            email: email,
            first_name: try(:first_name),
            last_name: try(:last_name),
            payment_method_nonce: card_token
          )
          raise BraintreeError.new(result), result.message unless result.success?
          update(processor: "braintree", processor_id: result.customer.id)
          if card_token.present?
            update_braintree_card_on_file result.customer.payment_methods.last
          end
          result.customer
        end
      rescue ::Braintree::AuthorizationError => e
        raise BraintreeAuthorizationError
      rescue ::Braintree::BraintreeError => e
        raise BraintreeError, e.message
      end
def braintree_customer if processor_id? gateway . customer . find ( processor_id ) else result = gateway . customer . create ( email : email , first_name : try ( :first_name ) , last_name : try ( :last_name ) , payment_method_nonce : card_token ) raise BraintreeError . new ( result ) , result . message unless result . success? update ( processor : "braintree" , processor_id : result . customer . id ) if card_token . present? update_braintree_card_on_file result . customer . payment_methods . last end result . customer end rescue :: Braintree :: AuthorizationError => e raise BraintreeAuthorizationError rescue :: Braintree :: BraintreeError => e raise BraintreeError , e . message end
Handles Billable#customer
Returns Braintree::Customer
Handles Billable#customer Returns Braintree :: Customer