Class: ActiveMerchant::Billing::CardknoxGateway
- Defined in:
- lib/active_merchant/billing/gateways/cardknox.rb
Constant Summary collapse
- COMMANDS =
{ credit_card: { purchase: 'cc:sale', authorization: 'cc:authonly', capture: 'cc:capture', refund: 'cc:refund', void: 'cc:void', save: 'cc:save' }, check: { purchase: 'check:sale', refund: 'check:refund', void: 'check:void', save: 'check:save' } }
Constants inherited from Gateway
Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE
Instance Attribute Summary
Attributes inherited from Gateway
Instance Method Summary collapse
- #authorize(amount, source, options = {}) ⇒ Object
- #capture(amount, authorization, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ CardknoxGateway
constructor
A new instance of CardknoxGateway.
-
#purchase(amount, source, options = {}) ⇒ Object
There are three sources for doing a purchase transation: - credit card - check - cardknox token, which is returned in the the authorization string “ref_num;token;command”.
- #refund(amount, authorization, options = {}) ⇒ Object
- #scrub(transcript) ⇒ Object
- #store(source, options = {}) ⇒ Object
- #supports_scrubbing? ⇒ Boolean
- #verify(credit_card, options = {}) ⇒ Object
- #void(authorization, options = {}) ⇒ Object
Methods inherited from Gateway
#add_field_to_post_if_present, #add_fields_to_post_if_present, #card_brand, card_brand, #generate_unique_id, inherited, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #test?
Methods included from CreditCardFormatting
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
#initialize(options = {}) ⇒ CardknoxGateway
Returns a new instance of CardknoxGateway.
30 31 32 33 |
# File 'lib/active_merchant/billing/gateways/cardknox.rb', line 30 def initialize(={}) requires!(, :api_key) super end |
Instance Method Details
#authorize(amount, source, options = {}) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/active_merchant/billing/gateways/cardknox.rb', line 51 def (amount, source, ={}) post = {} add_amount(post, amount) add_invoice(post, ) add_source(post, source) add_address(post, source, ) add_customer_data(post, ) add_custom_fields(post, ) commit(:authorization, source_type(source), post) end |
#capture(amount, authorization, options = {}) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/active_merchant/billing/gateways/cardknox.rb', line 62 def capture(amount, , = {}) post = {} add_reference(post, ) add_amount(post, amount) commit(:capture, source_type(), post) end |
#purchase(amount, source, options = {}) ⇒ Object
There are three sources for doing a purchase transation:
-
credit card
-
check
-
cardknox token, which is returned in the the authorization string “ref_num;token;command”
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/active_merchant/billing/gateways/cardknox.rb', line 40 def purchase(amount, source, ={}) post = {} add_amount(post, amount, ) add_invoice(post, ) add_source(post, source) add_address(post, source, ) add_customer_data(post, ) add_custom_fields(post, ) commit(:purchase, source_type(source), post) end |
#refund(amount, authorization, options = {}) ⇒ Object
69 70 71 72 73 74 |
# File 'lib/active_merchant/billing/gateways/cardknox.rb', line 69 def refund(amount, , ={}) post = {} add_reference(post, ) add_amount(post, amount) commit(:refund, source_type(), post) end |
#scrub(transcript) ⇒ Object
103 104 105 106 107 108 109 110 |
# File 'lib/active_merchant/billing/gateways/cardknox.rb', line 103 def scrub(transcript) transcript. gsub(%r((xCardNum=)\d+), '\1[FILTERED]'). gsub(%r((xCVV=)\d+), '\1[FILTERED]'). gsub(%r((xAccount=)\d+), '\1[FILTERED]'). gsub(%r((xRouting=)\d+), '\1[FILTERED]'). gsub(%r((xKey=)\w+), '\1[FILTERED]') end |
#store(source, options = {}) ⇒ Object
89 90 91 92 93 94 95 96 97 |
# File 'lib/active_merchant/billing/gateways/cardknox.rb', line 89 def store(source, = {}) post = {} add_source(post, source) add_address(post, source, ) add_invoice(post, ) add_customer_data(post, ) add_custom_fields(post, ) commit(:save, source_type(source), post) end |
#supports_scrubbing? ⇒ Boolean
99 100 101 |
# File 'lib/active_merchant/billing/gateways/cardknox.rb', line 99 def supports_scrubbing? true end |
#verify(credit_card, options = {}) ⇒ Object
82 83 84 85 86 87 |
# File 'lib/active_merchant/billing/gateways/cardknox.rb', line 82 def verify(credit_card, ={}) MultiResponse.run(:use_first_response) do |r| r.process { (100, credit_card, ) } r.process(:ignore_result) { void(r., ) } end end |
#void(authorization, options = {}) ⇒ Object
76 77 78 79 80 |
# File 'lib/active_merchant/billing/gateways/cardknox.rb', line 76 def void(, = {}) post = {} add_reference(post, ) commit(:void, source_type(), post) end |