Project

clearsale

0.01
No commit activity in last 3 years
No release in over 3 years
clearsale gem to use Clearsale service
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

active_support
>= 0
>= 0
>= 0
>= 0
>= 0
>= 0
~> 1.11.3
~> 1.7.0

Runtime

~> 1.1.0
 Project Readme

Clearsale¶ ↑

Instalação¶ ↑

Defina a variavél de ambiente CLEARSALE_ENTITYCODE

export CLEARSALE_ENTITYCODE=03524C82-F434-4A32-8D34-EFFF2023341B

Defina a variavél de ambiente CLEARSALE_ENV

export CLEARSALE_ENV=production

Adicione no seu Gemfile

gem 'clearsale', :github => 'Baby-com-br/clearsale'

Execute

bundle install

Uso¶ ↑

require 'clearsale'

order = {
  :id => 1234,
  :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 => 20.00,
  :total_order => 25.00,
  :items_count => 3,
  :created_at => Time.current,
  :order_items => [
     {
        :product => {
         :id => 5555,
         :name => 'Pogobol',
         :category => { :id => 7777, :name => 'Disney' }
         },
       :price => 5.00,
       :quantity => 2,
     },
     {
        :product => {
         :id => 5555,
         :name => 'Pogobol',
         :category => { :id => 7777, :name => 'Disney' }
         },
       :price => 5.00,
       :quantity => 2,
     },
  ],
}

payment = {
  :card_holder => 'Petter L Griffin',
  :card_number => '1234432111112222',
  :card_expiration => '05/2012',
  :card_security_code => '123',
  :acquirer => 'visa',
  :amount => 50.00,
}

user = {
  :email     => 'petergriffin@abc.com',
  :id        => 8888,
  :cpf       => '248.783.463-37',
  :full_name => 'Peter Löwenbräu Griffin',
  :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