Class: ActiveMerchant::Billing::TrexleGateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/active_merchant/billing/gateways/trexle.rb

Constant Summary

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, #generate_unique_id, inherited, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #supports_scrubbing?, #test?

Methods included from CreditCardFormatting

#expdate, #format

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Constructor Details

#initialize(options = {}) ⇒ TrexleGateway

Returns a new instance of TrexleGateway


17
18
19
20
# File 'lib/active_merchant/billing/gateways/trexle.rb', line 17

def initialize(options = {})
  requires!(options, :api_key)
  super
end

Instance Method Details

#authorize(money, creditcard, options = {}) ⇒ Object

Authorize an amount on a credit card. Once authorized, you can later capture this charge using the charge token that is returned.


55
56
57
58
59
60
61
62
63
64
65
# File 'lib/active_merchant/billing/gateways/trexle.rb', line 55

def authorize(money, creditcard, options = {})
  post = {}

  add_amount(post, money, options)
  add_customer_data(post, options)
  add_invoice(post, options)
  add_creditcard(post, creditcard)
  add_address(post, creditcard, options)
  post[:capture] = false
  commit(:post, 'charges', post, options)
end

#capture(money, token, options = {}) ⇒ Object

Captures a previously authorized charge. Capturing only part of the original authorization is currently not supported.


69
70
71
# File 'lib/active_merchant/billing/gateways/trexle.rb', line 69

def capture(money, token, options = {})
  commit(:put, "charges/#{CGI.escape(token)}/capture", { amount: amount(money) }, options)
end

#purchase(money, creditcard, options = {}) ⇒ Object

Create a charge using a credit card, card token or customer token

To charge a credit card: purchase(, [creditcard hash], …) To charge a customer: purchase(, [token], …)


26
27
28
29
30
31
32
33
34
35
# File 'lib/active_merchant/billing/gateways/trexle.rb', line 26

def purchase(money, creditcard, options = {})
  post = {}

  add_amount(post, money, options)
  add_customer_data(post, options)
  add_invoice(post, options)
  add_creditcard(post, creditcard)
  add_address(post, creditcard, options)
  commit(:post, 'charges', post, options)
end

#refund(money, token, options = {}) ⇒ Object

Refund a transaction


49
50
51
# File 'lib/active_merchant/billing/gateways/trexle.rb', line 49

def refund(money, token, options = {})
  commit(:post, "charges/#{CGI.escape(token)}/refunds", { amount: amount(money) }, options)
end

#scrub(transcript) ⇒ Object


87
88
89
90
91
92
# File 'lib/active_merchant/billing/gateways/trexle.rb', line 87

def scrub(transcript)
  transcript.
    gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
    gsub(/(number\\?":\\?")(\d*)/, '\1[FILTERED]').
    gsub(/(cvc\\?":\\?")(\d*)/, '\1[FILTERED]')
end

#store(creditcard, options = {}) ⇒ Object

Create a customer and associated credit card. The token that is returned can be used instead of a credit card parameter in the purchase method


39
40
41
42
43
44
45
46
# File 'lib/active_merchant/billing/gateways/trexle.rb', line 39

def store(creditcard, options = {})
  post = {}

  add_creditcard(post, creditcard)
  add_customer_data(post, options)
  add_address(post, creditcard, options)
  commit(:post, 'customers', post, options)
end

#supports_scrubbingObject


83
84
85
# File 'lib/active_merchant/billing/gateways/trexle.rb', line 83

def supports_scrubbing
  true
end

#update(token, creditcard, options = {}) ⇒ Object

Updates the credit card for the customer.


74
75
76
77
78
79
80
81
# File 'lib/active_merchant/billing/gateways/trexle.rb', line 74

def update(token, creditcard, options = {})
  post = {}

  add_creditcard(post, creditcard)
  add_customer_data(post, options)
  add_address(post, creditcard, options)
  commit(:put, "customers/#{CGI.escape(token)}", post, options)
end