Class: PaynetEasy::PaynetEasyApi::Callback::CallbackPrototype

Inherits:
Object
  • Object
show all
Includes:
Error, PaymentData, Transport, Util
Defined in:
lib/paynet_easy/paynet_easy_api/callback/callback_prototype.rb

Direct Known Subclasses

CustomerReturnCallback, PaynetEasyCallback

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(callback_type) ⇒ CallbackPrototype

Returns a new instance of CallbackPrototype.

[View source]

45
46
47
48
# File 'lib/paynet_easy/paynet_easy_api/callback/callback_prototype.rb', line 45

def initialize(callback_type)
  @callback_type = callback_type
  validate_callback_definition
end

Class Method Details

.inherited(subclass) ⇒ Object

Make instance variables available in child classes

[View source]

169
170
171
172
173
# File 'lib/paynet_easy/paynet_easy_api/callback/callback_prototype.rb', line 169

def inherited(subclass)
  instance_variables.each do |variable_name|
    subclass.instance_variable_set variable_name, instance_variable_get(variable_name)
  end
end

Instance Method Details

#process_callback(payment_transaction, callback_response) ⇒ CallbackResponse

Process API gateway Response and update Payment transaction

Parameters:

Returns:

[View source]

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/paynet_easy/paynet_easy_api/callback/callback_prototype.rb', line 56

def process_callback(payment_transaction, callback_response)
  begin
    validate_callback payment_transaction, callback_response
  rescue Exception => error
    payment_transaction.add_error error
    payment_transaction.status = PaymentTransaction::STATUS_ERROR

    raise error
  end

  update_payment_transaction payment_transaction, callback_response

  if callback_response.error?
    raise callback_response.error
  end

  callback_response
end