Skip to content

Instantly share code, notes, and snippets.

@samflores
Last active October 4, 2018 20:01
Show Gist options
  • Save samflores/7c33770d9702084628f00aa5f861618c to your computer and use it in GitHub Desktop.
Save samflores/7c33770d9702084628f00aa5f861618c to your computer and use it in GitHub Desktop.
[4] pry(#<API::V0::CheckoutsController>)> client = Sift::Client.new(api_key:ENV['SIFT_ACCESS_KEY'], account_id: ENV['SIFT_ACCOUNT_ID'])
=> #<Sift::Client:0x0055ce34aaba38
@account_id="[redacted]",
@api_key="[redacted]",
@path="/v204/events",
@timeout=2,
@version="204">
[5] pry(#<API::V0::CheckoutsController>)> opts = { api_key: client.api_key, timeout: nil, path: nil, return_score: nil, return_action: true }
=> {:api_key=>"[redacted]",
:timeout=>nil,
:path=>nil,
:return_score=>nil,
:return_action=>true}
[6] pry(#<API::V0::CheckoutsController>)> event_name = '$create_order'
=> "$create_order"
[7] pry(#<API::V0::CheckoutsController>)> properties = current_cart_order.fraud_fields(session_id: session[:session_id], create_order: true, payment_processor_token: current_cart_order.user.payment_processor_token)
=> {"$user_id"=>5223441,
"$session_id"=>"21b10fb2bd649b023c0b683b772d6b36",
"$order_id"=>8778500,
"$user_email"=>"[email protected]",
"$amount"=>19000000,
"$billing_address"=>
{"$name"=>"Samuel Flores",
"$address_1"=>"1, Infinite Loop",
"$city"=>"Cupertino",
"$region"=>"California",
"$country"=>"US",
"$zipcode"=>"95014"},
"$shipping_address"=>
{"$name"=>"Samuel Flores",
"$address_1"=>"1, Infinite Loop",
"$city"=>"Cupertino",
"$region"=>"California",
"$country"=>"US",
"$zipcode"=>"95014"},
"coupon_code"=>false,
"is_first_time_buyer"=>true,
"$payment_methods"=>nil,
"$currency_code"=>"USD",
"$items"=>
[{"$item_id"=>9753,
"$product_title"=>"Python Network Programming Bundle",
"$price"=>19000000,
"$manufacturer"=>nil,
"$category"=>"Online Courses / Development / Programming Languages",
"$tags"=>
["Skillwise Bundles",
"ALL DEALS",
"ALL SKILLWISE COURSES FOR SALES",
"ALL Digital",
"Science/Innovative Tech Black Friday 2017 - eLearning",
"Gaming Persona Black Friday 2017 eLearning",
"Semi Annual Sale $19",
"Online Courses / Development / Web Development",
"Online Courses / Development / Programming Languages"],
"$quantity"=>1}]}
[8] pry(#<API::V0::CheckoutsController>)> response = client.track(event_name, properties, opts)
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment