Class: CurrencyCloud::Payment

Inherits:
Object
  • Object
show all
Includes:
Resource
Defined in:
lib/currency_cloud/payment.rb

Instance Attribute Summary

Attributes included from Resource

#changed_attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Resource

included, #initialize, #inspect

Class Method Details

.authorise(*ids) ⇒ Object



17
18
19
20
# File 'lib/currency_cloud/payment.rb', line 17

def self.authorise(*ids)
  result = client.post("authorise", payment_ids: ids)['authorisations']
  result.map { |pa| PaymentAuthorisationResult.new(pa) }
end

.create(params = {}, sca_id = nil, sca_token = nil) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/currency_cloud/payment.rb', line 49

def self.create(params = {}, sca_id = nil, sca_token = nil)
  # If no SCA values are provided
  return super(params) if sca_id.nil? && sca_token.nil?

  headers = {}
  headers['x-sca-id']    = sca_id unless sca_id.nil?
  headers['x-sca-token'] = sca_token unless sca_token.nil?

  opts  = { headers: headers }
  attrs = client.post("create", params, opts)
  new(attrs)
end

.payment_delivery_date(params) ⇒ Object



27
28
29
30
# File 'lib/currency_cloud/payment.rb', line 27

def self.payment_delivery_date(params)
  result = client.get("payment_delivery_date", params)
  PaymentDeliveryDateResult.new(result)
end

.quote_payment_fee(params) ⇒ Object



32
33
34
35
# File 'lib/currency_cloud/payment.rb', line 32

def self.quote_payment_fee(params)
  result = client.get("quote_payment_fee", params)
  QuotePaymentFee.new(result)
end

.tracking_info(id) ⇒ Object



37
38
39
40
# File 'lib/currency_cloud/payment.rb', line 37

def self.tracking_info(id)
  result = client.get("#{id}/tracking_info")
  PaymentTrackingInfo.new(result)
end

.validate(params, sca_to_authenticated_user = nil) ⇒ Object



42
43
44
45
46
47
# File 'lib/currency_cloud/payment.rb', line 42

def self.validate(params, sca_to_authenticated_user = nil)
  headers = sca_to_authenticated_user.nil? ? {} : { 'x-sca-to-authenticated-user' => sca_to_authenticated_user.to_s }
  opts = { headers: headers, return_response_headers: true }
  body, response_headers = client.post("validate", params, opts)
  PaymentValidationResult.new(body, response_headers)
end

Instance Method Details

#confirmation(params = {}) ⇒ Object



22
23
24
25
# File 'lib/currency_cloud/payment.rb', line 22

def confirmation(params = {})
  result = client.get("#{id}/confirmation", params)
  PaymentConfirmationResult.new(result)
end

#retry_notifications(params = {}) ⇒ Object



13
14
15
# File 'lib/currency_cloud/payment.rb', line 13

def retry_notifications(params = {})
  client.post("#{id}/notifications/retry", params)
end

#submission_info(params = {}) ⇒ Object



8
9
10
11
# File 'lib/currency_cloud/payment.rb', line 8

def submission_info(params = {})
  result = client.get("#{id}/submission_info", params)
  PaymentSubmissionInfo.new(result)
end