Class: DPay::CardPaymentResult
- Inherits:
-
Object
- Object
- DPay::CardPaymentResult
- Defined in:
- lib/dpay/card/card_payment_result.rb,
sig/dpay/card/card_payment_result.rbs
Instance Attribute Summary collapse
-
#dcc_offer ⇒ DccOffer?
readonly
Returns the value of attribute dcc_offer.
-
#raw ⇒ Hash[String, untyped]
readonly
Returns the value of attribute raw.
-
#redirect_text ⇒ String?
readonly
Returns the value of attribute redirect_text.
-
#redirect_type ⇒ String?
readonly
Returns the value of attribute redirect_type.
Class Method Summary collapse
Instance Method Summary collapse
- #dcc_offer? ⇒ Boolean
- #decode ⇒ String?
-
#initialize(data) ⇒ CardPaymentResult
constructor
A new instance of CardPaymentResult.
- #redirect_url ⇒ String?
- #requires_redirect? ⇒ Boolean
- #success? ⇒ Boolean
- #three_ds_form? ⇒ Boolean
- #three_ds_form_html ⇒ String?
Constructor Details
#initialize(data) ⇒ CardPaymentResult
Returns a new instance of CardPaymentResult.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/dpay/card/card_payment_result.rb', line 11 def initialize(data) @raw = data = data["message"].is_a?(Hash) ? data["message"] : {} @redirect_type = ["redirectType"].is_a?(String) ? ["redirectType"] : nil text = ["redirectText"] @redirect_text = text.is_a?(String) && !text.empty? ? text : nil @dcc_offer = ["dccOffer"].is_a?(Hash) ? DccOffer.from_api(["dccOffer"]) : nil freeze end |
Instance Attribute Details
#dcc_offer ⇒ DccOffer? (readonly)
Returns the value of attribute dcc_offer.
5 6 7 |
# File 'lib/dpay/card/card_payment_result.rb', line 5 def dcc_offer @dcc_offer end |
#raw ⇒ Hash[String, untyped] (readonly)
Returns the value of attribute raw.
5 6 7 |
# File 'lib/dpay/card/card_payment_result.rb', line 5 def raw @raw end |
#redirect_text ⇒ String? (readonly)
Returns the value of attribute redirect_text.
5 6 7 |
# File 'lib/dpay/card/card_payment_result.rb', line 5 def redirect_text @redirect_text end |
#redirect_type ⇒ String? (readonly)
Returns the value of attribute redirect_type.
5 6 7 |
# File 'lib/dpay/card/card_payment_result.rb', line 5 def redirect_type @redirect_type end |
Class Method Details
.from_api(data) ⇒ CardPaymentResult
7 8 9 |
# File 'lib/dpay/card/card_payment_result.rb', line 7 def self.from_api(data) new(data) end |
Instance Method Details
#dcc_offer? ⇒ Boolean
34 35 36 |
# File 'lib/dpay/card/card_payment_result.rb', line 34 def dcc_offer? @redirect_type == RedirectType::DCC_OFFER end |
#decode ⇒ String?
48 49 50 51 52 53 54 55 56 |
# File 'lib/dpay/card/card_payment_result.rb', line 48 def decode text = @redirect_text return nil if text.nil? decoded = text.unpack1("m0") decoded.is_a?(String) ? decoded : nil rescue ArgumentError nil end |
#redirect_url ⇒ String?
42 43 44 |
# File 'lib/dpay/card/card_payment_result.rb', line 42 def redirect_url requires_redirect? ? decode : nil end |
#requires_redirect? ⇒ Boolean
30 31 32 |
# File 'lib/dpay/card/card_payment_result.rb', line 30 def requires_redirect? @redirect_type == RedirectType::URL end |
#success? ⇒ Boolean
22 23 24 |
# File 'lib/dpay/card/card_payment_result.rb', line 22 def success? @redirect_type == RedirectType::SUCCESS end |
#three_ds_form? ⇒ Boolean
26 27 28 |
# File 'lib/dpay/card/card_payment_result.rb', line 26 def three_ds_form? @redirect_type == RedirectType::FORM end |
#three_ds_form_html ⇒ String?
38 39 40 |
# File 'lib/dpay/card/card_payment_result.rb', line 38 def three_ds_form_html three_ds_form? ? decode : nil end |