jamtrack price change

This commit is contained in:
Seth Call 2017-02-05 14:42:51 -06:00
parent 063cbd27ee
commit cf553009bf
40 changed files with 656 additions and 146 deletions

View File

@ -371,4 +371,5 @@ retailers_v2.sql
retailer_interest.sql
connection_role.sql
retailer_payment_split.sql
teacher_distribution_fields.sql
teacher_distribution_fields.sql
jam_track_download_rights.sql

View File

@ -0,0 +1,8 @@
ALTER TABLE jam_tracks ADD COLUMN download_price numeric;
UPDATE jam_tracks SET download_price = 4.99;
ALTER TABLE jam_track_rights ADD COLUMN can_download BOOLEAN NOT NULL DEFAULT FALSE;
UPDATE jam_track_rights SET can_download = TRUE;
ALTER TABLE shopping_carts ADD COLUMN variant VARCHAR;
UPDATE shopping_carts set variant = 'stream' where cart_type = 'JamTrack';
ALTER TABLE sale_line_items ADD COLUMN variant VARCHAR;
UPDATE sale_line_items set variant = 'full';

View File

@ -42,7 +42,7 @@
yourself playing along with the rest of the band in audio or video, and more. Get your first
JamTrack free to try one out! After that they are just $1.99 each. <a href="https://jamkazam.desk.com/customer/en/portal/articles/2414618-playing-with-jamtracks" style="color:#fc0">Click here for more
JamTrack free to try one out! After that they are just $1.99/$4.99 each. <a href="https://jamkazam.desk.com/customer/en/portal/articles/2414618-playing-with-jamtracks" style="color:#fc0">Click here for more
information</a> on how you can use JamTracks in your browser, in our free Mac or Windows

View File

@ -868,6 +868,7 @@ module JamRuby
jam_track.genres = determine_genres(metadata)
jam_track.language = determine_language(metadata)
jam_track.price = 1.99
jam_track.download_price = 4.99
jam_track.reproduction_royalty_amount = nil
jam_track.reproduction_royalty = true
jam_track.public_performance_royalty = true

View File

@ -28,6 +28,10 @@ module JamRuby
sale_display
end
def variant_price(variant = nil)
price
end
def price
if card_type == JAM_TRACKS_5
10.00
@ -39,7 +43,7 @@ module JamRuby
end
def sale_display
def sale_display(variant = nil)
if card_type == JAM_TRACKS_5
'JamTracks Gift Card (5)'
elsif card_type == JAM_TRACKS_10

View File

@ -161,9 +161,22 @@ module JamRuby
true
end
def sale_display
"JamTrack: " + name
def sale_display(variant = nil)
if variant == ShoppingCart::JAMTRACK_FULL
variant_desc = 'FULL'
elsif variant == ShoppingCart::JAMTRACK_DOWNLOAD
variant_desc = 'UPRGADE'
elsif variant == ShoppingCart::JAMTRACK_STREAM
variant_desc = 'FOR USE ONLY WITHIN APP'
else
variant_desc = 'UNKNOWN'
end
"JamTrack: #{name} - #{variant_desc}"
end
def duplicate_positions?
counter = {}
jam_track_tracks.each do |track|
@ -504,14 +517,43 @@ module JamRuby
owners.include?(user)
end
def right_for_user(user)
jam_track_rights.where("user_id=?", user).first
def right_for_user(user, variant = nil)
query = jam_track_rights.where("user_id=?", user)
if variant
if variant == ShoppingCart::JAMTRACK_DOWNLOAD
query = query.where('can_download', true)
elsif variant == ShoppingCart::JAMTRACK_FULL
query = query.where('can_download', true)
elsif variant == ShoppingCart::JAMTRACK_STREAM
else
throw 'unknown variant ' + variant
end
end
query.first
end
def mixdowns_for_user(user)
JamTrackMixdown.where(user_id: user.id).where(jam_track_id: self.id)
end
def upgrade_price
variant_price('download')
end
def variant_price(variant)
if variant == 'full'
download_price
elsif variant == 'download'
download_price - price
else
price
end
end
def short_plan_code
prefix = 'jamtrack-'
plan_code[prefix.length..-1]

View File

@ -116,7 +116,7 @@ module JamRuby
teacher_dist = TeacherDistribution.create_for_lesson_package_purchase(purchase, false, (teacher_split / 100.0).round(2), retailer_rate)
purchase.teacher_distributions << teacher_dist
# price should always match the teacher_distribution, if there is one
purchase.price = teacher_dist.real_distribution_in_cents / 100
purchase.price = teacher_dist.amount_in_cents / 100
end
if retailer_split && retailer_split > 0
@ -130,7 +130,7 @@ module JamRuby
teacher_dist = TeacherDistribution.create_for_lesson_package_purchase(purchase, false)
purchase.teacher_distributions << teacher_dist
# price should always match the teacher_distribution, if there is one
purchase.price = teacher_dist.real_distribution_in_cents / 100
purchase.price = teacher_dist.amount_in_cents / 100
if lesson_booking.school_on_school_payment?
teacher_dist = TeacherDistribution.create_for_lesson_package_purchase(purchase, true)

View File

@ -102,10 +102,13 @@ module JamRuby
end
def sale_display
def sale_display(variant = nil)
name
end
def variant_price(variant = nil)
price
end
def plan_code
if package_type == SINGLE_FREE
"lesson-package-single-free"

View File

@ -36,6 +36,10 @@ module JamRuby
sale_display
end
def variant_price(variant = nil)
price
end
def price
if card_type == JAM_TRACKS_5
10.00
@ -49,7 +53,7 @@ module JamRuby
end
def sale_display
def sale_display(variant = nil)
if card_type == JAM_TRACKS_5
'JamTracks Card (5)'
elsif card_type == JAM_TRACKS_10

View File

@ -118,8 +118,24 @@ module JamRuby
price_info
end
def self.ios_purchase(current_user, jam_track, receipt, price_data)
jam_track_right = nil
def self.ios_purchase(current_user, jam_track, receipt, price_data, variant)
if variant.nil?
variant = ShoppingCart::JAMTRACK_STREAM
end
# see if we should bail because we already own these rights
jam_track_right = jam_track.right_for_user(current_user)
if !jam_track_right.nil? && jam_track_right.can_download
# if the user already has full rights to the JamTrack, there is nothing else to do in this path
return jam_track_right
end
if !jam_track_right.can_download && variant == ShoppingCart::JAMTRACK_STREAM
# if the user does have the track, but isn't upgrading it, bail
return jam_track_right
end
# everything needs to go into a transaction! If anything goes wrong, we need to raise an exception to break it
Sale.transaction do
@ -158,6 +174,11 @@ module JamRuby
jam_track_right.redeemed = using_free_credit
jam_track_right.version = jam_track.version
end
if variant == ShoppingCart::JAMTRACK_DOWNLOAD || variant == ShoppingCart::JAMTRACK_FULL
jam_track_right.can_download = true
jam_track_right.save
end
end
jam_track_right
@ -607,7 +628,8 @@ module JamRuby
if shopping_cart.is_jam_track?
jam_track = cart_product
if jam_track.right_for_user(current_user)
if jam_track.right_for_user(current_user, shopping_cart.variant)
# if the user already owns the JamTrack, we should just skip this cart item, and destroy it
# if this occurs, we have to reload every shopping_cart as we iterate. so, we do at the top of the loop
ShoppingCart.remove_jam_track_from_cart(current_user, shopping_cart)
@ -663,6 +685,13 @@ module JamRuby
jam_track_right.version = jam_track.version
end
# deal with variant behavior
if shopping_cart.purchasing_downloadable_rights?
jam_track_right.can_download = true
jam_track_right.save
end
# also if the purchase was a free one, then:
# first, mark the free has_redeemable_jamtrack field if that's still true
# and if still they have more free things, then redeem the giftable_jamtracks

View File

@ -175,6 +175,7 @@ module JamRuby
sale_line_item = SaleLineItem.new
sale_line_item.product_type = shopping_cart.cart_type
sale_line_item.variant = shopping_cart.variant
sale_line_item.unit_price = product_info[:price]
sale_line_item.quantity = product_info[:quantity]
sale_line_item.free = product_info[:marked_for_redeem]

View File

@ -10,6 +10,11 @@ module JamRuby
PURCHASE_REASONS = [PURCHASE_NORMAL, PURCHASE_FREE, PURCHASE_FREE_CREDIT]
JAMTRACK_FULL = 'full'
JAMTRACK_STREAM = 'stream'
JAMTRACK_DOWNLOAD = 'download'
JAMTRACK_VARIANTS = ['full', 'stream', 'download']
attr_accessible :quantity, :cart_type, :product_info
attr_accessor :skip_mix_check
@ -22,13 +27,15 @@ module JamRuby
validates :cart_type, presence: true
validates :cart_class_name, presence: true
validates :marked_for_redeem, numericality: {only_integer: true}
validates :variant, inclusion: {in: [nil, JAMTRACK_FULL, JAMTRACK_STREAM, JAMTRACK_DOWNLOAD]}
#validate :not_mixed
default_scope { order('created_at DESC') }
def product_info(instance = nil)
product = self.cart_product
data = {type: cart_type, name: product.name, price: product.price, product_id: cart_id, plan_code: product.plan_code, real_price: real_price(product), total_price: total_price(product), quantity: quantity, marked_for_redeem: marked_for_redeem, free: free?, sales_region: product.sales_region, sale_display:product.sale_display, allow_free: allow_free(product)} unless product.nil?
data = {type: cart_type, name: product.name, price: product.variant_price(variant), product_id: cart_id, plan_code: product.plan_code, real_price: real_price(product), total_price: total_price(product), quantity: quantity, marked_for_redeem: marked_for_redeem, free: free?, sales_region: product.sales_region, sale_display:product.sale_display(variant), allow_free: allow_free(product)} unless product.nil?
if data && instance
data.merge!(instance.product_info)
end
@ -37,12 +44,16 @@ module JamRuby
# multiply quantity by price
def total_price(product)
quantity * product.price
quantity * product.variant_price(variant)
end
def purchasing_downloadable_rights?
is_jam_track? && (variant == ShoppingCart::JAMTRACK_DOWNLOAD || variant == ShoppingCart::JAMTRACK_FULL)
end
# multiply (quantity - redeemable) by price
def real_price(product)
(quantity - marked_for_redeem) * product.price
(quantity - marked_for_redeem) * product.variant_price(variant)
end
def allow_free(product)
@ -101,7 +112,7 @@ module JamRuby
end
end
def self.create user, product, quantity = 1, mark_redeem = false
def self.create(user, product, quantity = 1, mark_redeem = false, variant = nil)
cart = ShoppingCart.new
if user.is_a?(User)
@ -111,6 +122,14 @@ module JamRuby
end
cart.cart_type = product.class::PRODUCT_TYPE
if cart.cart_type == JamTrack::PRODUCT_TYPE && variant.nil?
cart.variant = JAMTRACK_STREAM # default to jamtrack 'stream'
else
cart.variant = variant
end
cart.cart_class_name = product.class.name
cart.cart_id = product.id
cart.quantity = quantity
@ -158,9 +177,9 @@ module JamRuby
shopping_carts.each do |shopping_cart|
if shopping_cart.is_jam_track?
mark_redeem = ShoppingCart.user_has_redeemable_jam_track?(user)
cart = ShoppingCart.create(user, shopping_cart.cart_product, shopping_cart.quantity, mark_redeem)
cart = ShoppingCart.create(user, shopping_cart.cart_product, shopping_cart.quantity, mark_redeem, shopping_cart.variant)
else
cart = ShoppingCart.create(user, shopping_cart.cart_product, shopping_cart.quantity, false)
cart = ShoppingCart.create(user, shopping_cart.cart_product, shopping_cart.quantity, false, shopping_cart.variant)
end
end
@ -201,8 +220,13 @@ module JamRuby
end
# adds a jam_track to cart, checking for promotions
def self.add_jam_track_to_cart(any_user, jam_track, clear:false)
def self.add_jam_track_to_cart(any_user, jam_track, variant = JAMTRACK_FULL)
cart = nil
if variant.nil?
variant = JAMTRACK_FULL
end
ShoppingCart.transaction do
# if clear
@ -213,7 +237,7 @@ module JamRuby
end
mark_redeem = jam_track.allow_free ? ShoppingCart.user_has_redeemable_jam_track?(any_user) : false
cart = ShoppingCart.create(any_user, jam_track, 1, mark_redeem)
cart = ShoppingCart.create(any_user, jam_track, 1, mark_redeem, variant)
end
any_user.reload
cart

View File

@ -784,6 +784,7 @@ FactoryGirl.define do
sequence(:publisher) { |n| "publisher-#{n}" }
sales_region 'United States'
price 1.99
download_price 4.99
reproduction_royalty true
public_performance_royalty true
reproduction_royalty_amount 0.999

View File

@ -486,7 +486,7 @@ describe Sale do
purchase= adjustments[0]
purchase.unit_amount_in_cents.should eq((jamtrack.price * 100).to_i)
purchase.accounting_code.should eq(ShoppingCart::PURCHASE_NORMAL)
purchase.description.should eq("JamTrack: " + jamtrack.name)
purchase.description.should eq("JamTrack: " + jamtrack.name + '- FOR USE ONLY WITHIN APP')
purchase.state.should eq('invoiced')
purchase.uuid.should eq(sale_line_item.recurly_adjustment_uuid)

View File

@ -32,11 +32,11 @@ describe ShoppingCart do
end
it "allows mix of free and not free stuff" do
cart1 = ShoppingCart.add_jam_track_to_cart(user, jam_track, clear: true)
cart1 = ShoppingCart.add_jam_track_to_cart(user, jam_track)
cart1.should_not be_nil
cart1.errors.any?.should be_false
user.reload
cart2 = ShoppingCart.add_jam_track_to_cart(user, jam_track, clear: true)
cart2 = ShoppingCart.add_jam_track_to_cart(user, jam_track)
cart2.errors.any?.should be_false
user.reload
user.shopping_carts.length.should eq(1)
@ -44,7 +44,7 @@ describe ShoppingCart do
cart3.errors.any?.should be_false
user.reload
user.shopping_carts.length.should eq(2)
cart4 = ShoppingCart.add_jam_track_to_cart(user, jam_track2, clear: true)
cart4 = ShoppingCart.add_jam_track_to_cart(user, jam_track2)
cart4.errors.any?.should be_false
user.reload
user.shopping_carts.length.should eq(3)
@ -70,12 +70,12 @@ describe ShoppingCart do
it "removes redeemable item to shopping cart (maintains only one in cart)" do
user.has_redeemable_jamtrack.should be_true
cart1 = ShoppingCart.add_jam_track_to_cart(user, jam_track, clear: true)
cart1 = ShoppingCart.add_jam_track_to_cart(user, jam_track)
cart1.should_not be_nil
cart1.errors.any?.should be_false
cart1.marked_for_redeem.should eq(1)
user.reload
cart2 = ShoppingCart.add_jam_track_to_cart(user, jam_track2, clear: true)
cart2 = ShoppingCart.add_jam_track_to_cart(user, jam_track2)
cart2.should_not be_nil
cart2.errors.any?.should be_false
cart2.marked_for_redeem.should eq(1)

View File

@ -188,6 +188,37 @@
return context.JK.prodBubble($element, 'teacher-profile', {}, bigHelpDarkOptions({spikeGirth:0, spikeLength: 0, duration:10000, offsetParent:$offsetParent, width:385, positions:['top', 'right', 'bottom']}))
}
helpBubble.jamtrackVariants = function($element, $offsetParent) {
var offer = function() {
console.log("jamtrackVariant turn off")
$element.btOff()
$offsetParent.off('click', offer)
}
var bubble = context.JK.prodBubble($element, 'jamtrack-variants', {}, bigHelpDarkOptions({clickAnywhereToClose: true, spikeGirth:0, spikeLength: 0, duration:20000, positions:['bottom', 'right', 'left'], offsetParent: $offsetParent}))
setTimeout(function() {
$offsetParent.on('click', offer)
}, 1)
return bubble
}
helpBubble.jamtrackUpgrade = function($element, $offsetParent) {
var offer = function() {
console.log("jamtrackUpgrade turn off")
$element.btOff()
$offsetParent.off('click', offer)
}
var bubble = context.JK.prodBubble($element, 'jamtrack-upgrade', {}, bigHelpDarkOptions({clickAnywhereToClose: true, spikeGirth:0, spikeLength: 0, duration:20000, positions:['bottom', 'right', 'left'], offsetParent: $offsetParent}))
setTimeout(function() {
$offsetParent.on('click', offer)
}, 1)
return bubble
}
helpBubble.showUseRemainingTestDrives = function($element, $offsetParent, user, callback) {
return context.JK.onceBubble($element, 'side-remaining-test-drives', user, {offsetParent:$offsetParent, width:260, positions:['right'], postShow: function(container) {

View File

@ -73,13 +73,37 @@ MIX_MODES = context.JK.MIX_MODES
actionBtn = null
if jamtrack.purchased
actionBtn = `<a className="jamtrack-add-cart-disabled button-grey button-disabled" href="javascript:void(0)">PURCHASED</a>`
if jamtrack.can_download
actionBtn = `<a className="jamtrack-add-cart-disabled button-grey button-disabled" href="javascript:void(0)">PURCHASED</a>`
else
priceNotice = `<div className={jamtrackPricesClasses}>$ {Number(jamtrack.upgrade_price).toFixed(2)}</div>`
actionBtn = `<div>
<div className="jamtrack-add-zone">
{priceNotice}
<a className="jamtrack-add-cart button-orange" href="#" data-jamtrack-id={jamtrack.id} data-variant="download">UPGRADE TO FULL</a>
</div>
<a className="jamtrack-upgrade-help" href='#'>HELP</a>
</div>`
else if jamtrack.is_free
actionBtn = `<a className="jamtrack-add-cart button-orange is_free" href="#" data-jamtrack-id={jamtrack.id}>GET IT FREE!</a>`
actionBtn = `<a className="jamtrack-add-cart button-orange is_free" href="#" data-jamtrack-id={jamtrack.id} data-variant="full">GET IT FREE!</a>`
else if jamtrack.added_cart
actionBtn = `<a className="jamtrack-add-cart-disabled button-grey button-disabled" href="client#/shoppingCart">ALREADY IN CART</a>`
else
actionBtn = `<a className="jamtrack-add-cart button-orange" href="#" data-jamtrack-id={jamtrack.id}>ADD TO CART</a>`
priceNotice = `<div className={jamtrackPricesClasses}>$ {jamtrack.price}</div>`
fullPriceNotice = `<div className={jamtrackPricesClasses}>$ {jamtrack.download_price}</div>`
actionBtn = `<div>
<div className="jamtrack-add-zone">
{priceNotice}
<a className="jamtrack-add-cart button-orange" href="#" data-jamtrack-id={jamtrack.id} data-variant="stream">ADD TO CART</a>
</div>
<div className="jamtrack-add-zone">
{fullPriceNotice}
<a className="jamtrack-add-cart button-orange" href="#" data-jamtrack-id={jamtrack.id} data-variant="full">ADD TO CART (FULL)</a>
</div>
<a className="jamtrack-variant-help" href='#'>HELP</a>
</div>`
availabilityNotice = null
if jamtrack.sales_region==context.JK.AVAILABILITY_US
@ -114,7 +138,6 @@ MIX_MODES = context.JK.MIX_MODES
<td className="jamtrack-action">
<div className="jamtrack-action-container">
<div className="jamtrack-actions">
<div className={jamtrackPricesClasses}>$ {jamtrack.price}</div>
{actionBtn}
{availabilityNotice}
</div>
@ -300,6 +323,7 @@ MIX_MODES = context.JK.MIX_MODES
e.preventDefault()
$target = $(e.target)
params = id: $target.attr('data-jamtrack-id')
params.variant = $target.attr('data-variant')
isFree = $(e.target).is('.is_free')
@rest.addJamtrackToShoppingCart(params).done((response) =>
@ -322,6 +346,18 @@ MIX_MODES = context.JK.MIX_MODES
$parent.find('.jamtrack-add-cart').on 'click', @addToCartJamtrack
$parent.find('.license-us-why').on 'click', @licenseUSWhy
$parent.find('.jamtrack-detail-btn').on 'click', @toggleExpanded
$parent.find('.jamtrack-variant-help').on 'click', @showVariantHelp
$parent.find('.jamtrack-upgrade-help').on 'click', @showUpgradeHelp
showVariantHelp: (e) ->
$screen = $('#jamtrackFilter')
e.preventDefault()
context.JK.HelpBubbleHelper.jamtrackVariants($(e.target), $screen)
showUpgradeHelp: (e) ->
$screen = $('#jamtrackFilter')
e.preventDefault()
context.JK.HelpBubbleHelper.jamtrackUpgrade($(e.target), $screen)
toggleExpanded:(e) ->
e.preventDefault()

View File

@ -95,13 +95,37 @@ MIX_MODES = context.JK.MIX_MODES
actionBtn = null
if jamtrack.purchased
actionBtn = `<a className="jamtrack-add-cart-disabled button-grey button-disabled" href="javascript:void(0)">PURCHASED</a>`
if jamtrack.can_download
actionBtn = `<a className="jamtrack-add-cart-disabled button-grey button-disabled" href="javascript:void(0)">PURCHASED</a>`
else
priceNotice = `<div className={jamtrackPricesClasses}>$ {Number(jamtrack.upgrade_price).toFixed(2)}</div>`
actionBtn = `<div>
<div className="jamtrack-add-zone">
{priceNotice}
<a className="jamtrack-add-cart button-orange" href="#" data-jamtrack-id={jamtrack.id} data-variant="download">UPGRADE TO FULL</a>
</div>
<a className="jamtrack-upgrade-help" href='#'>HELP</a>
</div>`
else if jamtrack.is_free
actionBtn = `<a className="jamtrack-add-cart button-orange is_free" href="#" data-jamtrack-id={jamtrack.id}>GET IT FREE!</a>`
actionBtn = `<a className="jamtrack-add-cart button-orange is_free" href="#" data-jamtrack-id={jamtrack.id} data-variant="full">GET IT FREE!</a>`
else if jamtrack.added_cart
actionBtn = `<a className="jamtrack-add-cart-disabled button-grey button-disabled" href="client#/shoppingCart">ALREADY IN CART</a>`
else
actionBtn = `<a className="jamtrack-add-cart button-orange" href="#" data-jamtrack-id={jamtrack.id}>ADD TO CART</a>`
priceNotice = `<div className={jamtrackPricesClasses}>$ {jamtrack.price}</div>`
fullPriceNotice = `<div className={jamtrackPricesClasses}>$ {jamtrack.download_price}</div>`
actionBtn = `<div>
<div className="jamtrack-add-zone">
{priceNotice}
<a className="jamtrack-add-cart button-orange" href="#" data-jamtrack-id={jamtrack.id} data-variant="stream">ADD TO CART</a>
</div>
<div className="jamtrack-add-zone">
{fullPriceNotice}
<a className="jamtrack-add-cart button-orange" href="#" data-jamtrack-id={jamtrack.id} data-variant="full">ADD TO CART (FULL)</a>
</div>
<a className="jamtrack-variant-help" href='#'>HELP</a>
</div>`
availabilityNotice = null
if jamtrack.sales_region==context.JK.AVAILABILITY_US
@ -136,7 +160,6 @@ MIX_MODES = context.JK.MIX_MODES
<td className="jamtrack-action">
<div className="jamtrack-action-container">
<div className="jamtrack-actions">
<div className={jamtrackPricesClasses}>$ {jamtrack.price}</div>
{actionBtn}
{availabilityNotice}
</div>
@ -440,6 +463,7 @@ MIX_MODES = context.JK.MIX_MODES
e.preventDefault()
$target = $(e.target)
params = id: $target.attr('data-jamtrack-id')
params.variant = $target.attr('data-variant')
isFree = $(e.target).is('.is_free')
@rest.addJamtrackToShoppingCart(params).done((response) =>
@ -475,6 +499,18 @@ MIX_MODES = context.JK.MIX_MODES
$parent.find('.jamtrack-add-cart').on 'click', @addToCartJamtrack
$parent.find('.license-us-why').on 'click', @licenseUSWhy
$parent.find('.jamtrack-detail-btn').on 'click', @toggleExpanded
$parent.find('.jamtrack-variant-help').on 'click', @showVariantHelp
$parent.find('.jamtrack-upgrade-help').on 'click', @showUpgradeHelp
showVariantHelp: (e) ->
$screen = $('#jamtrackSearch')
e.preventDefault()
context.JK.HelpBubbleHelper.jamtrackVariants($(e.target), $screen)
showUpgradeHelp: (e) ->
$screen = $('#jamtrackSearch')
e.preventDefault()
context.JK.HelpBubbleHelper.jamtrackUpgrade($(e.target), $screen)
toggleExpanded:(e) ->
e.preventDefault()

View File

@ -592,6 +592,37 @@ mixins.push(Reflux.listenTo(UserStore, 'onUserChanged'))
# make this package the active one
JamTrackPlayerActions.openStem(selectedTrackId)
addUpgradeToCart: (jamtrack) ->
console.log("adding upgrade to cart")
params = {id: jamtrack.id, variant: 'download'}
rest.addJamtrackToShoppingCart(params).done((response) =>
console.log("added item to shopping cart. fast_redeem? " + response.fast_redeem)
if response.fast_reedem
if context.JK.currentUserId?
window.open('/client#/redeemComplete')
else
window.open('/client#/redeemSignup')
else
window.open('/client#/shoppingCart')
).fail(((jqxhr) =>
handled = false
if jqxhr.status == 422
body = JSON.parse(jqxhr.responseText)
if body.errors?.cart_id?[0] == 'has already been taken'
console.log("already taken, just show shopping cart")
window.open('/client#/shoppingCart')
return
else if body.errors && body.errors.base
handled = true
alert("You can not have a mix of free and non-free items in your shopping cart.\n\nIf you want to add this new item to your shopping cart, then clear out all current items by clicking on the shopping cart icon and clicking 'delete' next to each item.")
if !handled
alert("Error adding to shoppig cart. " + jqxhr.responseText)
))
downloadStem: (e) ->
if @verificationCheck()
e.preventDefault()
@ -601,6 +632,12 @@ mixins.push(Reflux.listenTo(UserStore, 'onUserChanged'))
selectedTrackId = $select.val()
if !@state.jamTrackState.jamTrack.can_download
e.preventDefault()
if confirm("You have not purchased the rights to download a JamTrack. Add them to your shopping cart?")
@addUpgradeToCart(@state.jamTrackState.jamTrack)
return
if !selectedTrackId? || selectedTrackId == ''
e.preventDefault()
alert("You must select a track in order to download and also click the folder icon.")
@ -658,6 +695,13 @@ mixins.push(Reflux.listenTo(UserStore, 'onUserChanged'))
e.preventDefault()
return
if !@state.jamTrackState.jamTrack.can_download
e.preventDefault()
if confirm("You have not purchased the rights to download a JamTrack. Add them to your shopping cart?")
@addUpgradeToCart(@state.jamTrackState.jamTrack)
return
if /iPhone|iPad|iPod/i.test(navigator.userAgent)
# fall through

View File

@ -1,7 +1,7 @@
context = window
logger = context.JK.logger
ReactCSSTransitionGroup = React.addons.CSSTransitionGroup;
rest = context.JK.Rest()
mixins = []
@ -523,12 +523,49 @@ mixins.push(Reflux.listenTo(UserStore, 'onUserChanged'))
return if @verificationCheck()
if !@state.jamTrackState.jamTrack.can_download
e.preventDefault()
if confirm("You have not purchased the rights to download a JamTrack. Add them to your shopping cart?")
@addUpgradeToCart(@state.jamTrackState.jamTrack)
return
new window.Fingerprint2().get((result, components) => (
redirectTo = "/api/jamtracks/#{jamTrack.id}/stems/master/download.mp3?file_type=mp3&download=1&mark=#{result}"
redirectTo = encodeURIComponent(redirectTo)
AppActions.openExternalUrl(window.location.protocol + '//' + window.location.host + "/signin?redirect-to=#{redirectTo}")
))
addUpgradeToCart: (jamtrack) ->
console.log("adding upgrade to cart")
params = {id: jamtrack.id, variant: 'download'}
rest.addJamtrackToShoppingCart(params).done((response) =>
console.log("added item to shopping cart. fast_redeem? " + response.fast_redeem)
if response.fast_reedem
if context.JK.currentUserId?
AppActions.openExternalUrl(window.location.protocol + '//' + window.location.host + '/client#/redeemComplete')
else
AppActions.openExternalUrl(window.location.protocol + '//' + window.location.host + '/client#/redeemSignup')
else
AppActions.openExternalUrl(window.location.protocol + '//' + window.location.host + '/client#/shoppingCart')
).fail(((jqxhr) =>
handled = false
if jqxhr.status == 422
body = JSON.parse(jqxhr.responseText)
if body.errors?.cart_id?[0] == 'has already been taken'
console.log("already taken, just show shopping cart")
AppActions.openExternalUrl(window.location.protocol + '//' + window.location.host + '/client#/shoppingCart')
return
else if body.errors && body.errors.base
handled = true
alert("You can not have a mix of free and non-free items in your shopping cart.\n\nIf you want to add this new item to your shopping cart, then clear out all current items by clicking on the shopping cart icon and clicking 'delete' next to each item.")
if !handled
alert("Error adding to shoppig cart. " + jqxhr.responseText)
))
stemChanged:() ->
stemDownload: (e) ->
e.preventDefault()
@ -537,6 +574,12 @@ mixins.push(Reflux.listenTo(UserStore, 'onUserChanged'))
$select = $(this.getDOMNode()).find('.active-stem-select')
if !@state.jamTrackState.jamTrack.can_download
e.preventDefault()
if confirm("You have not purchased the rights to download a JamTrack. Add them to your shopping cart?")
@addUpgradeToCart(@state.jamTrackState.jamTrack)
return
selectedTrackId = $select.val()
if !selectedTrackId? || selectedTrackId == ''

View File

@ -98,7 +98,7 @@ rest = context.JK.Rest()
<li>And more</li>
</ul>
<p>
JamTracks sell for $1.99 each. Musicians love to play with these, and typically buy a few at a
JamTracks sell for $1.99 each ($4.99 to include ability to download). Musicians love to play with these, and typically buy a few at a
time. Imagine that you are selling a set of guitar strings to an electric guitar player. As a

View File

@ -72,7 +72,7 @@ rest = context.JK.Rest()
<a href="/client#/jamtrack/search" onClick={this.redeem} className="cta-free-jamtrack" alt="ClICK HERE TO PICK YOUR FIRST JAMTRACK FREE!">
{img}
</a>
<span className="value-indicator">$1.99 value</span>
<span className="value-indicator">#{this.props.jam_track.download_price} value</span>
</div>
<br/>
<div className="browse-band">

View File

@ -35,10 +35,10 @@ rest = context.JK.Rest()
if loggedIn
loggedInCtaButton = `<button className={classNames({'cta-button' : true, 'processing': this.state.processing})} onClick={this.ctaClick}>{ctaButtonText}</button>`
if !@isFree()
loggedInPriceAdvisory = `<div className="price-advisory">${this.props.jam_track.price}</div>`
loggedInPriceAdvisory = `<div className="price-advisory">${this.props.jam_track.download_price}</div>`
else
if !@isFree()
loggedOutPriceAdvisory = `<div className="price-advisory">${this.props.jam_track.price}</div>`
loggedOutPriceAdvisory = `<div className="price-advisory">${this.props.jam_track.download_price}</div>`
if this.state.loginErrors?
for key, value of this.state.loginErrors

View File

@ -108,7 +108,7 @@ context = window
<iframe src="//www.youtube.com/embed/ysptXwFYDhQ" frameborder="0" allowfullscreen="allowfullscreen"/>
</div>
</div>
<p>Your first JamTrack is free, and after that JamTracks are just $1.99 each.</p>
<p>Your first JamTrack is free, and after that JamTracks are just $1.99/$4.99 each.</p>
<div className="clearall"/>
</div>
</div>

View File

@ -266,9 +266,19 @@
margin-top: 5px;
}
.jamtrack-variant-help {
margin-bottom:20px;
}
.jamtrack-add-zone {
margin: 8px 0px;
position:relative;
}
.jamtrack-price {
margin-top: 5px;
width:100%;
margin: 0 auto 10px;
font-size: 20px;
color:white;
display:block;
&.free {
margin-top:0;
@ -282,7 +292,7 @@
}
.jamtrack-add-cart, .jamtrack-add-cart-disabled {
margin: 8px 0px;
position:relative;
}
.jamtrack-license {

View File

@ -164,6 +164,11 @@ class ApiJamTracksController < ApiController
end
if params[:download]
if !@jam_track_right.can_download
render :json => { :message => "Download rights not purchased"}, :status => 403
return
end
if DownloadTracker.check(current_user, request.remote_ip, jam_track_track, !@jam_track_right.redeemed, params[:mark], false)
render :json => { :message => "IP blacklisted"}, :status => 403
return
@ -323,20 +328,12 @@ class ApiJamTracksController < ApiController
def ios_order_placed
jam_track = JamTrack.find(params[:jam_track_id])
jam_track_right = jam_track.right_for_user(current_user)
# the user already owns this JamTrac, so just short-circuit out
if jam_track_right
response = {name: jam_track.name, id: jam_track.id, jam_track_right_id: jam_track_right.id, version: jam_track.version}
render :json => response, :status => 200
return
end
begin
Sale.ios_purchase(current_user,
jam_track,
params[:receipt],
params[:price_data])
params[:price_data],
params[:variant])
rescue
response = { message: $!.to_s }
render :json => response, :status => 422

View File

@ -20,7 +20,7 @@ class ApiShoppingCartsController < ApiController
raise StateError, "Invalid JamTrack."
end
@cart = ShoppingCart.add_jam_track_to_cart(any_user, jam_track, clear:params[:clear])
@cart = ShoppingCart.add_jam_track_to_cart(any_user, jam_track, params[:variant])
if @cart.errors.any?
response.status = :unprocessable_entity

View File

@ -1,6 +1,6 @@
object @jam_track
attributes :id, :name, :description, :recording_type, :original_artist, :songwriter, :publisher, :sales_region, :price, :version, :duration, :year, :plan_code, :allow_free
attributes :id, :name, :description, :recording_type, :original_artist, :songwriter, :publisher, :sales_region, :price, :version, :duration, :year, :plan_code, :allow_free, :download_price, :upgrade_price
node :genres do |item|
item.genres.select(:description).map(&:description)
@ -10,6 +10,10 @@ node :added_cart do |item|
any_user.shopping_carts.where(cart_id: item.id).count != 0
end
node :can_download do |item|
!!item.right_for_user(current_user, ShoppingCart::JAMTRACK_FULL)
end
node :purchased do |item|
!!item.right_for_user(current_user)
end

View File

@ -10,6 +10,10 @@ node :jmep do |jam_track|
jam_track.jmep_json ? jam_track.jmep_json : nil
end
node :can_download do |item|
!!item.right_for_user(current_user, ShoppingCart::JAMTRACK_FULL)
end
child(:jam_track_tracks => :tracks) {
attributes :id, :part, :instrument, :track_type, :position

View File

@ -1,7 +1,11 @@
object @jam_track
attributes :id, :name, :original_artist, :year, :genre_name
attributes :id, :name, :original_artist, :year, :genre_name, :can_download
node :purchased_at do |jt|
Time.parse(jt.purchased_at).to_i rescue Time.now.to_i
end
node :can_download do |item|
!!item.right_for_user(current_user, ShoppingCart::JAMTRACK_FULL)
end

View File

@ -1,3 +1,3 @@
object @jam_track_right
attributes :id, :error_count, :error_reason, :error_detail, :signing_state, :packaging_steps, :current_packaging_step
attributes :id, :error_count, :error_reason, :error_detail, :signing_state, :packaging_steps, :current_packaging_step, :can_download

View File

@ -400,6 +400,15 @@ script type="text/template" id="template-help-teacher-profile"
a href="https://jamkazam.desk.com/customer/en/portal/articles/2405835-creating-your-teacher-profile#EditTeacherProfile" rel="external" Click here
| &nbsp; for a help article that explains how to fill out your teacher profile effectively to attract students.
script type="text/template" id="template-help-jamtrack-variants"
.jamtrack-variants.big-dark-help
p
| The FULL package of a JamTrack will let you also download each track or mix to a personal device. You can always upgrade to FULL later.
script type="text/template" id="template-help-jamtrack-upgrade"
.jamtrack-upgrade.big-dark-help
p
| Upgrade your JamTrack so that you can download each track or mix to a personal device.
script type="text/template" id="template-help-side-remaining-jamclass-credits"
.side-remaining-jamclass-credits

View File

@ -56,7 +56,7 @@
<% if @show_cta_free_jamtrack %>
<div class="cta-free-jamtrack">
<%= link_to image_tag("web/free-jamtrack-cta.png", :alt => "ClICK HERE TO PICK YOUR FIRST JAMTRACK FREE!"), "/client#/jamtrack/search", class: "cta-free-jamtrack" %>
<span class="value-indicator">$1.99 value</span>
<span class="value-indicator">$4.99 value</span>
</div>
<% end %>
</div>

View File

@ -29,7 +29,7 @@
.badge-number 3
| Get your free JamTrack
span.special-value
| &nbsp; ($1.99 value)
| &nbsp; ($4.99 value)
.jamtrack-content

View File

@ -23,7 +23,7 @@ Rails.application.routes.draw do
match '/redeem_giftcard', to: 'landings#redeem_giftcard', via: :get
# landing pages
# landing pageslanding
get '/jamtracks', to: 'landings#simple_jamtracks', as: 'landing_simple_jamtracks'
get '/jamclass', to: 'landings#simple_jamclass', as: 'landing_simple_class'
get '/landing/wb', to: 'landings#watch_bands', as: 'landing_wb'

View File

@ -5,6 +5,8 @@ describe ApiJamblastersController, type: :controller do
let(:user) { FactoryGirl.create(:user) }
let(:jamblaster) { FactoryGirl.create(:jamblaster, user: user) }
let(:user2) { FactoryGirl.create(:user) }
before(:each) do
JamblasterUser.delete_all
JamblasterPairingRequest.delete_all
@ -301,6 +303,77 @@ describe ApiJamblastersController, type: :controller do
jamblaster.reload
jamblaster.users.include?(user).should be true
end
it "across two users" do
post :start_pairing, {:format => 'json', jbid: jamblaster.client_id, vtoken: 'vtoken4'}
response.status.should == 200
request = JamblasterPairingRequest.where(jamblaster_client_id: jamblaster.client_id, vtoken: 'vtoken4', user_id: user.id).first
request.should_not be_nil
request.user.should eql(user)
request.vtoken.should eq 'vtoken4'
request.jamblaster_client_id.should eq jamblaster.client_id
post :login, {:format => 'json', jbid: jamblaster.client_id, serial_no: jamblaster.serial_no, user_id: user.id, vtoken: 'vtoken4'}
json = JSON.parse(response.body)
response.status.should == 200
jamblaster.reload
jamblaster.users.include?(user).should be false
post :pair, {:format => 'json', vtoken: 'vtoken4', user_id: user.id, jbid: jamblaster.client_id, key: 'abc'}
response.status.should == 200
json = JSON.parse(response.body)
json["id"].should eq jamblaster.id
get :get_tokens, {:format => 'json'}
response.status.should == 200
json = JSON.parse(response.body)
json.length.should eq(1)
key = json[0]["pairing"]["key"]
key.should eq("abc")
jamblaster.reload
jamblaster.users.include?(user).should be true
# now try with second user!
controller.current_user = user2
post :start_pairing, {:format => 'json', jbid: jamblaster.client_id, vtoken: 'vtoken5'}
response.status.should == 200
puts "JSON.parse(response.body) #{JSON.parse(response.body)}"
request = JamblasterPairingRequest.where(jamblaster_client_id: jamblaster.client_id, vtoken: 'vtoken5', user_id: user2.id).first
request.should_not be_nil
request.user.should eql(user2)
request.vtoken.should eq 'vtoken5'
request.jamblaster_client_id.should eq jamblaster.client_id
post :login, {:format => 'json', jbid: jamblaster.client_id, serial_no: jamblaster.serial_no, user_id: user2.id, vtoken: 'vtoken5'}
json = JSON.parse(response.body)
response.status.should == 200
jamblaster.reload
jamblaster.users.include?(user2).should be false
post :pair, {:format => 'json', vtoken: 'vtoken5', user_id: user2.id, jbid: jamblaster.client_id, key: 'abcd'}
response.status.should == 200
json = JSON.parse(response.body)
json["id"].should eq jamblaster.id
get :get_tokens, {:format => 'json'}
response.status.should == 200
json = JSON.parse(response.body)
json.length.should eq(1)
key = json[0]["pairing"]["key"]
key.should eq("abcd")
jamblaster.reload
jamblaster.users.include?(user).should be true
jamblaster.users.include?(user2).should be true
end
end
end

View File

@ -768,8 +768,9 @@ FactoryGirl.define do
sequence(:original_artist) { |n| "original-artist-#{n}" }
sequence(:songwriter) { |n| "songwriter-#{n}" }
sequence(:publisher) { |n| "publisher-#{n}" }
sales_region 'United States'
sales_region 'Worldwide'
price 1.99
download_price 4.99
reproduction_royalty true
public_performance_royalty true
reproduction_royalty_amount 0.999

View File

@ -38,9 +38,9 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
JamTrack.delete_all
@jamtrack_acdc_backinblack = FactoryGirl.create(:jam_track, name: 'Back in Black', original_artist: 'AC/DC', sales_region: 'United States', make_track: true, plan_code: 'jamtrack-acdc-backinblack')
@jamtrack_pearljam_evenflow = FactoryGirl.create(:jam_track, name: 'Even Flow', original_artist: 'Pearl Jam', sales_region: 'United States', make_track: true, plan_code: 'jamtrack-pearljam-evenflow')
@jamtrack_led_zeppelin_kashmir = FactoryGirl.create(:jam_track, name: 'Kashmir', original_artist: 'Led Zeppelin', sales_region: 'United States', make_track: true, plan_code: 'jamtrack-led-zeppelin-kashmir')
@jamtrack_acdc_backinblack = FactoryGirl.create(:jam_track, name: 'Back in Black', original_artist: 'AC/DC', sales_region: 'Worldwide', make_track: true, plan_code: 'jamtrack-acdc-backinblack')
@jamtrack_pearljam_evenflow = FactoryGirl.create(:jam_track, name: 'Even Flow', original_artist: 'Pearl Jam', sales_region: 'Worldwide', make_track: true, plan_code: 'jamtrack-pearljam-evenflow')
@jamtrack_led_zeppelin_kashmir = FactoryGirl.create(:jam_track, name: 'Kashmir', original_artist: 'Led Zeppelin', sales_region: 'Worldwide', make_track: true, plan_code: 'jamtrack-led-zeppelin-kashmir')
# make sure plans are there
@recurlyClient.create_jam_track_plan(@jamtrack_acdc_backinblack) unless @recurlyClient.find_jam_track_plan(@jamtrack_acdc_backinblack)
@ -525,11 +525,11 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
fast_signin(user, '/client#/checkoutOrder')
find('p.order-prompt')
find('.order-items-value.order-total', text:'$1.99')
find('.order-items-value.order-total', text:'$4.99')
find('.order-items-value.shipping-handling', text:'$0.00')
find('.order-items-value.sub-total', text:'$1.99')
find('.order-items-value.sub-total', text:'$4.99')
find('.order-items-value.taxes', text:'$0.00')
find('.order-items-value.grand-total', text:'$1.99')
find('.order-items-value.grand-total', text:'$4.99')
end
it "shows one free, one not free item correctly (Texas)" do
@ -550,11 +550,11 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
fast_signin(user, '/client#/checkoutOrder')
find('p.order-prompt')
find('.order-items-value.order-total', text:'$1.99')
find('.order-items-value.order-total', text:'$4.99')
find('.order-items-value.shipping-handling', text:'$0.00')
find('.order-items-value.sub-total', text:'$1.99')
find('.order-items-value.taxes', text:'$0.16')
find('.order-items-value.grand-total', text:'$2.15')
find('.order-items-value.sub-total', text:'$4.99')
find('.order-items-value.taxes', text:'$0.41')
find('.order-items-value.grand-total', text:'$5.40')
end
it "shows one non-free item correctly (not Texas)" do
@ -573,11 +573,11 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
fast_signin(user, '/client#/checkoutOrder')
find('p.order-prompt')
find('.order-items-value.order-total', text:'$1.99')
find('.order-items-value.order-total', text:'$4.99')
find('.order-items-value.shipping-handling', text:'$0.00')
find('.order-items-value.sub-total', text:'$1.99')
find('.order-items-value.sub-total', text:'$4.99')
find('.order-items-value.taxes', text:'$0.00')
find('.order-items-value.grand-total', text:'$1.99')
find('.order-items-value.grand-total', text:'$4.99')
end
it "shows one non-free item correctly (Texas)" do
@ -595,11 +595,11 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
fast_signin(user, '/client#/checkoutOrder')
find('p.order-prompt')
find('.order-items-value.order-total', text:'$1.99')
find('.order-items-value.order-total', text:'$4.99')
find('.order-items-value.shipping-handling', text:'$0.00')
find('.order-items-value.sub-total', text:'$1.99')
find('.order-items-value.taxes', text:'$0.16')
find('.order-items-value.grand-total', text:'$2.15')
find('.order-items-value.sub-total', text:'$4.99')
find('.order-items-value.taxes', text:'$0.41')
find('.order-items-value.grand-total', text:'$5.40')
end
it "shows two non-free items correctly (non-Texas)" do
@ -620,11 +620,11 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
fast_signin(user, '/client#/checkoutOrder')
find('p.order-prompt')
find('.order-items-value.order-total', text:'$3.98')
find('.order-items-value.order-total', text:'$9.98')
find('.order-items-value.shipping-handling', text:'$0.00')
find('.order-items-value.sub-total', text:'$3.98')
find('.order-items-value.sub-total', text:'$9.98')
find('.order-items-value.taxes', text:'$0.00')
find('.order-items-value.grand-total', text:'$3.98')
find('.order-items-value.grand-total', text:'$9.98')
end
it "shows two non-free items correctly (Texas)" do
@ -644,11 +644,11 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
fast_signin(user, '/client#/checkoutOrder')
find('p.order-prompt')
find('.order-items-value.order-total', text:'$3.98')
find('.order-items-value.order-total', text:'$9.98')
find('.order-items-value.shipping-handling', text:'$0.00')
find('.order-items-value.sub-total', text:'$3.98')
find('.order-items-value.taxes', text:'$0.33')
find('.order-items-value.grand-total', text:'$4.31')
find('.order-items-value.sub-total', text:'$9.98')
find('.order-items-value.taxes', text:'$0.82')
find('.order-items-value.grand-total', text:'$10.80')
find('.place-order-center a.button-orange.place-order').trigger(:click)
@ -675,7 +675,7 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
acdc_sale.product_id.should eq(jamtrack_acdc_backinblack.id)
acdc_sale.quantity.should eq(1)
acdc_sale.free.should eq(0)
acdc_sale.unit_price.should eq(1.99)
acdc_sale.unit_price.should eq(4.99)
acdc_sale.sale.should eq(sale)
pearljam_sale = SaleLineItem.find_by_recurly_adjustment_uuid(pearljam.recurly_adjustment_uuid)
pearljam_sale.recurly_plan_code.should eq(jamtrack_pearljam_evenflow.plan_code)
@ -683,7 +683,7 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
pearljam_sale.product_id.should eq(jamtrack_pearljam_evenflow.id)
pearljam_sale.quantity.should eq(1)
pearljam_sale.free.should eq(0)
pearljam_sale.unit_price.should eq(1.99)
pearljam_sale.unit_price.should eq(4.99)
pearljam_sale.sale.should eq(sale)
end
@ -760,7 +760,7 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
acdc_sale.product_id.should eq(jamtrack_acdc_backinblack.id)
acdc_sale.quantity.should eq(1)
acdc_sale.free.should eq(1)
acdc_sale.unit_price.should eq(1.99)
acdc_sale.unit_price.should eq(4.99)
acdc_sale.sale.should eq(sale)
@ -772,11 +772,11 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
visit "/client?song=#{jamtrack_pearljam_evenflow.name}#/jamtrack/search"
find("a.jamtrack-add-cart[data-jamtrack-id=\"#{jamtrack_pearljam_evenflow.id}\"]", text: 'ADD TO CART').trigger(:click)
find("a.jamtrack-add-cart[data-jamtrack-id=\"#{jamtrack_pearljam_evenflow.id}\"]", text: 'ADD TO CART (FULL)').trigger(:click)
find('h1', text: 'shopping cart')
find('.cart-item-caption', text: "JamTrack: #{jamtrack_pearljam_evenflow.name}")
find('.cart-item-price', text: "$ #{jamtrack_pearljam_evenflow.price}")
find('.shopping-sub-total', text:"Subtotal:$ #{jamtrack_pearljam_evenflow.price}")
find('.cart-item-price', text: "$ #{jamtrack_pearljam_evenflow.download_price}")
find('.shopping-sub-total', text:"Subtotal:$ #{jamtrack_pearljam_evenflow.download_price}")
# attempt to checkout
find('a.button-orange', text: 'PROCEED TO CHECKOUT').trigger(:click)
@ -803,11 +803,11 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
# now see order page, and everything should no longer appear free
find('p.order-prompt')
find('.order-items-value.order-total', text:'$1.99')
find('.order-items-value.order-total', text:'$4.99')
find('.order-items-value.shipping-handling', text:'$0.00')
find('.order-items-value.sub-total', text:'$1.99')
find('.order-items-value.taxes', text:'$0.16')
find('.order-items-value.grand-total', text:'$2.15')
find('.order-items-value.sub-total', text:'$4.99')
find('.order-items-value.taxes', text:'$0.41')
find('.order-items-value.grand-total', text:'$5.40')
# click the ORDER button
find('.place-order-center a.button-orange.place-order').trigger(:click)
@ -823,6 +823,7 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
# make sure it appears the user actually bought the jamtrack!
jam_track_right.should_not be_nil
jam_track_right.redeemed.should be false
jam_track_right.can_download.should be true
guy.has_redeemable_jamtrack.should be false
# verify sales data
@ -835,7 +836,7 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
acdc_sale.product_id.should eq(jamtrack_pearljam_evenflow.id)
acdc_sale.quantity.should eq(1)
acdc_sale.free.should eq(0)
acdc_sale.unit_price.should eq(1.99)
acdc_sale.unit_price.should eq(4.99)
acdc_sale.sale.should eq(sale)
end
@ -877,11 +878,11 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
visit "/client?song=#{jamtrack_pearljam_evenflow.name}#/jamtrack/search"
find("a.jamtrack-add-cart[data-jamtrack-id=\"#{jamtrack_pearljam_evenflow.id}\"]", text: 'ADD TO CART').trigger(:click)
find("a.jamtrack-add-cart[data-jamtrack-id=\"#{jamtrack_pearljam_evenflow.id}\"]", text: 'ADD TO CART (FULL)').trigger(:click)
find('h1', text: 'shopping cart')
find('.cart-item-caption', text: "JamTrack: #{jamtrack_pearljam_evenflow.name}")
find('.cart-item-price', text: "$ #{jamtrack_pearljam_evenflow.price}")
find('.shopping-sub-total', text:"Subtotal:$ #{jamtrack_pearljam_evenflow.price}")
find('.cart-item-price', text: "$ #{jamtrack_pearljam_evenflow.download_price}")
find('.shopping-sub-total', text:"Subtotal:$ #{jamtrack_pearljam_evenflow.download_price}")
# attempt to checkout
find('a.button-orange', text: 'PROCEED TO CHECKOUT').trigger(:click)
@ -908,11 +909,11 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
# now see order page, and everything should no longer appear free
find('p.order-prompt')
find('.order-items-value.order-total', text:'$1.99')
find('.order-items-value.order-total', text:'$4.99')
find('.order-items-value.shipping-handling', text:'$0.00')
find('.order-items-value.sub-total', text:'$1.99')
find('.order-items-value.taxes', text:'$0.16')
find('.order-items-value.grand-total', text:'$2.15')
find('.order-items-value.sub-total', text:'$4.99')
find('.order-items-value.taxes', text:'$0.41')
find('.order-items-value.grand-total', text:'$5.40')
# click the ORDER button
find('.place-order-center a.button-orange.place-order').trigger(:click)
@ -928,6 +929,7 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
# make sure it appears the user actually bought the jamtrack!
jam_track_right.should_not be_nil
jam_track_right.redeemed.should be false
jam_track_right.can_download.should be true
guy.has_redeemable_jamtrack.should be false
# verify sales data
@ -938,7 +940,7 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
acdc_sale.affiliate_referral.should eq(partner)
acdc_sale.affiliate_refunded.should be false
acdc_sale.affiliate_refunded_at.should be_nil
acdc_sale.affiliate_referral_fee_in_cents.should eq(20)
acdc_sale.affiliate_referral_fee_in_cents.should eq(50)
end
@ -969,7 +971,65 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
find('h1', text: 'jamtracks')
#find('a', text: 'What is a JamTrack?')
find("a.jamtrack-add-cart[data-jamtrack-id=\"#{jamtrack_acdc_backinblack.id}\"]", text: 'ADD TO CART').trigger(:click)
find("a.jamtrack-add-cart[data-jamtrack-id=\"#{jamtrack_acdc_backinblack.id}\"]", text: 'ADD TO CART (FULL)').trigger(:click)
find('h1', text: 'shopping cart')
find('.cart-item-caption', text: "JamTrack: #{jamtrack_acdc_backinblack.name}")
find('.cart-item-price', text: "$ #{jamtrack_acdc_backinblack.download_price}") # 1st one is free!
find('.shopping-sub-total', text:"Subtotal:$ 4.99")
# attempt to checkout
find('a.button-orange', text: 'PROCEED TO CHECKOUT').trigger(:click)
# we should be skipping the signin screen, and be taken directly to payment
# this should take us to the payment screen
find('p.payment-prompt')
# fill out all billing info and account info
fill_in 'billing-first-name', with: 'Seth'
fill_in 'billing-last-name', with: 'Call'
fill_in 'billing-address1', with: '10704 Buckthorn Drive'
fill_in 'billing-city', with: 'Austin'
fill_in 'billing-state', with: 'Texas'
fill_in 'billing-zip', with: '78759'
fill_in 'card-number', with: '4111111111111111'
fill_in 'card-verify', with: '012'
# try to submit, and see order page
find('#payment-info-next').trigger(:click)
# now see order page, and everything should appear free
find('p.order-prompt')
find('.order-items-value.order-total', text:'$4.99')
find('.order-items-value.shipping-handling', text:'$0.00')
find('.order-items-value.sub-total', text:'$4.99')
find('.order-items-value.taxes', text:'$0.41')
find('.order-items-value.grand-total', text:'$5.40')
# click the ORDER button
find('.place-order-center a.button-orange.place-order').trigger(:click)
# and now we should see confirmation, and a notice that we are in a normal browser
find('.thanks-detail.jam-tracks-in-browser')
user.reload
jam_track_right = jamtrack_acdc_backinblack.right_for_user(user)
# make sure it appears the user actually bought the jamtrack!
jam_track_right.should_not be_nil
jam_track_right.redeemed.should be false
jam_track_right.can_download.should be true
user.has_redeemable_jamtrack.should be false
end
it "for existing user buying stream-only with no freebie available (already logged in)" do
user.has_redeemable_jamtrack = false
user.save!
fast_signin(user, "/client?song=#{jamtrack_acdc_backinblack.name}#/jamtrack/search")
find('h1', text: 'jamtracks')
#find('a', text: 'What is a JamTrack?')
find("a.jamtrack-add-cart[data-jamtrack-id=\"#{jamtrack_acdc_backinblack.id}\"][data-variant=\"stream\"]", text: 'ADD TO CART').trigger(:click)
find('h1', text: 'shopping cart')
find('.cart-item-caption', text: "JamTrack: #{jamtrack_acdc_backinblack.name}")
find('.cart-item-price', text: "$ #{jamtrack_acdc_backinblack.price}") # 1st one is free!
@ -1015,9 +1075,48 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
# make sure it appears the user actually bought the jamtrack!
jam_track_right.should_not be_nil
jam_track_right.redeemed.should be false
jam_track_right.can_download.should be false
user.has_redeemable_jamtrack.should be false
user.sales.length.should eq(1)
sale = user.sales.last
sale.sale_line_items.length.should eq(1)
line_item = sale.sale_line_items[0]
line_item.unit_price.should eq(1.99)
# now to upgrade it!
visit "/client?song=#{jamtrack_acdc_backinblack.name}#/jamtrack/search"
find('h1', text: 'jamtracks')
#find('a', text: 'What is a JamTrack?')
upgrade_price = jamtrack_acdc_backinblack.download_price - jamtrack_acdc_backinblack.price
upgrade_price.should eql 3
find("a.jamtrack-add-cart[data-jamtrack-id=\"#{jamtrack_acdc_backinblack.id}\"][data-variant=\"download\"]", text: 'UPGRADE').trigger(:click)
find('h1', text: 'shopping cart')
find('.cart-item-caption', text: "JamTrack: #{jamtrack_acdc_backinblack.name}")
find('.cart-item-price', text: "$ 3.00")
find('.shopping-sub-total', text:"Subtotal:$ 3.00")
# attempt to checkout
find('a.button-orange', text: 'PROCEED TO CHECKOUT').trigger(:click)
# click the ORDER button
find('.place-order-center a.button-orange.place-order').trigger(:click)
find('.thanks-detail.jam-tracks-in-browser')
user.reload
user.sales.length.should eq(2)
sale = user.sales.last
sale.sale_line_items.length.should eq(1)
line_item = sale.sale_line_items[0]
line_item.unit_price.should eq(3.00)
end
it "for existing user with a freebie (starts shopping anonymously)" do
user.has_redeemable_jamtrack = true
user.save!
@ -1063,6 +1162,7 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
# make sure it appears the user actually bought the jamtrack!
jam_track_right.should_not be_nil
jam_track_right.redeemed.should be true
jam_track_right.can_download.should be true
user.has_redeemable_jamtrack.should be false
# verify sales data
@ -1075,7 +1175,7 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
acdc_sale.product_id.should eq(jamtrack_acdc_backinblack.id)
acdc_sale.quantity.should eq(1)
acdc_sale.free.should eq(1)
acdc_sale.unit_price.should eq(1.99)
acdc_sale.unit_price.should eq(4.99)
acdc_sale.sale.should eq(sale)
end
@ -1089,11 +1189,11 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
find('h1', text: 'jamtracks')
#find('a', text: 'What is a JamTrack?')
find("a.jamtrack-add-cart[data-jamtrack-id=\"#{jamtrack_acdc_backinblack.id}\"]", text:'ADD TO CART').trigger(:click)
find("a.jamtrack-add-cart[data-jamtrack-id=\"#{jamtrack_acdc_backinblack.id}\"]", text:'ADD TO CART (FULL)').trigger(:click)
find('h1', text: 'shopping cart')
find('.cart-item-caption', text: "JamTrack: #{jamtrack_acdc_backinblack.name}")
find('.cart-item-price', text: "$ 1.99") # 1st one is free!
find('.shopping-sub-total', text:"Subtotal:$ 1.99")
find('.cart-item-price', text: "$ 4.99") # 1st one is free!
find('.shopping-sub-total', text:"Subtotal:$ 4.99")
# attempt to checkout
find('a.button-orange', text: 'PROCEED TO CHECKOUT').trigger(:click)
@ -1140,7 +1240,7 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
acdc_sale.product_id.should eq(jamtrack_acdc_backinblack.id)
acdc_sale.quantity.should eq(1)
acdc_sale.free.should eq(1)
acdc_sale.unit_price.should eq(1.99)
acdc_sale.unit_price.should eq(4.99)
acdc_sale.sale.should eq(sale)
end
@ -1154,11 +1254,11 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
find('h1', text: 'jamtracks')
#find('a', text: 'What is a JamTrack?')
find("a.jamtrack-add-cart[data-jamtrack-id=\"#{jamtrack_acdc_backinblack.id}\"]", text:'ADD TO CART').trigger(:click)
find("a.jamtrack-add-cart[data-jamtrack-id=\"#{jamtrack_acdc_backinblack.id}\"]", text:'ADD TO CART (FULL)').trigger(:click)
find('h1', text: 'shopping cart')
find('.cart-item-caption', text: "JamTrack: #{jamtrack_acdc_backinblack.name}")
find('.cart-item-price', text: "$ 1.99") # 1st one is free!
find('.shopping-sub-total', text:"Subtotal:$ 1.99")
find('.cart-item-price', text: "$ 4.99") # 1st one is free!
find('.shopping-sub-total', text:"Subtotal:$ 4.99")
# attempt to checkout
find('a.button-orange', text: 'PROCEED TO CHECKOUT').trigger(:click)
@ -1196,11 +1296,11 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
# now see order page, and everything should appear free
find('p.order-prompt')
find('.order-items-value.order-total', text:'$1.99')
find('.order-items-value.order-total', text:'$4.99')
find('.order-items-value.shipping-handling', text:'$0.00')
find('.order-items-value.sub-total', text:'$1.99')
find('.order-items-value.taxes', text:'$0.16')
find('.order-items-value.grand-total', text:'$2.15')
find('.order-items-value.sub-total', text:'$4.99')
find('.order-items-value.taxes', text:'$0.41')
find('.order-items-value.grand-total', text:'$5.40')
# click the ORDER button
find('.place-order-center a.button-orange.place-order').trigger(:click)
@ -1233,7 +1333,7 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
acdc_sale.product_id.should eq(jamtrack_acdc_backinblack.id)
acdc_sale.quantity.should eq(1)
acdc_sale.free.should eq(0)
acdc_sale.unit_price.should eq(1.99)
acdc_sale.unit_price.should eq(4.99)
acdc_sale.sale.should eq(sale)
end
end
@ -1334,14 +1434,14 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
find('a.continue-shopping').trigger(:click)
find('h1', text: 'search jamtracks')
find('.jamtrack-record[data-jamtrack-id="' + jamtrack_pearljam_evenflow.id + '"]')
find("a.jamtrack-add-cart[data-jamtrack-id=\"#{jamtrack_pearljam_evenflow.id}\"]", text: 'ADD TO CART').trigger(:click)
find("a.jamtrack-add-cart[data-jamtrack-id=\"#{jamtrack_pearljam_evenflow.id}\"]", text: 'ADD TO CART (FULL)').trigger(:click)
find('h1', text: 'shopping cart')
find('.cart-item-caption', text: "JamTrack: #{jamtrack_pearljam_evenflow.name}")
find('.cart-item-caption', text: "JamTrack: #{jamtrack_led_zeppelin_kashmir.name}")
find('.cart-price', text: "$ 0.00")
find('.cart-price', text: "$ #{jamtrack_pearljam_evenflow.price}")
find('.shopping-sub-total', text:"Subtotal:$ #{jamtrack_pearljam_evenflow.price}")
find('.cart-price', text: "$ #{jamtrack_pearljam_evenflow.download_price}")
find('.shopping-sub-total', text:"Subtotal:$ #{jamtrack_pearljam_evenflow.download_price}")
# attempt to checkout
find('a.button-orange', text: 'PROCEED TO CHECKOUT').trigger(:click)
@ -1368,11 +1468,11 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
# now see order page, and everything should no longer appear free
find('p.order-prompt')
find('.order-items-value.order-total', text:'$1.99')
find('.order-items-value.order-total', text:'$4.99')
find('.order-items-value.shipping-handling', text:'$0.00')
find('.order-items-value.sub-total', text:'$1.99')
find('.order-items-value.taxes', text:'$0.16')
find('.order-items-value.grand-total', text:'$2.15')
find('.order-items-value.sub-total', text:'$4.99')
find('.order-items-value.taxes', text:'$0.41')
find('.order-items-value.grand-total', text:'$5.40')
# click the ORDER button
find('.place-order-center a.button-orange.place-order').trigger(:click)
@ -1399,7 +1499,7 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
fast_signin(user, "/client?song=#{jamtrack_led_zeppelin_kashmir.name}#/jamtrack/search")
find('h1', text: 'jamtracks')
find("a.jamtrack-add-cart[data-jamtrack-id=\"#{jamtrack_led_zeppelin_kashmir.id}\"]", text: 'ADD TO CART').trigger(:click)
find("a.jamtrack-add-cart[data-jamtrack-id=\"#{jamtrack_led_zeppelin_kashmir.id}\"]", text: 'ADD TO CART (FULL)').trigger(:click)
find('h1', text: 'shopping cart')
sleep 2
user.reload
@ -1408,8 +1508,8 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
find('h1', text: 'shopping cart')
find('.cart-item-caption', text: "JamTrack: #{jamtrack_led_zeppelin_kashmir.name}")
find('.cart-price', text: "$ #{jamtrack_led_zeppelin_kashmir.price}")
find('.shopping-sub-total', text:"Subtotal:$ #{jamtrack_led_zeppelin_kashmir.price}")
find('.cart-price', text: "$ #{jamtrack_led_zeppelin_kashmir.download_price}")
find('.shopping-sub-total', text:"Subtotal:$ #{jamtrack_led_zeppelin_kashmir.download_price}")
go_to_root
@ -1431,8 +1531,8 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
find('.cart-item-caption', text: "JamTrack: #{jamtrack_acdc_backinblack.name}")
find('.cart-item-caption', text: "JamTrack: #{jamtrack_led_zeppelin_kashmir.name}")
find('.cart-price', text: "$ 0.00")
find('.cart-price', text: "$ #{jamtrack_led_zeppelin_kashmir.price}")
find('.shopping-sub-total', text:"Subtotal:$ #{jamtrack_led_zeppelin_kashmir.price}")
find('.cart-price', text: "$ #{jamtrack_led_zeppelin_kashmir.download_price}")
find('.shopping-sub-total', text:"Subtotal:$ #{jamtrack_led_zeppelin_kashmir.download_price}")
# attempt to checkout
find('a.button-orange', text: 'PROCEED TO CHECKOUT').trigger(:click)
@ -1459,11 +1559,11 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
# now see order page, and everything should no longer appear free
find('p.order-prompt')
find('.order-items-value.order-total', text:'$1.99')
find('.order-items-value.order-total', text:'$4.99')
find('.order-items-value.shipping-handling', text:'$0.00')
find('.order-items-value.sub-total', text:'$1.99')
find('.order-items-value.taxes', text:'$0.16')
find('.order-items-value.grand-total', text:'$2.15')
find('.order-items-value.sub-total', text:'$4.99')
find('.order-items-value.taxes', text:'$0.41')
find('.order-items-value.grand-total', text:'$5.40')
# click the ORDER button
find('.place-order-center a.button-orange.place-order').trigger(:click)
@ -1492,7 +1592,7 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
fast_signin(user, "/client?song=#{jamtrack_led_zeppelin_kashmir.name}#/jamtrack/search")
find('h1', text: 'jamtracks')
find("a.jamtrack-add-cart[data-jamtrack-id=\"#{jamtrack_led_zeppelin_kashmir.id}\"]", text: 'ADD TO CART').trigger(:click)
find("a.jamtrack-add-cart[data-jamtrack-id=\"#{jamtrack_led_zeppelin_kashmir.id}\"]", text: 'ADD TO CART (FULL)').trigger(:click)
find('h1', text: 'shopping cart')
sleep 2
user.reload
@ -1501,8 +1601,8 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
find('h1', text: 'shopping cart')
find('.cart-item-caption', text: "JamTrack: #{jamtrack_led_zeppelin_kashmir.name}")
find('.cart-price', text: "$ #{jamtrack_led_zeppelin_kashmir.price}")
find('.shopping-sub-total', text:"Subtotal:$ #{jamtrack_led_zeppelin_kashmir.price}")
find('.cart-price', text: "$ #{jamtrack_led_zeppelin_kashmir.download_price}")
find('.shopping-sub-total', text:"Subtotal:$ #{jamtrack_led_zeppelin_kashmir.download_price}")
# attempt to checkout
@ -1530,11 +1630,11 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
# now see order page, and everything should no longer appear free
find('p.order-prompt')
find('.order-items-value.order-total', text:'$1.99')
find('.order-items-value.order-total', text:'$4.99')
find('.order-items-value.shipping-handling', text:'$0.00')
find('.order-items-value.sub-total', text:'$1.99')
find('.order-items-value.taxes', text:'$0.16')
find('.order-items-value.grand-total', text:'$2.15')
find('.order-items-value.sub-total', text:'$4.99')
find('.order-items-value.taxes', text:'$0.41')
find('.order-items-value.grand-total', text:'$5.40')
# click the ORDER button
find('.place-order-center a.button-orange.place-order').trigger(:click)

View File

@ -74,7 +74,7 @@ describe "Individual JamTrack", :js => true, :type => :feature, :capybara_featur
# now go back, and then try to click checkout again
visit "/landing/jamtracks/#{@jamtrack_acdc_backinblack.slug}"
find('button.cta-button', text: 'Add To Cart')
find('.price-advisory', text:"$1.99")
find('.price-advisory', text:"$4.99")
find('button.cta-button').trigger(:click)
find('h1', text: 'shopping cart')

View File

@ -101,16 +101,16 @@ describe "JamTrack Search", :js => true, :type => :feature, :capybara_feature =>
find('a.jamtrack-add-cart.is_free[data-jamtrack-id="' + jt_us.id + '"]', text: 'GET IT FREE!')
find('.jamtrack-record[data-jamtrack-id="' + jt_ww.id + '"] .jamtrack-price.non-free', text: "$ #{jt_ww.price}")
find('a.jamtrack-add-cart[data-jamtrack-id="' + jt_ww.id + '"]', text: 'ADD TO CART').trigger(:click)
find('a.jamtrack-add-cart[data-jamtrack-id="' + jt_ww.id + '"][data-variant="stream"]', text: 'ADD TO CART').trigger(:click)
find('h1', text: 'shopping cart')
find('.cart-item-price', text: "$ #{jt_ww.price}")
find('a', text: 'CONTINUE SHOPPING').trigger(':click')
find('a.jamtrack-add-cart.is_free[data-jamtrack-id="' + jt_us.id + '"]', text: 'GET IT FREE!').trigger(:click)
find('a.jamtrack-add-cart.is_free[data-jamtrack-id="' + jt_us.id + '"][data-variant="full"]', text: 'GET IT FREE!').trigger(:click)
find('.cart-item-price', text: "$ #{jt_us.price}")
find('.cart-item-price', text: "$ #{jt_us.download_price}")
find('.cart-item-price', text: "$ #{jt_ww.price}")
end