Class: FakeBraintree

Inherits:
Object
  • Object
show all
Defined in:
lib/saucy/fake_braintree.rb

Constant Summary collapse

@@customers =
{}
@@subscriptions =
{}
@@failures =
{}
@@transaction =
{}

Class Method Summary collapse

Class Method Details

.clear!Object



18
19
20
21
22
23
# File 'lib/saucy/fake_braintree.rb', line 18

def self.clear!
  @@customers = {}
  @@subscriptions = {}
  @@failures = {}
  @@transaction = {}
end

.failure?(card_number) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/saucy/fake_braintree.rb', line 25

def self.failure?(card_number)
  self.failures.include?(card_number)
end

.failure_response(card_number) ⇒ Object



29
30
31
32
33
# File 'lib/saucy/fake_braintree.rb', line 29

def self.failure_response(card_number)
  failure = self.failures[card_number]
  failure["errors"] ||= { "errors" => [] }
  { "message" => failure["message"], "verification" => { "status" => failure["status"], "processor_response_text"  => failure["message"], "processor-response-code" => failure["code"], "gateway_rejection_reason" => "cvv", "cvv_response_code" => failure["code"] }, "errors" => failure["errors"], "params" => {}}
end

.generated_transactionObject



35
36
37
# File 'lib/saucy/fake_braintree.rb', line 35

def self.generated_transaction
  {"status_history"=>[{"timestamp"=>Time.now, "amount"=>FakeBraintree.transaction[:amount], "transaction_source"=>"CP", "user"=>"copycopter", "status"=>"authorized"}, {"timestamp"=>Time.now, "amount"=>FakeBraintree.transaction[:amount], "transaction_source"=>"CP", "user"=>"copycopter", "status"=>FakeBraintree.transaction[:status]}], "created_at"=>(FakeBraintree.transaction[:created_at] || Time.now), "currency_iso_code"=>"USD", "settlement_batch_id"=>nil, "processor_authorization_code"=>"ZKB4VJ", "avs_postal_code_response_code"=>"I", "order_id"=>nil, "updated_at"=>Time.now, "refunded_transaction_id"=>nil, "amount"=>FakeBraintree.transaction[:amount], "credit_card"=>{"last_4"=>"1111", "card_type"=>"Visa", "token"=>"8yq7", "customer_location"=>"US", "expiration_year"=>"2013", "expiration_month"=>"02", "bin"=>"411111", "cardholder_name"=>"Chad Lee Pytel"}, "refund_id"=>nil, "add_ons"=>[], "shipping"=>{"region"=>nil, "company"=>nil, "country_name"=>nil, "extended_address"=>nil, "postal_code"=>nil, "id"=>nil, "street_address"=>nil, "country_code_numeric"=>nil, "last_name"=>nil, "locality"=>nil, "country_code_alpha2"=>nil, "country_code_alpha3"=>nil, "first_name"=>nil}, "id"=>"49sbx6", "merchant_account_id"=>"Thoughtbot", "type"=>"sale", "cvv_response_code"=>"I", "subscription_id"=>FakeBraintree.transaction[:subscription_id], "custom_fields"=>"\n    ", "discounts"=>[], "billing"=>{"region"=>nil, "company"=>nil, "country_name"=>nil, "extended_address"=>nil, "postal_code"=>nil, "id"=>nil, "street_address"=>nil, "country_code_numeric"=>nil, "last_name"=>nil, "locality"=>nil, "country_code_alpha2"=>nil, "country_code_alpha3"=>nil, "first_name"=>nil}, "processor_response_code"=>"1000", "refund_ids"=>[], "customer"=>{"company"=>nil, "id"=>"108427", "last_name"=>nil, "fax"=>nil, "phone"=>nil, "website"=>nil, "first_name"=>nil, "email"=>"[email protected]"}, "avs_error_response_code"=>nil, "processor_response_text"=>"Approved", "avs_street_address_response_code"=>"I", "status"=>FakeBraintree.transaction[:status], "gateway_rejection_reason"=>nil}
end