Class: VaultedBilling::Gateways::Bogus

Inherits:
Object
  • Object
show all
Includes:
VaultedBilling::Gateway, Failure
Defined in:
lib/vaulted_billing/gateways/bogus.rb,
lib/vaulted_billing/gateways/bogus/failure.rb

Overview

The Bogus gateway should only be used for simple interface testing to the VaultedBilling library. All customer and credit card requests will always return successfully. All transaction requests (purchase, authorize, capture, etc.) will always return successfully, unless a failure credit card number is given.

If a failure credit card number is given, then the transaction amount is used to determine the error message and code to return.

The primary purpose of this gateway is to provide you with an end point for testing your interface, as well as a fairly reasonable gateway for performing simple, non-network based tests against.

To test failure messages, use the credit card number ‘4222222222222’. This card number will trigger failed transaction responses from the Bogus gateway for purchase and authorize requests. In order to receive a specific error message / code, set the transaction amount to one of the following:

0: 'This transaction has been declined.'
1: 'This transaction has been approved.'
2: 'This transaction has been declined.'
3: 'This transaction has been declined.'
4: 'This transaction has been declined.'
5: 'A valid amount is required.'
6: 'The credit card number is invalid.'
7: 'The credit card expiration date is invalid'
8: 'The credit card has expired.'
9: 'The ABA code is invalid'
10: 'The account number is invalid.'
11: 'A duplicate transaction has been submitted.'

Example:

customer = Customer.new(...)
credit_card = CreditCard.new(:card_number => '4222222222222')
bogus.purchase(customer, credit_card, 6.00)
# => Failed transaction, 'The credit card number is invalid.'

Defined Under Namespace

Modules: Failure

Constant Summary

Constants included from Failure

Failure::FailureCards, Failure::FailureMessages

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Bogus

Returns a new instance of Bogus.



52
53
# File 'lib/vaulted_billing/gateways/bogus.rb', line 52

def initialize(options = {})
end

Instance Method Details

#add_customer(customer) ⇒ Object



55
56
57
# File 'lib/vaulted_billing/gateways/bogus.rb', line 55

def add_customer(customer)
  respond_with(customer.to_vaulted_billing) { |c| c.vault_id = new_identifier }
end

#add_customer_credit_card(customer, credit_card, options = {}) ⇒ Object



67
68
69
# File 'lib/vaulted_billing/gateways/bogus.rb', line 67

def add_customer_credit_card(customer, credit_card, options = {})
  respond_with(credit_card.to_vaulted_billing) { |c| c.vault_id = new_identifier }
end

#authorize(customer, credit_card, amount, options = {}) ⇒ Object



79
80
81
# File 'lib/vaulted_billing/gateways/bogus.rb', line 79

def authorize(customer, credit_card, amount, options = {})
  transaction_response credit_card, amount
end

#capture(transaction_id, amount, options = {}) ⇒ Object



91
92
93
# File 'lib/vaulted_billing/gateways/bogus.rb', line 91

def capture(transaction_id, amount, options = {})
  transaction_response nil, amount
end

#purchase(customer, credit_card, amount, options = {}) ⇒ Object



83
84
85
# File 'lib/vaulted_billing/gateways/bogus.rb', line 83

def purchase(customer, credit_card, amount, options = {})
  transaction_response credit_card, amount
end

#refund(transaction_id, amount, options = {}) ⇒ Object



95
96
97
# File 'lib/vaulted_billing/gateways/bogus.rb', line 95

def refund(transaction_id, amount, options = {})
  transaction_response nil, amount
end

#remove_customer(customer) ⇒ Object



63
64
65
# File 'lib/vaulted_billing/gateways/bogus.rb', line 63

def remove_customer(customer)
  respond_with customer.to_vaulted_billing
end

#remove_customer_credit_card(customer, credit_card) ⇒ Object



75
76
77
# File 'lib/vaulted_billing/gateways/bogus.rb', line 75

def remove_customer_credit_card(customer, credit_card)
  respond_with credit_card.to_vaulted_billing
end

#update_customer(customer) ⇒ Object



59
60
61
# File 'lib/vaulted_billing/gateways/bogus.rb', line 59

def update_customer(customer)
  respond_with customer.to_vaulted_billing
end

#update_customer_credit_card(customer, credit_card, options = {}) ⇒ Object



71
72
73
# File 'lib/vaulted_billing/gateways/bogus.rb', line 71

def update_customer_credit_card(customer, credit_card, options = {})
  respond_with credit_card.to_vaulted_billing
end

#void(transaction_id, options = {}) ⇒ Object



87
88
89
# File 'lib/vaulted_billing/gateways/bogus.rb', line 87

def void(transaction_id, options = {})
  transaction_response nil, nil
end