diff --git a/.rubocop.yml b/.rubocop.yml index 1931a23c..2e0a3665 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -33,6 +33,12 @@ Layout/IndentationStyle: Layout/TrailingWhitespace: Enabled: true +Lint/AmbiguousAssignment: + Enabled: true + +Lint/AmbiguousBlockAssociation: + Enabled: true + Lint/AmbiguousOperator: Enabled: true @@ -57,9 +63,20 @@ Lint/CircularArgumentReference: Lint/ConstantDefinitionInBlock: Enabled: true +# NEXT_MAJOR_VERSION add ConstantResolution rule and start changing all constants to +# SCREAMING_SNAKE_CASE +Lint/ConstantResolution: + Enabled: false + +Lint/Debugger: + Enabled: true + Lint/DeprecatedClassMethods: Enabled: true +Lint/DeprecatedConstants: + Enabled: true + Lint/DeprecatedOpenSSLConstant: Enabled: true @@ -78,6 +95,9 @@ Lint/DuplicateHashKey: Lint/DuplicateMethods: Enabled: true +Lint/DuplicateRegexpCharacterClassElement: + Enabled: true + Lint/DuplicateRequire: Enabled: true @@ -90,6 +110,15 @@ Lint/EachWithObjectArgument: Lint/ElseLayout: Enabled: true +Lint/EmptyBlock: + Enabled: true + AllowComments: true + Exclude: + - spec/integration/braintree/document_upload_spec.rb + +Lint/EmptyClass: + Enabled: true + Lint/EmptyConditionalBody: Enabled: true @@ -111,6 +140,176 @@ Lint/EmptyWhen: Lint/EnsureReturn: Enabled: true +Lint/FlipFlop: + Enabled: true + +Lint/FloatComparison: + Enabled: true + +Lint/FloatOutOfRange: + Enabled: true + +Lint/FormatParameterMismatch: + Enabled: true + +Lint/HashCompareByIdentity: + Enabled: true + +Lint/HeredocMethodCallPosition: + Enabled: true + +Lint/IdentityComparison: + Enabled: true + +Lint/ImplicitStringConcatenation: + Enabled: true + +Lint/IneffectiveAccessModifier: + Enabled: true + +Lint/InheritException: + Enabled: true + +Lint/InterpolationCheck: + Enabled: true + +Lint/LambdaWithoutLiteralBlock: + Enabled: true + +Lint/LiteralAsCondition: + Enabled: true + +Lint/LiteralInInterpolation: + Enabled: true + +Lint/Loop: + Enabled: true + +Lint/MissingCopEnableDirective: + Enabled: true + +Lint/MultipleComparison: + Enabled: true + +Lint/NestedMethodDefinition: + Enabled: true + +Lint/NestedPercentLiteral: + Enabled: true + +Lint/NextWithoutAccumulator: + Enabled: true + +Lint/NonDeterministicRequireOrder: + Enabled: true + +Lint/NoReturnInBeginEndBlocks: + Enabled: true + +Lint/NonLocalExitFromIterator: + Enabled: true + +Lint/NumberedParameterAssignment: + Enabled: true + +Lint/OrAssignmentToConstant: + Enabled: true + +Lint/OrderedMagicComments: + Enabled: true + +Lint/OutOfRangeRegexpRef: + Enabled: true + +Lint/ParenthesesAsGroupedExpression: + Enabled: true + +Lint/PercentStringArray: + Enabled: true + +Lint/PercentSymbolArray: + Enabled: true + +Lint/RaiseException: + Enabled: true + +Lint/RandOne: + Enabled: true + +Lint/RedundantCopDisableDirective: + Enabled: true + +Lint/RedundantCopEnableDirective: + Enabled: true + +Lint/RedundantDirGlobSort: + Enabled: true + +Lint/RedundantRequireStatement: + Enabled: true + +Lint/RedundantSafeNavigation: + Enabled: true + +Lint/RedundantSplatExpansion: + Enabled: true + +Lint/RedundantStringCoercion: + Enabled: true + +Lint/RedundantWithIndex: + Enabled: true + +Lint/RedundantWithObject: + Enabled: true + +Lint/RegexpAsCondition: + Enabled: true + +Lint/RequireParentheses: + Enabled: true + +Lint/RescueException: + Enabled: true + +Lint/RescueType: + Enabled: true + +Lint/ReturnInVoidContext: + Enabled: true + +Lint/SafeNavigationChain: + Enabled: true + +Lint/SafeNavigationConsistency: + Enabled: true + +Lint/SafeNavigationWithEmpty: + Enabled: true + +Lint/ScriptPermission: + Enabled: true + +Lint/SelfAssignment: + Enabled: true + +Lint/SendWithMixinArgument: + Enabled: true + +Lint/ShadowedArgument: + Enabled: true + +Lint/ShadowedException: + Enabled: true + +Lint/ShadowingOuterLocalVariable: + Enabled: true + Exclude: + - spec/**/* + +Lint/StructNewOverride: + Enabled: true + Lint/SuppressedException: Enabled: false diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ac7d982..d156b6a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,18 @@ # Changelog +## 4.16.0 + +- Add `meta_checkout_card` and `meta_checkout_token` payment methods +- Add `meta_checkout_card_details` and `meta_checkout_token_details` to Transaction +- Add `industry_data` to `Transaction.submit_for_settlement` options +- Add `dateOfBirth` and `countryCode` parameters to `Transaction.sale.industry.data` +- Add `billing_address` and `shipping_address` to `VenmoProfileData` +- Add `additional_processor_response` to `UsBankAccountVerification` +- Add `verification_add_ons` to `PaymentMethod` create options for `ACH NetworkCheck` +- Add `Maestro` to `DebitNetwork` enum + ## 4.15.0 + - Add `retry_ids`, `retried_transaction_id`, and `debit_network` to `Transaction` - Add `evidence_submittable` to Dispute - Add `implicitly_vaulted_payment_method_token` and `implicitly_vaulted_payment_method_global_id` to `LocalPaymentDetails` diff --git a/Gemfile b/Gemfile index a819ee44..981a938a 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ group :development do gem "pry", "0.13.1" gem "rake", "13.0.1" gem "rspec", "3.9.0" - gem "rubocop", "~>1.12.0" + gem "rubocop", "1.50.2" gem "webrick", "~>1.7.0" end diff --git a/lib/braintree.rb b/lib/braintree.rb index 3a45fd5e..b45dbd4a 100644 --- a/lib/braintree.rb +++ b/lib/braintree.rb @@ -3,7 +3,6 @@ require "cgi" require "date" require "digest/sha1" -require "enumerator" require "forwardable" require "logger" require "net/http" @@ -91,6 +90,8 @@ require "braintree/merchant_account/business_details" require "braintree/merchant_account/funding_details" require "braintree/merchant_account/address_details" +require "braintree/meta_checkout_card" +require "braintree/meta_checkout_token" require "braintree/oauth_gateway" require "braintree/oauth_credentials" require "braintree/payment_instrument_type" @@ -153,6 +154,8 @@ require "braintree/transaction/payment_receipt" require "braintree/transaction/payment_receipt/card_present_data.rb" require "braintree/transaction/payment_receipt/merchant_address.rb" +require "braintree/transaction/meta_checkout_card_details" +require "braintree/transaction/meta_checkout_token_details" require "braintree/transaction/paypal_details" require "braintree/transaction/paypal_here_details" require "braintree/transaction/samsung_pay_card_details" diff --git a/lib/braintree/account_updater_daily_report.rb b/lib/braintree/account_updater_daily_report.rb index 2b95ffba..a82d2338 100644 --- a/lib/braintree/account_updater_daily_report.rb +++ b/lib/braintree/account_updater_daily_report.rb @@ -1,5 +1,5 @@ module Braintree - class AccountUpdaterDailyReport # :nodoc: + class AccountUpdaterDailyReport include BaseModule attr_reader :report_date @@ -7,12 +7,12 @@ class AccountUpdaterDailyReport # :nodoc: class << self protected :new - def _new(*args) # :nodoc: + def _new(*args) self.new(*args) end end - def initialize(attributes) # :nodoc: + def initialize(attributes) set_instance_variables_from_hash(attributes) @report_date = Date.parse(report_date) end diff --git a/lib/braintree/ach_mandate.rb b/lib/braintree/ach_mandate.rb index 8241c792..2adbe9bc 100644 --- a/lib/braintree/ach_mandate.rb +++ b/lib/braintree/ach_mandate.rb @@ -1,6 +1,6 @@ module Braintree class AchMandate - include BaseModule # :nodoc: + include BaseModule attr_reader :accepted_at attr_reader :text diff --git a/lib/braintree/add_on_gateway.rb b/lib/braintree/add_on_gateway.rb index fbc00417..2bfacd70 100644 --- a/lib/braintree/add_on_gateway.rb +++ b/lib/braintree/add_on_gateway.rb @@ -1,5 +1,5 @@ module Braintree - class AddOnGateway # :nodoc + class AddOnGateway def initialize(gateway) @gateway = gateway @config = gateway.config diff --git a/lib/braintree/address.rb b/lib/braintree/address.rb index b1ff821c..21c9ae13 100644 --- a/lib/braintree/address.rb +++ b/lib/braintree/address.rb @@ -1,6 +1,6 @@ module Braintree class Address - include BaseModule # :nodoc: + include BaseModule attr_reader :company attr_reader :country_code_alpha2 @@ -44,12 +44,12 @@ def self.update!(*args) Configuration.gateway.address.update!(*args) end - def initialize(gateway, attributes) # :nodoc: + def initialize(gateway, attributes) @gateway = gateway set_instance_variables_from_hash(attributes) end - def ==(other) # :nodoc: + def ==(other) return false unless other.is_a?(Address) id == other.id && customer_id == other.customer_id end @@ -58,7 +58,7 @@ class << self protected :new end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end end diff --git a/lib/braintree/address_gateway.rb b/lib/braintree/address_gateway.rb index b11c6076..ab3a02b9 100644 --- a/lib/braintree/address_gateway.rb +++ b/lib/braintree/address_gateway.rb @@ -1,5 +1,5 @@ module Braintree - class AddressGateway # :nodoc + class AddressGateway include BaseModule def initialize(gateway) @@ -62,7 +62,7 @@ def update!(*args) return_object_or_raise(:address) { update(*args) } end - def _determine_customer_id(customer_or_customer_id) # :nodoc: + def _determine_customer_id(customer_or_customer_id) customer_id = customer_or_customer_id.is_a?(Customer) ? customer_or_customer_id.id : customer_or_customer_id unless customer_id =~ /\A[\w_-]+\z/ raise ArgumentError, "customer_id contains invalid characters" @@ -70,17 +70,17 @@ def _determine_customer_id(customer_or_customer_id) # :nodoc: customer_id end - def self._create_signature # :nodoc: + def self._create_signature _shared_signature + [:customer_id] end - def self._shared_signature # :nodoc: + def self._shared_signature [:company, :country_code_alpha2, :country_code_alpha3, :country_code_numeric, :country_name, :extended_address, :first_name, :last_name, :locality, :phone_number, :postal_code, :region, :street_address] end - def self._update_signature # :nodoc: + def self._update_signature _create_signature end end diff --git a/lib/braintree/advanced_search.rb b/lib/braintree/advanced_search.rb index 2d2c5b5e..156ab436 100644 --- a/lib/braintree/advanced_search.rb +++ b/lib/braintree/advanced_search.rb @@ -1,6 +1,6 @@ module Braintree - class AdvancedSearch # :nodoc: - class SearchNode # :nodoc: + class AdvancedSearch + class SearchNode def self.operators(*operator_names) operator_names.each do |operator| define_method(operator) do |value| @@ -14,29 +14,29 @@ def initialize(name, parent) end end - class IsNode < SearchNode # :nodoc: + class IsNode < SearchNode operators :is end - class EqualityNode < IsNode # :nodoc: + class EqualityNode < IsNode operators :is_not end - class PartialMatchNode < EqualityNode # :nodoc: + class PartialMatchNode < EqualityNode operators :ends_with, :starts_with end - class TextNode < PartialMatchNode # :nodoc: + class TextNode < PartialMatchNode operators :contains end - class KeyValueNode < SearchNode # :nodoc: + class KeyValueNode < SearchNode def is(value) @parent.add_criteria(@node_name, value) end end - class MultipleValueNode < SearchNode # :nodoc: + class MultipleValueNode < SearchNode def in(*values) values.flatten! @@ -62,7 +62,7 @@ def is(value) end end - class EndsWithNode < SearchNode # :nodoc: + class EndsWithNode < SearchNode operators :ends_with end @@ -76,7 +76,7 @@ def initialize(name, parent, options) end end - class RangeNode < SearchNode # :nodoc: + class RangeNode < SearchNode operators :is def between(min, max) diff --git a/lib/braintree/apple_pay.rb b/lib/braintree/apple_pay.rb index 63c583ad..d91ace2c 100644 --- a/lib/braintree/apple_pay.rb +++ b/lib/braintree/apple_pay.rb @@ -1,8 +1,8 @@ module Braintree class ApplePay - include BaseModule # :nodoc: + include BaseModule - def initialize(gateway, attributes) # :nodoc: + def initialize(gateway, attributes) set_instance_variables_from_hash(attributes) end @@ -10,7 +10,7 @@ class << self protected :new end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end diff --git a/lib/braintree/apple_pay_card.rb b/lib/braintree/apple_pay_card.rb index 191590fe..eb6cecba 100644 --- a/lib/braintree/apple_pay_card.rb +++ b/lib/braintree/apple_pay_card.rb @@ -1,6 +1,6 @@ module Braintree class ApplePayCard - include BaseModule # :nodoc: + include BaseModule module CardType AmEx = "Apple Pay - American Express" @@ -39,7 +39,7 @@ module CardType attr_reader :token attr_reader :updated_at - def initialize(gateway, attributes) # :nodoc: + def initialize(gateway, attributes) @gateway = gateway set_instance_variables_from_hash(attributes) @billing_address = attributes[:billing_address] ? Address._new(@gateway, attributes[:billing_address]) : nil @@ -58,7 +58,7 @@ class << self protected :new end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end end diff --git a/lib/braintree/apple_pay_options.rb b/lib/braintree/apple_pay_options.rb index 1cee1cf6..c804fe04 100644 --- a/lib/braintree/apple_pay_options.rb +++ b/lib/braintree/apple_pay_options.rb @@ -1,10 +1,10 @@ module Braintree class ApplePayOptions - include BaseModule # :nodoc: + include BaseModule attr_reader :domains - def initialize(attributes) # :nodoc: + def initialize(attributes) set_instance_variables_from_hash(attributes) end @@ -12,7 +12,7 @@ class << self protected :new end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end end diff --git a/lib/braintree/authorization_adjustment.rb b/lib/braintree/authorization_adjustment.rb index fe55377d..b8dda527 100644 --- a/lib/braintree/authorization_adjustment.rb +++ b/lib/braintree/authorization_adjustment.rb @@ -1,5 +1,5 @@ module Braintree - class AuthorizationAdjustment # :nodoc: + class AuthorizationAdjustment include BaseModule attr_reader :amount @@ -11,12 +11,12 @@ class AuthorizationAdjustment # :nodoc: class << self protected :new - def _new(*args) # :nodoc: + def _new(*args) self.new(*args) end end - def initialize(attributes) # :nodoc: + def initialize(attributes) set_instance_variables_from_hash(attributes) end end diff --git a/lib/braintree/base_module.rb b/lib/braintree/base_module.rb index f68dbd28..abcff495 100644 --- a/lib/braintree/base_module.rb +++ b/lib/braintree/base_module.rb @@ -1,5 +1,5 @@ module Braintree - module BaseModule # :nodoc: all + module BaseModule module Methods def return_object_or_raise(object_to_return) result = yield diff --git a/lib/braintree/bin_data.rb b/lib/braintree/bin_data.rb index 57090513..f49d46c9 100644 --- a/lib/braintree/bin_data.rb +++ b/lib/braintree/bin_data.rb @@ -1,5 +1,5 @@ module Braintree - class BinData # :nodoc: + class BinData include BaseModule attr_reader :commercial @@ -23,7 +23,7 @@ def inspect "#<#{self.class} #{formatted_attributes.join(", ")}>" end - def self._attributes # :nodoc: + def self._attributes [ :commercial, :country_of_issuance, :debit, :durbin_regulated, :healthcare, :issuing_bank, :payroll, :prepaid, :product_id diff --git a/lib/braintree/client_token_gateway.rb b/lib/braintree/client_token_gateway.rb index 66ede8d4..5161b67c 100644 --- a/lib/braintree/client_token_gateway.rb +++ b/lib/braintree/client_token_gateway.rb @@ -25,7 +25,7 @@ def generate(options={}) end end - def self._generate_signature # :nodoc: + def self._generate_signature [ :address_id, :customer_id, :proxy_merchant_id, :merchant_account_id, :version, diff --git a/lib/braintree/configuration.rb b/lib/braintree/configuration.rb index f9a2d10a..3fc8c871 100644 --- a/lib/braintree/configuration.rb +++ b/lib/braintree/configuration.rb @@ -1,8 +1,9 @@ module Braintree class Configuration - API_VERSION = "6" # :nodoc: - DEFAULT_ENDPOINT = "api" # :nodoc: - GRAPHQL_API_VERSION = "2018-09-10" # :nodoc: + API_VERSION = "6" + DEFAULT_ENDPOINT = "api" + # NEXT_MAJOR_VERSION update to the latest version of GraphQL API + GRAPHQL_API_VERSION = "2018-09-10" READABLE_ATTRIBUTES = [ :merchant_id, @@ -47,18 +48,17 @@ class << self attr_reader(*NON_REQUIRED_READABLE_ATTRIBUTES) attr_writer(*WRITABLE_ATTRIBUTES) - def self.expectant_reader(*attributes) # :nodoc: + def self.expectant_reader(*attributes) attributes.each do |attribute| (class << self; self; end).send(:define_method, attribute) do attribute_value = instance_variable_get("@#{attribute}") - raise ConfigurationError.new("Braintree::Configuration.#{attribute.to_s} needs to be set") if attribute_value.nil? || attribute_value.to_s.empty? + raise ConfigurationError.new("Braintree::Configuration.#{attribute} needs to be set") if attribute_value.nil? || attribute_value.to_s.empty? attribute_value end end end expectant_reader(*READABLE_ATTRIBUTES) - # Sets the Braintree environment to use. Valid values are :sandbox and :production def self.environment=(env) env = env.to_sym unless [:development, :qa, :sandbox, :production].include?(env) @@ -67,11 +67,11 @@ def self.environment=(env) @environment = env end - def self.gateway # :nodoc: + def self.gateway Braintree::Gateway.new(instantiate) end - def self.instantiate # :nodoc: + def self.instantiate config = new( :custom_user_agent => @custom_user_agent, :endpoint => @endpoint, @@ -158,15 +158,15 @@ def _check_for_mixed_environment(options_environment, token_environment) end end - def api_version # :nodoc: + def api_version API_VERSION end - def graphql_api_version # :nodoc: + def graphql_api_version GRAPHQL_API_VERSION end - def base_merchant_path # :nodoc: + def base_merchant_path "/merchants/#{merchant_id}" end @@ -178,11 +178,11 @@ def graphql_base_url "#{protocol}://#{graphql_server}:#{graphql_port}/graphql" end - def base_merchant_url # :nodoc: + def base_merchant_url "#{base_url}#{base_merchant_path}" end - def ca_file # :nodoc: + def ca_file File.expand_path(File.join(File.dirname(__FILE__), "..", "ssl", "api_braintreegateway_com.ca.crt")) end @@ -190,7 +190,7 @@ def endpoint @endpoint || DEFAULT_ENDPOINT end - def http # :nodoc: + def http Http.new(self) end @@ -202,7 +202,7 @@ def logger @logger ||= self.class._default_logger end - def port # :nodoc: + def port case @environment when :development, :integration ENV["GATEWAY_PORT"] || 3000 @@ -211,7 +211,7 @@ def port # :nodoc: end end - def graphql_port # :nodoc: + def graphql_port case @environment when :development, :integration ENV["GRAPHQL_PORT"] || 8080 @@ -220,7 +220,7 @@ def graphql_port # :nodoc: end end - def protocol # :nodoc: + def protocol ssl? ? "https" : "http" end @@ -232,7 +232,7 @@ def http_read_timeout @http_read_timeout end - def server # :nodoc: + def server case @environment when :development, :integration ENV["GATEWAY_HOST"] || "localhost" @@ -245,7 +245,7 @@ def server # :nodoc: end end - def graphql_server # :nodoc: + def graphql_server case @environment when :development, :integration ENV["GRAPHQL_HOST"] || "graphql.bt.local" @@ -271,7 +271,7 @@ def auth_url end end - def ssl? # :nodoc: + def ssl? case @environment when :development, :integration false @@ -280,12 +280,12 @@ def ssl? # :nodoc: end end - def user_agent # :nodoc: + def user_agent base_user_agent = "Braintree Ruby Gem #{Braintree::Version::String}" @custom_user_agent ? "#{base_user_agent} (#{@custom_user_agent})" : base_user_agent end - def self._default_logger # :nodoc: + def self._default_logger logger = Logger.new(STDOUT) logger.level = Logger::INFO logger diff --git a/lib/braintree/connected_merchant_paypal_status_changed.rb b/lib/braintree/connected_merchant_paypal_status_changed.rb index f8f7a79b..89f4fd27 100644 --- a/lib/braintree/connected_merchant_paypal_status_changed.rb +++ b/lib/braintree/connected_merchant_paypal_status_changed.rb @@ -14,7 +14,7 @@ def initialize(attributes) class << self protected :new - def _new(*args) # :nodoc: + def _new(*args) self.new(*args) end end diff --git a/lib/braintree/connected_merchant_status_transitioned.rb b/lib/braintree/connected_merchant_status_transitioned.rb index 24143519..2f80d7e9 100644 --- a/lib/braintree/connected_merchant_status_transitioned.rb +++ b/lib/braintree/connected_merchant_status_transitioned.rb @@ -14,7 +14,7 @@ def initialize(attributes) class << self protected :new - def _new(*args) # :nodoc: + def _new(*args) self.new(*args) end end diff --git a/lib/braintree/credit_card.rb b/lib/braintree/credit_card.rb index 9a28eb8d..292d5de6 100644 --- a/lib/braintree/credit_card.rb +++ b/lib/braintree/credit_card.rb @@ -1,6 +1,6 @@ module Braintree class CreditCard - include BaseModule # :nodoc: + include BaseModule include Braintree::Util::TokenEquality module CardType @@ -25,6 +25,7 @@ module CardType module DebitNetwork Accel = "ACCEL" + Maestro = "MAESTRO" Nyce = "NYCE" Pulse = "PULSE" Star = "STAR" @@ -124,7 +125,7 @@ def self.update!(*args) Configuration.gateway.credit_card.update!(*args) end - def initialize(gateway, attributes) # :nodoc: + def initialize(gateway, attributes) @gateway = gateway set_instance_variables_from_hash(attributes) @billing_address = attributes[:billing_address] ? Address._new(@gateway, attributes[:billing_address]) : nil @@ -133,11 +134,10 @@ def initialize(gateway, attributes) # :nodoc: end def _most_recent_verification(attributes) - verification = (attributes[:verifications] || []).sort_by { |verification| verification[:created_at] }.reverse.first - CreditCardVerification._new(verification) if verification + sorted_verifications = (attributes[:verifications] || []).sort_by { |verification| verification[:created_at] }.reverse.first + CreditCardVerification._new(sorted_verifications) if sorted_verifications end - # Returns true if this credit card is the customer's default payment method. def default? @default end @@ -147,12 +147,11 @@ def expiration_date "#{expiration_month}/#{expiration_year}" end - # Returns true if the credit card is expired. def expired? @expired end - def inspect # :nodoc: + def inspect first = [:token] order = first + (self.class._attributes - first) nice_attributes = order.map do |attr| @@ -169,6 +168,7 @@ def nonce @nonce ||= PaymentMethodNonce.create(token) end + # NEXT_MAJOR_VERSION can this be removed? Venmo SDK integration is no more # Returns true if the card is associated with Venmo SDK # NEXT_MAJOR_VERSION Remove this method # The old venmo SDK class has been deprecated @@ -185,7 +185,7 @@ class << self protected :new end - def self._attributes # :nodoc: + def self._attributes [ :billing_address, :bin, :card_type, :cardholder_name, :created_at, :customer_id, :expiration_month, :expiration_year, :last_4, :token, :updated_at, :prepaid, :payroll, :product_id, :commercial, :debit, :durbin_regulated, @@ -193,7 +193,7 @@ def self._attributes # :nodoc: ] end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end end diff --git a/lib/braintree/credit_card_gateway.rb b/lib/braintree/credit_card_gateway.rb index 44cadbf8..9ab58c9f 100644 --- a/lib/braintree/credit_card_gateway.rb +++ b/lib/braintree/credit_card_gateway.rb @@ -1,5 +1,5 @@ module Braintree - class CreditCardGateway # :nodoc: + class CreditCardGateway include BaseModule def initialize(gateway) @@ -77,15 +77,15 @@ def update!(*args) return_object_or_raise(:credit_card) { update(*args) } end - def self._create_signature # :nodoc: + def self._create_signature _signature(:create) end - def self._update_signature # :nodoc: + def self._update_signature _signature(:update) end - def self._signature(type) # :nodoc: + def self._signature(type) billing_address_params = AddressGateway._shared_signature # NEXT_MAJOR_VERSION Remove venmo_sdk_session # The old venmo SDK class has been deprecated @@ -136,7 +136,7 @@ def self._signature(type) # :nodoc: return signature end - def _do_create(path, params=nil) # :nodoc: + def _do_create(path, params=nil) response = @config.http.post("#{@config.base_merchant_path}#{path}", params) if response[:credit_card] SuccessfulResult.new(:credit_card => CreditCard._new(@gateway, response[:credit_card])) @@ -147,7 +147,7 @@ def _do_create(path, params=nil) # :nodoc: end end - def _do_update(http_verb, path, params) # :nodoc: + def _do_update(http_verb, path, params) response = @config.http.send(http_verb, "#{@config.base_merchant_path}#{path}", params) if response[:credit_card] SuccessfulResult.new(:credit_card => CreditCard._new(@gateway, response[:credit_card])) @@ -158,13 +158,13 @@ def _do_update(http_verb, path, params) # :nodoc: end end - def _fetch_expired(ids) # :nodoc: + def _fetch_expired(ids) response = @config.http.post("#{@config.base_merchant_path}/payment_methods/all/expired", :search => {:ids => ids}) attributes = response[:payment_methods] Util.extract_attribute_as_array(attributes, :credit_card).map { |attrs| CreditCard._new(@gateway, attrs) } end - def _fetch_expiring_between(formatted_start_date, formatted_end_date, ids) # :nodoc: + def _fetch_expiring_between(formatted_start_date, formatted_end_date, ids) response = @config.http.post( "#{@config.base_merchant_path}/payment_methods/all/expiring?start=#{formatted_start_date}&end=#{formatted_end_date}", :search => {:ids => ids}, diff --git a/lib/braintree/credit_card_verification.rb b/lib/braintree/credit_card_verification.rb index b7d79f9d..a29fb468 100644 --- a/lib/braintree/credit_card_verification.rb +++ b/lib/braintree/credit_card_verification.rb @@ -48,7 +48,7 @@ module Status attr_reader :three_d_secure_info attr_reader :status - def initialize(attributes) # :nodoc: + def initialize(attributes) set_instance_variables_from_hash(attributes) @amount = Util.to_big_decimal(amount) @@ -57,7 +57,7 @@ def initialize(attributes) # :nodoc: @three_d_secure_info = ThreeDSecureInfo.new(attributes[:three_d_secure_info]) if attributes[:three_d_secure_info] end - def inspect # :nodoc: + def inspect attr_order = [ :status, :processor_response_code, @@ -91,7 +91,7 @@ class << self protected :new end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end diff --git a/lib/braintree/credit_card_verification_search.rb b/lib/braintree/credit_card_verification_search.rb index b43acfae..0333efb9 100644 --- a/lib/braintree/credit_card_verification_search.rb +++ b/lib/braintree/credit_card_verification_search.rb @@ -1,5 +1,5 @@ module Braintree - class CreditCardVerificationSearch < AdvancedSearch # :nodoc: + class CreditCardVerificationSearch < AdvancedSearch text_fields( :billing_address_details_postal_code, :credit_card_cardholder_name, diff --git a/lib/braintree/customer.rb b/lib/braintree/customer.rb index 093a44c9..2018bc62 100644 --- a/lib/braintree/customer.rb +++ b/lib/braintree/customer.rb @@ -67,7 +67,6 @@ def self.search(&block) Configuration.gateway.customer.search(&block) end - # Returns a ResourceCollection of transactions for the customer with the given +customer_id+. def self.transactions(*args) Configuration.gateway.customer.transactions(*args) end @@ -80,7 +79,7 @@ def self.update!(*args) Configuration.gateway.customer.update!(*args) end - def initialize(gateway, attributes) # :nodoc: + def initialize(gateway, attributes) @gateway = gateway set_instance_variables_from_hash(attributes) @credit_cards = (@credit_cards || []).map { |pm| CreditCard._new gateway, pm } @@ -105,7 +104,6 @@ def credit!(transaction_attributes) return_object_or_raise(:transaction) { credit(transaction_attributes) } end - # Returns the customer's default payment method. def default_payment_method payment_methods.find { |payment_instrument| payment_instrument.default? } end @@ -114,7 +112,6 @@ def delete @gateway.customer.delete(id) end - # Returns the customer's payment methods def payment_methods @credit_cards + @paypal_accounts + @@ -127,7 +124,7 @@ def payment_methods @sepa_direct_debit_accounts end - def inspect # :nodoc: + def inspect first = [:id] last = [:addresses, :credit_cards, :paypal_accounts, :tax_identifiers] order = first + (self.class._attributes - first - last) + last @@ -137,7 +134,6 @@ def inspect # :nodoc: "#<#{self.class} #{nice_attributes.join(', ')}>" end - # Returns a ResourceCollection of transactions for the customer. def transactions(options = {}) @gateway.customer.transactions(id, options) end @@ -146,18 +142,18 @@ class << self protected :new end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end - def self._attributes # :nodoc: + def self._attributes [ :addresses, :company, :credit_cards, :email, :fax, :first_name, :id, :last_name, :phone, :website, :created_at, :updated_at, :tax_identifiers ] end - def self._now_timestamp # :nodoc: + def self._now_timestamp Time.now.to_i end end diff --git a/lib/braintree/customer_gateway.rb b/lib/braintree/customer_gateway.rb index 443206b4..bfbf8004 100644 --- a/lib/braintree/customer_gateway.rb +++ b/lib/braintree/customer_gateway.rb @@ -1,5 +1,5 @@ module Braintree - class CustomerGateway # :nodoc: + class CustomerGateway include BaseModule def initialize(gateway) @@ -60,7 +60,7 @@ def update!(*args) return_object_or_raise(:customer) { update(*args) } end - def self._create_signature # :nodoc: + def self._create_signature credit_card_signature = CreditCardGateway._create_signature - [:customer_id] paypal_account_signature = PayPalAccountGateway._create_nested_signature paypal_options_shipping_signature = AddressGateway._shared_signature @@ -86,7 +86,7 @@ def self._create_signature # :nodoc: ] end - def _do_create(path, params=nil) # :nodoc: + def _do_create(path, params=nil) response = @config.http.post("#{@config.base_merchant_path}#{path}", params) if response[:customer] SuccessfulResult.new(:customer => Customer._new(@gateway, response[:customer])) @@ -97,7 +97,7 @@ def _do_create(path, params=nil) # :nodoc: end end - def _do_update(http_verb, path, params) # :nodoc: + def _do_update(http_verb, path, params) response = @config.http.send(http_verb, "#{@config.base_merchant_path}#{path}", params) if response[:customer] SuccessfulResult.new(:customer => Customer._new(@gateway, response[:customer])) @@ -108,14 +108,14 @@ def _do_update(http_verb, path, params) # :nodoc: end end - def _fetch_customers(search, ids) # :nodoc: + def _fetch_customers(search, ids) search.ids.in ids response = @config.http.post("#{@config.base_merchant_path}/customers/advanced_search", {:search => search.to_hash}) attributes = response[:customers] Util.extract_attribute_as_array(attributes, :customer).map { |attrs| Customer._new(@gateway, attrs) } end - def _fetch_transactions(customer_id, ids) # :nodoc: + def _fetch_transactions(customer_id, ids) response = @config.http.post("#{@config.base_merchant_path}/customers/#{customer_id}/transactions", :search => {:ids => ids}) attributes = response[:credit_card_transactions] Util.extract_attribute_as_array(attributes, :transaction).map do |transaction_attributes| @@ -123,7 +123,7 @@ def _fetch_transactions(customer_id, ids) # :nodoc: end end - def self._update_signature # :nodoc: + def self._update_signature credit_card_signature = CreditCardGateway._update_signature - [:customer_id] credit_card_options = credit_card_signature.find { |item| item.respond_to?(:keys) && item.keys == [:options] } credit_card_options[:options] << :update_existing_token diff --git a/lib/braintree/customer_search.rb b/lib/braintree/customer_search.rb index 1337e11b..5476f82e 100644 --- a/lib/braintree/customer_search.rb +++ b/lib/braintree/customer_search.rb @@ -1,5 +1,5 @@ module Braintree - class CustomerSearch < AdvancedSearch # :nodoc: + class CustomerSearch < AdvancedSearch text_fields( :address_country_name, :address_extended_address, diff --git a/lib/braintree/descriptor.rb b/lib/braintree/descriptor.rb index 3197a126..18f8e0ca 100644 --- a/lib/braintree/descriptor.rb +++ b/lib/braintree/descriptor.rb @@ -1,5 +1,5 @@ module Braintree - class Descriptor # :nodoc: + class Descriptor include BaseModule attr_reader :name diff --git a/lib/braintree/digest.rb b/lib/braintree/digest.rb index 2e2d45bf..61cad483 100644 --- a/lib/braintree/digest.rb +++ b/lib/braintree/digest.rb @@ -1,5 +1,5 @@ module Braintree - module Digest # :nodoc: + module Digest def self.hexdigest(private_key, string) _hmac_sha1(private_key, string) end diff --git a/lib/braintree/disbursement.rb b/lib/braintree/disbursement.rb index a275a721..25155945 100644 --- a/lib/braintree/disbursement.rb +++ b/lib/braintree/disbursement.rb @@ -20,7 +20,7 @@ module Types alias_method :success?, :success - def initialize(gateway, attributes) # :nodoc: + def initialize(gateway, attributes) @gateway = gateway set_instance_variables_from_hash(attributes) @amount = Util.to_big_decimal(amount) @@ -34,10 +34,10 @@ def transactions end end - def inspect # :nodoc: + def inspect nice_attributes = self.class._inspect_attributes.map { |attr| "#{attr}: #{send(attr).inspect}" } nice_attributes << "amount: #{self.amount.to_s("F").inspect}" - nice_attributes << "disbursement_date: #{self.disbursement_date.to_s}" + nice_attributes << "disbursement_date: #{self.disbursement_date}" "#<#{self.class} #{nice_attributes.join(', ')}>" end @@ -51,12 +51,12 @@ def credit? class << self protected :new - def _new(*args) # :nodoc: + def _new(*args) self.new(*args) end end - def self._inspect_attributes # :nodoc: + def self._inspect_attributes [:id, :exception_message, :follow_up_action, :merchant_account, :transaction_ids, :retry, :success] end end diff --git a/lib/braintree/discount_gateway.rb b/lib/braintree/discount_gateway.rb index c884e0b3..05af8e0b 100644 --- a/lib/braintree/discount_gateway.rb +++ b/lib/braintree/discount_gateway.rb @@ -1,5 +1,5 @@ module Braintree - class DiscountGateway # :nodoc + class DiscountGateway def initialize(gateway) @gateway = gateway @config = gateway.config diff --git a/lib/braintree/dispute.rb b/lib/braintree/dispute.rb index c65e6f6f..312d1178 100644 --- a/lib/braintree/dispute.rb +++ b/lib/braintree/dispute.rb @@ -1,5 +1,5 @@ module Braintree - class Dispute # :nodoc: + class Dispute include BaseModule include Braintree::Util::IdEquality @@ -97,7 +97,7 @@ module PreDisputeProgram class << self protected :new - def _new(*args) # :nodoc: + def _new(*args) self.new(*args) end end @@ -130,7 +130,7 @@ def self.search(&block) Configuration.gateway.dispute.search(&block) end - def initialize(attributes) # :nodoc: + def initialize(attributes) set_instance_variables_from_hash(attributes) @date_opened = Date.parse(date_opened) unless date_opened.nil? @date_won = Date.parse(date_won) unless date_won.nil? diff --git a/lib/braintree/dispute/evidence.rb b/lib/braintree/dispute/evidence.rb index a3074531..e71a5e31 100644 --- a/lib/braintree/dispute/evidence.rb +++ b/lib/braintree/dispute/evidence.rb @@ -1,6 +1,6 @@ module Braintree class Dispute - class Evidence # :nodoc: + class Evidence include BaseModule attr_reader :category, diff --git a/lib/braintree/dispute/paypal_message.rb b/lib/braintree/dispute/paypal_message.rb index 5d8d545a..9fca00ac 100644 --- a/lib/braintree/dispute/paypal_message.rb +++ b/lib/braintree/dispute/paypal_message.rb @@ -1,6 +1,6 @@ module Braintree class Dispute - class PayPalMessage # :nodoc: + class PayPalMessage include BaseModule attr_reader :message, diff --git a/lib/braintree/dispute/status_history.rb b/lib/braintree/dispute/status_history.rb index c503a4e5..086c8bb9 100644 --- a/lib/braintree/dispute/status_history.rb +++ b/lib/braintree/dispute/status_history.rb @@ -1,6 +1,6 @@ module Braintree class Dispute - class StatusHistory # :nodoc: + class StatusHistory include BaseModule attr_reader :disbursement_date diff --git a/lib/braintree/dispute/transaction.rb b/lib/braintree/dispute/transaction.rb index 511ba358..016ee75c 100644 --- a/lib/braintree/dispute/transaction.rb +++ b/lib/braintree/dispute/transaction.rb @@ -1,6 +1,6 @@ module Braintree class Dispute - class Transaction # :nodoc: + class Transaction include BaseModule attr_reader :amount diff --git a/lib/braintree/dispute/transaction_details.rb b/lib/braintree/dispute/transaction_details.rb index f00535ef..a478eb3c 100644 --- a/lib/braintree/dispute/transaction_details.rb +++ b/lib/braintree/dispute/transaction_details.rb @@ -1,6 +1,6 @@ module Braintree class Dispute - class TransactionDetails # :nodoc: + class TransactionDetails include BaseModule attr_reader :amount diff --git a/lib/braintree/dispute_gateway.rb b/lib/braintree/dispute_gateway.rb index 99637fbc..e47e53e7 100644 --- a/lib/braintree/dispute_gateway.rb +++ b/lib/braintree/dispute_gateway.rb @@ -1,5 +1,5 @@ module Braintree - class DisputeGateway # :nodoc: + class DisputeGateway def initialize(gateway) @gateway = gateway @config = gateway.config diff --git a/lib/braintree/dispute_search.rb b/lib/braintree/dispute_search.rb index 1706f076..f694ec4d 100644 --- a/lib/braintree/dispute_search.rb +++ b/lib/braintree/dispute_search.rb @@ -1,5 +1,5 @@ module Braintree - class DisputeSearch < AdvancedSearch # :nodoc: + class DisputeSearch < AdvancedSearch text_fields( :case_number, :customer_id, diff --git a/lib/braintree/document_upload.rb b/lib/braintree/document_upload.rb index 646d551e..a6387adb 100644 --- a/lib/braintree/document_upload.rb +++ b/lib/braintree/document_upload.rb @@ -23,13 +23,13 @@ def self.create!(*args) Configuration.gateway.document_upload.create!(*args) end - def initialize(attributes) # :nodoc: + def initialize(attributes) set_instance_variables_from_hash(attributes) end class << self protected :new - def _new(*args) # :nodoc: + def _new(*args) self.new(*args) end end diff --git a/lib/braintree/document_upload_gateway.rb b/lib/braintree/document_upload_gateway.rb index 77c22590..ad14c3aa 100644 --- a/lib/braintree/document_upload_gateway.rb +++ b/lib/braintree/document_upload_gateway.rb @@ -1,5 +1,5 @@ module Braintree - class DocumentUploadGateway # :nodoc: + class DocumentUploadGateway include BaseModule def initialize(gateway) @@ -17,14 +17,14 @@ def create!(*args) return_object_or_raise(:document_upload) { create(*args) } end - def self._create_signature # :nodoc: + def self._create_signature [ :kind, :file ] end - def _do_create(path, params, file) # :nodoc: + def _do_create(path, params, file) response = @config.http.post("#{@config.base_merchant_path}#{path}", params, file) if response[:document_upload] SuccessfulResult.new(:document_upload => DocumentUpload._new(response[:document_upload])) diff --git a/lib/braintree/enriched_customer_data.rb b/lib/braintree/enriched_customer_data.rb index 635d0d41..3cd8787e 100644 --- a/lib/braintree/enriched_customer_data.rb +++ b/lib/braintree/enriched_customer_data.rb @@ -5,7 +5,7 @@ class EnrichedCustomerData attr_reader :fields_updated attr_reader :profile_data - def initialize(attributes) # :nodoc: + def initialize(attributes) set_instance_variables_from_hash(attributes) @profile_data = VenmoProfileData._new(attributes[:profile_data]) end @@ -14,7 +14,7 @@ class << self protected :new end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end end diff --git a/lib/braintree/error_result.rb b/lib/braintree/error_result.rb index 53fe7205..48c44658 100644 --- a/lib/braintree/error_result.rb +++ b/lib/braintree/error_result.rb @@ -10,7 +10,7 @@ class ErrorResult attr_reader :transaction attr_reader :verification - def initialize(gateway, data) # :nodoc: + def initialize(gateway, data) @gateway = gateway @params = data[:params] @credit_card_verification = CreditCardVerification._new(data[:verification]) if data[:verification] @@ -22,7 +22,7 @@ def initialize(gateway, data) # :nodoc: @errors = Errors.new(data[:errors]) end - def inspect # :nodoc: + def inspect if @credit_card_verification verification_inspect = " credit_card_verification: #{@credit_card_verification.inspect}" end @@ -32,7 +32,6 @@ def inspect # :nodoc: "#<#{self.class} params:{...} errors:<#{@errors._inner_inspect}>#{verification_inspect}#{transaction_inspect}>" end - # Always returns false. def success? false end diff --git a/lib/braintree/errors.rb b/lib/braintree/errors.rb index eb45c4fd..4fd5b299 100644 --- a/lib/braintree/errors.rb +++ b/lib/braintree/errors.rb @@ -2,7 +2,7 @@ module Braintree class Errors include Enumerable - def initialize(data = {}) # :nodoc: + def initialize(data = {}) @errors = ValidationErrorCollection.new(data.merge(:errors => [])) end @@ -14,7 +14,7 @@ def for(scope) @errors.for(scope) end - def inspect # :nodoc: + def inspect "#<#{self.class} #{_inner_inspect}>" end @@ -25,7 +25,7 @@ def size @errors.deep_size end - def _inner_inspect # :nodoc: + def _inner_inspect @errors._inner_inspect end end diff --git a/lib/braintree/exceptions.rb b/lib/braintree/exceptions.rb index c074d356..ffa65c6a 100644 --- a/lib/braintree/exceptions.rb +++ b/lib/braintree/exceptions.rb @@ -1,5 +1,4 @@ -module Braintree # :nodoc: - # Super class for all Braintree exceptions. +module Braintree class BraintreeError < ::StandardError; end class AuthenticationError < BraintreeError; end diff --git a/lib/braintree/exchange_rate.rb b/lib/braintree/exchange_rate.rb index 0b941833..e0ffec8f 100644 --- a/lib/braintree/exchange_rate.rb +++ b/lib/braintree/exchange_rate.rb @@ -1,8 +1,8 @@ module Braintree class ExchangeRate - include BaseModule # :nodoc: + include BaseModule - def initialize(gateway, attributes) # :nodoc: + def initialize(gateway, attributes) set_instance_variables_from_hash(attributes) end diff --git a/lib/braintree/exchange_rate_quote.rb b/lib/braintree/exchange_rate_quote.rb index 7cecc7ab..c31a6acd 100644 --- a/lib/braintree/exchange_rate_quote.rb +++ b/lib/braintree/exchange_rate_quote.rb @@ -1,6 +1,6 @@ module Braintree class ExchangeRateQuote - include BaseModule # :nodoc: + include BaseModule attr_reader :attrs attr_reader :base_amount @@ -11,12 +11,12 @@ class ExchangeRateQuote attr_reader :refreshes_at attr_reader :trade_rate - def initialize(attributes) # :nodoc: + def initialize(attributes) @attrs = attributes.keys set_instance_variables_from_hash(attributes) end - def inspect # :nodoc: + def inspect inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" } "#<#{self.class} #{inspected_attributes.join(" ")}>" end diff --git a/lib/braintree/exchange_rate_quote_gateway.rb b/lib/braintree/exchange_rate_quote_gateway.rb index fc76dbff..89c1df6c 100644 --- a/lib/braintree/exchange_rate_quote_gateway.rb +++ b/lib/braintree/exchange_rate_quote_gateway.rb @@ -1,5 +1,5 @@ module Braintree - class ExchangeRateQuoteGateway # :nodoc + class ExchangeRateQuoteGateway def initialize(gateway) @gateway = gateway end diff --git a/lib/braintree/exchange_rate_quote_input.rb b/lib/braintree/exchange_rate_quote_input.rb index 9c786126..a3d19609 100644 --- a/lib/braintree/exchange_rate_quote_input.rb +++ b/lib/braintree/exchange_rate_quote_input.rb @@ -1,6 +1,6 @@ module Braintree class ExchangeRateQuoteInput - include BaseModule # :nodoc: + include BaseModule attr_reader :attrs attr_reader :base_currency @@ -8,12 +8,12 @@ class ExchangeRateQuoteInput attr_reader :markup attr_reader :quote_currency - def initialize(attributes) # :nodoc: + def initialize(attributes) @attrs = attributes.keys set_instance_variables_from_hash(attributes) end - def inspect # :nodoc: + def inspect inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" } "#<#{self.class} #{inspected_attributes.join(" ")}>" end diff --git a/lib/braintree/exchange_rate_quote_request.rb b/lib/braintree/exchange_rate_quote_request.rb index 3547b36b..17ec72f3 100644 --- a/lib/braintree/exchange_rate_quote_request.rb +++ b/lib/braintree/exchange_rate_quote_request.rb @@ -1,16 +1,16 @@ module Braintree class ExchangeRateQuoteRequest - include BaseModule # :nodoc: + include BaseModule attr_reader :quotes - def initialize(attributes) # :nodoc: + def initialize(attributes) @attrs = attributes.keys set_instance_variables_from_hash(attributes) @quotes = (@quotes || []).map { |quote_hash| ExchangeRateQuoteInput.new(quote_hash) } end - def inspect # :nodoc: + def inspect inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" } "#<#{self.class} #{inspected_attributes.join(" ")}>" end diff --git a/lib/braintree/exchange_rate_quote_response.rb b/lib/braintree/exchange_rate_quote_response.rb index aad029de..4aca1328 100644 --- a/lib/braintree/exchange_rate_quote_response.rb +++ b/lib/braintree/exchange_rate_quote_response.rb @@ -1,16 +1,16 @@ module Braintree class ExchangeRateQuoteResponse - include BaseModule # :nodoc: + include BaseModule attr_reader :quotes - def initialize(attributes) # :nodoc: + def initialize(attributes) @attrs = attributes.keys set_instance_variables_from_hash(attributes) @quotes = (@quotes || []).map { |quote_hash| ExchangeRateQuote.new(quote_hash) } end - def inspect # :nodoc: + def inspect inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" } "#<#{self.class} #{inspected_attributes.join(" ")}>" end diff --git a/lib/braintree/facilitated_details.rb b/lib/braintree/facilitated_details.rb index 4ceb3812..66f74310 100644 --- a/lib/braintree/facilitated_details.rb +++ b/lib/braintree/facilitated_details.rb @@ -1,5 +1,5 @@ module Braintree - class FacilitatedDetails # :nodoc: + class FacilitatedDetails include BaseModule attr_reader :merchant_id diff --git a/lib/braintree/facilitator_details.rb b/lib/braintree/facilitator_details.rb index 8fce1840..71f3ab2d 100644 --- a/lib/braintree/facilitator_details.rb +++ b/lib/braintree/facilitator_details.rb @@ -1,5 +1,5 @@ module Braintree - class FacilitatorDetails # :nodoc: + class FacilitatorDetails include BaseModule attr_reader :oauth_application_client_id diff --git a/lib/braintree/google_pay_card.rb b/lib/braintree/google_pay_card.rb index 96b3ded1..31b216d0 100644 --- a/lib/braintree/google_pay_card.rb +++ b/lib/braintree/google_pay_card.rb @@ -1,6 +1,6 @@ module Braintree class GooglePayCard - include BaseModule # :nodoc: + include BaseModule attr_reader :bin attr_reader :commercial @@ -28,7 +28,7 @@ class GooglePayCard attr_reader :virtual_card_last_4 attr_reader :virtual_card_type - def initialize(gateway, attributes) # :nodoc: + def initialize(gateway, attributes) @gateway = gateway set_instance_variables_from_hash(attributes) @subscriptions = (@subscriptions || []).map { |subscription_hash| Subscription._new(@gateway, subscription_hash) } @@ -54,7 +54,7 @@ class << self protected :new end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end end diff --git a/lib/braintree/granted_payment_instrument_update.rb b/lib/braintree/granted_payment_instrument_update.rb index 138cc31e..8b84f53c 100644 --- a/lib/braintree/granted_payment_instrument_update.rb +++ b/lib/braintree/granted_payment_instrument_update.rb @@ -15,7 +15,7 @@ def initialize(attributes) class << self protected :new - def _new(*args) # :nodoc: + def _new(*args) self.new(*args) end end diff --git a/lib/braintree/graphql_client.rb b/lib/braintree/graphql_client.rb index 4d7bd4db..21a97809 100644 --- a/lib/braintree/graphql_client.rb +++ b/lib/braintree/graphql_client.rb @@ -1,5 +1,5 @@ module Braintree - class GraphQLClient < Http # :nodoc: + class GraphQLClient < Http def initialize(config) @config = config diff --git a/lib/braintree/http.rb b/lib/braintree/http.rb index 5439d113..75b0bed6 100644 --- a/lib/braintree/http.rb +++ b/lib/braintree/http.rb @@ -1,5 +1,5 @@ module Braintree - class Http # :nodoc: + class Http LINE_FEED = "\r\n" diff --git a/lib/braintree/local_payment_completed.rb b/lib/braintree/local_payment_completed.rb index 1a45b997..a7b5648c 100644 --- a/lib/braintree/local_payment_completed.rb +++ b/lib/braintree/local_payment_completed.rb @@ -7,7 +7,7 @@ class LocalPaymentCompleted attr_reader :payment_method_nonce attr_reader :transaction - def initialize(attributes) # :nodoc: + def initialize(attributes) set_instance_variables_from_hash(attributes) @transaction = Transaction._new(Configuration.gateway, transaction) unless transaction.nil? end @@ -16,7 +16,7 @@ class << self protected :new end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end end diff --git a/lib/braintree/local_payment_expired.rb b/lib/braintree/local_payment_expired.rb index 1b4213de..20986f65 100644 --- a/lib/braintree/local_payment_expired.rb +++ b/lib/braintree/local_payment_expired.rb @@ -5,7 +5,7 @@ class LocalPaymentExpired attr_reader :payment_id attr_reader :payment_context_id - def initialize(attributes) # :nodoc: + def initialize(attributes) set_instance_variables_from_hash(attributes) end @@ -13,7 +13,7 @@ class << self protected :new end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end end diff --git a/lib/braintree/local_payment_funded.rb b/lib/braintree/local_payment_funded.rb index 7ba8fbad..be1132b4 100644 --- a/lib/braintree/local_payment_funded.rb +++ b/lib/braintree/local_payment_funded.rb @@ -6,7 +6,7 @@ class LocalPaymentFunded attr_reader :payment_context_id attr_reader :transaction - def initialize(attributes) # :nodoc: + def initialize(attributes) set_instance_variables_from_hash(attributes) @transaction = Transaction._new(Configuration.gateway, transaction) end @@ -15,7 +15,7 @@ class << self protected :new end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end end diff --git a/lib/braintree/local_payment_reversed.rb b/lib/braintree/local_payment_reversed.rb index 0b0d3478..9b560cec 100644 --- a/lib/braintree/local_payment_reversed.rb +++ b/lib/braintree/local_payment_reversed.rb @@ -4,7 +4,7 @@ class LocalPaymentReversed attr_reader :payment_id - def initialize(attributes) # :nodoc: + def initialize(attributes) set_instance_variables_from_hash(attributes) end @@ -12,7 +12,7 @@ class << self protected :new end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end end diff --git a/lib/braintree/merchant.rb b/lib/braintree/merchant.rb index 8ada5e5f..3402f9a6 100644 --- a/lib/braintree/merchant.rb +++ b/lib/braintree/merchant.rb @@ -1,6 +1,6 @@ module Braintree class Merchant - include BaseModule # :nodoc: + include BaseModule attr_reader :company_name attr_reader :country_code_alpha2 @@ -11,7 +11,7 @@ class Merchant attr_reader :id attr_reader :merchant_accounts - def initialize(gateway, attributes) # :nodoc: + def initialize(gateway, attributes) @merchant_accounts = attributes.delete(:merchant_accounts).map do |merchant_account| MerchantAccount._new(gateway, merchant_account) end @@ -23,7 +23,7 @@ class << self protected :new end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end diff --git a/lib/braintree/merchant_account.rb b/lib/braintree/merchant_account.rb index 8a61e9b3..35ca1fb5 100644 --- a/lib/braintree/merchant_account.rb +++ b/lib/braintree/merchant_account.rb @@ -49,7 +49,7 @@ def self.update!(*args) Configuration.gateway.merchant_account.update!(*args) end - def initialize(gateway, attributes) # :nodoc + def initialize(gateway, attributes) @gateway = gateway set_instance_variables_from_hash(attributes) @individual_details = IndividualDetails.new(@individual) @@ -60,7 +60,7 @@ def initialize(gateway, attributes) # :nodoc class << self protected :new - def _new(*args) # :nodoc: + def _new(*args) self.new(*args) end end diff --git a/lib/braintree/merchant_account_gateway.rb b/lib/braintree/merchant_account_gateway.rb index f0d252d5..8447ca25 100644 --- a/lib/braintree/merchant_account_gateway.rb +++ b/lib/braintree/merchant_account_gateway.rb @@ -1,5 +1,5 @@ module Braintree - class MerchantAccountGateway # :nodoc: + class MerchantAccountGateway include BaseModule def initialize(gateway) @@ -51,7 +51,7 @@ def create_for_currency(params) _create_for_currency(params) end - def _do_create(path, params=nil) # :nodoc: + def _do_create(path, params=nil) response = @config.http.post("#{@config.base_merchant_path}#{path}", params) if response[:api_error_response] ErrorResult.new(@gateway, response[:api_error_response]) @@ -60,7 +60,7 @@ def _do_create(path, params=nil) # :nodoc: end end - def _do_update(path, params=nil) # :nodoc: + def _do_update(path, params=nil) response = @config.http.put("#{@config.base_merchant_path}#{path}", params) if response[:api_error_response] ErrorResult.new(@gateway, response[:api_error_response]) @@ -83,7 +83,7 @@ def _create_for_currency(params) end end - # this is part of Marketplace and shouldn't be removed unless we're removing all Marketplace code + # NEXT_MAJOR_VERSION this is part of Marketplace and shouldn't be removed unless we're removing all Marketplace code def self._detect_signature(attributes) if attributes.has_key?(:applicant_details) warn "[DEPRECATED] Passing :applicant_details to create is deprecated. Please use :individual, :business, and :funding." @@ -93,8 +93,8 @@ def self._detect_signature(attributes) end end - # this is part of Marketplace and shouldn't be removed unless we're removing all Marketplace code - def self._deprecated_create_signature # :nodoc: + # NEXT_MAJOR_VERSION this is part of Marketplace and shouldn't be removed unless we're removing all Marketplace code + def self._deprecated_create_signature [ {:applicant_details => [ :first_name, :last_name, :email, :date_of_birth, :ssn, :routing_number, @@ -105,7 +105,7 @@ def self._deprecated_create_signature # :nodoc: ] end - def self._signature # :nodoc: + def self._signature [ {:individual => [ :first_name, :last_name, :email, :date_of_birth, :ssn, :phone, @@ -119,11 +119,11 @@ def self._signature # :nodoc: ] end - def self._create_signature # :nodoc: + def self._create_signature _signature + [:tos_accepted, :master_merchant_account_id, :id] end - def self._update_signature # :nodoc: + def self._update_signature _signature end end diff --git a/lib/braintree/meta_checkout_card.rb b/lib/braintree/meta_checkout_card.rb new file mode 100644 index 00000000..9444d9b6 --- /dev/null +++ b/lib/braintree/meta_checkout_card.rb @@ -0,0 +1,89 @@ +module Braintree + class MetaCheckoutCard + include BaseModule # :nodoc: + include Braintree::Util::TokenEquality + + attr_reader :bin + attr_reader :container_id + attr_reader :card_type + attr_reader :cardholder_name + attr_reader :commercial + attr_reader :country_of_issuance + attr_reader :created_at + attr_reader :customer_id + attr_reader :customer_location + attr_reader :debit + attr_reader :durbin_regulated + attr_reader :expiration_month + attr_reader :expiration_year + attr_reader :healthcare + attr_reader :image_url + attr_reader :issuing_bank + attr_reader :last_4 + attr_reader :payroll + attr_reader :prepaid + attr_reader :product_id + attr_reader :subscriptions + attr_reader :token + attr_reader :unique_number_identifier + attr_reader :updated_at + attr_reader :verification + + + def initialize(gateway, attributes) # :nodoc: + @gateway = gateway + set_instance_variables_from_hash(attributes) + @subscriptions = (@subscriptions || []).map { |subscription_hash| Subscription._new(@gateway, subscription_hash) } + @verification = _most_recent_verification(attributes) + end + + def _most_recent_verification(attributes) + verification = (attributes[:verifications] || []).sort_by { |v| v[:created_at] }.reverse.first + CreditCardVerification._new(verification) if verification + end + + def default? + @default + end + + # Expiration date formatted as MM/YYYY + def expiration_date + "#{expiration_month}/#{expiration_year}" + end + + def expired? + @expired + end + + def inspect # :nodoc: + first = [:token] + order = first + (self.class._attributes - first) + nice_attributes = order.map do |attr| + "#{attr}: #{send(attr).inspect}" + end + "#<#{self.class} #{nice_attributes.join(', ')}>" + end + + def masked_number + "#{bin}******#{last_4}" + end + + class << self + protected :new + end + + def self._attributes # :nodoc: + [ + :bin, :card_type, :cardholder_name, :created_at, + :customer_id, :customer_location, :expiration_month, :expiration_year, + :last_4, :token, :updated_at, :prepaid, :payroll, :product_id, + :commercial, :debit, :durbin_regulated, :healthcare, + :country_of_issuance, :issuing_bank, :image_url, :container_id + ] + end + + def self._new(*args) # :nodoc: + self.new(*args) + end + end + end diff --git a/lib/braintree/meta_checkout_token.rb b/lib/braintree/meta_checkout_token.rb new file mode 100644 index 00000000..7527f159 --- /dev/null +++ b/lib/braintree/meta_checkout_token.rb @@ -0,0 +1,88 @@ +module Braintree + class MetaCheckoutToken + include BaseModule # :nodoc: + include Braintree::Util::TokenEquality + + attr_reader :bin + attr_reader :container_id + attr_reader :card_type + attr_reader :cardholder_name + attr_reader :commercial + attr_reader :country_of_issuance + attr_reader :created_at + attr_reader :cryptogram + attr_reader :customer_id + attr_reader :customer_location + attr_reader :debit + attr_reader :durbin_regulated + attr_reader :ecommerce_indicator + attr_reader :expiration_month + attr_reader :expiration_year + attr_reader :healthcare + attr_reader :image_url + attr_reader :issuing_bank + attr_reader :last_4 + attr_reader :payroll + attr_reader :prepaid + attr_reader :product_id + attr_reader :token + attr_reader :unique_number_identifier + attr_reader :updated_at + attr_reader :verification + + def initialize(gateway, attributes) # :nodoc: + @gateway = gateway + set_instance_variables_from_hash(attributes) + @verification = _most_recent_verification(attributes) + end + + def _most_recent_verification(attributes) + verification = (attributes[:verifications] || []).sort_by { |v| v[:created_at] }.reverse.first + CreditCardVerification._new(verification) if verification + end + + def default? + @default + end + + # Expiration date formatted as MM/YYYY + def expiration_date + "#{expiration_month}/#{expiration_year}" + end + + def expired? + @expired + end + + def inspect # :nodoc: + first = [:token] + order = first + (self.class._attributes - first) + nice_attributes = order.map do |attr| + "#{attr}: #{send(attr).inspect}" + end + "#<#{self.class} #{nice_attributes.join(', ')}>" + end + + def masked_number + "#{bin}******#{last_4}" + end + + class << self + protected :new + end + + def self._attributes # :nodoc: + [ + :bin, :card_type, :cardholder_name, :created_at, + :customer_id, :customer_location, :expiration_month, :expiration_year, + :last_4, :token, :updated_at, :prepaid, :payroll, :product_id, + :commercial, :debit, :durbin_regulated, :healthcare, :ecommerce_indicator, + :country_of_issuance, :issuing_bank, :image_url, :container_id, :cryptogram + ] + end + + def self._new(*args) # :nodoc: + self.new(*args) + end + end + end diff --git a/lib/braintree/modification.rb b/lib/braintree/modification.rb index b64739bd..66ccb3ff 100644 --- a/lib/braintree/modification.rb +++ b/lib/braintree/modification.rb @@ -1,5 +1,5 @@ module Braintree - class Modification # :nodoc: + class Modification include BaseModule attr_reader :amount @@ -17,12 +17,12 @@ class Modification # :nodoc: class << self protected :new - def _new(*args) # :nodoc: + def _new(*args) self.new(*args) end end - def initialize(attributes) # :nodoc: + def initialize(attributes) set_instance_variables_from_hash(attributes) @amount = Util.to_big_decimal(amount) end diff --git a/lib/braintree/oauth_credentials.rb b/lib/braintree/oauth_credentials.rb index 9760c0b7..a25f6427 100644 --- a/lib/braintree/oauth_credentials.rb +++ b/lib/braintree/oauth_credentials.rb @@ -1,13 +1,13 @@ module Braintree class OAuthCredentials - include BaseModule # :nodoc: + include BaseModule attr_reader :access_token attr_reader :expires_at attr_reader :refresh_token attr_reader :token_type - def initialize(attributes) # :nodoc: + def initialize(attributes) set_instance_variables_from_hash(attributes) end @@ -15,7 +15,7 @@ class << self protected :new end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end end diff --git a/lib/braintree/paginated_collection.rb b/lib/braintree/paginated_collection.rb index 6b846fe6..3de7ad2e 100644 --- a/lib/braintree/paginated_collection.rb +++ b/lib/braintree/paginated_collection.rb @@ -1,8 +1,8 @@ module Braintree - class PaginatedCollection # :nodoc: + class PaginatedCollection include Enumerable - def initialize(&block) # :nodoc: + def initialize(&block) @next_page_block = block end diff --git a/lib/braintree/paginated_result.rb b/lib/braintree/paginated_result.rb index 3ed8df42..ca51e9ab 100644 --- a/lib/braintree/paginated_result.rb +++ b/lib/braintree/paginated_result.rb @@ -6,7 +6,7 @@ class PaginatedResult attr_reader :page_size attr_reader :total_items - def initialize(total_items, page_size, current_page) # :nodoc: + def initialize(total_items, page_size, current_page) @total_items = total_items @current_page = current_page @page_size = page_size diff --git a/lib/braintree/payment_instrument_type.rb b/lib/braintree/payment_instrument_type.rb index f639a063..2ccd167e 100644 --- a/lib/braintree/payment_instrument_type.rb +++ b/lib/braintree/payment_instrument_type.rb @@ -4,6 +4,8 @@ module PaymentInstrumentType CreditCard = "credit_card" GooglePayCard = "android_pay_card" LocalPayment = "local_payment" + MetaCheckoutCard = "meta_checkout_card" + MetaCheckoutToken = "meta_checkout_token" PayPalAccount = "paypal_account" PayPalHere = "paypal_here" SamsungPayCard = "samsung_pay_card" diff --git a/lib/braintree/payment_method_customer_data_updated_metadata.rb b/lib/braintree/payment_method_customer_data_updated_metadata.rb index 53df6a37..48f8af4f 100644 --- a/lib/braintree/payment_method_customer_data_updated_metadata.rb +++ b/lib/braintree/payment_method_customer_data_updated_metadata.rb @@ -7,7 +7,7 @@ class PaymentMethodCustomerDataUpdatedMetadata attr_reader :datetime_updated attr_reader :enriched_customer_data - def initialize(gateway, attributes) # :nodoc: + def initialize(gateway, attributes) set_instance_variables_from_hash(attributes) @payment_method = PaymentMethodParser.parse_payment_method(gateway, attributes[:payment_method]) @enriched_customer_data = EnrichedCustomerData._new(enriched_customer_data) if enriched_customer_data @@ -17,7 +17,7 @@ class << self protected :new end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end end diff --git a/lib/braintree/payment_method_gateway.rb b/lib/braintree/payment_method_gateway.rb index 52417896..907128ed 100644 --- a/lib/braintree/payment_method_gateway.rb +++ b/lib/braintree/payment_method_gateway.rb @@ -1,5 +1,5 @@ module Braintree - class PaymentMethodGateway # :nodoc: + class PaymentMethodGateway include BaseModule def initialize(gateway) @@ -21,7 +21,7 @@ def create!(*args) return_object_or_raise(:payment_method) { create(*args) } end - def _do_create(path, params=nil) # :nodoc: + def _do_create(path, params=nil) response = @config.http.post("#{@config.base_merchant_path}#{path}", params) if response[:api_error_response] ErrorResult.new(@gateway, response[:api_error_response]) @@ -76,7 +76,7 @@ def update!(*args) return_object_or_raise(:payment_method) { update(*args) } end - def _do_update(http_verb, path, params) # :nodoc: + def _do_update(http_verb, path, params) response = @config.http.send(http_verb, "#{@config.base_merchant_path}#{path}", params) if response[:api_error_response] ErrorResult.new(@gateway, response[:api_error_response]) @@ -142,19 +142,19 @@ def _do_revoke(path, params=nil) end end - def self._create_signature # :nodoc: + def self._create_signature _signature(:create) end - def self._update_signature # :nodoc: + def self._update_signature _signature(:update) end - def self._delete_signature # :nodoc: + def self._delete_signature [:revoke_all_grants] end - def self._signature(type) # :nodoc: + def self._signature(type) billing_address_params = AddressGateway._shared_signature paypal_options_shipping_signature = AddressGateway._shared_signature # NEXT_MAJOR_VERSION Remove venmo_sdk_session @@ -165,6 +165,7 @@ def self._signature(type) # :nodoc: :us_bank_account_verification_method, :venmo_sdk_session, # Deprecated :verification_account_type, + :verification_add_ons, :verification_amount, :verification_currency_iso_code, :verification_merchant_account_id, diff --git a/lib/braintree/payment_method_nonce.rb b/lib/braintree/payment_method_nonce.rb index b63593ba..1f482e04 100644 --- a/lib/braintree/payment_method_nonce.rb +++ b/lib/braintree/payment_method_nonce.rb @@ -1,6 +1,6 @@ module Braintree class PaymentMethodNonce - include BaseModule # :nodoc: + include BaseModule def self.create(*args) Configuration.gateway.payment_method_nonce.create(*args) @@ -22,7 +22,7 @@ def self.find(*args) attr_reader :type attr_reader :authentication_insight - def initialize(gateway, attributes) # :nodoc: + def initialize(gateway, attributes) @gateway = gateway set_instance_variables_from_hash(attributes) @details = PaymentMethodNonceDetails.new(attributes[:details]) if attributes[:details] @@ -34,7 +34,7 @@ def default? @default end - def to_s # :nodoc: + def to_s nonce end @@ -42,7 +42,7 @@ class << self protected :new end - def self._new(gateway, attributes) # :nodoc: + def self._new(gateway, attributes) new(gateway, attributes) end end diff --git a/lib/braintree/payment_method_nonce_details.rb b/lib/braintree/payment_method_nonce_details.rb index 1487f2fd..51315113 100644 --- a/lib/braintree/payment_method_nonce_details.rb +++ b/lib/braintree/payment_method_nonce_details.rb @@ -1,5 +1,5 @@ module Braintree - class PaymentMethodNonceDetails # :nodoc: + class PaymentMethodNonceDetails include BaseModule attr_reader :bin diff --git a/lib/braintree/payment_method_nonce_details_payer_info.rb b/lib/braintree/payment_method_nonce_details_payer_info.rb index b046c49b..ba607e9a 100644 --- a/lib/braintree/payment_method_nonce_details_payer_info.rb +++ b/lib/braintree/payment_method_nonce_details_payer_info.rb @@ -1,5 +1,5 @@ module Braintree - class PaymentMethodNonceDetailsPayerInfo # :nodoc: + class PaymentMethodNonceDetailsPayerInfo include BaseModule attr_reader :billing_agreement_id diff --git a/lib/braintree/payment_method_nonce_gateway.rb b/lib/braintree/payment_method_nonce_gateway.rb index a223def7..c7ba44f4 100644 --- a/lib/braintree/payment_method_nonce_gateway.rb +++ b/lib/braintree/payment_method_nonce_gateway.rb @@ -1,5 +1,5 @@ module Braintree - class PaymentMethodNonceGateway # :nodoc: + class PaymentMethodNonceGateway include BaseModule def initialize(gateway) diff --git a/lib/braintree/paypal_account.rb b/lib/braintree/paypal_account.rb index 75bb73cb..e865ac27 100644 --- a/lib/braintree/paypal_account.rb +++ b/lib/braintree/paypal_account.rb @@ -13,7 +13,7 @@ class PayPalAccount attr_reader :token attr_reader :updated_at - def initialize(gateway, attributes) # :nodoc: + def initialize(gateway, attributes) @gateway = gateway set_instance_variables_from_hash(attributes) @subscriptions = (@subscriptions || []).map { |subscription_hash| Subscription._new(@gateway, subscription_hash) } @@ -51,7 +51,6 @@ def self.sale!(token, transaction_attributes) return_object_or_raise(:transaction) { sale(token, transaction_attributes) } end - # Returns true if this paypal account is the customer's default payment method. def default? @default end diff --git a/lib/braintree/paypal_account_gateway.rb b/lib/braintree/paypal_account_gateway.rb index 056bd347..18d70296 100644 --- a/lib/braintree/paypal_account_gateway.rb +++ b/lib/braintree/paypal_account_gateway.rb @@ -28,7 +28,7 @@ def delete(token) @config.http.delete("#{@config.base_merchant_path}/payment_methods/paypal_account/#{token}") end - def _do_create(path, params) # :nodoc: + def _do_create(path, params) response = @config.http.post("#{@config.base_merchant_path}#{path}", params) if response[:paypal_account] SuccessfulResult.new(:paypal_account => PayPalAccount._new(@gateway, response[:paypal_account])) @@ -39,7 +39,7 @@ def _do_create(path, params) # :nodoc: end end - def _do_update(http_verb, path, params) # :nodoc: + def _do_update(http_verb, path, params) response = @config.http.send(http_verb, "#{@config.base_merchant_path}#{path}", params) if response[:paypal_account] SuccessfulResult.new(:paypal_account => PayPalAccount._new(@gateway, response[:paypal_account])) @@ -50,7 +50,7 @@ def _do_update(http_verb, path, params) # :nodoc: end end - def self._create_signature # :nodoc: + def self._create_signature options = [:fail_on_duplicate_payment_method, :make_default] [ :email, :token, :billing_agreement_id, :customer_id, @@ -58,14 +58,14 @@ def self._create_signature # :nodoc: ] end - def self._create_nested_signature # :nodoc: + def self._create_nested_signature [ :email, :token, :billing_agreement_id, {:options => [:make_default]} ] end - def self._update_signature # :nodoc: + def self._update_signature options = [:fail_on_duplicate_payment_method, :make_default] [:email, :token, :billing_agreement_id, {:options => options}] end diff --git a/lib/braintree/plan.rb b/lib/braintree/plan.rb index a4b7a6e5..d64ea936 100644 --- a/lib/braintree/plan.rb +++ b/lib/braintree/plan.rb @@ -23,7 +23,7 @@ def self.all Configuration.gateway.plan.all end - def initialize(gateway, attributes) # :nodoc: + def initialize(gateway, attributes) @gateway = gateway set_instance_variables_from_hash(attributes) add_ons.map! { |attrs| AddOn._new(attrs) } diff --git a/lib/braintree/plan_gateway.rb b/lib/braintree/plan_gateway.rb index ee3f1e8a..9891f01a 100644 --- a/lib/braintree/plan_gateway.rb +++ b/lib/braintree/plan_gateway.rb @@ -1,5 +1,5 @@ module Braintree - class PlanGateway # :nodoc: + class PlanGateway include BaseModule def initialize(gateway) @@ -102,7 +102,7 @@ def self._add_on_discount_signature ] end - def _do_create(path, params) # :nodoc: + def _do_create(path, params) response = @config.http.post("#{@config.base_merchant_path}#{path}", params) if response[:plan] SuccessfulResult.new(:plan => Plan._new(@gateway, response[:plan])) diff --git a/lib/braintree/resource_collection.rb b/lib/braintree/resource_collection.rb index cebf7e15..80bf4acb 100644 --- a/lib/braintree/resource_collection.rb +++ b/lib/braintree/resource_collection.rb @@ -1,10 +1,10 @@ module Braintree - class ResourceCollection # :nodoc: + class ResourceCollection include Enumerable attr_reader :ids - def initialize(response, &block) # :nodoc: + def initialize(response, &block) @ids = Util.extract_attribute_as_array(response[:search_results], :ids) @page_size = response[:search_results][:page_size] @paging_block = block diff --git a/lib/braintree/revoked_payment_method_metadata.rb b/lib/braintree/revoked_payment_method_metadata.rb index 649309f4..741f7b5c 100644 --- a/lib/braintree/revoked_payment_method_metadata.rb +++ b/lib/braintree/revoked_payment_method_metadata.rb @@ -14,7 +14,7 @@ def initialize(gateway, attributes) class << self protected :new - def _new(*args) # :nodoc: + def _new(*args) self.new(*args) end end diff --git a/lib/braintree/risk_data.rb b/lib/braintree/risk_data.rb index 86376b67..c3f887c8 100644 --- a/lib/braintree/risk_data.rb +++ b/lib/braintree/risk_data.rb @@ -1,5 +1,5 @@ module Braintree - class RiskData # :nodoc: + class RiskData include BaseModule attr_reader :customer_device_id diff --git a/lib/braintree/samsung_pay_card.rb b/lib/braintree/samsung_pay_card.rb index d25f84c1..97bb6731 100644 --- a/lib/braintree/samsung_pay_card.rb +++ b/lib/braintree/samsung_pay_card.rb @@ -1,6 +1,6 @@ module Braintree class SamsungPayCard - include BaseModule # :nodoc: + include BaseModule include Braintree::Util::TokenEquality attr_reader :billing_address @@ -29,7 +29,7 @@ class SamsungPayCard attr_reader :unique_number_identifier attr_reader :updated_at - def initialize(gateway, attributes) # :nodoc: + def initialize(gateway, attributes) @gateway = gateway set_instance_variables_from_hash(attributes) @billing_address = attributes[:billing_address] ? Address._new(@gateway, attributes[:billing_address]) : nil @@ -49,7 +49,7 @@ def expired? @expired end - def inspect # :nodoc: + def inspect first = [:token] order = first + (self.class._attributes - first) nice_attributes = order.map do |attr| @@ -66,7 +66,7 @@ class << self protected :new end - def self._attributes # :nodoc: + def self._attributes [ :billing_address, :bin, :cardholder_name, :card_type, :created_at, :customer_id, :customer_location, :expiration_month, :expiration_year, @@ -76,7 +76,7 @@ def self._attributes # :nodoc: ] end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end end diff --git a/lib/braintree/sepa_direct_debit_account.rb b/lib/braintree/sepa_direct_debit_account.rb index 6f9e2bfd..ca93722c 100644 --- a/lib/braintree/sepa_direct_debit_account.rb +++ b/lib/braintree/sepa_direct_debit_account.rb @@ -17,7 +17,7 @@ class SepaDirectDebitAccount attr_reader :updated_at attr_reader :view_mandate_url - def initialize(gateway, attributes) # :nodoc: + def initialize(gateway, attributes) @gateway = gateway @subscriptions = (@subscriptions || []).map { |subscription_hash| Subscription._new(@gateway, subscription_hash) } set_instance_variables_from_hash(attributes) @@ -31,7 +31,7 @@ class << self protected :new end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end diff --git a/lib/braintree/sepa_direct_debit_account_nonce_details.rb b/lib/braintree/sepa_direct_debit_account_nonce_details.rb index 4c785957..51357651 100644 --- a/lib/braintree/sepa_direct_debit_account_nonce_details.rb +++ b/lib/braintree/sepa_direct_debit_account_nonce_details.rb @@ -1,5 +1,5 @@ module Braintree - class SepaDirectDebitAccountNonceDetails# :nodoc: + class SepaDirectDebitAccountNonceDetails include BaseModule attr_reader :bank_reference_token diff --git a/lib/braintree/settlement_batch_summary_gateway.rb b/lib/braintree/settlement_batch_summary_gateway.rb index d36a631b..9d8d4ade 100644 --- a/lib/braintree/settlement_batch_summary_gateway.rb +++ b/lib/braintree/settlement_batch_summary_gateway.rb @@ -1,5 +1,5 @@ module Braintree - class SettlementBatchSummaryGateway # :nodoc + class SettlementBatchSummaryGateway include BaseModule def initialize(gateway) diff --git a/lib/braintree/sha256_digest.rb b/lib/braintree/sha256_digest.rb index 699ba2b1..f2439327 100644 --- a/lib/braintree/sha256_digest.rb +++ b/lib/braintree/sha256_digest.rb @@ -1,5 +1,5 @@ module Braintree - module SHA256Digest # :nodoc: + module SHA256Digest def self.hexdigest(private_key, string) _hmac(private_key, string) end diff --git a/lib/braintree/subscription.rb b/lib/braintree/subscription.rb index 82836bed..d5cefbc2 100644 --- a/lib/braintree/subscription.rb +++ b/lib/braintree/subscription.rb @@ -91,7 +91,7 @@ def self.update!(*args) Configuration.gateway.subscription.update!(*args) end - def initialize(gateway, attributes) # :nodoc: + def initialize(gateway, attributes) @gateway = gateway set_instance_variables_from_hash(attributes) @balance = Util.to_big_decimal(balance) @@ -114,7 +114,7 @@ def never_expires? class << self protected :new - def _new(*args) # :nodoc: + def _new(*args) self.new(*args) end end diff --git a/lib/braintree/subscription/status_details.rb b/lib/braintree/subscription/status_details.rb index bce562cc..150efd1b 100644 --- a/lib/braintree/subscription/status_details.rb +++ b/lib/braintree/subscription/status_details.rb @@ -1,6 +1,6 @@ module Braintree class Subscription - class StatusDetails # :nodoc: + class StatusDetails include BaseModule attr_reader :balance diff --git a/lib/braintree/subscription_gateway.rb b/lib/braintree/subscription_gateway.rb index 35b33afc..4329e4d7 100644 --- a/lib/braintree/subscription_gateway.rb +++ b/lib/braintree/subscription_gateway.rb @@ -1,5 +1,5 @@ module Braintree - class SubscriptionGateway # :nodoc: + class SubscriptionGateway include BaseModule def initialize(gateway) @@ -70,7 +70,7 @@ def update!(*args) return_object_or_raise(:subscription) { update(*args) } end - def self._create_signature # :nodoc: + def self._create_signature [ :billing_day_of_month, :first_billing_date, @@ -94,7 +94,7 @@ def self._create_signature # :nodoc: ] + _add_on_discount_signature end - def self._update_signature # :nodoc: + def self._update_signature [ :id, :merchant_account_id, @@ -114,7 +114,7 @@ def self._update_signature # :nodoc: ] + _add_on_discount_signature end - def self._add_on_discount_signature # :nodoc: + def self._add_on_discount_signature [ { :add_ons => [ @@ -133,7 +133,7 @@ def self._add_on_discount_signature # :nodoc: ] end - def _do_create(path, params) # :nodoc: + def _do_create(path, params) response = @config.http.post("#{@config.base_merchant_path}#{path}", params) if response[:subscription] SuccessfulResult.new(:subscription => Subscription._new(@gateway, response[:subscription])) @@ -144,7 +144,7 @@ def _do_create(path, params) # :nodoc: end end - def _fetch_subscriptions(search, ids) # :nodoc: + def _fetch_subscriptions(search, ids) search.ids.in ids response = @config.http.post("#{@config.base_merchant_path}/subscriptions/advanced_search", {:search => search.to_hash}) attributes = response[:subscriptions] diff --git a/lib/braintree/subscription_search.rb b/lib/braintree/subscription_search.rb index e090268f..957e69fb 100644 --- a/lib/braintree/subscription_search.rb +++ b/lib/braintree/subscription_search.rb @@ -1,5 +1,5 @@ module Braintree - class SubscriptionSearch < AdvancedSearch # :nodoc: + class SubscriptionSearch < AdvancedSearch multiple_value_field :in_trial_period multiple_value_field :ids text_fields :id, :transaction_id diff --git a/lib/braintree/successful_result.rb b/lib/braintree/successful_result.rb index d5085553..07e157dd 100644 --- a/lib/braintree/successful_result.rb +++ b/lib/braintree/successful_result.rb @@ -25,7 +25,7 @@ class SuccessfulResult attr_reader :transaction attr_reader :us_bank_account_verification - def initialize(attributes = {}) # :nodoc: + def initialize(attributes = {}) @attrs = attributes.keys attributes.each do |key, value| instance_variable_set("@#{key}", value) @@ -33,7 +33,7 @@ def initialize(attributes = {}) # :nodoc: @credit_card_verification = @verification end - def inspect # :nodoc: + def inspect inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" } "#<#{self.class} #{inspected_attributes.join(" ")}>" end diff --git a/lib/braintree/test/credit_card.rb b/lib/braintree/test/credit_card.rb index 4a84f8a5..d7033bc2 100644 --- a/lib/braintree/test/credit_card.rb +++ b/lib/braintree/test/credit_card.rb @@ -1,8 +1,5 @@ module Braintree - module Test # :nodoc: - # The constants contained in the Braintree::Test::CreditCardNumbers module provide - # credit card numbers that should be used when working in the sandbox environment. The sandbox - # will not accept any credit card numbers other than the ones listed below. + module Test module CreditCardNumbers module CardTypeIndicators Prepaid = "4111111111111210" @@ -18,16 +15,16 @@ module CardTypeIndicators end AmExes = %w[378282246310005 371449635398431 378734493671000] - CarteBlanches = %w[30569309025904] # :nodoc: - DinersClubs = %w[38520000023237] # :nodoc: + CarteBlanches = %w[30569309025904] + DinersClubs = %w[38520000023237] Discover = "6011111111111117" Discovers = %w[6011111111111117 6011000990139424] - JCBs = %w[3530111333300000 3566002020360505] # :nodoc: + JCBs = %w[3530111333300000 3566002020360505] - Maestro = "6304000000000000" # :nodoc: + Maestro = "6304000000000000" MasterCard = "5555555555554444" - MasterCardInternational = "5105105105105100" # :nodoc: + MasterCardInternational = "5105105105105100" MasterCards = %w[5105105105105100 5555555555554444] @@ -37,7 +34,7 @@ module CardTypeIndicators Visa = "4012888888881881" VisaCountryOfIssuanceIE = "4023490000000008" - VisaInternational = "4009348888881881" # :nodoc: + VisaInternational = "4009348888881881" VisaPrepaid = "4500600000000061" Fraud = "4000111111111511" diff --git a/lib/braintree/test/merchant_account.rb b/lib/braintree/test/merchant_account.rb index 52539cba..856852de 100644 --- a/lib/braintree/test/merchant_account.rb +++ b/lib/braintree/test/merchant_account.rb @@ -1,5 +1,5 @@ module Braintree - module Test # :nodoc: + module Test module MerchantAccount Approve = "approve_me" diff --git a/lib/braintree/test/nonce.rb b/lib/braintree/test/nonce.rb index 5ebba33d..119a0a34 100644 --- a/lib/braintree/test/nonce.rb +++ b/lib/braintree/test/nonce.rb @@ -18,6 +18,8 @@ module Nonce GooglePayVisa = "fake-android-pay-visa-nonce" GooglePayMasterCard = "fake-android-pay-mastercard-nonce" GooglePayAmEx = "fake-android-pay-amex-nonce" + MetaCheckoutCard = "fake-meta-checkout-card-nonce" + MetaCheckoutToken = "fake-meta-checkout-token-nonce" VenmoAccount = "fake-venmo-account-nonce" VenmoAccountTokenIssuanceError = "fake-token-issuance-error-venmo-account-nonce" ThreeDSecureVisaFullAuthentication = "fake-three-d-secure-visa-full-authentication-nonce" @@ -72,6 +74,7 @@ module Nonce SamsungPayMasterCard = "tokensam_fake_mastercard" SamsungPayVisa = "tokensam_fake_visa" SepaDirectDebit = "fake-sepa-direct-debit-nonce" + UsBankAccount = "fake-us-bank-account-nonce" end end end diff --git a/lib/braintree/test/transaction_amounts.rb b/lib/braintree/test/transaction_amounts.rb index 7cb48a83..6aaac55e 100644 --- a/lib/braintree/test/transaction_amounts.rb +++ b/lib/braintree/test/transaction_amounts.rb @@ -1,7 +1,6 @@ module Braintree - module Test # :nodoc: - # The constants in this module can be used to create transactions with - # the desired status in the sandbox environment. + module Test + # NEXT_MAJOR_VERSION are these even being used anymore? Can we remove this class?? module TransactionAmounts Authorize = "1000.00" Decline = "2000.00" diff --git a/lib/braintree/testing_gateway.rb b/lib/braintree/testing_gateway.rb index 24be73cd..e5f81563 100644 --- a/lib/braintree/testing_gateway.rb +++ b/lib/braintree/testing_gateway.rb @@ -1,5 +1,5 @@ module Braintree - class TestingGateway # :nodoc: + class TestingGateway def initialize(gateway) @gateway = gateway diff --git a/lib/braintree/three_d_secure_info.rb b/lib/braintree/three_d_secure_info.rb index 075217d6..56e41ec0 100644 --- a/lib/braintree/three_d_secure_info.rb +++ b/lib/braintree/three_d_secure_info.rb @@ -1,5 +1,5 @@ module Braintree - class ThreeDSecureInfo # :nodoc: + class ThreeDSecureInfo include BaseModule attr_reader :acs_transaction_id diff --git a/lib/braintree/transaction.rb b/lib/braintree/transaction.rb index acfcbfe1..06c7459d 100644 --- a/lib/braintree/transaction.rb +++ b/lib/braintree/transaction.rb @@ -77,9 +77,9 @@ module AdditionalCharge All = constants.map { |c| const_get(c) } end - module Type # :nodoc: - Credit = "credit" # :nodoc: - Sale = "sale" # :nodoc: + module Type + Credit = "credit" + Sale = "sale" All = constants.map { |c| const_get(c) } end @@ -131,6 +131,8 @@ module Status attr_reader :merchant_account_id attr_reader :merchant_advice_code attr_reader :merchant_advice_code_text + attr_reader :meta_checkout_card_details + attr_reader :meta_checkout_token_details attr_reader :network_response_code # Response code from the card network attr_reader :network_response_text # Response text from the card network attr_reader :network_token_details @@ -142,12 +144,12 @@ module Status attr_reader :paypal_details attr_reader :paypal_here_details attr_reader :plan_id - attr_reader :processor_authorization_code # Authorization code from the processor. - attr_reader :processor_response_code # Response code from the processor. - attr_reader :processor_response_text # Response text from the processor. - attr_reader :processor_response_type # Response type from the processor. - attr_reader :processor_settlement_response_code # Settlement response code from the processor. - attr_reader :processor_settlement_response_text # Settlement response text from the processor. + attr_reader :processor_authorization_code + attr_reader :processor_response_code + attr_reader :processor_response_text + attr_reader :processor_response_type + attr_reader :processor_settlement_response_code + attr_reader :processor_settlement_response_text attr_reader :product_sku attr_reader :purchase_order_number attr_reader :recurring @@ -175,7 +177,7 @@ module Status attr_reader :tax_amount attr_reader :tax_exempt attr_reader :three_d_secure_info - attr_reader :type # Will either be "sale" or "credit" + attr_reader :type attr_reader :updated_at attr_reader :us_bank_account_details attr_reader :venmo_account_details @@ -298,7 +300,7 @@ def self.void!(*args) Configuration.gateway.transaction.void!(*args) end - def initialize(gateway, attributes) # :nodoc: + def initialize(gateway, attributes) @gateway = gateway set_instance_variables_from_hash(attributes) @@ -313,6 +315,8 @@ def initialize(gateway, attributes) # :nodoc: @disbursement_details = DisbursementDetails.new(@disbursement_details) @google_pay_details = GooglePayDetails.new(@google_pay_card) @local_payment_details = LocalPaymentDetails.new(@local_payment) + @meta_checkout_card_details = MetaCheckoutCardDetails.new(attributes[:meta_checkout_card]) + @meta_checkout_token_details = MetaCheckoutTokenDetails.new(attributes[:meta_checkout_token]) @payment_instrument_type = attributes[:payment_instrument_type] @payment_receipt = PaymentReceipt.new(attributes[:payment_receipt]) if attributes[:payment_receipt] @paypal_details = PayPalDetails.new(@paypal) @@ -342,7 +346,7 @@ def initialize(gateway, attributes) # :nodoc: refunded_installments.map! { |attrs| Installment.new(attrs) } if refunded_installments end - def inspect # :nodoc: + def inspect first = [:id, :type, :amount, :status] order = first + (self.class._attributes - first) nice_attributes = order.map do |attr| @@ -359,12 +363,10 @@ def line_items @gateway.transaction_line_item.find_all(id) end - # Returns true if the transaction has been refunded. False otherwise. def refunded? !@refund_id.nil? end - # Returns true if the transaction has been disbursed. False otherwise. def disbursed? @disbursement_details.valid? end @@ -373,6 +375,7 @@ def disbursed? # vault_billing_address will return the associated Braintree::Address. Because the # vault billing address can be updated after the transaction was created, the attributes # on vault_billing_address may not match the attributes on billing_details. + # NEXT_MAJOR_VERSION these methods are not documented in the developer docs, remove def vault_billing_address return nil if billing_details.id.nil? @gateway.address.find(customer_details.id, billing_details.id) @@ -382,6 +385,7 @@ def vault_billing_address # vault_credit_card will return the associated Braintree::CreditCard. Because the # vault credit card can be updated after the transaction was created, the attributes # on vault_credit_card may not match the attributes on credit_card_details. + # NEXT_MAJOR_VERSION these methods are not documented in the developer docs, remove def vault_credit_card return nil if credit_card_details.token.nil? @gateway.credit_card.find(credit_card_details.token) @@ -391,6 +395,7 @@ def vault_credit_card # vault_customer will return the associated Braintree::Customer. Because the # vault customer can be updated after the transaction was created, the attributes # on vault_customer may not match the attributes on customer_details. + # NEXT_MAJOR_VERSION these methods are not documented in the developer docs, remove def vault_customer return nil if customer_details.id.nil? @gateway.customer.find(customer_details.id) @@ -400,6 +405,7 @@ def vault_customer # vault_shipping_address will return the associated Braintree::Address. Because the # vault shipping address can be updated after the transaction was created, the attributes # on vault_shipping_address may not match the attributes on shipping_details. + # NEXT_MAJOR_VERSION these methods are not documented in the developer docs, remove def vault_shipping_address return nil if shipping_details.id.nil? @gateway.address.find(customer_details.id, shipping_details.id) @@ -411,12 +417,12 @@ def processed_with_network_token? class << self protected :new - def _new(*args) # :nodoc: + def _new(*args) self.new(*args) end end - def self._attributes # :nodoc: + def self._attributes [:amount, :created_at, :credit_card_details, :customer_details, :id, :status, :subscription_details, :type, :updated_at, :processed_with_network_token?] end end diff --git a/lib/braintree/transaction/address_details.rb b/lib/braintree/transaction/address_details.rb index 31916cc8..dc43197c 100644 --- a/lib/braintree/transaction/address_details.rb +++ b/lib/braintree/transaction/address_details.rb @@ -1,6 +1,6 @@ module Braintree class Transaction - class AddressDetails # :nodoc: + class AddressDetails include BaseModule module ShippingMethod diff --git a/lib/braintree/transaction/credit_card_details.rb b/lib/braintree/transaction/credit_card_details.rb index 8590e0ae..049214c5 100644 --- a/lib/braintree/transaction/credit_card_details.rb +++ b/lib/braintree/transaction/credit_card_details.rb @@ -1,6 +1,6 @@ module Braintree class Transaction - class CreditCardDetails # :nodoc: + class CreditCardDetails include BaseModule attr_reader :account_type diff --git a/lib/braintree/transaction/customer_details.rb b/lib/braintree/transaction/customer_details.rb index 4227a92e..5ee68b94 100644 --- a/lib/braintree/transaction/customer_details.rb +++ b/lib/braintree/transaction/customer_details.rb @@ -1,6 +1,6 @@ module Braintree class Transaction - class CustomerDetails # :nodoc: + class CustomerDetails include BaseModule attr_reader :company diff --git a/lib/braintree/transaction/disbursement_details.rb b/lib/braintree/transaction/disbursement_details.rb index 7df3b4aa..954127dd 100644 --- a/lib/braintree/transaction/disbursement_details.rb +++ b/lib/braintree/transaction/disbursement_details.rb @@ -1,6 +1,6 @@ module Braintree class Transaction - class DisbursementDetails # :nodoc: + class DisbursementDetails include BaseModule attr_reader :disbursement_date diff --git a/lib/braintree/transaction/meta_checkout_card_details.rb b/lib/braintree/transaction/meta_checkout_card_details.rb new file mode 100644 index 00000000..04866387 --- /dev/null +++ b/lib/braintree/transaction/meta_checkout_card_details.rb @@ -0,0 +1,52 @@ +module Braintree + class Transaction + class MetaCheckoutCardDetails # :nodoc: + include BaseModule + + attr_reader :bin + attr_reader :card_type + attr_reader :cardholder_name + attr_reader :commercial + attr_reader :container_id + attr_reader :country_of_issuance + attr_reader :created_at + attr_reader :customer_location + attr_reader :debit + attr_reader :durbin_regulated + attr_reader :expiration_month + attr_reader :expiration_year + attr_reader :healthcare + attr_reader :image_url + attr_reader :is_network_tokenized + attr_reader :issuing_bank + attr_reader :last_4 + attr_reader :payroll + attr_reader :prepaid + attr_reader :product_id + attr_reader :token + attr_reader :unique_number_identifier + attr_reader :updated_at + + def initialize(attributes) + set_instance_variables_from_hash attributes unless attributes.nil? + end + + def expiration_date + "#{expiration_month}/#{expiration_year}" + end + + def inspect + attr_order = [:token, :bin, :last_4, :card_type, :expiration_date, :cardholder_name, :customer_location, :prepaid, + :healthcare, :durbin_regulated, :debit, :commercial, :payroll, :product_id, :country_of_issuance, :issuing_bank, :image_url, :container_id] + formatted_attrs = attr_order.map do |attr| + "#{attr}: #{send(attr).inspect}" + end + "#<#{formatted_attrs.join(", ")}>" + end + + def masked_number + "#{bin}******#{last_4}" + end + end + end + end diff --git a/lib/braintree/transaction/meta_checkout_token_details.rb b/lib/braintree/transaction/meta_checkout_token_details.rb new file mode 100644 index 00000000..50772954 --- /dev/null +++ b/lib/braintree/transaction/meta_checkout_token_details.rb @@ -0,0 +1,54 @@ +module Braintree + class Transaction + class MetaCheckoutTokenDetails # :nodoc: + include BaseModule + + attr_reader :bin + attr_reader :container_id + attr_reader :card_type + attr_reader :cardholder_name + attr_reader :commercial + attr_reader :country_of_issuance + attr_reader :created_at + attr_reader :cryptogram + attr_reader :customer_location + attr_reader :debit + attr_reader :durbin_regulated + attr_reader :ecommerce_indicator + attr_reader :expiration_month + attr_reader :expiration_year + attr_reader :healthcare + attr_reader :image_url + attr_reader :issuing_bank + attr_reader :is_network_tokenized + attr_reader :last_4 + attr_reader :payroll + attr_reader :prepaid + attr_reader :product_id + attr_reader :token + attr_reader :unique_number_identifier + attr_reader :updated_at + + def initialize(attributes) + set_instance_variables_from_hash attributes unless attributes.nil? + end + + def expiration_date + "#{expiration_month}/#{expiration_year}" + end + + def inspect + attr_order = [:container_id, :cryptogram, :ecommerce_indicator, :token, :bin, :last_4, :card_type, :expiration_date, :cardholder_name, :customer_location, :prepaid, + :healthcare, :durbin_regulated, :debit, :commercial, :payroll, :product_id, :country_of_issuance, :issuing_bank, :is_network_tokenized, :image_url] + formatted_attrs = attr_order.map do |attr| + "#{attr}: #{send(attr).inspect}" + end + "#<#{formatted_attrs.join(", ")}>" + end + + def masked_number + "#{bin}******#{last_4}" + end + end + end + end diff --git a/lib/braintree/transaction/samsung_pay_card_details.rb b/lib/braintree/transaction/samsung_pay_card_details.rb index 00bad28b..3a6d70f6 100644 --- a/lib/braintree/transaction/samsung_pay_card_details.rb +++ b/lib/braintree/transaction/samsung_pay_card_details.rb @@ -1,6 +1,6 @@ module Braintree class Transaction - class SamsungPayCardDetails # :nodoc: + class SamsungPayCardDetails include BaseModule attr_reader :bin diff --git a/lib/braintree/transaction/sepa_direct_debit_account_details.rb b/lib/braintree/transaction/sepa_direct_debit_account_details.rb index 71d65ad2..11b2d307 100644 --- a/lib/braintree/transaction/sepa_direct_debit_account_details.rb +++ b/lib/braintree/transaction/sepa_direct_debit_account_details.rb @@ -1,6 +1,6 @@ module Braintree class Transaction - class SepaDirectDebitAccountDetails # :nodoc: + class SepaDirectDebitAccountDetails include BaseModule attr_reader :bank_reference_token diff --git a/lib/braintree/transaction/status_details.rb b/lib/braintree/transaction/status_details.rb index 9aca17f1..af9304cf 100644 --- a/lib/braintree/transaction/status_details.rb +++ b/lib/braintree/transaction/status_details.rb @@ -1,6 +1,6 @@ module Braintree class Transaction - class StatusDetails # :nodoc: + class StatusDetails include BaseModule attr_reader :amount diff --git a/lib/braintree/transaction/subscription_details.rb b/lib/braintree/transaction/subscription_details.rb index 7ddfcadb..10409f0c 100644 --- a/lib/braintree/transaction/subscription_details.rb +++ b/lib/braintree/transaction/subscription_details.rb @@ -1,6 +1,6 @@ module Braintree class Transaction - class SubscriptionDetails # :nodoc: + class SubscriptionDetails include BaseModule attr_reader :billing_period_end_date diff --git a/lib/braintree/transaction/us_bank_account_details.rb b/lib/braintree/transaction/us_bank_account_details.rb index f9fff9b5..cfd85a21 100644 --- a/lib/braintree/transaction/us_bank_account_details.rb +++ b/lib/braintree/transaction/us_bank_account_details.rb @@ -1,6 +1,6 @@ module Braintree class Transaction - class UsBankAccountDetails # :nodoc: + class UsBankAccountDetails include BaseModule attr_reader :account_holder_name diff --git a/lib/braintree/transaction/visa_checkout_card_details.rb b/lib/braintree/transaction/visa_checkout_card_details.rb index c77b2d32..8246921c 100644 --- a/lib/braintree/transaction/visa_checkout_card_details.rb +++ b/lib/braintree/transaction/visa_checkout_card_details.rb @@ -1,6 +1,6 @@ module Braintree class Transaction - class VisaCheckoutCardDetails # :nodoc: + class VisaCheckoutCardDetails include BaseModule attr_reader :bin diff --git a/lib/braintree/transaction_gateway.rb b/lib/braintree/transaction_gateway.rb index 3bb2db2e..d85e1b43 100644 --- a/lib/braintree/transaction_gateway.rb +++ b/lib/braintree/transaction_gateway.rb @@ -1,5 +1,5 @@ module Braintree - class TransactionGateway # :nodoc: + class TransactionGateway include BaseModule def initialize(gateway) @@ -187,15 +187,14 @@ def void!(*args) return_object_or_raise(:transaction) { void(*args) } end - def self._clone_signature # :nodoc: + def self._clone_signature [:amount, :channel, {:options => [:submit_for_settlement]}] end - # NEXT_MAJOR_VERSION Remove venmo_sdk_payment_method_code, venmo_sdk_session, and three_d_secure_token # The old venmo SDK class has been deprecated # three_d_secure_token has been deprecated in favor of three_d_secure_authentication_id - def self._create_signature # :nodoc: + def self._create_signature [ :amount, :billing_address_id, :channel, :customer_id, :device_data, :discount_amount, :merchant_account_id, :order_id, :payment_method_nonce, :payment_method_token, @@ -258,7 +257,7 @@ def self._create_signature # :nodoc: {:industry => [ :industry_type, {:data => [ - :folio_number, :check_in_date, :check_out_date, :travel_package, :lodging_check_in_date, :lodging_check_out_date, :departure_date, :lodging_name, :room_rate, :room_tax, + :country_code, :date_of_birth, :folio_number, :check_in_date, :check_out_date, :travel_package, :lodging_check_in_date, :lodging_check_out_date, :departure_date, :lodging_name, :room_rate, :room_tax, :passenger_first_name, :passenger_last_name, :passenger_middle_initial, :passenger_title, :issued_date, :travel_agency_name, :travel_agency_code, :ticket_number, :issuing_carrier_code, :customer_code, :fare_amount, :fee_amount, :tax_amount, :restricted_ticket, :no_show, :advanced_deposit, :fire_safe, :property_phone, :ticket_issuer_address, :arrival_date, {:legs => [ @@ -276,14 +275,14 @@ def self._create_signature # :nodoc: ] end - def self._submit_for_settlement_signature # :nodoc: + def self._submit_for_settlement_signature [ :order_id, {:descriptor => [:name, :phone, :url]}, {:industry => [ :industry_type, {:data => [ - :folio_number, :check_in_date, :check_out_date, :travel_package, :lodging_check_in_date, :lodging_check_out_date, :departure_date, :lodging_name, :room_rate, :room_tax, + :country_code, :date_of_birth, :folio_number, :check_in_date, :check_out_date, :travel_package, :lodging_check_in_date, :lodging_check_out_date, :departure_date, :lodging_name, :room_rate, :room_tax, :passenger_first_name, :passenger_last_name, :passenger_middle_initial, :passenger_title, :issued_date, :travel_agency_name, :travel_agency_code, :ticket_number, :issuing_carrier_code, :customer_code, :fare_amount, :fee_amount, :tax_amount, :restricted_ticket, :no_show, :advanced_deposit, :fire_safe, :property_phone, :ticket_issuer_address, :arrival_date, {:legs => [ @@ -311,7 +310,7 @@ def self._adjust_authorization_signature ] end - def self._update_details_signature # :nodoc: + def self._update_details_signature [ :amount, :order_id, @@ -327,7 +326,7 @@ def self._refund_signature ] end - def _do_create(path, params=nil) # :nodoc: + def _do_create(path, params=nil) if !params.nil? params = Util.replace_key(params, :google_pay_card, :android_pay_card) end @@ -335,7 +334,7 @@ def _do_create(path, params=nil) # :nodoc: _handle_transaction_response(response) end - def _fetch_transactions(search, ids) # :nodoc: + def _fetch_transactions(search, ids) search.ids.in ids response = @config.http.post("#{@config.base_merchant_path}/transactions/advanced_search", {:search => search.to_hash}) attributes = response[:credit_card_transactions] diff --git a/lib/braintree/transaction_line_item.rb b/lib/braintree/transaction_line_item.rb index 2cdff8b6..08077bda 100644 --- a/lib/braintree/transaction_line_item.rb +++ b/lib/braintree/transaction_line_item.rb @@ -15,7 +15,7 @@ class TransactionLineItem attr_reader :commodity_code attr_reader :url - def initialize(gateway, attributes) # :nodoc: + def initialize(gateway, attributes) @gateway = gateway set_instance_variables_from_hash(attributes) @quantity = Util.to_big_decimal(quantity) @@ -28,7 +28,7 @@ def initialize(gateway, attributes) # :nodoc: class << self protected :new - def _new(*args) # :nodoc: + def _new(*args) self.new(*args) end end diff --git a/lib/braintree/transaction_line_item_gateway.rb b/lib/braintree/transaction_line_item_gateway.rb index 7ec30d5f..94da2b1f 100644 --- a/lib/braintree/transaction_line_item_gateway.rb +++ b/lib/braintree/transaction_line_item_gateway.rb @@ -1,5 +1,5 @@ module Braintree - class TransactionLineItemGateway # :nodoc: + class TransactionLineItemGateway def initialize(gateway) @gateway = gateway @config = gateway.config diff --git a/lib/braintree/transaction_review.rb b/lib/braintree/transaction_review.rb index bbda8789..c9274900 100644 --- a/lib/braintree/transaction_review.rb +++ b/lib/braintree/transaction_review.rb @@ -10,7 +10,7 @@ def initialize(attributes) class << self protected :new - def _new(*args) # :nodoc: + def _new(*args) self.new(*args) end end diff --git a/lib/braintree/transaction_search.rb b/lib/braintree/transaction_search.rb index b24e5dd6..41c327e8 100644 --- a/lib/braintree/transaction_search.rb +++ b/lib/braintree/transaction_search.rb @@ -1,5 +1,5 @@ module Braintree - class TransactionSearch < AdvancedSearch # :nodoc: + class TransactionSearch < AdvancedSearch text_fields( :billing_company, :billing_country_name, diff --git a/lib/braintree/unknown_payment_method.rb b/lib/braintree/unknown_payment_method.rb index af2c25e4..d9bf4c87 100644 --- a/lib/braintree/unknown_payment_method.rb +++ b/lib/braintree/unknown_payment_method.rb @@ -19,7 +19,7 @@ def image_url "https://assets.braintreegateway.com/payment_method_logo/unknown.png" end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end end diff --git a/lib/braintree/us_bank_account.rb b/lib/braintree/us_bank_account.rb index e63c669f..68dfc93c 100644 --- a/lib/braintree/us_bank_account.rb +++ b/lib/braintree/us_bank_account.rb @@ -14,7 +14,7 @@ class UsBankAccount attr_reader :verifications attr_reader :verified - def initialize(gateway, attributes) # :nodoc: + def initialize(gateway, attributes) @gateway = gateway set_instance_variables_from_hash(attributes) @ach_mandate = AchMandate.new(attributes[:ach_mandate]) if attributes[:ach_mandate] @@ -34,7 +34,7 @@ class << self protected :new end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end diff --git a/lib/braintree/us_bank_account_verification.rb b/lib/braintree/us_bank_account_verification.rb index 1c7dd2c2..5c20207a 100644 --- a/lib/braintree/us_bank_account_verification.rb +++ b/lib/braintree/us_bank_account_verification.rb @@ -22,33 +22,41 @@ module VerificationMethod All = [IndependentCheck, NetworkCheck, TokenizedCheck, MicroTransfers] end + module VerificationAddOns + CustomerVerification = "customer_verification" + + All = [CustomerVerification] + end + + attr_reader :additional_processor_response + attr_reader :created_at + attr_reader :gateway_rejection_reason attr_reader :id - attr_reader :status - attr_reader :verification_determined_at - attr_reader :verification_method + attr_reader :merchant_account_id attr_reader :processor_response_code attr_reader :processor_response_text - attr_reader :merchant_account_id - attr_reader :gateway_rejection_reason + attr_reader :status attr_reader :us_bank_account - attr_reader :created_at + attr_reader :verification_determined_at + attr_reader :verification_method - def initialize(attributes) # :nodoc: + def initialize(attributes) set_instance_variables_from_hash(attributes) end - def inspect # :nodoc: + def inspect attr_order = [ - :status, - :processor_response_code, - :processor_response_text, - :merchant_account_id, + :additional_processor_response, + :created_at, :gateway_rejection_reason, :id, + :merchant_account_id, + :processor_response_code, + :processor_response_text, + :status, :us_bank_account, - :verification_method, :verification_determined_at, - :created_at + :verification_method ] formatted_attrs = attr_order.map do |attr| @@ -62,7 +70,7 @@ class << self protected :new end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end diff --git a/lib/braintree/us_bank_account_verification_search.rb b/lib/braintree/us_bank_account_verification_search.rb index 194934fc..0daf08a1 100644 --- a/lib/braintree/us_bank_account_verification_search.rb +++ b/lib/braintree/us_bank_account_verification_search.rb @@ -1,5 +1,5 @@ module Braintree - class UsBankAccountVerificationSearch < AdvancedSearch # :nodoc: + class UsBankAccountVerificationSearch < AdvancedSearch text_fields( :id, :account_holder_name, diff --git a/lib/braintree/util.rb b/lib/braintree/util.rb index 1362ed2c..7bb68623 100644 --- a/lib/braintree/util.rb +++ b/lib/braintree/util.rb @@ -1,5 +1,5 @@ module Braintree - module Util # :nodoc: + module Util def self.extract_attribute_as_array(hash, attribute) raise UnexpectedError.new("Unprocessable entity due to an invalid request") if hash.nil? value = hash.has_key?(attribute) ? hash.delete(attribute) : [] @@ -195,14 +195,14 @@ def self._get_invalid_keys(valid_keys, hash) end module IdEquality - def ==(other) # :nodoc: + def ==(other) return false unless other.is_a?(self.class) id == other.id end end module TokenEquality - def ==(other) # :nodoc: + def ==(other) return false unless other.is_a?(self.class) token == other.token end diff --git a/lib/braintree/validation_error.rb b/lib/braintree/validation_error.rb index 1f9fd2bf..53d1f8bd 100644 --- a/lib/braintree/validation_error.rb +++ b/lib/braintree/validation_error.rb @@ -18,7 +18,7 @@ def initialize(error_hash) set_instance_variables_from_hash error_hash end - def inspect # :nodoc: + def inspect "#<#{self.class} (#{code}) #{message}>" end end diff --git a/lib/braintree/validation_error_collection.rb b/lib/braintree/validation_error_collection.rb index 3ba6822c..e815411b 100644 --- a/lib/braintree/validation_error_collection.rb +++ b/lib/braintree/validation_error_collection.rb @@ -2,7 +2,7 @@ module Braintree class ValidationErrorCollection include Enumerable - def initialize(data) # :nodoc: + def initialize(data) return if !data.is_a? Hash @errors = (data[:errors] || {}).map { |hash| Braintree::ValidationError.new(hash) } @nested = {} @@ -42,7 +42,7 @@ def for_index(index) self.for("index_#{index}".to_sym) end - def inspect # :nodoc: + def inspect "#<#{self.class} errors#{_inner_inspect}>" end @@ -61,7 +61,7 @@ def size @errors.size end - def _inner_inspect(scope = []) # :nodoc: + def _inner_inspect(scope = []) all = [] scope_string = scope.join("/") if @errors.any? diff --git a/lib/braintree/venmo_account.rb b/lib/braintree/venmo_account.rb index 99789267..691fe189 100644 --- a/lib/braintree/venmo_account.rb +++ b/lib/braintree/venmo_account.rb @@ -1,6 +1,6 @@ module Braintree class VenmoAccount - include BaseModule # :nodoc: + include BaseModule attr_reader :created_at attr_reader :customer_id @@ -13,7 +13,7 @@ class VenmoAccount attr_reader :username attr_reader :venmo_user_id - def initialize(gateway, attributes) # :nodoc: + def initialize(gateway, attributes) @gateway = gateway set_instance_variables_from_hash(attributes) @subscriptions = (@subscriptions || []).map { |subscription_hash| Subscription._new(@gateway, subscription_hash) } @@ -27,7 +27,7 @@ class << self protected :new end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end end diff --git a/lib/braintree/venmo_profile_data.rb b/lib/braintree/venmo_profile_data.rb index d3b88e98..2239905f 100644 --- a/lib/braintree/venmo_profile_data.rb +++ b/lib/braintree/venmo_profile_data.rb @@ -2,13 +2,15 @@ module Braintree class VenmoProfileData include BaseModule - attr_reader :username + attr_reader :billing_address + attr_reader :email attr_reader :first_name attr_reader :last_name attr_reader :phone_number - attr_reader :email + attr_reader :shipping_address + attr_reader :username - def initialize(attributes) # :nodoc: + def initialize(attributes) set_instance_variables_from_hash(attributes) end @@ -16,7 +18,7 @@ class << self protected :new end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end end diff --git a/lib/braintree/version.rb b/lib/braintree/version.rb index 280dda3c..310eccfc 100644 --- a/lib/braintree/version.rb +++ b/lib/braintree/version.rb @@ -1,7 +1,7 @@ module Braintree module Version Major = 4 - Minor = 15 + Minor = 16 Tiny = 0 String = "#{Major}.#{Minor}.#{Tiny}" diff --git a/lib/braintree/visa_checkout_card.rb b/lib/braintree/visa_checkout_card.rb index 0a57f329..394fcf81 100644 --- a/lib/braintree/visa_checkout_card.rb +++ b/lib/braintree/visa_checkout_card.rb @@ -1,6 +1,6 @@ module Braintree class VisaCheckoutCard - include BaseModule # :nodoc: + include BaseModule include Braintree::Util::TokenEquality attr_reader :billing_address @@ -30,7 +30,7 @@ class VisaCheckoutCard attr_reader :updated_at attr_reader :verification - def initialize(gateway, attributes) # :nodoc: + def initialize(gateway, attributes) @gateway = gateway set_instance_variables_from_hash(attributes) @billing_address = attributes[:billing_address] ? Address._new(@gateway, attributes[:billing_address]) : nil @@ -39,8 +39,8 @@ def initialize(gateway, attributes) # :nodoc: end def _most_recent_verification(attributes) - verification = (attributes[:verifications] || []).sort_by { |verification| verification[:created_at] }.reverse.first - CreditCardVerification._new(verification) if verification + sorted_verifications = (attributes[:verifications] || []).sort_by { |verification| verification[:created_at] }.reverse.first + CreditCardVerification._new(sorted_verifications) if sorted_verifications end def default? @@ -56,7 +56,7 @@ def expired? @expired end - def inspect # :nodoc: + def inspect first = [:token] order = first + (self.class._attributes - first) nice_attributes = order.map do |attr| @@ -73,7 +73,7 @@ class << self protected :new end - def self._attributes # :nodoc: + def self._attributes [ :billing_address, :bin, :card_type, :cardholder_name, :created_at, :customer_id, :customer_location, :expiration_month, :expiration_year, @@ -83,7 +83,7 @@ def self._attributes # :nodoc: ] end - def self._new(*args) # :nodoc: + def self._new(*args) self.new(*args) end end diff --git a/lib/braintree/webhook_notification.rb b/lib/braintree/webhook_notification.rb index be71796b..1cf3a3fd 100644 --- a/lib/braintree/webhook_notification.rb +++ b/lib/braintree/webhook_notification.rb @@ -92,7 +92,7 @@ def self.verify(*args) Configuration.gateway.webhook_notification.verify(*args) end - def initialize(gateway, attributes) # :nodoc: + def initialize(gateway, attributes) @gateway = gateway set_instance_variables_from_hash(attributes) @error_result = ErrorResult.new(gateway, @subject[:api_error_response]) if @subject.has_key?(:api_error_response) @@ -135,7 +135,7 @@ def check? class << self protected :new - def _new(*args) # :nodoc: + def _new(*args) self.new(*args) end end diff --git a/lib/braintree/webhook_notification_gateway.rb b/lib/braintree/webhook_notification_gateway.rb index e7f36456..7e4b5455 100644 --- a/lib/braintree/webhook_notification_gateway.rb +++ b/lib/braintree/webhook_notification_gateway.rb @@ -1,5 +1,5 @@ module Braintree - class WebhookNotificationGateway # :nodoc: + class WebhookNotificationGateway def initialize(gateway) @gateway = gateway @config = gateway.config @@ -36,8 +36,8 @@ def _verify_signature(signature_string, payload) public_key, signature = _matching_signature_pair(signature_string) raise InvalidSignature, "no matching public key" if public_key.nil? - signature_matches = [payload, payload + "\n"].any? do |payload| - payload_signature = Braintree::Digest.hexdigest(@config.private_key, payload) + signature_matches = [payload, payload + "\n"].any? do |_payload| + payload_signature = Braintree::Digest.hexdigest(@config.private_key, _payload) Braintree::Digest.secure_compare(signature, payload_signature) end raise InvalidSignature, "signature does not match payload - one has been modified" unless signature_matches diff --git a/lib/braintree/webhook_testing.rb b/lib/braintree/webhook_testing.rb index 94da2c6f..db63ba06 100644 --- a/lib/braintree/webhook_testing.rb +++ b/lib/braintree/webhook_testing.rb @@ -1,5 +1,5 @@ module Braintree - class WebhookTesting # :nodoc: + class WebhookTesting def self.sample_notification(*args) Configuration.gateway.webhook_testing.sample_notification(*args) end diff --git a/lib/braintree/webhook_testing_gateway.rb b/lib/braintree/webhook_testing_gateway.rb index 04fa0583..59c29a76 100644 --- a/lib/braintree/webhook_testing_gateway.rb +++ b/lib/braintree/webhook_testing_gateway.rb @@ -1,5 +1,5 @@ module Braintree - class WebhookTestingGateway # :nodoc: + class WebhookTestingGateway def initialize(gateway) @gateway = gateway @config = gateway.config diff --git a/lib/braintree/xml.rb b/lib/braintree/xml.rb index 9d827c5e..6b98daf1 100644 --- a/lib/braintree/xml.rb +++ b/lib/braintree/xml.rb @@ -1,5 +1,5 @@ module Braintree - module Xml # :nodoc: + module Xml def self.hash_from_xml(xml) Parser.hash_from_xml(xml) end diff --git a/lib/braintree/xml/generator.rb b/lib/braintree/xml/generator.rb index 84cac556..69b22c94 100644 --- a/lib/braintree/xml/generator.rb +++ b/lib/braintree/xml/generator.rb @@ -2,7 +2,7 @@ # under the MIT license, copyright (c) 2005-2009 David Heinemeier Hansson module Braintree module Xml - module Generator # :nodoc: + module Generator XML_TYPE_NAMES = { "Fixnum" => "integer", "Bignum" => "integer", diff --git a/lib/braintree/xml/libxml.rb b/lib/braintree/xml/libxml.rb index 2ab76eed..1ecb134b 100644 --- a/lib/braintree/xml/libxml.rb +++ b/lib/braintree/xml/libxml.rb @@ -2,7 +2,7 @@ # under the MIT license, copyright (c) 2005-2009 David Heinemeier Hansson module Braintree module Xml - module Libxml # :nodoc: + module Libxml LIB_XML_LIMIT = 30000000 def self.parse(xml_string) diff --git a/lib/braintree/xml/parser.rb b/lib/braintree/xml/parser.rb index 89a354f5..012826e4 100644 --- a/lib/braintree/xml/parser.rb +++ b/lib/braintree/xml/parser.rb @@ -1,10 +1,10 @@ # Portions of this code were copied and modified from Ruby on Rails, released # under the MIT license, copyright (c) 2005-2009 David Heinemeier Hansson module Braintree - module Xml # :nodoc: + module Xml CONTENT_ROOT = "__content__" - module Parser # :nodoc: + module Parser XML_PARSING = { "datetime" => Proc.new { |time| ::Time.parse(time).utc }, "integer" => Proc.new { |integer| integer.to_i }, diff --git a/lib/braintree/xml/rexml.rb b/lib/braintree/xml/rexml.rb index a7bc765b..95acecd5 100644 --- a/lib/braintree/xml/rexml.rb +++ b/lib/braintree/xml/rexml.rb @@ -1,8 +1,8 @@ # Portions of this code were copied and modified from Ruby on Rails, released # under the MIT license, copyright (c) 2005-2009 David Heinemeier Hansson module Braintree - module Xml # :nodoc: - module Rexml # :nodoc: + module Xml + module Rexml CONTENT_KEY = "__content__".freeze diff --git a/spec/integration/braintree/dispute_search_spec.rb b/spec/integration/braintree/dispute_search_spec.rb index 49f82857..7ce6c128 100644 --- a/spec/integration/braintree/dispute_search_spec.rb +++ b/spec/integration/braintree/dispute_search_spec.rb @@ -24,7 +24,6 @@ :number => Braintree::Test::CreditCardNumbers::Disputes::Chargeback, }, :customer_id => customer.id, - :merchant_account_id => "14LaddersLLC_instant", :options => { :submit_for_settlement => true, }, diff --git a/spec/integration/braintree/payment_method_nonce_spec.rb b/spec/integration/braintree/payment_method_nonce_spec.rb index 4d9bd143..6655dccb 100644 --- a/spec/integration/braintree/payment_method_nonce_spec.rb +++ b/spec/integration/braintree/payment_method_nonce_spec.rb @@ -91,6 +91,26 @@ expect(nonce.details.payer_info).to be_nil end + it "return meta_checkout_card_details nonce if exist" do + result = Braintree::PaymentMethodNonce.find(Braintree::Test::Nonce::MetaCheckoutCard) + nonce = result.payment_method_nonce + nonce.details.bin.should == "401288" + nonce.details.last_two.should == "81" + nonce.details.card_type.should == "Visa" + nonce.details.expiration_year.should == "2024" + nonce.details.expiration_month.should == "12" + end + + it "return meta_checkout_token_details nonce if exist" do + result = Braintree::PaymentMethodNonce.find(Braintree::Test::Nonce::MetaCheckoutToken) + nonce = result.payment_method_nonce + nonce.details.bin.should == "401288" + nonce.details.last_two.should == "81" + nonce.details.card_type.should == "Visa" + nonce.details.expiration_year.should == "2024" + nonce.details.expiration_month.should == "12" + end + it "return paypal details if details exist" do result = Braintree::PaymentMethodNonce.find("fake-paypal-one-time-nonce") nonce = result.payment_method_nonce diff --git a/spec/integration/braintree/payment_method_us_bank_account_spec.rb b/spec/integration/braintree/payment_method_us_bank_account_spec.rb index b79001a7..ea2a67f2 100644 --- a/spec/integration/braintree/payment_method_us_bank_account_spec.rb +++ b/spec/integration/braintree/payment_method_us_bank_account_spec.rb @@ -78,6 +78,78 @@ expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount) end end + + it "succeeds and verifies with verification_add_ons for NetworkCheck with fake nonce" do + customer = Braintree::Customer.create.customer + result = Braintree::PaymentMethod.create( + :payment_method_nonce => Braintree::Test::Nonce::UsBankAccount, + :customer_id => customer.id, + :options => { + :us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck, + :verification_add_ons => Braintree::UsBankAccountVerification::VerificationAddOns::CustomerVerification, + :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId, + }, + ) + + expect(result).to be_success + us_bank_account = result.payment_method + expect(us_bank_account).to be_a(Braintree::UsBankAccount) + expect(us_bank_account.routing_number).to eq("123456789") + expect(us_bank_account.last_4).to eq("0000") + expect(us_bank_account.account_type).to eq("checking") + expect(us_bank_account.account_holder_name).to eq("Dan Schulman") + expect(us_bank_account.bank_name).to match(/Wells Fargo/) + expect(us_bank_account.default).to eq(true) + expect(us_bank_account.ach_mandate.text).to eq("example mandate text") + expect(us_bank_account.ach_mandate.accepted_at).to be_a Time + + expect(us_bank_account.verifications.count).to eq(1) + expect(us_bank_account.verifications.first.status).to eq(Braintree::UsBankAccountVerification::Status::Verified) + expect(us_bank_account.verifications.first.verification_method).to eq(Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck) + expect(us_bank_account.verifications.first.id).not_to be_empty + expect(us_bank_account.verifications.first.verification_determined_at).to be_a Time + expect(us_bank_account.verifications.first.processor_response_code).to eq("1000") + expect(us_bank_account.verified).to eq(true) + + expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount) + end + + it "returns additional processor response for failed NetworkCheck" do + customer = Braintree::Customer.create.customer + invalid_nonce = generate_non_plaid_us_bank_account_nonce(account_number = "1000000005") + result = Braintree::PaymentMethod.create( + :payment_method_nonce => invalid_nonce, + :customer_id => customer.id, + :options => { + :us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck, + :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId, + }, + ) + + expect(result).to be_success + us_bank_account = result.payment_method + expect(us_bank_account).to be_a(Braintree::UsBankAccount) + expect(us_bank_account.routing_number).to eq("021000021") + expect(us_bank_account.last_4).to eq("0005") + expect(us_bank_account.account_type).to eq("checking") + expect(us_bank_account.account_holder_name).to eq("John Doe") + expect(us_bank_account.bank_name).to match(/CHASE/) + expect(us_bank_account.default).to eq(true) + expect(us_bank_account.ach_mandate.text).to eq("cl mandate text") + expect(us_bank_account.ach_mandate.accepted_at).to be_a Time + + expect(us_bank_account.verifications.count).to eq(1) + expect(us_bank_account.verifications.first.status).to eq(Braintree::UsBankAccountVerification::Status::ProcessorDeclined) + expect(us_bank_account.verifications.first.verification_method).to eq(Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck) + expect(us_bank_account.verifications.first.id).not_to be_empty + expect(us_bank_account.verifications.first.verification_determined_at).to be_a Time + expect(us_bank_account.verifications.first.processor_response_code).to eq("2061") + expect(us_bank_account.verifications.first.additional_processor_response).to eq("Invalid routing number") + + expect(us_bank_account.verified).to eq(false) + + expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount) + end end it "fails with invalid nonce" do diff --git a/spec/integration/braintree/transaction_search_spec.rb b/spec/integration/braintree/transaction_search_spec.rb index 58060caf..9f2ddcda 100644 --- a/spec/integration/braintree/transaction_search_spec.rb +++ b/spec/integration/braintree/transaction_search_spec.rb @@ -1494,6 +1494,33 @@ }.to raise_error(Braintree::UnexpectedError) end end + + it "searches by payment instrument type meta checkout" do + meta_checkout_card_transaction = Braintree::Transaction.sale!( + :amount => Braintree::Test::TransactionAmounts::Authorize, + :options => { + :submit_for_settlement => true + }, + :payment_method_nonce => Braintree::Test::Nonce::MetaCheckoutCard, + ) + + meta_checkout_token_transaction = Braintree::Transaction.sale!( + :amount => Braintree::Test::TransactionAmounts::Authorize, + :options => { + :submit_for_settlement => true + }, + :payment_method_nonce => Braintree::Test::Nonce::MetaCheckoutToken, + ) + + collection = Braintree::Transaction.search do |search| + search.payment_instrument_type.in ["MetaCheckout"] + end + + collection.maximum_size.should == 2 + txn_ids = collection.map(&:id) + expect(txn_ids).to include(meta_checkout_card_transaction.id) + expect(txn_ids).to include(meta_checkout_token_transaction.id) + end end context "pagination" do diff --git a/spec/integration/braintree/transaction_spec.rb b/spec/integration/braintree/transaction_spec.rb index 38cdd383..47cfddc8 100644 --- a/spec/integration/braintree/transaction_spec.rb +++ b/spec/integration/braintree/transaction_spec.rb @@ -2,6 +2,72 @@ require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper") describe Braintree::Transaction do + let(:industry_data_flight_params) do + { + :industry => { + :industry_type => Braintree::Transaction::IndustryType::TravelAndFlight, + :data => { + :country_code => "US", + :date_of_birth => "2012-12-12", + :passenger_first_name => "John", + :passenger_last_name => "Doe", + :passenger_middle_initial => "M", + :passenger_title => "Mr.", + :issued_date => Date.new(2018, 1, 1), + :travel_agency_name => "Expedia", + :travel_agency_code => "12345678", + :ticket_number => "ticket-number", + :issuing_carrier_code => "AA", + :customer_code => "customer-code", + :fare_amount => 70_00, + :fee_amount => 10_00, + :tax_amount => 20_00, + :restricted_ticket => false, + :legs => [ + { + :conjunction_ticket => "CJ0001", + :exchange_ticket => "ET0001", + :coupon_number => "1", + :service_class => "Y", + :carrier_code => "AA", + :fare_basis_code => "W", + :flight_number => "AA100", + :departure_date => Date.new(2018, 1, 2), + :departure_airport_code => "MDW", + :departure_time => "08:00", + :arrival_airport_code => "ATX", + :arrival_time => "10:00", + :stopover_permitted => false, + :fare_amount => 35_00, + :fee_amount => 5_00, + :tax_amount => 10_00, + :endorsement_or_restrictions => "NOT REFUNDABLE" + }, + { + :conjunction_ticket => "CJ0002", + :exchange_ticket => "ET0002", + :coupon_number => "1", + :service_class => "Y", + :carrier_code => "AA", + :fare_basis_code => "W", + :flight_number => "AA200", + :departure_date => Date.new(2018, 1, 3), + :departure_airport_code => "ATX", + :departure_time => "12:00", + :arrival_airport_code => "MDW", + :arrival_time => "14:00", + :stopover_permitted => false, + :fare_amount => 35_00, + :fee_amount => 5_00, + :tax_amount => 10_00, + :endorsement_or_restrictions => "NOT REFUNDABLE" + } + ] + } + }, + } + end + describe "self.clone_transaction" do it "creates a new transaction from the card of the transaction to clone" do result = Braintree::Transaction.sale( @@ -306,8 +372,8 @@ check_out_date_must_follow_check_in_date = Braintree::ErrorCodes::Transaction::Industry::Lodging::CheckOutDateMustFollowCheckInDate room_rate_format_is_invalid = Braintree::ErrorCodes::Transaction::Industry::Lodging::RoomRateFormatIsInvalid invalid_additional_charge_kind = Braintree::ErrorCodes::Transaction::Industry::AdditionalCharge::KindIsInvalid - expect(result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort).to include(*[invalid_folio, check_out_date_must_follow_check_in_date, room_rate_format_is_invalid]) - expect(result.errors.for(:transaction).for(:industry).for(:additional_charges).for(:index_0).on(:kind).map { |e| e.code }.sort).to include(*[invalid_additional_charge_kind]) + expect(result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort).to include(invalid_folio, check_out_date_must_follow_check_in_date, room_rate_format_is_invalid) + expect(result.errors.for(:transaction).for(:industry).for(:additional_charges).for(:index_0).on(:kind).map { |e| e.code }.sort).to include(invalid_additional_charge_kind) end end @@ -356,74 +422,18 @@ context "for travel flight" do it "accepts valid industry data" do - result = Braintree::Transaction.create( + params = { :type => "sale", :amount => 1_00, :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment, :options => { :submit_for_settlement => true }, - :industry => { - :industry_type => Braintree::Transaction::IndustryType::TravelAndFlight, - :data => { - :passenger_first_name => "John", - :passenger_last_name => "Doe", - :passenger_middle_initial => "M", - :passenger_title => "Mr.", - :issued_date => Date.new(2018, 1, 1), - :travel_agency_name => "Expedia", - :travel_agency_code => "12345678", - :ticket_number => "ticket-number", - :issuing_carrier_code => "AA", - :customer_code => "customer-code", - :fare_amount => 70_00, - :fee_amount => 10_00, - :tax_amount => 20_00, - :restricted_ticket => false, - :legs => [ - { - :conjunction_ticket => "CJ0001", - :exchange_ticket => "ET0001", - :coupon_number => "1", - :service_class => "Y", - :carrier_code => "AA", - :fare_basis_code => "W", - :flight_number => "AA100", - :departure_date => Date.new(2018, 1, 2), - :departure_airport_code => "MDW", - :departure_time => "08:00", - :arrival_airport_code => "ATX", - :arrival_time => "10:00", - :stopover_permitted => false, - :fare_amount => 35_00, - :fee_amount => 5_00, - :tax_amount => 10_00, - :endorsement_or_restrictions => "NOT REFUNDABLE" - }, - { - :conjunction_ticket => "CJ0002", - :exchange_ticket => "ET0002", - :coupon_number => "1", - :service_class => "Y", - :carrier_code => "AA", - :fare_basis_code => "W", - :flight_number => "AA200", - :departure_date => Date.new(2018, 1, 3), - :departure_airport_code => "ATX", - :departure_time => "12:00", - :arrival_airport_code => "MDW", - :arrival_time => "14:00", - :stopover_permitted => false, - :fare_amount => 35_00, - :fee_amount => 5_00, - :tax_amount => 10_00, - :endorsement_or_restrictions => "NOT REFUNDABLE" - } - ] - } - }, - ) - expect(result.success?).to be(true) + } + params.merge(industry_data_flight_params) + + result = Braintree::Transaction.create(params) + result.success?.should be(true) end it "returns errors if validations on industry data fails" do @@ -1452,8 +1462,7 @@ it "returns an error if no credit card is given" do params = { - :transaction => { - } + :transaction => {} } result = Braintree::Transaction.create(params[:transaction]) expect(result.success?).to eq(false) @@ -2107,6 +2116,61 @@ expect(result.transaction.paypal_details.debug_id).not_to be_nil end + it "can create a transaction with a fake meta checkout card nonce" do + result = Braintree::Transaction.create( + :type => "sale", + :amount => Braintree::Test::TransactionAmounts::Authorize, + :payment_method_nonce => Braintree::Test::Nonce::MetaCheckoutCard, + ) + + result.success?.should == true + result.transaction.should_not be_nil + meta_checkout_card_details = result.transaction.meta_checkout_card_details + meta_checkout_card_details.should_not be_nil + meta_checkout_card_details.bin.should == "401288" + meta_checkout_card_details.card_type.should == Braintree::CreditCard::CardType::Visa + meta_checkout_card_details.cardholder_name.should == "Meta Checkout Card Cardholder" + meta_checkout_card_details.container_id.should == "container123" + meta_checkout_card_details.customer_location.should == "US" + meta_checkout_card_details.expiration_date.should == "12/2024" + meta_checkout_card_details.expiration_year.should == "2024" + meta_checkout_card_details.expiration_month.should == "12" + meta_checkout_card_details.image_url.should == "https://assets.braintreegateway.com/payment_method_logo/visa.png?environment=development" + meta_checkout_card_details.is_network_tokenized.should == false + meta_checkout_card_details.last_4.should == "1881" + meta_checkout_card_details.masked_number.should == "401288******1881" + meta_checkout_card_details.prepaid.should == "No" + end + + it "can create a transaction with a fake meta checkout token nonce" do + result = Braintree::Transaction.create( + :type => "sale", + :amount => Braintree::Test::TransactionAmounts::Authorize, + :payment_method_nonce => Braintree::Test::Nonce::MetaCheckoutToken, + ) + + result.success?.should == true + result.transaction.should_not be_nil + meta_checkout_token_details = result.transaction.meta_checkout_token_details + + meta_checkout_token_details.should_not be_nil + meta_checkout_token_details.bin.should == "401288" + meta_checkout_token_details.card_type.should == Braintree::CreditCard::CardType::Visa + meta_checkout_token_details.cardholder_name.should == "Meta Checkout Token Cardholder" + meta_checkout_token_details.container_id.should == "container123" + meta_checkout_token_details.cryptogram.should == "AlhlvxmN2ZKuAAESNFZ4GoABFA==" + meta_checkout_token_details.customer_location.should == "US" + meta_checkout_token_details.ecommerce_indicator.should == "07" + meta_checkout_token_details.expiration_date.should == "12/2024" + meta_checkout_token_details.expiration_year.should == "2024" + meta_checkout_token_details.expiration_month.should == "12" + meta_checkout_token_details.image_url.should == "https://assets.braintreegateway.com/payment_method_logo/visa.png?environment=development" + meta_checkout_token_details.is_network_tokenized.should == true + meta_checkout_token_details.last_4.should == "1881" + meta_checkout_token_details.masked_number.should == "401288******1881" + meta_checkout_token_details.prepaid.should == "No" + end + it "can create a transaction with a fake apple pay nonce" do customer = Braintree::Customer.create! result = Braintree::Transaction.create( @@ -5935,6 +5999,54 @@ end end + it "succeeds when industry data is provided" do + transaction = Braintree::Transaction.create( + :type => "sale", + :amount => Braintree::Test::TransactionAmounts::Authorize, + :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment, + :options => { + :submit_for_settlement => false + }, + ).transaction + + result = Braintree::Transaction.submit_for_settlement(transaction.id, Braintree::Test::TransactionAmounts::Authorize, industry_data_flight_params) + expect(result.success?).to be_truthy + end + + it "returns errors if validations on industry data fails" do + transaction = Braintree::Transaction.create( + :type => "sale", + :amount => Braintree::Test::TransactionAmounts::Authorize, + :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment, + :options => { + :submit_for_settlement => false + }, + ).transaction + + options = { + :industry => { + :industry_type => Braintree::Transaction::IndustryType::TravelAndFlight, + :data => { + :fare_amount => -1_23, + :restricted_ticket => false, + :legs => [ + { + :fare_amount => -1_23 + } + ] + } + }, + } + + result = Braintree::Transaction.submit_for_settlement(transaction.id, Braintree::Test::TransactionAmounts::Authorize, options) + expect(result.success?).to be_falsey + industry_errors = result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort + expect(industry_errors).to eq([Braintree::ErrorCodes::Transaction::Industry::TravelFlight::FareAmountCannotBeNegative]) + + leg_errors = result.errors.for(:transaction).for(:industry).for(:legs).for(:index_0).map { |e| e.code }.sort + expect(leg_errors).to eq([Braintree::ErrorCodes::Transaction::Industry::Leg::TravelFlight::FareAmountCannotBeNegative]) + end + xit "succeeds when level 2 data is provided" do result = Braintree::Transaction.sale( :amount => Braintree::Test::TransactionAmounts::Authorize, @@ -6371,6 +6483,20 @@ expect(result.success?).to eq(false) expect(result.errors.for(:transaction).on(:base)[0].code).to eq(Braintree::ErrorCodes::Transaction::CannotSubmitForSettlement) end + + it "succeeds when industry data is provided" do + transaction = Braintree::Transaction.create( + :type => "sale", + :amount => Braintree::Test::TransactionAmounts::Authorize, + :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment, + :options => { + :submit_for_settlement => false + }, + ).transaction + + result = Braintree::Transaction.submit_for_partial_settlement(transaction.id, Braintree::Test::TransactionAmounts::Authorize, industry_data_flight_params) + expect(result.success?).to be_truthy + end end describe "self.submit_for_partial_settlement!" do diff --git a/spec/unit/braintree/enriched_customer_data_spec.rb b/spec/unit/braintree/enriched_customer_data_spec.rb index 15fca914..2ddd5ac7 100644 --- a/spec/unit/braintree/enriched_customer_data_spec.rb +++ b/spec/unit/braintree/enriched_customer_data_spec.rb @@ -12,6 +12,13 @@ describe "self._new" do it "initializes the object with the appropriate attributes set" do + address = { + street_address: "a-street-address", + extended_address: "an-extended-address", + locality: "a-locality", + region: "a-region", + postal_code: "a-postal-code" + } params = { fields_updated: ["username"], profile_data: { @@ -20,6 +27,8 @@ last_name: "a-last-name", phone_number: "a-phone-number", email: "a-email", + billing_address: address, + shipping_address: address, }, } diff --git a/spec/unit/braintree/http_spec.rb b/spec/unit/braintree/http_spec.rb index fbf220a5..bdf4d841 100644 --- a/spec/unit/braintree/http_spec.rb +++ b/spec/unit/braintree/http_spec.rb @@ -121,7 +121,7 @@ end describe "_compose_headers" do - before (:each) do + before(:each) do config = Braintree::Configuration.new @http = Braintree::Http.new(config) end diff --git a/spec/unit/braintree/meta_checkout_card_details_spec.rb b/spec/unit/braintree/meta_checkout_card_details_spec.rb new file mode 100644 index 00000000..7ff3951d --- /dev/null +++ b/spec/unit/braintree/meta_checkout_card_details_spec.rb @@ -0,0 +1,60 @@ +require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") + +describe Braintree::Transaction::MetaCheckoutCardDetails do + let(:attributes) do { + + :bin => "abc1234", + :container_id => "a-container-id", + :card_type => "Visa", + :cardholder_name => "Meta Checkout Card CardHolder", + :commercial => "NO", + :country_of_issuance => "US", + :created_at => "2023-05-05T21:28:37Z", + :debit => "NO", + :durbin_regulated => "NO", + :expiration_month => "05", + :expiration_year => "2024", + :healthcare => "NO", + :last_4 => "1234", + :payroll => "NO", + :prepaid => "NO", + :token => "token1", + :unique_number_identifier => "abc1234", + :updated_at => "2023-05-05T21:28:37Z" + } + end + + describe "unit tests" do + it "initializes with the correct attributes" do + card = Braintree::Transaction::MetaCheckoutCardDetails.new(attributes) + + card.bin.should == "abc1234" + card.container_id.should == "a-container-id" + card.card_type.should == "Visa" + card.cardholder_name.should == "Meta Checkout Card CardHolder" + card.commercial == "NO" + card.country_of_issuance == "US" + card.created_at == "2023-05-05T21:28:37Z" + card.updated_at == "2023-05-05T21:28:37Z" + card.debit == "NO" + card.payroll == "NO" + card.prepaid == "NO" + card.healthcare == "NO" + card.token == "token1" + card.unique_number_identifier == "abc1234" + card.expiration_month.should == "05" + card.expiration_year.should == "2024" + card.last_4.should == "1234" + end + + it "sets expiration date correctly" do + card = Braintree::Transaction::MetaCheckoutCardDetails.new(attributes) + card.expiration_date.should == "05/2024" + end + + it "masks the card number correctly" do + card = Braintree::Transaction::MetaCheckoutCardDetails.new(attributes) + card.masked_number.should == "abc1234******1234" + end + end +end \ No newline at end of file diff --git a/spec/unit/braintree/meta_checkout_card_spec.rb b/spec/unit/braintree/meta_checkout_card_spec.rb new file mode 100644 index 00000000..fca214b0 --- /dev/null +++ b/spec/unit/braintree/meta_checkout_card_spec.rb @@ -0,0 +1,60 @@ +require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") + +describe Braintree::MetaCheckoutCard do + let(:attributes) do { + + :bin => "abc1234", + :container_id => "a-container-id", + :card_type => "Visa", + :cardholder_name => "Meta Checkout Card CardHolder", + :commercial => "NO", + :country_of_issuance => "US", + :created_at => "2023-05-05T21:28:37Z", + :debit => "NO", + :durbin_regulated => "NO", + :expiration_month => "05", + :expiration_year => "2024", + :healthcare => "NO", + :last_4 => "1234", + :payroll => "NO", + :prepaid => "NO", + :token => "token1", + :unique_number_identifier => "abc1234", + :updated_at => "2023-05-05T21:28:37Z" + } + end + + describe "unit tests" do + it "initializes with the correct attributes" do + card = Braintree::MetaCheckoutCard._new(:gateway, attributes) + + card.bin.should == "abc1234" + card.container_id.should == "a-container-id" + card.card_type.should == "Visa" + card.cardholder_name.should == "Meta Checkout Card CardHolder" + card.commercial == "NO" + card.country_of_issuance == "US" + card.created_at == "2023-05-05T21:28:37Z" + card.updated_at == "2023-05-05T21:28:37Z" + card.debit == "NO" + card.payroll == "NO" + card.prepaid == "NO" + card.healthcare == "NO" + card.token == "token1" + card.unique_number_identifier == "abc1234" + card.expiration_month.should == "05" + card.expiration_year.should == "2024" + card.last_4.should == "1234" + end + + it "sets expiration date correctly" do + card = Braintree::MetaCheckoutCard._new(:gateway, attributes) + card.expiration_date.should == "05/2024" + end + + it "masks the card number correctly" do + card = Braintree::MetaCheckoutCard._new(:gateway, attributes) + card.masked_number.should == "abc1234******1234" + end + end +end \ No newline at end of file diff --git a/spec/unit/braintree/meta_checkout_token_details_spec.rb b/spec/unit/braintree/meta_checkout_token_details_spec.rb new file mode 100644 index 00000000..00368cf3 --- /dev/null +++ b/spec/unit/braintree/meta_checkout_token_details_spec.rb @@ -0,0 +1,63 @@ +require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") + +describe Braintree::Transaction::MetaCheckoutTokenDetails do + let(:attributes) do { + :bin => "abc1234", + :container_id => "a-container-id", + :card_type => "Visa", + :cardholder_name => "Meta Checkout Card CardHolder", + :commercial => "NO", + :country_of_issuance => "US", + :created_at => "2023-05-05T21:28:37Z", + :debit => "NO", + :durbin_regulated => "NO", + :expiration_month => "05", + :expiration_year => "2024", + :healthcare => "NO", + :last_4 => "1234", + :payroll => "NO", + :prepaid => "NO", + :token => "token1", + :unique_number_identifier => "abc1234", + :updated_at => "2023-05-05T21:28:37Z", + :cryptogram => "AlhlvxmN2ZKuAAESNFZ4GoABFA==", + :ecommerce_indicator => "07" + } + end + + describe "unit tests" do + it "initializes with the correct attributes" do + card = Braintree::Transaction::MetaCheckoutTokenDetails.new(attributes) + + card.bin.should == "abc1234" + card.container_id.should == "a-container-id" + card.card_type.should == "Visa" + card.cardholder_name.should == "Meta Checkout Card CardHolder" + card.commercial == "NO" + card.country_of_issuance == "US" + card.created_at == "2023-05-05T21:28:37Z" + card.updated_at == "2023-05-05T21:28:37Z" + card.debit == "NO" + card.payroll == "NO" + card.prepaid == "NO" + card.healthcare == "NO" + card.token == "token1" + card.unique_number_identifier == "abc1234" + card.expiration_month.should == "05" + card.expiration_year.should == "2024" + card.last_4.should == "1234" + card.cryptogram == "AlhlvxmN2ZKuAAESNFZ4GoABFA==" + card.ecommerce_indicator == "07" + end + + it "sets expiration date correctly" do + card = Braintree::Transaction::MetaCheckoutTokenDetails.new(attributes) + card.expiration_date.should == "05/2024" + end + + it "masks the card number correctly" do + card = Braintree::Transaction::MetaCheckoutTokenDetails.new(attributes) + card.masked_number.should == "abc1234******1234" + end + end +end \ No newline at end of file diff --git a/spec/unit/braintree/meta_checkout_token_spec.rb b/spec/unit/braintree/meta_checkout_token_spec.rb new file mode 100644 index 00000000..018caeaf --- /dev/null +++ b/spec/unit/braintree/meta_checkout_token_spec.rb @@ -0,0 +1,63 @@ +require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") + +describe Braintree::MetaCheckoutToken do + let(:attributes) do { + :bin => "abc1234", + :container_id => "a-container-id", + :card_type => "Visa", + :cardholder_name => "Meta Checkout Card CardHolder", + :commercial => "NO", + :country_of_issuance => "US", + :created_at => "2023-05-05T21:28:37Z", + :debit => "NO", + :durbin_regulated => "NO", + :expiration_month => "05", + :expiration_year => "2024", + :healthcare => "NO", + :last_4 => "1234", + :payroll => "NO", + :prepaid => "NO", + :token => "token1", + :unique_number_identifier => "abc1234", + :updated_at => "2023-05-05T21:28:37Z", + :cryptogram => "AlhlvxmN2ZKuAAESNFZ4GoABFA==", + :ecommerce_indicator => "07" + } + end + + describe "unit tests" do + it "initializes with the correct attributes" do + card = Braintree::MetaCheckoutToken._new(:gateway, attributes) + + card.bin.should == "abc1234" + card.container_id.should == "a-container-id" + card.card_type.should == "Visa" + card.cardholder_name.should == "Meta Checkout Card CardHolder" + card.commercial == "NO" + card.country_of_issuance == "US" + card.created_at == "2023-05-05T21:28:37Z" + card.updated_at == "2023-05-05T21:28:37Z" + card.debit == "NO" + card.payroll == "NO" + card.prepaid == "NO" + card.healthcare == "NO" + card.token == "token1" + card.unique_number_identifier == "abc1234" + card.expiration_month.should == "05" + card.expiration_year.should == "2024" + card.last_4.should == "1234" + card.cryptogram == "AlhlvxmN2ZKuAAESNFZ4GoABFA==" + card.ecommerce_indicator == "07" + end + + it "sets expiration date correctly" do + card = Braintree::MetaCheckoutToken._new(:gateway, attributes) + card.expiration_date.should == "05/2024" + end + + it "masks the card number correctly" do + card = Braintree::MetaCheckoutToken._new(:gateway, attributes) + card.masked_number.should == "abc1234******1234" + end + end +end \ No newline at end of file diff --git a/spec/unit/braintree/transaction_gateway_spec.rb b/spec/unit/braintree/transaction_gateway_spec.rb index a239765e..b1d78fa7 100644 --- a/spec/unit/braintree/transaction_gateway_spec.rb +++ b/spec/unit/braintree/transaction_gateway_spec.rb @@ -94,7 +94,7 @@ {:industry => [ :industry_type, {:data => [ - :folio_number, :check_in_date, :check_out_date, :travel_package, :lodging_check_in_date, :lodging_check_out_date, :departure_date, :lodging_name, :room_rate, :room_tax, + :country_code, :date_of_birth, :folio_number, :check_in_date, :check_out_date, :travel_package, :lodging_check_in_date, :lodging_check_out_date, :departure_date, :lodging_name, :room_rate, :room_tax, :passenger_first_name, :passenger_last_name, :passenger_middle_initial, :passenger_title, :issued_date, :travel_agency_name, :travel_agency_code, :ticket_number, :issuing_carrier_code, :customer_code, :fare_amount, :fee_amount, :tax_amount, :restricted_ticket, :no_show, :advanced_deposit, :fire_safe, :property_phone, :ticket_issuer_address, :arrival_date, {:legs => [ @@ -111,5 +111,34 @@ {:installments => [:count]}, ]) end + + it "creates a transaction gateway submit for settlement signature" do + expect(Braintree::TransactionGateway._submit_for_settlement_signature).to match([ + :order_id, + {:descriptor => [:name, :phone, :url]}, + {:industry => [ + :industry_type, + {:data => [ + :country_code, :date_of_birth, :folio_number, :check_in_date, :check_out_date, :travel_package, :lodging_check_in_date, :lodging_check_out_date, :departure_date, :lodging_name, :room_rate, :room_tax, + :passenger_first_name, :passenger_last_name, :passenger_middle_initial, :passenger_title, :issued_date, :travel_agency_name, :travel_agency_code, :ticket_number, + :issuing_carrier_code, :customer_code, :fare_amount, :fee_amount, :tax_amount, :restricted_ticket, :no_show, :advanced_deposit, :fire_safe, :property_phone, :ticket_issuer_address, :arrival_date, + {:legs => [ + :conjunction_ticket, :exchange_ticket, :coupon_number, :service_class, :carrier_code, :fare_basis_code, :flight_number, :departure_date, :departure_airport_code, :departure_time, + :arrival_airport_code, :arrival_time, :stopover_permitted, :fare_amount, :fee_amount, :tax_amount, :endorsement_or_restrictions, + ]}, + {:additional_charges => [ + :kind, :amount, + ]}, + ]}, + ]}, + :purchase_order_number, + :tax_amount, + :tax_exempt, + :discount_amount, + :shipping_amount, + :ships_from_postal_code, + :line_items => [:commodity_code, :description, :discount_amount, :kind, :name, :product_code, :quantity, :tax_amount, :total_amount, :unit_amount, :unit_of_measure, :unit_tax_amount, :url, :tax_amount], + ]) + end end end diff --git a/spec/unit/braintree/us_bank_account_verification_spec.rb b/spec/unit/braintree/us_bank_account_verification_spec.rb index c318fe13..7d6e15b8 100644 --- a/spec/unit/braintree/us_bank_account_verification_spec.rb +++ b/spec/unit/braintree/us_bank_account_verification_spec.rb @@ -8,12 +8,17 @@ :status => Braintree::UsBankAccountVerification::Status::Verified, :verification_method => Braintree::UsBankAccountVerification::VerificationMethod::IndependentCheck, :verification_determined_at => "2018-02-28T12:01:01Z", + :additional_processor_response => "some_invalid_processor_response", ) end it "has a status" do expect(verification.status).to eq(Braintree::UsBankAccountVerification::Status::Verified) end + + it "has additional processor response" do + expect(verification.additional_processor_response).to eq("some_invalid_processor_response") + end end describe "self.confirm_micro_transfer_amounts" do diff --git a/spec/unit/braintree/venmo_profile_data_spec.rb b/spec/unit/braintree/venmo_profile_data_spec.rb index 978dff59..e6af080f 100644 --- a/spec/unit/braintree/venmo_profile_data_spec.rb +++ b/spec/unit/braintree/venmo_profile_data_spec.rb @@ -12,12 +12,21 @@ describe "self._new" do it "initializes the object with the appropriate attributes set" do + address = { + street_address: "a-street-address", + extended_address: "an-extended-address", + locality: "a-locality", + region: "a-region", + postal_code: "a-postal-code" + } params = { username: "a-username", first_name: "a-first-name", last_name: "a-last-name", phone_number: "12312312343", email: "a-email", + billing_address: address, + shipping_address: address } payment_method_customer_data_updated = Braintree::VenmoProfileData._new(params) @@ -27,6 +36,8 @@ expect(payment_method_customer_data_updated.last_name).to eq("a-last-name") expect(payment_method_customer_data_updated.phone_number).to eq("12312312343") expect(payment_method_customer_data_updated.email).to eq("a-email") + expect(payment_method_customer_data_updated.billing_address).to eq(address) + expect(payment_method_customer_data_updated.shipping_address).to eq(address) end end end