~singpolyma/sgx-jmp

ref: 36f441c031a5318385ec78d7d2e021a8e2fab186 sgx-jmp/lib/payment_method.rb -rw-r--r-- 532 bytes
36f441c0Stephen Paul Weber Merge branch 'three_d_secure' 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

require "delegate"

class PaymentMethod < SimpleDelegator
	def self.for(method, three_d_secure={})
		three_d = three_d_secure[method.token]
		return ThreeDSecure.new(method, three_d) if three_d

		new(method)
	end

	def transaction_details
		{
			payment_method_token: token
		}
	end

	class ThreeDSecure < PaymentMethod
		def initialize(method, three_d)
			super(method)
			@three_d = three_d
		end

		def transaction_details
			super.merge(three_d_secure_authentication_id: @three_d)
		end
	end
end