Class: TransactionGateway::FortisGateway
- Includes:
- GatewayErrors
- Defined in:
- lib/transaction_gateway/fortis_gateway.rb
Defined Under Namespace
Modules: API
Constant Summary
Constants inherited from Result
Result::AUTHORIZEDOTNET, Result::BRAINTREE, Result::FORTIS
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
-
#location_api_key ⇒ Object
Returns the value of attribute location_api_key.
-
#user_api_key ⇒ Object
Returns the value of attribute user_api_key.
-
#user_id ⇒ Object
Returns the value of attribute user_id.
Class Method Summary collapse
Instance Method Summary collapse
- #create_card_account(card, customer_profile_id) ⇒ Object
- #create_customer_profile(customer, card = nil) ⇒ Object
- #create_transaction(card, amount) ⇒ Object
- #force_settle(profile, authorize_code, amount) ⇒ Object
-
#initialize(user_id, user_api_key, location_api_key, environment = :sandbox) ⇒ FortisGateway
constructor
A new instance of FortisGateway.
- #refund(profile, amount) ⇒ Object
- #settle_transaction(card_transaction_id, amount = nil) ⇒ Object
- #void_transaction(transaction_id) ⇒ Object
Methods inherited from Result
Constructor Details
#initialize(user_id, user_api_key, location_api_key, environment = :sandbox) ⇒ FortisGateway
Returns a new instance of FortisGateway.
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/transaction_gateway/fortis_gateway.rb', line 50 def initialize(user_id, user_api_key, location_api_key, environment = :sandbox) self.user_id = user_id self.user_api_key = user_api_key self.location_api_key = location_api_key case environment.to_s.gsub(/\s/, '').downcase.to_sym when :production self.api = "https://api.zeamster.com" else self.api = "https://api.sandbox.zeamster.com" end end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
7 8 9 |
# File 'lib/transaction_gateway/fortis_gateway.rb', line 7 def api @api end |
#location_api_key ⇒ Object
Returns the value of attribute location_api_key.
7 8 9 |
# File 'lib/transaction_gateway/fortis_gateway.rb', line 7 def location_api_key @location_api_key end |
#user_api_key ⇒ Object
Returns the value of attribute user_api_key.
7 8 9 |
# File 'lib/transaction_gateway/fortis_gateway.rb', line 7 def user_api_key @user_api_key end |
#user_id ⇒ Object
Returns the value of attribute user_id.
7 8 9 |
# File 'lib/transaction_gateway/fortis_gateway.rb', line 7 def user_id @user_id end |
Class Method Details
.gateway_url(environment = :sandbox) ⇒ Object
63 64 65 66 67 |
# File 'lib/transaction_gateway/fortis_gateway.rb', line 63 def self.gateway_url(environment = :sandbox) environment = environment.to_s.gsub(/\s/, "").downcase environment = "sandbox" if environment == "" return self.new("", "", "", environment.to_sym).api end |
Instance Method Details
#create_card_account(card, customer_profile_id) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/transaction_gateway/fortis_gateway.rb', line 116 def create_card_account(card, customer_profile_id) raise TransactionGatewayInvalidCardType unless card.class == GatewayCard sale_info ={ :contact_id => customer_profile_id, :card_number => card.card_number, :exp_date => "#{card.expiration_month}#{card.expiration_year}" } return handle_result(call_request(API::CARD_ACCOUNT, sale_info, "POST"), FORTIS) end |
#create_customer_profile(customer, card = nil) ⇒ Object
105 106 107 108 109 110 111 112 113 114 |
# File 'lib/transaction_gateway/fortis_gateway.rb', line 105 def create_customer_profile(customer, card = nil) raise InvalidCustomerType unless customer.class == GatewayCustomer result = handle_result(call_request(API::CONTACT, customer.convert_to_fortis_input, "POST"), FORTIS) result = create_card_account(card, result["contact"]["contact_id"]) if card return result end |
#create_transaction(card, amount) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/transaction_gateway/fortis_gateway.rb', line 69 def create_transaction(card, amount) raise TransactionGatewayInvalidCardType unless card.class == GatewayCard raise TransactionGatewayInvalidAmount if amount.to_f <= 0 sale_info ={ :cv => card.cvv, :card_number => card.card_number, :exp_date => "#{card.expiration_month}#{card.expiration_year}", :transaction_amount => amount } return handle_result(call_request(API::AUTHONLYPATH, sale_info, "POST"), FORTIS) end |
#force_settle(profile, authorize_code, amount) ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/transaction_gateway/fortis_gateway.rb', line 128 def force_settle(profile, , amount) raise InvalidPaymentProfileType unless profile.class == GatewayCustomerProfile raise TransactionGatewayInvalidAmount if amount.to_f <= 0 sale_info ={ :card_account_id => profile.payment_profile_id, :transaction_amount => amount, :auth => } return handle_result(call_request(API::CAPTURE_FORCE, sale_info, "POST"), FORTIS) end |
#refund(profile, amount) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/transaction_gateway/fortis_gateway.rb', line 89 def refund(profile, amount) raise InvalidPaymentProfileType unless profile.class == GatewayCustomerProfile raise TransactionGatewayInvalidAmount, "Amount to refund shouldn't equal to zero." if amount.to_f == 0 sale_info ={ :card_account_id => profile.profile_id, :transaction_amount => amount.abs } return handle_result(call_request(API::REFUND, sale_info, "POST"), FORTIS) end |
#settle_transaction(card_transaction_id, amount = nil) ⇒ Object
83 84 85 86 87 |
# File 'lib/transaction_gateway/fortis_gateway.rb', line 83 def settle_transaction(card_transaction_id, amount = nil) sale_info = {} sale_info = {:transaction_amount => amount} if amount return handle_result(call_request(API::SETTLEPATH.gsub('?', card_transaction_id), sale_info), FORTIS) end |