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


46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/active_merchant/billing/gateways/rapyd.rb', line 46

def authorize(money, payment, options = {})
  post = {}
  add_invoice(post, money, options)
  add_payment(post, payment, options)
  add_3ds(post, payment, options)
  add_address(post, payment, options)
  (post, options)
  add_ewallet(post, options)
  add_payment_fields(post, options)
  add_payment_urls(post, options)
  post[:capture] = false

  commit(:post, 'payments', post)
end

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


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

def capture(money, authorization, options = {})
  post = {}
  commit(:post, "payments/#{add_reference(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
42
43
44
# 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_3ds(post, payment, options)
  add_address(post, payment, options)
  (post, options)
  add_ewallet(post, options)
  add_payment_fields(post, options)
  add_payment_urls(post, options)
  post[:capture] = true if payment.is_a?(CreditCard)

  if payment.is_a?(Check)
    MultiResponse.run do |r|
      r.process { commit(:post, 'payments', post) }
      post = {}
      post[:token] = add_reference(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


66
67
68
69
70
71
72
73
74
# File 'lib/active_merchant/billing/gateways/rapyd.rb', line 66

def refund(money, authorization, options = {})
  post = {}
  post[:payment] = add_reference(authorization)
  add_invoice(post, money, options)
  (post, options)
  add_ewallet(post, options)

  commit(:post, 'refunds', post)
end

#scrub(transcript) ⇒ Object


105
106
107
108
109
110
111
112
# File 'lib/active_merchant/billing/gateways/rapyd.rb', line 105

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

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


85
86
87
88
89
90
91
92
93
94
95
# File 'lib/active_merchant/billing/gateways/rapyd.rb', line 85

def store(payment, options = {})
  post = {}
  add_payment(post, payment, options)
  add_customer_object(post, payment, options)
  (post, options)
  add_ewallet(post, options)
  add_payment_fields(post, options)
  add_payment_urls(post, options)
  add_address(post, payment, options)
  commit(:post, 'customers', post)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)

101
102
103
# File 'lib/active_merchant/billing/gateways/rapyd.rb', line 101

def supports_scrubbing?
  true
end

#unstore(customer) ⇒ Object


97
98
99
# File 'lib/active_merchant/billing/gateways/rapyd.rb', line 97

def unstore(customer)
  commit(:delete, "customers/#{add_reference(customer)}", {})
end

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


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

def verify(credit_card, options = {})
  authorize(0, credit_card, options)
end

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


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

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