Class: DPay::ApplePayRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/dpay/card/apple_pay_request.rb,
sig/dpay/card/apple_pay_request.rbs

Constant Summary collapse

INIT =

Returns:

  • (String)
"APPLE_PAY_INIT"
PAY =

Returns:

  • (String)
"APPLE_PAY"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x_pay_type, token, device_info) ⇒ ApplePayRequest

Returns a new instance of ApplePayRequest.

Parameters:

  • x_pay_type (String)
  • token (String, nil)
  • device_info (DeviceInfo)


16
17
18
19
20
21
# File 'lib/dpay/card/apple_pay_request.rb', line 16

def initialize(x_pay_type, token, device_info)
  @x_pay_type = x_pay_type
  @token = token
  @device_info = device_info
  @channel_id = nil
end

Class Method Details

.init(device_info) ⇒ ApplePayRequest

Parameters:

Returns:



8
9
10
# File 'lib/dpay/card/apple_pay_request.rb', line 8

def self.init(device_info)
  new(INIT, nil, device_info)
end

.pay(token, device_info) ⇒ ApplePayRequest

Parameters:

Returns:



12
13
14
# File 'lib/dpay/card/apple_pay_request.rb', line 12

def self.pay(token, device_info)
  new(PAY, token, device_info)
end

Instance Method Details

#to_bodyHash[String, untyped]

Returns:

  • (Hash[String, untyped])


28
29
30
31
32
33
34
35
36
# File 'lib/dpay/card/apple_pay_request.rb', line 28

def to_body
  body = {}
  body["channelId"] = @channel_id unless @channel_id.nil?
  body["xPayType"] = @x_pay_type
  body["xPayToken"] = @token unless @token.nil?
  body["deviceInfo"] = @device_info.to_h

  body
end

#with_channel_id(channel_id) ⇒ self

Parameters:

  • channel_id (Integer)

Returns:

  • (self)


23
24
25
26
# File 'lib/dpay/card/apple_pay_request.rb', line 23

def with_channel_id(channel_id)
  @channel_id = channel_id
  self
end