Class: AmplifypayRuby::Checkout::Invoice

Inherits:
Core
  • Object
show all
Defined in:
lib/amplifypay_ruby/checkout/redirect_invoice.rb

Instance Attribute Summary collapse

Attributes inherited from Core

#description, #invoice_token, #response_code, #result, #status, #token, #transaction_id

Instance Method Summary collapse

Methods inherited from Core

#push_results

Methods included from Utilities

#hash_to_json, #http_get_request, #http_json_request, #json_to_hash

Constructor Details

#initializeInvoice

Returns a new instance of Invoice.



8
9
10
11
12
13
14
# File 'lib/amplifypay_ruby/checkout/redirect_invoice.rb', line 8

def initialize
  @trans_id = "22"
  @customer = {}
  @total_amount =  0.0
  @redirect_url  =  ""
  @paymentDescription = ""
end

Instance Attribute Details

#customerObject

Returns the value of attribute customer.



6
7
8
# File 'lib/amplifypay_ruby/checkout/redirect_invoice.rb', line 6

def customer
  @customer
end

#invoice_urlObject

Returns the value of attribute invoice_url.



6
7
8
# File 'lib/amplifypay_ruby/checkout/redirect_invoice.rb', line 6

def invoice_url
  @invoice_url
end

#paymentDescriptionObject

Returns the value of attribute paymentDescription.



5
6
7
# File 'lib/amplifypay_ruby/checkout/redirect_invoice.rb', line 5

def paymentDescription
  @paymentDescription
end

#redirect_urlObject

Returns the value of attribute redirect_url.



5
6
7
# File 'lib/amplifypay_ruby/checkout/redirect_invoice.rb', line 5

def redirect_url
  @redirect_url
end

#response_textObject

Returns the value of attribute response_text.



6
7
8
# File 'lib/amplifypay_ruby/checkout/redirect_invoice.rb', line 6

def response_text
  @response_text
end

#status_codeObject

Returns the value of attribute status_code.



6
7
8
# File 'lib/amplifypay_ruby/checkout/redirect_invoice.rb', line 6

def status_code
  @status_code
end

#status_descObject

Returns the value of attribute status_desc.



6
7
8
# File 'lib/amplifypay_ruby/checkout/redirect_invoice.rb', line 6

def status_desc
  @status_desc
end

#storeObject

Returns the value of attribute store.



5
6
7
# File 'lib/amplifypay_ruby/checkout/redirect_invoice.rb', line 5

def store
  @store
end

#total_amountObject

Returns the value of attribute total_amount.



5
6
7
# File 'lib/amplifypay_ruby/checkout/redirect_invoice.rb', line 5

def total_amount
  @total_amount
end

#trans_idObject

Returns the value of attribute trans_id.



6
7
8
# File 'lib/amplifypay_ruby/checkout/redirect_invoice.rb', line 6

def trans_id
  @trans_id
end

#transaction_refObject

Returns the value of attribute transaction_ref.



6
7
8
# File 'lib/amplifypay_ruby/checkout/redirect_invoice.rb', line 6

def transaction_ref
  @transaction_ref
end

Instance Method Details

#confirm(token) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/amplifypay_ruby/checkout/redirect_invoice.rb', line 24

def confirm(token)
  verification_payload = build_verification_payload(token)
  result = http_json_request(AmplifypayRuby::Setup.checkout_confirm_base_url, verification_payload)

  if result["StatusDesc"] == "Approved"
    # rebuild_invoice(result)
    @response_text = "Payment was successful"
    true
  else
    @status = result["status"]
    @response_text = "Invoice status is #{result['StatusDesc'].upcase}"
    false
  end
end

#createObject



39
40
41
42
43
# File 'lib/amplifypay_ruby/checkout/redirect_invoice.rb', line 39

def create
  result = http_json_request(AmplifypayRuby::Setup.checkout_base_url,build_invoice_payload)
  @store = result.inspect
  create_response(result)
end

#get_custom_data(key) ⇒ Object



20
21
22
# File 'lib/amplifypay_ruby/checkout/redirect_invoice.rb', line 20

def get_custom_data(key)
  @custom_data["#{key}"]
end

#get_customer_info(key) ⇒ Object



16
17
18
# File 'lib/amplifypay_ruby/checkout/redirect_invoice.rb', line 16

def get_customer_info(key)
  @customer["#{key}"]
end