Class: DPay::CardPaymentRequest

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(device_info) ⇒ CardPaymentRequest

Returns a new instance of CardPaymentRequest.

Parameters:



9
10
11
12
13
# File 'lib/dpay/card/card_payment_request.rb', line 9

def initialize(device_info)
  @device_info = device_info
  @leading = {}
  @trailing = {}
end

Class Method Details

.create(device_info) ⇒ CardPaymentRequest

Parameters:

Returns:



5
6
7
# File 'lib/dpay/card/card_payment_request.rb', line 5

def self.create(device_info)
  new(device_info)
end

Instance Method Details

#to_bodyHash[String, untyped]

Returns:

  • (Hash[String, untyped])


47
48
49
50
51
52
53
54
55
56
57
# File 'lib/dpay/card/card_payment_request.rb', line 47

def to_body
  body = {}

  %w[email channelId cardHolderFirstName cardHolderLastName encryptedCardData].each do |key|
    body[key] = @leading[key] if @leading.key?(key)
  end
  body["deviceInfo"] = @device_info.to_h
  %w[threeDsConfirmed dccDecision].each { |key| body[key] = @trailing[key] if @trailing.key?(key) }

  body
end

#with_card_holder(first_name, last_name) ⇒ self

Parameters:

  • first_name (String)
  • last_name (String)

Returns:

  • (self)


25
26
27
28
29
# File 'lib/dpay/card/card_payment_request.rb', line 25

def with_card_holder(first_name, last_name)
  @leading["cardHolderFirstName"] = first_name
  @leading["cardHolderLastName"] = last_name
  self
end

#with_channel_id(channel_id) ⇒ self

Parameters:

  • channel_id (Integer)

Returns:

  • (self)


20
21
22
23
# File 'lib/dpay/card/card_payment_request.rb', line 20

def with_channel_id(channel_id)
  @leading["channelId"] = channel_id
  self
end

#with_dcc_decision(decision) ⇒ self

Parameters:

  • decision (String)

Returns:

  • (self)


41
42
43
44
45
# File 'lib/dpay/card/card_payment_request.rb', line 41

def with_dcc_decision(decision)
  DccDecision.assert_valid(decision)
  @trailing["dccDecision"] = decision
  self
end

#with_email(email) ⇒ self

Parameters:

  • email (String)

Returns:

  • (self)


15
16
17
18
# File 'lib/dpay/card/card_payment_request.rb', line 15

def with_email(email)
  @leading["email"] = email
  self
end

#with_encrypted_card_data(encrypted_card_data) ⇒ self

Parameters:

  • encrypted_card_data (String)

Returns:

  • (self)


31
32
33
34
# File 'lib/dpay/card/card_payment_request.rb', line 31

def with_encrypted_card_data(encrypted_card_data)
  @leading["encryptedCardData"] = encrypted_card_data
  self
end

#with_three_ds_confirmed(confirmed) ⇒ self

Parameters:

  • confirmed (Boolean)

Returns:

  • (self)


36
37
38
39
# File 'lib/dpay/card/card_payment_request.rb', line 36

def with_three_ds_confirmed(confirmed)
  @trailing["threeDsConfirmed"] = confirmed
  self
end