lib/cic_embeded_payment/payment.rb
# Permit to parse default options with payment options
#
# @return [Hash] The options
Permit to parse default options with payment options
Permit to parse default options with payment options
def parse_opts
        base_opts = {
          :version => CicEmbededPayment.configuration.version,
          :TPE     => CicEmbededPayment.configuration.tpe,
          :date    => DateTime.now.strftime('%d/%m/%Y:%H:%M:%S'),
          :lgue    => CicEmbededPayment.configuration.lang.to_s.upcase,
          :societe => CicEmbededPayment.configuration.company
        }
        devise = get_arg(:devise) || CicEmbededPayment.configuration.default_devise
        validity = get_arg(:validity)
        parsed_opts = {
          :montant        => Utils::process_amount(get_arg(:amount, true), devise),
          :numero_carte   => get_arg(:card_number, true),
          :annee_validite => validity[:year] || raise(Errors::KeyRequieredError,
                                                      "Card validity year is requiered"),
          :mois_validite  => validity[:month] || raise(Errors::KeyRequieredError,
                                                       "Card validity month is requiered"),
          :cvx            => get_arg(:ccv, true)
        }
        if text = get_arg(:text)
          parsed_opts['texte-libre'] = text
        end
        if ref = get_arg(:ref)
          parsed_opts[:reference] = ref
        end
        if mail = get_arg(:mail)
          parsed_opts[:mail] = mail
        end
        if options = get_arg(:options)
          parsed_opts[:options] = options.map { |k, v| "#{k}=#{v}" }.join('&')
        end
        base_opts.merge(parsed_opts)
      end
def parse_opts base_opts = { :version => CicEmbededPayment . configuration . version , :TPE => CicEmbededPayment . configuration . tpe , :date => DateTime . now . strftime ( '%d/%m/%Y:%H:%M:%S' ) , :lgue => CicEmbededPayment . configuration . lang . to_s . upcase , :societe => CicEmbededPayment . configuration . company } devise = get_arg ( :devise ) || CicEmbededPayment . configuration . default_devise validity = get_arg ( :validity ) parsed_opts = { :montant => Utils :: process_amount ( get_arg ( :amount , true ) , devise ) , :numero_carte => get_arg ( :card_number , true ) , :annee_validite => validity [ :year ] || raise ( Errors :: KeyRequieredError , "Card validity year is requiered" ) , :mois_validite => validity [ :month ] || raise ( Errors :: KeyRequieredError , "Card validity month is requiered" ) , :cvx => get_arg ( :ccv , true ) } if text = get_arg ( :text ) parsed_opts [ 'texte-libre' ] = text end if ref = get_arg ( :ref ) parsed_opts [ :reference ] = ref end if mail = get_arg ( :mail ) parsed_opts [ :mail ] = mail end if options = get_arg ( :options ) parsed_opts [ :options ] = options . map { | k , v | "#{k}=#{v}" } . join ( '&' ) end base_opts . merge ( parsed_opts ) end
Permit to parse default options with payment options
Permit to parse default options with payment options
# Opts to cuse for each calls # Get devise from args or config # Create base payment opts # Add keys for optionnals parameters
None
Hash