Class: ActiveMerchant::Billing::RapydGateway

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

Constant Summary collapse

STANDARD_ERROR_CODE_MAPPING =
{}

Constants inherited from Gateway

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

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

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

Methods included from PostsData

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

Constructor Details

#initialize(options = {}) ⇒ RapydGateway

Returns a new instance of RapydGateway.



16
17
18
19
# File 'lib/active_merchant/billing/gateways/rapyd.rb', line 16

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

Instance Method Details

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



43
44
45
46
47
48
49
50
51
52
# File 'lib/active_merchant/billing/gateways/rapyd.rb', line 43

def authorize(money, payment, options = {})
  post = {}
  add_invoice(post, money, options)
  add_payment(post, payment, options)
  add_address(post, payment, options)
  (post, options)
  add_ewallet(post, options)
  post[:capture] = false
  commit(:post, 'payments', post)
end

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



54
55
56
57
# File 'lib/active_merchant/billing/gateways/rapyd.rb', line 54

def capture(money, authorization, options = {})
  post = {}
  commit(:post, "payments/#{authorization}/capture", post)
end

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



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/active_merchant/billing/gateways/rapyd.rb', line 21

def purchase(money, payment, options = {})
  post = {}
  add_invoice(post, money, options)
  add_payment(post, payment, options)
  add_address(post, payment, options)
  (post, options)
  add_ewallet(post, options)
  post[:capture] = true if payment_is_card?(options)

  if payment_is_ach?(options)
    MultiResponse.run do |r|
      r.process { commit(:post, 'payments', post) }
      post = {}
      post[:token] = r.authorization
      post[:param2] = r.params.dig('data', 'original_amount').to_s
      r.process { commit(:post, 'payments/completePayment', post) }
    end
  else
    commit(:post, 'payments', post)
  end
end

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



59
60
61
62
63
64
65
# File 'lib/active_merchant/billing/gateways/rapyd.rb', line 59

def refund(money, authorization, options = {})
  post = {}
  post[:payment] = authorization
  add_invoice(post, money, options)
  (post, options)
  commit(:post, 'refunds', post)
end

#scrub(transcript) ⇒ Object



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

def scrub(transcript)
  transcript.
    gsub(%r((Access_key: )\w+), '\1[FILTERED]').
    gsub(%r(("number\\?":\\?")\d+), '\1[FILTERED]').
    gsub(%r(("cvv\\?":\\?")\d+), '\1[FILTERED]')
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/active_merchant/billing/gateways/rapyd.rb', line 82

def supports_scrubbing?
  true
end

#verify(credit_card, options = {}) ⇒ Object

Gateway returns an error if trying to run a $0 auth as invalid payment amount Gateway does not support void on a card transaction and refunds can only be done on completed transactions (such as a purchase). Authorize transactions are considered ‘active’ and not ‘complete’ until they are captured.



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

def verify(credit_card, options = {})
  MultiResponse.run do |r|
    r.process { purchase(100, credit_card, options) }
    r.process { refund(100, r.authorization, options) }
  end
end

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



67
68
69
70
# File 'lib/active_merchant/billing/gateways/rapyd.rb', line 67

def void(authorization, options = {})
  post = {}
  commit(:delete, "payments/#{authorization}", post)
end