monetico_paiement/lib/monetico_paiement.rb

45 lines
1.1 KiB
Ruby
Raw Permalink Normal View History

2021-08-26 09:31:15 +02:00
# frozen_string_literal: true
2021-08-27 15:20:35 +02:00
require "monetico_paiement/version"
require "monetico_paiement/parameters"
require "monetico_paiement/ept"
require "monetico_paiement/railtie" if defined?(Rails)
2021-08-26 09:31:15 +02:00
module MoneticoPaiement
class Error < StandardError; end
2021-08-27 15:20:35 +02:00
API_VERSION = "3.0"
DATE_FORMAT = "%d/%m/%Y:%H:%M:%S"
END_POINTS = {
production: 'https://p.monetico-services.com/paiement.cgi',
test: 'https://p.monetico-services.com/test/paiement.cgi'
}
DEFAULT_ENV = :test
def self.configure(&block)
yield default_config
end
def self.default_config
@@default_config ||= MoneticoPaiement::Config.new
end
class Config
attr_accessor :hmac_key, :ept_number, :company_code, :env
attr_writer :target_url
def initialize(hmac_key: nil, ept_number: nil, company_code: nil, env: MoneticoPaiement::DEFAULT_ENV, target_url: nil)
self.hmac_key = hmac_key
self.ept_number = ept_number
self.company_code = company_code
self.env = env
self.target_url = target_url
end
def target_url
@target_url || END_POINTS[env]
end
end
2021-08-26 09:31:15 +02:00
end