Skip to content

Instantly share code, notes, and snippets.

@jakecraige
Created May 28, 2014 20:30
Show Gist options
  • Save jakecraige/558b2f829d5cc958b716 to your computer and use it in GitHub Desktop.
Save jakecraige/558b2f829d5cc958b716 to your computer and use it in GitHub Desktop.
TwoTap = Ember.Mixin.create
# returns either a two tap url or the product url if it's form an unsupported
# vendor
getTwoTapUrl: (product, tracking)->
return (product.get('affiliateUrl') || product.get('url')) unless tracking.get('twoTapEnabled')
uniqueToken = "#{product.get('id')}-#{tracking.get('id')}"
url = ENV.services.twotap.baseUrl
url += "public_token=#{ENV.services.twotap.token}"
url += "&callback_url=#{ENV.services.twotap.callbackUrl}"
#url += "&test_mode=dummy_data" unless ENV.production
url += "&unique_token=#{uniqueToken}"
url += "&user_token=#{@get('session.content.user_id')}"
url += "&products=#{encodeURIComponent(product.get('url'))}"
url += "&affiliate_links=#{encodeURIComponent(product.get('affiliateUrl'))}"
url += "&custom_css_url=#{encodeURIComponent(ENV.services.twotap.cssUrl)}"
`export default TwoTap;`
@jakecraige
Copy link
Author

baseUrl is https://checkout.twotap.com/?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment