Module: MandarinPay::ConformityParams

Included in:
Notification, PaymentInterface
Defined in:
lib/mandarin_pay/conformity_params.rb

Constant Summary collapse

PARAMS_CONFORMITY =
{
  merchant_id:    "merchantId",
  price:          "price",
  order_id:       "orderId",
  sign:           "sign",
  custom_value_1: "customValue1",
  custom_value_2: "customValue2",
  custom_value_3: "customValue3",
  custom_name_1:  "customName1",
  custom_name_2:  "customName2",
  custom_name_3:  "customName3",
  customer_email: "customer_email",
  customer_phone: "customer_phone"
}.freeze

Instance Method Summary collapse

Instance Method Details

#conformity_params(extra_params) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/mandarin_pay/conformity_params.rb', line 22

def conformity_params(extra_params)
  Hash[default_params.merge(extra_params.deep_symbolize_keys).map do |key, value|
    if key == :price
      [PARAMS_CONFORMITY[key], format("%.2f", value)]
    else
      [PARAMS_CONFORMITY[key], value]
    end
  end.compact]
end

#default_paramsObject



32
33
34
35
36
37
# File 'lib/mandarin_pay/conformity_params.rb', line 32

def default_params
  default = Hash[PARAMS_CONFORMITY.map do |internal_name, _external_name|
    [internal_name, send(internal_name)]
  end].compact
  initial_options.merge(default)
end

#initial_optionsObject



39
40
41
42
43
44
45
# File 'lib/mandarin_pay/conformity_params.rb', line 39

def initial_options
  {
    merchant_id: MandarinPay.merchant_id,
    price: @price,
    order_id: @order_id
  }
end