Class: Portmone::Responses::MobilePay

Inherits:
Object
  • Object
show all
Defined in:
lib/portmone/responses/mobile_pay.rb

Constant Summary collapse

SUCCESS_STATUS =
'PAYED'.freeze
CREATED_STATUS =
'CREATED'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(faraday_response, currency:, timezone:) ⇒ MobilePay

Returns a new instance of MobilePay.



7
8
9
10
11
12
# File 'lib/portmone/responses/mobile_pay.rb', line 7

def initialize(faraday_response, currency:, timezone:)
  @response = faraday_response
  @response_body = JSON.parse(@response.body)
  @currency = currency
  @timezone = timezone
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



5
6
7
# File 'lib/portmone/responses/mobile_pay.rb', line 5

def response
  @response
end

Instance Method Details

#acs_urlObject



38
39
40
# File 'lib/portmone/responses/mobile_pay.rb', line 38

def acs_url
  result['actionMPI'] if required_3ds?
end

#created?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/portmone/responses/mobile_pay.rb', line 22

def created?
  result['status'] == CREATED_STATUS
end

#error_codeObject



26
27
28
# File 'lib/portmone/responses/mobile_pay.rb', line 26

def error_code
  result['errorCode']
end

#error_descriptionObject



30
31
32
# File 'lib/portmone/responses/mobile_pay.rb', line 30

def error_description
  result['error']
end

#http_statusObject



14
15
16
# File 'lib/portmone/responses/mobile_pay.rb', line 14

def http_status
  response.status
end

#mdObject



42
43
44
# File 'lib/portmone/responses/mobile_pay.rb', line 42

def md
  result['md'] if required_3ds?
end

#pa_reqObject



46
47
48
# File 'lib/portmone/responses/mobile_pay.rb', line 46

def pa_req
  result['pareq'] if required_3ds?
end

#required_3ds?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/portmone/responses/mobile_pay.rb', line 34

def required_3ds?
  created? && result['isNeed3DS'] == 'Y'
end

#shop_bill_idObject



50
51
52
# File 'lib/portmone/responses/mobile_pay.rb', line 50

def shop_bill_id
  result['shopBillId']
end

#success?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/portmone/responses/mobile_pay.rb', line 18

def success?
  result['status'] == SUCCESS_STATUS
end