Class: HyperPay::PaymentParameterBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/HyperPay/payment_parameter_builder.rb

Constant Summary collapse

REQUIRED_PARAMETERS =
%w[entityId customer.email customer.mobile customer.givenName customer.surname billing.street1 billing.city billing.state billing.country billing.postcode customParameters[3DS2_enrolled] merchantTransactionId paymentType currency amount].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePaymentParameterBuilder

Returns a new instance of PaymentParameterBuilder.



7
8
9
# File 'lib/HyperPay/payment_parameter_builder.rb', line 7

def initialize
  @parameters = {}
end

Instance Attribute Details

#parametersObject (readonly)

Returns the value of attribute parameters.



5
6
7
# File 'lib/HyperPay/payment_parameter_builder.rb', line 5

def parameters
  @parameters
end

Instance Method Details

#add(key, value) ⇒ Object

Implementation of ‘add` method returns `self` to allow chaining



12
13
14
15
# File 'lib/HyperPay/payment_parameter_builder.rb', line 12

def add(key, value)
  @parameters[key] = value
  self # Return self to allow chaining
end

#validate!Object



17
18
19
20
21
22
# File 'lib/HyperPay/payment_parameter_builder.rb', line 17

def validate!
  missing_params = REQUIRED_PARAMETERS - @parameters.keys
  unless missing_params.empty?
    raise ArgumentError, "Missing required parameters: #{missing_params.join(', ')}"
  end
end