Class: Spree::BankPayments::Reconcilers::Base

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree/bank_payments/reconcilers/base.rb

Direct Known Subclasses

Manual

Defined Under Namespace

Classes: NotConfiguredError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payment_method:) ⇒ Base

Returns a new instance of Base.



28
29
30
# File 'app/models/spree/bank_payments/reconcilers/base.rb', line 28

def initialize(payment_method:)
  @payment_method = payment_method
end

Instance Attribute Details

#payment_methodObject (readonly)

Returns the value of attribute payment_method.



26
27
28
# File 'app/models/spree/bank_payments/reconcilers/base.rb', line 26

def payment_method
  @payment_method
end

Class Method Details

.build(payment_method:) ⇒ Object



16
17
18
19
20
21
22
23
# File 'app/models/spree/bank_payments/reconcilers/base.rb', line 16

def build(payment_method:)
  key = payment_method.preferred_reconciler.to_s
  klass = registry.fetch(key) do
    raise ArgumentError, "unknown reconciler #{key.inspect}"
  end

  klass.new(payment_method: payment_method)
end

.register(key, klass) ⇒ Object



12
13
14
# File 'app/models/spree/bank_payments/reconcilers/base.rb', line 12

def register(key, klass)
  registry[key.to_s] = klass
end

.registryObject



8
9
10
# File 'app/models/spree/bank_payments/reconcilers/base.rb', line 8

def registry
  @registry ||= {}
end

Instance Method Details

#configured?Boolean

Returns whether credentials and settings are complete.

Returns:

  • (Boolean)

    whether credentials and settings are complete

Raises:

  • (NotImplementedError)


50
51
52
# File 'app/models/spree/bank_payments/reconcilers/base.rb', line 50

def configured?
  raise NotImplementedError, "#{self.class} must implement #configured?"
end

#healthy?Boolean

Returns false means the expiry job must not cancel anything.

Returns:

  • (Boolean)

    false means the expiry job must not cancel anything

Raises:

  • (NotImplementedError)


45
46
47
# File 'app/models/spree/bank_payments/reconcilers/base.rb', line 45

def healthy?
  raise NotImplementedError, "#{self.class} must implement #healthy?"
end

#parse_webhook(raw_body, headers) ⇒ Spree::BankPayments::TransferData?

Returns nil for unsupported events.

Returns:

Raises:

  • (Spree::PaymentMethod::WebhookSignatureError)


40
41
42
# File 'app/models/spree/bank_payments/reconcilers/base.rb', line 40

def parse_webhook(raw_body, headers)
  raise NotImplementedError, "#{self.class} must implement #parse_webhook"
end

#poll(since:) ⇒ Array<Spree::BankPayments::TransferData>

Parameters:

  • since (Time)

Returns:

Raises:

  • (NotImplementedError)


34
35
36
# File 'app/models/spree/bank_payments/reconcilers/base.rb', line 34

def poll(since:)
  raise NotImplementedError, "#{self.class} must implement #poll"
end

#sync_accountsArray<Spree::BankPayments::AccountData>

Accounts this provider can see, for the admin sync flow. Providers that cannot enumerate accounts return [].



58
59
60
# File 'app/models/spree/bank_payments/reconcilers/base.rb', line 58

def sync_accounts
  []
end