ClearsaleID
Esta gem foi inspirada na Gem github.com/Baby-com-br/clearsale, fiz apenas a mudança dos campos e URL conformo manual da clearsale, deixo um agradecimento ao Daniel Konishi, pelo esforço.
Instalação
Defina a variavél de ambiente CLEARSALE_ENTITYCODE
Clearsale::Config.entity_code = '03524C82-F434-4A32-8D34-EFFF2023341B'
Defina a variavél de ambiente CLEARSALE_ENV
Clearsale::Config.env = 'production' ou 'holog'
Adicione no seu Gemfile
gem 'clearsaleID'
Execute
bundle install
Uso
require 'clearsale'
order = {
:order_id => 11989283922,
:session_id => '1l1j23lkj12lk3jl123',
:paid_at => 2.seconds.ago,
:billing_address => {
:street_name => 'Bla St',
:number => '123',
:complement => '',
:neighborhood => 'Rhode Island',
:city => 'Mayland',
:state => 'Maryland',
:postal_code => '00100-011'
},
:shipping_address => {
:street_name => 'Bla St',
:number => '123',
:complement => '',
:neighborhood => 'Rhode Island',
:city => 'Mayland',
:state => 'Maryland',
:postal_code => '00100-011'
},
:installments => 3,
:total_items => 150.00,
:total_order => 150.00,
:items_count => 2,
:created_at => Time.current,
:order_items => [
{
:product => {
:product_id => 5555,
:name => 'Pogobol',
:category => { :category_id => 7777, :name => 'Disney' }
},
:price => 75.00,
:quantity => 1,
},
{
:product => {
:product_id => 5555,
:name => 'Pogobol',
:category => { :category_id => 7777, :name => 'Disney' }
},
:price => 75.00,
:quantity => 1,
}
],
}
payment = {
:card_holder => 'Papai Noel',
:card_number => '1234432111112222',
:card_expiration => '05/2012',
:card_security_code => '123',
:acquirer => 'visa',
:amount => 150.00,
}
user = {
:email => '[email protected]',
:user_id => 8888,
:cpf => '248.783.463-37',
:full_name => 'Papai Noel',
:birthdate => 40.years.ago,
:phone => '11 8001 1002',
:gender => 'm',
:last_sign_in_ip => '127.0.0.1',
}
#Solicitando a analise
response = Clearsale::Analysis.send_order(order, payment, user)
#consultando a analise
order_id = '1234'
response = Clearsale::Analysis.get_order_status(order_id)
response.order_id
# => 1234
response.score
# => (0.01..21.11)
response.status
# => :automatic_approval
# => :manual_approval
# => :rejected_without_suspicion
# => :manual_analysis
# => :error
# => :waiting
# => :manual_rejection
# => :cancelled
# => :fraud