Class: Braintree::CreditCardVerificationGateway
- Inherits:
-
Object
- Object
- Braintree::CreditCardVerificationGateway
- Defined in:
- lib/braintree/credit_card_verification_gateway.rb
Class Method Summary collapse
Instance Method Summary collapse
- #_fetch_verifications(search, ids) ⇒ Object
- #_handle_verification_create_response(response) ⇒ Object
- #create(params) ⇒ Object
- #find(id) ⇒ Object
-
#initialize(gateway) ⇒ CreditCardVerificationGateway
constructor
A new instance of CreditCardVerificationGateway.
- #search(&block) ⇒ Object
Constructor Details
#initialize(gateway) ⇒ CreditCardVerificationGateway
Returns a new instance of CreditCardVerificationGateway.
3 4 5 6 7 |
# File 'lib/braintree/credit_card_verification_gateway.rb', line 3 def initialize(gateway) @gateway = gateway @config = gateway.config @config.assert_has_access_token_or_keys end |
Class Method Details
._create_signature ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/braintree/credit_card_verification_gateway.rb', line 47 def self._create_signature [ {:options => [:amount, :merchant_account_id, :account_type]}, {:credit_card => [ :cardholder_name, :cvv, :expiration_date, :expiration_month, :expiration_year, :number, {:billing_address => AddressGateway._shared_signature} ]} ] end |
Instance Method Details
#_fetch_verifications(search, ids) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/braintree/credit_card_verification_gateway.rb', line 40 def _fetch_verifications(search, ids) search.ids.in ids response = @config.http.post("#{@config.base_merchant_path}/verifications/advanced_search", {:search => search.to_hash}) attributes = response[:credit_card_verifications] Util.extract_attribute_as_array(attributes, :verification).map { |attrs| CreditCardVerification._new(attrs) } end |
#_handle_verification_create_response(response) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/braintree/credit_card_verification_gateway.rb', line 30 def _handle_verification_create_response(response) if response[:verification] SuccessfulResult.new(:verification => CreditCardVerification._new(response[:verification])) elsif response[:api_error_response] ErrorResult.new(@gateway, response[:api_error_response]) else raise UnexpectedError, "expected :verification or :api_error_response" end end |
#create(params) ⇒ Object
25 26 27 28 |
# File 'lib/braintree/credit_card_verification_gateway.rb', line 25 def create(params) response = @config.http.post("#{@config.base_merchant_path}/verifications", :verification => params) _handle_verification_create_response(response) end |
#find(id) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/braintree/credit_card_verification_gateway.rb', line 9 def find(id) raise ArgumentError if id.nil? || id.to_s.strip == "" response = @config.http.get("#{@config.base_merchant_path}/verifications/#{id}") CreditCardVerification._new(response[:verification]) rescue NotFoundError raise NotFoundError, "verification with id #{id.inspect} not found" end |
#search(&block) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/braintree/credit_card_verification_gateway.rb', line 17 def search(&block) search = CreditCardVerificationSearch.new block.call(search) if block response = @config.http.post("#{@config.base_merchant_path}/verifications/advanced_search_ids", {:search => search.to_hash}) ResourceCollection.new(response) { |ids| _fetch_verifications(search, ids) } end |