Class: DPay::CardPaymentRequest
- Inherits:
-
Object
- Object
- DPay::CardPaymentRequest
- Defined in:
- lib/dpay/card/card_payment_request.rb,
sig/dpay/card/card_payment_request.rbs
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(device_info) ⇒ CardPaymentRequest
constructor
A new instance of CardPaymentRequest.
- #to_body ⇒ Hash[String, untyped]
- #with_card_holder(first_name, last_name) ⇒ self
- #with_channel_id(channel_id) ⇒ self
- #with_dcc_decision(decision) ⇒ self
- #with_email(email) ⇒ self
- #with_encrypted_card_data(encrypted_card_data) ⇒ self
- #with_three_ds_confirmed(confirmed) ⇒ self
Constructor Details
#initialize(device_info) ⇒ CardPaymentRequest
Returns a new instance of CardPaymentRequest.
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
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_body ⇒ 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
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
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
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
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
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
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 |