1# frozen_string_literal: true
2
3require "delegate"
4
5class PaymentMethod < SimpleDelegator
6 def self.for(method, three_d_secure={})
7 three_d = three_d_secure[method.token]
8 return ThreeDSecure.new(method, three_d) if three_d
9
10 new(method)
11 end
12
13 def transaction_details
14 {
15 payment_method_token: token
16 }
17 end
18
19 class ThreeDSecure < PaymentMethod
20 def initialize(method, three_d)
21 super(method)
22 @three_d = three_d
23 end
24
25 def transaction_details
26 super.merge(three_d_secure_authentication_id: @three_d)
27 end
28 end
29end