Class: ActiveMerchant::Billing::TelrGateway
- Defined in:
- lib/active_merchant/billing/gateways/telr.rb
Constant Summary collapse
- CVC_CODE_TRANSLATOR =
{ 'Y' => 'M', 'N' => 'N', 'X' => 'P', 'E' => 'U' }
- AVS_CODE_TRANSLATOR =
{ 'Y' => 'M', 'P' => 'A', 'N' => 'N', 'X' => 'I', 'E' => 'R' }
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, payment_method, options = {}) ⇒ Object
- #capture(amount, authorization, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ TelrGateway
constructor
A new instance of TelrGateway.
- #purchase(amount, payment_method, options = {}) ⇒ Object
- #refund(amount, authorization, options = {}) ⇒ Object
- #scrub(transcript) ⇒ Object
- #supports_scrubbing? ⇒ Boolean
- #verify(credit_card, options = {}) ⇒ Object
- #verify_credentials ⇒ 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
#expdate, #format, #strftime_yyyymm
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
#initialize(options = {}) ⇒ TelrGateway
Returns a new instance of TelrGateway.
31 32 33 34 |
# File 'lib/active_merchant/billing/gateways/telr.rb', line 31 def initialize( = {}) requires!(, :merchant_id, :api_key) super end |
Instance Method Details
#authorize(amount, payment_method, options = {}) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/active_merchant/billing/gateways/telr.rb', line 44 def (amount, payment_method, = {}) commit(:authorize, amount, [:currency]) do |doc| add_invoice(doc, 'auth', amount, payment_method, ) add_payment_method(doc, payment_method, ) add_customer_data(doc, payment_method, ) end end |
#capture(amount, authorization, options = {}) ⇒ Object
52 53 54 55 56 |
# File 'lib/active_merchant/billing/gateways/telr.rb', line 52 def capture(amount, , = {}) commit(:capture) do |doc| add_invoice(doc, 'capture', amount, , ) end end |
#purchase(amount, payment_method, options = {}) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/active_merchant/billing/gateways/telr.rb', line 36 def purchase(amount, payment_method, = {}) commit(:purchase, amount, [:currency]) do |doc| add_invoice(doc, 'sale', amount, payment_method, ) add_payment_method(doc, payment_method, ) add_customer_data(doc, payment_method, ) end end |
#refund(amount, authorization, options = {}) ⇒ Object
65 66 67 68 69 |
# File 'lib/active_merchant/billing/gateways/telr.rb', line 65 def refund(amount, , = {}) commit(:refund) do |doc| add_invoice(doc, 'refund', amount, , ) end end |
#scrub(transcript) ⇒ Object
88 89 90 91 92 93 |
# File 'lib/active_merchant/billing/gateways/telr.rb', line 88 def scrub(transcript) transcript. gsub(%r((<Number>)[^<]+(<))i, '\1[FILTERED]\2'). gsub(%r((<CVV>)[^<]+(<))i, '\1[FILTERED]\2'). gsub(%r((<Key>)[^<]+(<))i, '\1[FILTERED]\2') end |
#supports_scrubbing? ⇒ Boolean
84 85 86 |
# File 'lib/active_merchant/billing/gateways/telr.rb', line 84 def supports_scrubbing? true end |
#verify(credit_card, options = {}) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/active_merchant/billing/gateways/telr.rb', line 71 def verify(credit_card, = {}) commit(:verify) do |doc| add_invoice(doc, 'verify', 100, credit_card, ) add_payment_method(doc, credit_card, ) add_customer_data(doc, credit_card, ) end end |
#verify_credentials ⇒ Object
79 80 81 82 |
# File 'lib/active_merchant/billing/gateways/telr.rb', line 79 def verify_credentials response = void('0') !%w[01 04].include?(response.error_code) end |
#void(authorization, options = {}) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/active_merchant/billing/gateways/telr.rb', line 58 def void(, = {}) _, amount, currency = () commit(:void) do |doc| add_invoice(doc, 'void', amount.to_i, , .merge(currency: currency)) end end |