braintree 2.73.0 → 2.74.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +1 -1
- data/lib/braintree.rb +6 -0
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +18 -0
- data/lib/braintree/connected_merchant_status_transitioned.rb +18 -0
- data/lib/braintree/credit_card_verification.rb +11 -2
- data/lib/braintree/customer.rb +6 -2
- data/lib/braintree/customer_gateway.rb +8 -0
- data/lib/braintree/masterpass_card.rb +66 -0
- data/lib/braintree/payment_instrument_type.rb +2 -0
- data/lib/braintree/payment_method_gateway.rb +11 -3
- data/lib/braintree/test/nonce.rb +8 -0
- data/lib/braintree/transaction.rb +5 -1
- data/lib/braintree/transaction/masterpass_card_details.rb +33 -0
- data/lib/braintree/transaction/visa_checkout_card_details.rb +33 -0
- data/lib/braintree/util.rb +4 -0
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +74 -0
- data/lib/braintree/webhook_notification.rb +16 -1
- data/lib/braintree/webhook_testing_gateway.rb +24 -0
- data/spec/httpsd.pid +1 -1
- data/spec/integration/braintree/client_api/spec_helper.rb +16 -1
- data/spec/integration/braintree/customer_spec.rb +58 -0
- data/spec/integration/braintree/masterpass_card_spec.rb +97 -0
- data/spec/integration/braintree/payment_method_spec.rb +30 -2
- data/spec/integration/braintree/visa_checkout_card_spec.rb +110 -0
- data/spec/unit/braintree/credit_card_verification_spec.rb +8 -1
- data/spec/unit/braintree/customer_spec.rb +2 -0
- data/spec/unit/braintree/webhook_notification_spec.rb +34 -0
- metadata +187 -179
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: b5ff462a25178db818b2842f450e090a3261bf43
         | 
| 4 | 
            +
              data.tar.gz: b9274e3d1eacf63c2d6586de28b74bc971269d0f
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 26a48d433fc182bc04d3c975180426dcda4223dd1a241ad1a9e1b423b9e83a06455fd72b14645fb6c3949328de68b86f301c9b6bd14b1fb3cc731ea95263c4d7
         | 
| 7 | 
            +
              data.tar.gz: 460a9239f0c15f74d0859fcb70b0ac4625025955f3ead20b2f5a791ae55cd9468b2f963906ab28a0c624b8e8c308ca5173b94a47135787fcd2d8c6e424592924
         | 
    
        data/README.rdoc
    CHANGED
    
    
    
        data/lib/braintree.rb
    CHANGED
    
    | @@ -35,6 +35,8 @@ require "braintree/client_token" | |
| 35 35 | 
             
            require "braintree/client_token_gateway"
         | 
| 36 36 | 
             
            require "braintree/coinbase_account"
         | 
| 37 37 | 
             
            require "braintree/configuration"
         | 
| 38 | 
            +
            require "braintree/connected_merchant_status_transitioned"
         | 
| 39 | 
            +
            require "braintree/connected_merchant_paypal_status_changed"
         | 
| 38 40 | 
             
            require "braintree/credentials_parser"
         | 
| 39 41 | 
             
            require "braintree/credit_card"
         | 
| 40 42 | 
             
            require "braintree/credit_card_gateway"
         | 
| @@ -119,6 +121,8 @@ require "braintree/transaction_gateway" | |
| 119 121 | 
             
            require "braintree/transaction_search"
         | 
| 120 122 | 
             
            require "braintree/transaction/status_details"
         | 
| 121 123 | 
             
            require "braintree/transaction/venmo_account_details"
         | 
| 124 | 
            +
            require "braintree/transaction/visa_checkout_card_details"
         | 
| 125 | 
            +
            require "braintree/transaction/masterpass_card_details"
         | 
| 122 126 | 
             
            require "braintree/unknown_payment_method"
         | 
| 123 127 | 
             
            require "braintree/disbursement"
         | 
| 124 128 | 
             
            require "braintree/transparent_redirect"
         | 
| @@ -128,6 +132,8 @@ require "braintree/validation_error" | |
| 128 132 | 
             
            require "braintree/validation_error_collection"
         | 
| 129 133 | 
             
            require "braintree/venmo_account"
         | 
| 130 134 | 
             
            require "braintree/version"
         | 
| 135 | 
            +
            require "braintree/visa_checkout_card"
         | 
| 136 | 
            +
            require "braintree/masterpass_card"
         | 
| 131 137 | 
             
            require "braintree/webhook_notification"
         | 
| 132 138 | 
             
            require "braintree/webhook_notification_gateway"
         | 
| 133 139 | 
             
            require "braintree/webhook_testing"
         | 
| @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            module Braintree
         | 
| 2 | 
            +
              class ConnectedMerchantPayPalStatusChanged
         | 
| 3 | 
            +
                include BaseModule
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                attr_reader :merchant_public_id, :action, :oauth_application_client_id
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                def initialize(attributes)
         | 
| 8 | 
            +
                  set_instance_variables_from_hash(attributes)
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                class << self
         | 
| 12 | 
            +
                  protected :new
         | 
| 13 | 
            +
                  def _new(*args) # :nodoc:
         | 
| 14 | 
            +
                    self.new *args
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
            end
         | 
| @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            module Braintree
         | 
| 2 | 
            +
              class ConnectedMerchantStatusTransitioned
         | 
| 3 | 
            +
                include BaseModule
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                attr_reader :merchant_public_id, :status, :oauth_application_client_id
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                def initialize(attributes)
         | 
| 8 | 
            +
                  set_instance_variables_from_hash(attributes)
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                class << self
         | 
| 12 | 
            +
                  protected :new
         | 
| 13 | 
            +
                  def _new(*args) # :nodoc:
         | 
| 14 | 
            +
                    self.new *args
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
            end
         | 
| @@ -13,22 +13,31 @@ module Braintree | |
| 13 13 |  | 
| 14 14 | 
             
                attr_reader :avs_error_response_code, :avs_postal_code_response_code, :avs_street_address_response_code,
         | 
| 15 15 | 
             
                  :cvv_response_code, :merchant_account_id, :processor_response_code, :processor_response_text, :status,
         | 
| 16 | 
            -
                  :id, :gateway_rejection_reason, :credit_card, :billing, :created_at, | 
| 16 | 
            +
                  :amount, :currency_iso_code, :id, :gateway_rejection_reason, :credit_card, :billing, :created_at,
         | 
| 17 | 
            +
                  :risk_data
         | 
| 17 18 |  | 
| 18 19 | 
             
                def initialize(attributes) # :nodoc:
         | 
| 19 20 | 
             
                  set_instance_variables_from_hash(attributes)
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  @amount = Util.to_big_decimal(amount)
         | 
| 23 | 
            +
             | 
| 20 24 | 
             
                  @risk_data = RiskData.new(attributes[:risk_data]) if attributes[:risk_data]
         | 
| 21 25 | 
             
                end
         | 
| 22 26 |  | 
| 23 27 | 
             
                def inspect # :nodoc:
         | 
| 24 28 | 
             
                  attr_order = [
         | 
| 25 29 | 
             
                    :status, :processor_response_code, :processor_response_text,
         | 
| 30 | 
            +
                    :amount, :currency_iso_code,
         | 
| 26 31 | 
             
                    :cvv_response_code, :avs_error_response_code,
         | 
| 27 32 | 
             
                    :avs_postal_code_response_code, :avs_street_address_response_code,
         | 
| 28 33 | 
             
                    :merchant_account_id, :gateway_rejection_reason, :id, :credit_card, :billing, :created_at
         | 
| 29 34 | 
             
                  ]
         | 
| 30 35 | 
             
                  formatted_attrs = attr_order.map do |attr|
         | 
| 31 | 
            -
                     | 
| 36 | 
            +
                    if attr == :amount
         | 
| 37 | 
            +
                      Util.inspect_amount(self.amount)
         | 
| 38 | 
            +
                    else
         | 
| 39 | 
            +
                      "#{attr}: #{send(attr).inspect}"
         | 
| 40 | 
            +
                    end
         | 
| 32 41 | 
             
                  end
         | 
| 33 42 | 
             
                  "#<#{self.class} #{formatted_attrs.join(", ")}>"
         | 
| 34 43 | 
             
                end
         | 
    
        data/lib/braintree/customer.rb
    CHANGED
    
    | @@ -4,7 +4,8 @@ module Braintree | |
| 4 4 |  | 
| 5 5 | 
             
                attr_reader :addresses, :company, :created_at, :credit_cards, :email, :fax, :first_name, :id, :last_name,
         | 
| 6 6 | 
             
                  :phone, :updated_at, :website, :custom_fields, :paypal_accounts, :apple_pay_cards, :coinbase_accounts,
         | 
| 7 | 
            -
                  :android_pay_cards, :amex_express_checkout_cards, :venmo_accounts, :us_bank_accounts
         | 
| 7 | 
            +
                  :android_pay_cards, :amex_express_checkout_cards, :venmo_accounts, :us_bank_accounts, :visa_checkout_cards,
         | 
| 8 | 
            +
                  :masterpass_cards
         | 
| 8 9 |  | 
| 9 10 | 
             
                def self.all
         | 
| 10 11 | 
             
                  Configuration.gateway.customer.all
         | 
| @@ -95,6 +96,8 @@ module Braintree | |
| 95 96 | 
             
                  @amex_express_checkout_cards = (@amex_express_checkout_cards || []).map { |pm| AmexExpressCheckoutCard._new gateway, pm }
         | 
| 96 97 | 
             
                  @venmo_accounts = (@venmo_accounts || []).map { |pm| VenmoAccount._new gateway, pm }
         | 
| 97 98 | 
             
                  @us_bank_accounts = (@us_bank_accounts || []).map { |pm| UsBankAccount._new gateway, pm }
         | 
| 99 | 
            +
                  @visa_checkout_cards = (@visa_checkout_cards|| []).map { |pm| VisaCheckoutCard._new gateway, pm }
         | 
| 100 | 
            +
                  @masterpass_cards = (@masterpass_cards|| []).map { |pm| MasterpassCard._new gateway, pm }
         | 
| 98 101 | 
             
                  @addresses = (@addresses || []).map { |addr| Address._new gateway, addr }
         | 
| 99 102 | 
             
                  @custom_fields = attributes[:custom_fields].is_a?(Hash) ? attributes[:custom_fields] : {}
         | 
| 100 103 | 
             
                end
         | 
| @@ -133,7 +136,8 @@ module Braintree | |
| 133 136 | 
             
                    @android_pay_cards +
         | 
| 134 137 | 
             
                    @amex_express_checkout_cards +
         | 
| 135 138 | 
             
                    @venmo_accounts +
         | 
| 136 | 
            -
                    @us_bank_accounts
         | 
| 139 | 
            +
                    @us_bank_accounts +
         | 
| 140 | 
            +
                    @visa_checkout_cards
         | 
| 137 141 | 
             
                end
         | 
| 138 142 |  | 
| 139 143 | 
             
                def inspect # :nodoc:
         | 
| @@ -74,12 +74,16 @@ module Braintree | |
| 74 74 | 
             
                def self._create_signature # :nodoc:
         | 
| 75 75 | 
             
                  credit_card_signature = CreditCardGateway._create_signature - [:customer_id]
         | 
| 76 76 | 
             
                  paypal_account_signature = PayPalAccountGateway._create_nested_signature
         | 
| 77 | 
            +
                  options = [
         | 
| 78 | 
            +
                    :paypal => [:payee_email],
         | 
| 79 | 
            +
                  ]
         | 
| 77 80 | 
             
                  [
         | 
| 78 81 | 
             
                    :company, :email, :fax, :first_name, :id, :last_name, :phone, :website,
         | 
| 79 82 | 
             
                    :device_data, :payment_method_nonce,
         | 
| 80 83 | 
             
                    {:risk_data => [:customer_browser, :customer_ip]},
         | 
| 81 84 | 
             
                    {:credit_card => credit_card_signature},
         | 
| 82 85 | 
             
                    {:paypal_account => paypal_account_signature},
         | 
| 86 | 
            +
                    {:options => options},
         | 
| 83 87 | 
             
                    {:custom_fields => :_any_key_}
         | 
| 84 88 | 
             
                  ]
         | 
| 85 89 | 
             
                end
         | 
| @@ -125,10 +129,14 @@ module Braintree | |
| 125 129 | 
             
                  credit_card_signature = CreditCardGateway._update_signature - [:customer_id]
         | 
| 126 130 | 
             
                  credit_card_options = credit_card_signature.find { |item| item.respond_to?(:keys) && item.keys == [:options] }
         | 
| 127 131 | 
             
                  credit_card_options[:options] << :update_existing_token
         | 
| 132 | 
            +
                  options = [
         | 
| 133 | 
            +
                    :paypal => [:payee_email],
         | 
| 134 | 
            +
                  ]
         | 
| 128 135 | 
             
                  [
         | 
| 129 136 | 
             
                    :company, :email, :fax, :first_name, :id, :last_name, :phone, :website,
         | 
| 130 137 | 
             
                    :device_data, :payment_method_nonce, :default_payment_method_token,
         | 
| 131 138 | 
             
                    {:credit_card => credit_card_signature},
         | 
| 139 | 
            +
                    {:options => options},
         | 
| 132 140 | 
             
                    {:custom_fields => :_any_key_}
         | 
| 133 141 | 
             
                  ]
         | 
| 134 142 | 
             
                end
         | 
| @@ -0,0 +1,66 @@ | |
| 1 | 
            +
            module Braintree
         | 
| 2 | 
            +
              class MasterpassCard
         | 
| 3 | 
            +
                include BaseModule # :nodoc:
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                attr_reader :billing_address, :bin, :card_type, :cardholder_name,
         | 
| 6 | 
            +
                  :commercial, :country_of_issuance, :created_at, :customer_id,
         | 
| 7 | 
            +
                  :customer_location, :debit, :durbin_regulated, :expiration_month,
         | 
| 8 | 
            +
                  :expiration_year, :healthcare, :issuing_bank, :last_4, :payroll,
         | 
| 9 | 
            +
                  :prepaid, :product_id, :subscriptions, :token, :unique_number_identifier,
         | 
| 10 | 
            +
                  :updated_at, :image_url, :verification
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                def initialize(gateway, attributes) # :nodoc:
         | 
| 13 | 
            +
                  @gateway = gateway
         | 
| 14 | 
            +
                  set_instance_variables_from_hash(attributes)
         | 
| 15 | 
            +
                  @billing_address = attributes[:billing_address] ? Address._new(@gateway, attributes[:billing_address]) : nil
         | 
| 16 | 
            +
                  @subscriptions = (@subscriptions || []).map { |subscription_hash| Subscription._new(@gateway, subscription_hash) }
         | 
| 17 | 
            +
                  @verification = _most_recent_verification(attributes)
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                def _most_recent_verification(attributes)
         | 
| 21 | 
            +
                  verification = (attributes[:verifications] || []).sort_by{ |verification| verification[:created_at] }.reverse.first
         | 
| 22 | 
            +
                  CreditCardVerification._new(verification) if verification
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                def default?
         | 
| 26 | 
            +
                  @default
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                # Expiration date formatted as MM/YYYY
         | 
| 30 | 
            +
                def expiration_date
         | 
| 31 | 
            +
                  "#{expiration_month}/#{expiration_year}"
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                def expired?
         | 
| 35 | 
            +
                  @expired
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                def ==(other)
         | 
| 39 | 
            +
                  return false unless other.is_a?(MasterpassCard)
         | 
| 40 | 
            +
                  token == other.token
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                def inspect # :nodoc:
         | 
| 44 | 
            +
                  first = [:token]
         | 
| 45 | 
            +
                  order = first + (self.class._attributes - first)
         | 
| 46 | 
            +
                  nice_attributes = order.map do |attr|
         | 
| 47 | 
            +
                    "#{attr}: #{send(attr).inspect}"
         | 
| 48 | 
            +
                  end
         | 
| 49 | 
            +
                  "#<#{self.class} #{nice_attributes.join(', ')}>"
         | 
| 50 | 
            +
                end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                def self._attributes # :nodoc:
         | 
| 53 | 
            +
                  [
         | 
| 54 | 
            +
                    :billing_address, :bin, :card_type, :cardholder_name, :created_at,
         | 
| 55 | 
            +
                    :customer_id, :customer_location, :expiration_month, :expiration_year,
         | 
| 56 | 
            +
                    :last_4, :token, :updated_at, :prepaid, :payroll, :product_id,
         | 
| 57 | 
            +
                    :commercial, :debit, :durbin_regulated, :healthcare,
         | 
| 58 | 
            +
                    :country_of_issuance, :issuing_bank, :image_url
         | 
| 59 | 
            +
                  ]
         | 
| 60 | 
            +
                end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                def self._new(*args) # :nodoc:
         | 
| 63 | 
            +
                  self.new *args
         | 
| 64 | 
            +
                end
         | 
| 65 | 
            +
              end
         | 
| 66 | 
            +
            end
         | 
| @@ -31,6 +31,10 @@ module Braintree | |
| 31 31 | 
             
                    SuccessfulResult.new(:payment_method => AmexExpressCheckoutCard._new(@gateway, response[:amex_express_checkout_card]))
         | 
| 32 32 | 
             
                  elsif response[:venmo_account]
         | 
| 33 33 | 
             
                    SuccessfulResult.new(:payment_method => VenmoAccount._new(@gateway, response[:venmo_account]))
         | 
| 34 | 
            +
                  elsif response[:visa_checkout_card]
         | 
| 35 | 
            +
                    SuccessfulResult.new(:payment_method => VisaCheckoutCard._new(@gateway, response[:visa_checkout_card]))
         | 
| 36 | 
            +
                  elsif response[:masterpass_card]
         | 
| 37 | 
            +
                    SuccessfulResult.new(:payment_method => MasterpassCard._new(@gateway, response[:masterpass_card]))
         | 
| 34 38 | 
             
                  elsif response[:payment_method_nonce]
         | 
| 35 39 | 
             
                    SuccessfulResult.new(:payment_method_nonce => PaymentMethodNonce._new(@gateway, response[:payment_method_nonce]))
         | 
| 36 40 | 
             
                  elsif response[:success]
         | 
| @@ -43,7 +47,7 @@ module Braintree | |
| 43 47 | 
             
                    raise UnexpectedError, "expected :payment_method or :api_error_response"
         | 
| 44 48 | 
             
                  end
         | 
| 45 49 | 
             
                end
         | 
| 46 | 
            -
             | 
| 50 | 
            +
             | 
| 47 51 | 
             
                def delete(token, options = {})
         | 
| 48 52 | 
             
                  Util.verify_keys(PaymentMethodGateway._delete_signature, options)
         | 
| 49 53 | 
             
                  query_param = "?" + Util.hash_to_query_string(options) if not options.empty?
         | 
| @@ -137,14 +141,18 @@ module Braintree | |
| 137 141 | 
             
                def self._update_signature # :nodoc:
         | 
| 138 142 | 
             
                  _signature(:update)
         | 
| 139 143 | 
             
                end
         | 
| 140 | 
            -
             | 
| 144 | 
            +
             | 
| 141 145 | 
             
                def self._delete_signature # :nodoc:
         | 
| 142 146 | 
             
                  [:revoke_all_grants]
         | 
| 143 147 | 
             
                end
         | 
| 144 148 |  | 
| 145 149 | 
             
                def self._signature(type) # :nodoc:
         | 
| 146 150 | 
             
                  billing_address_params = AddressGateway._shared_signature
         | 
| 147 | 
            -
                  options = [ | 
| 151 | 
            +
                  options = [
         | 
| 152 | 
            +
                    :make_default, :verification_merchant_account_id, :verify_card, :venmo_sdk_session,
         | 
| 153 | 
            +
                    :verification_amount,
         | 
| 154 | 
            +
                    :paypal => [:payee_email],
         | 
| 155 | 
            +
                  ]
         | 
| 148 156 | 
             
                  signature = [
         | 
| 149 157 | 
             
                    :billing_address_id, :cardholder_name, :cvv, :device_session_id, :expiration_date,
         | 
| 150 158 | 
             
                    :expiration_month, :expiration_year, :number, :token, :venmo_sdk_payment_method_code,
         | 
    
        data/lib/braintree/test/nonce.rb
    CHANGED
    
    | @@ -45,6 +45,14 @@ module Braintree | |
| 45 45 | 
             
                  PayPalFuturePaymentRefreshToken = "fake-paypal-future-refresh-token-nonce"
         | 
| 46 46 | 
             
                  SEPA = "fake-sepa-bank-account-nonce"
         | 
| 47 47 | 
             
                  GatewayRejectedFraud = "fake-gateway-rejected-fraud-nonce"
         | 
| 48 | 
            +
                  MasterpassAmEx = "fake-masterpass-amex-nonce"
         | 
| 49 | 
            +
                  MasterpassDiscover = "fake-masterpass-discover-nonce"
         | 
| 50 | 
            +
                  MasterpassMasterCard = "fake-masterpass-mastercard-nonce"
         | 
| 51 | 
            +
                  MasterpassVisa = "fake-masterpass-visa-nonce"
         | 
| 52 | 
            +
                  VisaCheckoutAmEx = "fake-visa-checkout-amex-nonce"
         | 
| 53 | 
            +
                  VisaCheckoutDiscover = "fake-visa-checkout-discover-nonce"
         | 
| 54 | 
            +
                  VisaCheckoutMasterCard = "fake-visa-checkout-mastercard-nonce"
         | 
| 55 | 
            +
                  VisaCheckoutVisa = "fake-visa-checkout-visa-nonce"
         | 
| 48 56 |  | 
| 49 57 | 
             
                  def self.const_missing(const_name)
         | 
| 50 58 | 
             
                    if const_name == :AndroidPay
         | 
| @@ -124,6 +124,8 @@ module Braintree | |
| 124 124 | 
             
                attr_reader :three_d_secure_info
         | 
| 125 125 | 
             
                attr_reader :us_bank_account_details
         | 
| 126 126 | 
             
                attr_reader :ideal_payment_details
         | 
| 127 | 
            +
                attr_reader :visa_checkout_card_details
         | 
| 128 | 
            +
                attr_reader :masterpass_card_details
         | 
| 127 129 |  | 
| 128 130 | 
             
                def self.create(attributes)
         | 
| 129 131 | 
             
                  Configuration.gateway.transaction.create(attributes)
         | 
| @@ -271,6 +273,8 @@ module Braintree | |
| 271 273 | 
             
                  @three_d_secure_info = ThreeDSecureInfo.new(attributes[:three_d_secure_info]) if attributes[:three_d_secure_info]
         | 
| 272 274 | 
             
                  @us_bank_account_details = UsBankAccountDetails.new(attributes[:us_bank_account]) if attributes[:us_bank_account]
         | 
| 273 275 | 
             
                  @ideal_payment_details = IdealPaymentDetails.new(attributes[:ideal_payment]) if attributes[:ideal_payment]
         | 
| 276 | 
            +
                  @visa_checkout_card_details = VisaCheckoutCardDetails.new(attributes[:visa_checkout_card])
         | 
| 277 | 
            +
                  @masterpass_card_details = MasterpassCardDetails.new(attributes[:masterpass_card])
         | 
| 274 278 | 
             
                end
         | 
| 275 279 |  | 
| 276 280 | 
             
                # True if <tt>other</tt> is a Braintree::Transaction with the same id.
         | 
| @@ -284,7 +288,7 @@ module Braintree | |
| 284 288 | 
             
                  order = first + (self.class._attributes - first)
         | 
| 285 289 | 
             
                  nice_attributes = order.map do |attr|
         | 
| 286 290 | 
             
                    if attr == :amount
         | 
| 287 | 
            -
                       | 
| 291 | 
            +
                      Util.inspect_amount(self.amount)
         | 
| 288 292 | 
             
                    else
         | 
| 289 293 | 
             
                      "#{attr}: #{send(attr).inspect}"
         | 
| 290 294 | 
             
                    end
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            module Braintree
         | 
| 2 | 
            +
              class Transaction
         | 
| 3 | 
            +
                class MasterpassCardDetails # :nodoc:
         | 
| 4 | 
            +
                  include BaseModule
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  attr_reader :bin, :card_type, :cardholder_name, :commercial, :country_of_issuance,
         | 
| 7 | 
            +
                    :customer_location, :debit, :durbin_regulated, :expiration_month, :expiration_year,
         | 
| 8 | 
            +
                    :healthcare, :image_url, :issuing_bank, :last_4, :payroll, :prepaid, :product_id,
         | 
| 9 | 
            +
                    :token
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  def initialize(attributes)
         | 
| 12 | 
            +
                    set_instance_variables_from_hash attributes unless attributes.nil?
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  def expiration_date
         | 
| 16 | 
            +
                    "#{expiration_month}/#{expiration_year}"
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  def inspect
         | 
| 20 | 
            +
                    attr_order = [:token, :bin, :last_4, :card_type, :expiration_date, :cardholder_name, :customer_location, :prepaid,
         | 
| 21 | 
            +
                    :healthcare, :durbin_regulated, :debit, :commercial, :payroll, :product_id, :country_of_issuance, :issuing_bank, :image_url]
         | 
| 22 | 
            +
                    formatted_attrs = attr_order.map do |attr|
         | 
| 23 | 
            +
                      "#{attr}: #{send(attr).inspect}"
         | 
| 24 | 
            +
                    end
         | 
| 25 | 
            +
                    "#<#{formatted_attrs.join(", ")}>"
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  def masked_number
         | 
| 29 | 
            +
                    "#{bin}******#{last_4}"
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
            end
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            module Braintree
         | 
| 2 | 
            +
              class Transaction
         | 
| 3 | 
            +
                class VisaCheckoutCardDetails # :nodoc:
         | 
| 4 | 
            +
                  include BaseModule
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  attr_reader :bin, :card_type, :cardholder_name, :commercial, :country_of_issuance,
         | 
| 7 | 
            +
                    :customer_location, :debit, :durbin_regulated, :expiration_month, :expiration_year,
         | 
| 8 | 
            +
                    :healthcare, :image_url, :issuing_bank, :last_4, :payroll, :prepaid, :product_id,
         | 
| 9 | 
            +
                    :token, :call_id
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  def initialize(attributes)
         | 
| 12 | 
            +
                    set_instance_variables_from_hash attributes unless attributes.nil?
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  def expiration_date
         | 
| 16 | 
            +
                    "#{expiration_month}/#{expiration_year}"
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  def inspect
         | 
| 20 | 
            +
                    attr_order = [:token, :bin, :last_4, :card_type, :expiration_date, :cardholder_name, :customer_location, :prepaid,
         | 
| 21 | 
            +
                    :healthcare, :durbin_regulated, :debit, :commercial, :payroll, :product_id, :country_of_issuance, :issuing_bank, :image_url, :call_id]
         | 
| 22 | 
            +
                    formatted_attrs = attr_order.map do |attr|
         | 
| 23 | 
            +
                      "#{attr}: #{send(attr).inspect}"
         | 
| 24 | 
            +
                    end
         | 
| 25 | 
            +
                    "#<#{formatted_attrs.join(", ")}>"
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  def masked_number
         | 
| 29 | 
            +
                    "#{bin}******#{last_4}"
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
            end
         | 
    
        data/lib/braintree/util.rb
    CHANGED
    
    | @@ -77,6 +77,10 @@ module Braintree | |
| 77 77 | 
             
                  end
         | 
| 78 78 | 
             
                end
         | 
| 79 79 |  | 
| 80 | 
            +
                def self.inspect_amount(amount)
         | 
| 81 | 
            +
                  amount ? "amount: #{amount.to_s("F").inspect}" : "amount: nil"
         | 
| 82 | 
            +
                end
         | 
| 83 | 
            +
             | 
| 80 84 | 
             
                def self.verify_keys(valid_keys, hash)
         | 
| 81 85 | 
             
                  flattened_valid_keys = _flatten_valid_keys(valid_keys)
         | 
| 82 86 | 
             
                  invalid_keys = _flatten_hash_keys(hash) - flattened_valid_keys
         | 
    
        data/lib/braintree/version.rb
    CHANGED
    
    
| @@ -0,0 +1,74 @@ | |
| 1 | 
            +
            module Braintree
         | 
| 2 | 
            +
              class VisaCheckoutCard
         | 
| 3 | 
            +
                include BaseModule # :nodoc:
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                attr_reader :billing_address, :bin, :card_type, :cardholder_name,
         | 
| 6 | 
            +
                  :commercial, :country_of_issuance, :created_at, :customer_id,
         | 
| 7 | 
            +
                  :customer_location, :debit, :durbin_regulated, :expiration_month,
         | 
| 8 | 
            +
                  :expiration_year, :healthcare, :issuing_bank, :last_4, :payroll,
         | 
| 9 | 
            +
                  :prepaid, :product_id, :subscriptions, :token, :unique_number_identifier,
         | 
| 10 | 
            +
                  :updated_at, :image_url, :verification, :call_id
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                def initialize(gateway, attributes) # :nodoc:
         | 
| 13 | 
            +
                  @gateway = gateway
         | 
| 14 | 
            +
                  set_instance_variables_from_hash(attributes)
         | 
| 15 | 
            +
                  @billing_address = attributes[:billing_address] ? Address._new(@gateway, attributes[:billing_address]) : nil
         | 
| 16 | 
            +
                  @subscriptions = (@subscriptions || []).map { |subscription_hash| Subscription._new(@gateway, subscription_hash) }
         | 
| 17 | 
            +
                  @verification = _most_recent_verification(attributes)
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                def _most_recent_verification(attributes)
         | 
| 21 | 
            +
                  verification = (attributes[:verifications] || []).sort_by{ |verification| verification[:created_at] }.reverse.first
         | 
| 22 | 
            +
                  CreditCardVerification._new(verification) if verification
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                def default?
         | 
| 26 | 
            +
                  @default
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                # Expiration date formatted as MM/YYYY
         | 
| 30 | 
            +
                def expiration_date
         | 
| 31 | 
            +
                  "#{expiration_month}/#{expiration_year}"
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                def expired?
         | 
| 35 | 
            +
                  @expired
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                def inspect # :nodoc:
         | 
| 39 | 
            +
                  first = [:token]
         | 
| 40 | 
            +
                  order = first + (self.class._attributes - first)
         | 
| 41 | 
            +
                  nice_attributes = order.map do |attr|
         | 
| 42 | 
            +
                    "#{attr}: #{send(attr).inspect}"
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
                  "#<#{self.class} #{nice_attributes.join(', ')}>"
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                def masked_number
         | 
| 48 | 
            +
                  "#{bin}******#{last_4}"
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                def ==(other)
         | 
| 52 | 
            +
                  return false unless other.is_a?(VisaCheckoutCard)
         | 
| 53 | 
            +
                  token == other.token
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                class << self
         | 
| 57 | 
            +
                  protected :new
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                def self._attributes # :nodoc:
         | 
| 61 | 
            +
                  [
         | 
| 62 | 
            +
                    :billing_address, :bin, :card_type, :cardholder_name, :created_at,
         | 
| 63 | 
            +
                    :customer_id, :customer_location, :expiration_month, :expiration_year,
         | 
| 64 | 
            +
                    :last_4, :token, :updated_at, :prepaid, :payroll, :product_id,
         | 
| 65 | 
            +
                    :commercial, :debit, :durbin_regulated, :healthcare,
         | 
| 66 | 
            +
                    :country_of_issuance, :issuing_bank, :image_url, :call_id
         | 
| 67 | 
            +
                  ]
         | 
| 68 | 
            +
                end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                def self._new(*args) # :nodoc:
         | 
| 71 | 
            +
                  self.new *args
         | 
| 72 | 
            +
                end
         | 
| 73 | 
            +
              end
         | 
| 74 | 
            +
            end
         |