HoC sale.
This commit is contained in:
parent
5365a9fdf1
commit
a97baa2207
3 changed files with 14 additions and 11 deletions
app
server/payments
|
@ -29,7 +29,7 @@ elementAcceptsKeystrokes = (el) ->
|
||||||
# not radio, checkbox, range, or color
|
# not radio, checkbox, range, or color
|
||||||
return (tag is 'textarea' or (tag is 'input' and type in textInputTypes) or el.contentEditable in ['', 'true']) and not (el.readOnly or el.disabled)
|
return (tag is 'textarea' or (tag is 'input' and type in textInputTypes) or el.contentEditable in ['', 'true']) and not (el.readOnly or el.disabled)
|
||||||
|
|
||||||
COMMON_FILES = ['/images/pages/base/modal_background.png', '/images/level/code_palette_wood_background.png', '/images/level/popover_background.png', '/images/level/code_editor_background.png']
|
COMMON_FILES = ['/images/pages/base/modal_background.png', '/images/level/popover_background.png'] #'/images/level/code_palette_wood_background.png', , '/images/level/code_editor_background.png'
|
||||||
preload = (arrayOfImages) ->
|
preload = (arrayOfImages) ->
|
||||||
$(arrayOfImages).each ->
|
$(arrayOfImages).each ->
|
||||||
$('<img/>')[0].src = @
|
$('<img/>')[0].src = @
|
||||||
|
|
|
@ -28,7 +28,8 @@ module.exports = class SubscribeModal extends ModalView
|
||||||
c = super()
|
c = super()
|
||||||
c.state = @state
|
c.state = @state
|
||||||
c.stateMessage = @stateMessage
|
c.stateMessage = @stateMessage
|
||||||
c.price = @product.amount / 100
|
#c.price = @product.amount / 100
|
||||||
|
c.price = 5.99 # Sale
|
||||||
c.BTest = me.getSubscribeCopyGroup() is 'new'
|
c.BTest = me.getSubscribeCopyGroup() is 'new'
|
||||||
return c
|
return c
|
||||||
|
|
||||||
|
@ -38,6 +39,8 @@ module.exports = class SubscribeModal extends ModalView
|
||||||
popoverContent = "<p>" + $.i18n.t('subscribe.parents_blurb1') + "</p>"
|
popoverContent = "<p>" + $.i18n.t('subscribe.parents_blurb1') + "</p>"
|
||||||
popoverContent += "<p>" + $.i18n.t('subscribe.parents_blurb2') + "</p>"
|
popoverContent += "<p>" + $.i18n.t('subscribe.parents_blurb2') + "</p>"
|
||||||
popoverContent += "<p>" + $.i18n.t('subscribe.parents_blurb3') + "</p>"
|
popoverContent += "<p>" + $.i18n.t('subscribe.parents_blurb3') + "</p>"
|
||||||
|
popoverContent = popoverContent.replace /9[.,]99/g, '5.99' # Sale
|
||||||
|
window.popoverContent = popoverContent
|
||||||
@$el.find('#parents-info').popover(
|
@$el.find('#parents-info').popover(
|
||||||
animation: true
|
animation: true
|
||||||
html: true
|
html: true
|
||||||
|
@ -64,10 +67,10 @@ module.exports = class SubscribeModal extends ModalView
|
||||||
# overwrite amount with sale price
|
# overwrite amount with sale price
|
||||||
# maybe also put in another description with details about how long it lasts, etc
|
# maybe also put in another description with details about how long it lasts, etc
|
||||||
# NOTE: Do not change this price without updating the context.price in getRenderData
|
# NOTE: Do not change this price without updating the context.price in getRenderData
|
||||||
# options = {
|
options = {
|
||||||
# description: 'Subscription. Half price for three months!'
|
description: 'Monthly Subscription (HoC sale)'
|
||||||
# amount: 499
|
amount: 599
|
||||||
# }
|
}
|
||||||
|
|
||||||
stripeHandler.open(options)
|
stripeHandler.open(options)
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ class SubscriptionHandler extends Handler
|
||||||
@logSubscriptionError(user, 'Cannot find customer: ', +customer.id + '\n\n' + err)
|
@logSubscriptionError(user, 'Cannot find customer: ', +customer.id + '\n\n' + err)
|
||||||
return done({res: 'Cannot find customer.', code: 404})
|
return done({res: 'Cannot find customer.', code: 404})
|
||||||
@checkForExistingSubscription(req, user, customer, done)
|
@checkForExistingSubscription(req, user, customer, done)
|
||||||
|
|
||||||
else
|
else
|
||||||
newCustomer = {
|
newCustomer = {
|
||||||
card: token
|
card: token
|
||||||
|
@ -47,7 +47,7 @@ class SubscriptionHandler extends Handler
|
||||||
else
|
else
|
||||||
@logSubscriptionError(user, 'Stripe customer creation error. '+err)
|
@logSubscriptionError(user, 'Stripe customer creation error. '+err)
|
||||||
return done({res: 'Database error.', code: 500})
|
return done({res: 'Database error.', code: 500})
|
||||||
|
|
||||||
stripeInfo = _.cloneDeep(user.get('stripe') ? {})
|
stripeInfo = _.cloneDeep(user.get('stripe') ? {})
|
||||||
stripeInfo.customerID = customer.id
|
stripeInfo.customerID = customer.id
|
||||||
user.set('stripe', stripeInfo)
|
user.set('stripe', stripeInfo)
|
||||||
|
@ -68,11 +68,11 @@ class SubscriptionHandler extends Handler
|
||||||
|
|
||||||
checkForExistingSubscription: (req, user, customer, done) ->
|
checkForExistingSubscription: (req, user, customer, done) ->
|
||||||
couponID = user.get('stripe')?.couponID
|
couponID = user.get('stripe')?.couponID
|
||||||
|
|
||||||
# SALE LOGIC
|
# SALE LOGIC
|
||||||
# overwrite couponID with another for everyone-sales
|
# overwrite couponID with another for everyone-sales
|
||||||
# couponID = 'hoc_bonanza' if not couponID
|
couponID = 'hoc_599' if not couponID
|
||||||
|
|
||||||
if subscription = customer.subscriptions?.data?[0]
|
if subscription = customer.subscriptions?.data?[0]
|
||||||
|
|
||||||
if subscription.cancel_at_period_end
|
if subscription.cancel_at_period_end
|
||||||
|
|
Reference in a new issue