* VRFS-2978 - give temporary pass to payment screen if you just filled out info
This commit is contained in:
parent
fb3ca2cec1
commit
eee6be5d0b
|
|
@ -172,11 +172,11 @@ module JamRuby
|
|||
break
|
||||
end
|
||||
|
||||
if !found_line_item
|
||||
@@log.error("can't find line item #{sale_line_item.recurly_adjustment_uuid}")
|
||||
puts "CANT FIND LINE ITEM"
|
||||
end
|
||||
end
|
||||
|
||||
if !found_line_item
|
||||
@@log.error("can't find line item #{sale_line_item.recurly_adjustment_uuid}")
|
||||
puts "CANT FIND LINE ITEM"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
var logger = context.JK.logger;
|
||||
var rest = context.JK.Rest();
|
||||
var jamTrackUtils = context.JK.JamTrackUtils;
|
||||
var checkoutUtils = context.JK.CheckoutUtilsInstance;
|
||||
|
||||
var $screen = null;
|
||||
var $navigation = null;
|
||||
|
|
@ -219,6 +220,7 @@
|
|||
}
|
||||
|
||||
function moveToThanks(purchaseResponse) {
|
||||
checkoutUtils.deletePreserveBillingInfo()
|
||||
$("#order_error").addClass("hidden")
|
||||
$orderPanel.addClass("hidden")
|
||||
$thanksPanel.removeClass("hidden")
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
var EVENTS = context.JK.EVENTS;
|
||||
var logger = context.JK.logger;
|
||||
var jamTrackUtils = context.JK.JamTrackUtils;
|
||||
var checkoutUtils = context.JK.CheckoutUtilsInstance;
|
||||
|
||||
var $screen = null;
|
||||
var $navigation = null;
|
||||
|
|
@ -30,6 +31,7 @@
|
|||
var selectCountryLoaded = false;
|
||||
var $freeJamTrackPrompt = null;
|
||||
var $noFreeJamTrackPrompt = null;
|
||||
var $alreadyEnteredJamTrackPrompt = null;
|
||||
|
||||
function afterShow() {
|
||||
|
||||
|
|
@ -44,12 +46,26 @@
|
|||
|
||||
|
||||
function renderAccountInfo() {
|
||||
|
||||
$paymentInfoPanel.addClass('hidden')
|
||||
$reuseExistingCard.addClass('hidden');
|
||||
$newCardInfo.removeClass('hidden');
|
||||
$freeJamTrackPrompt.addClass('hidden');
|
||||
$noFreeJamTrackPrompt.addClass('hidden');
|
||||
$alreadyEnteredJamTrackPrompt.addClass('hidden')
|
||||
$("#payment_error").addClass('hidden').text('')
|
||||
|
||||
|
||||
if(checkoutUtils.shouldPreserveBillingInfo()) {
|
||||
logger.debug("showing 'user has already set up billing info' because 'preserve billing' session is active")
|
||||
checkoutUtils.refreshPreserveBillingInfo()
|
||||
$alreadyEnteredJamTrackPrompt.removeClass('hidden')
|
||||
return
|
||||
}
|
||||
|
||||
$paymentInfoPanel.removeClass('hidden')
|
||||
|
||||
|
||||
var selectCountryReady = selectCountry.ready();
|
||||
if(!selectCountryReady) {
|
||||
// one time init of country dropdown
|
||||
|
|
@ -138,8 +154,6 @@
|
|||
}
|
||||
|
||||
function beforeShow(data) {
|
||||
// XXX : style-test code
|
||||
// moveToThanks({jam_tracks: [{id: 14, jam_track_right_id: 11, name: 'Back in Black'}, {id: 15, jam_track_right_id: 11, name: 'In Bloom'}, {id: 16, jam_track_right_id: 11, name: 'Love Bird Supreme'}]});
|
||||
}
|
||||
|
||||
function beforeHide() {
|
||||
|
|
@ -152,6 +166,13 @@
|
|||
|
||||
// TODO: Refactor: this function is long and fraught with many return points.
|
||||
function next(e) {
|
||||
|
||||
// check if we are showing the 'change payment info' pass; if so, just move on to checkoutOrder
|
||||
if($alreadyEnteredJamTrackPrompt.is(':visible')) {
|
||||
logger.debug("skipping payment logic ")
|
||||
context.location = '/client#/checkoutOrder'
|
||||
return false;
|
||||
}
|
||||
$paymentInfoPanel.find('.error-text').remove();
|
||||
$paymentInfoPanel.find('.error').removeClass('error');
|
||||
e.preventDefault();
|
||||
|
|
@ -471,6 +492,8 @@
|
|||
$screen.find("#payment-info-next").off("click");
|
||||
rest.createRecurlyAccount({billing_info: billing_info, terms_of_service: terms, email: email, password: password, reuse_card_this_time: reuse_card_this_time, reuse_card_next_time: reuse_card_next_time})
|
||||
.done(function() {
|
||||
// so the user can hit back in checkoutOrder and not have to re-enter billing info right away
|
||||
checkoutUtils.setPreserveBillingInfo();
|
||||
$screen.find("#payment-info-next").on("click", next);
|
||||
|
||||
if(isLoggedIn) {
|
||||
|
|
@ -564,6 +587,20 @@
|
|||
}
|
||||
}
|
||||
|
||||
function changeBillingInfo(e) {
|
||||
if(e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
logger.debug("change billing info requested")
|
||||
|
||||
// clear out the skip billing info behavior
|
||||
checkoutUtils.deletePreserveBillingInfo()
|
||||
|
||||
renderAccountInfo();
|
||||
|
||||
return false;
|
||||
}
|
||||
function toggleReuseExistingCard(e) {
|
||||
if(e) {
|
||||
e.preventDefault();
|
||||
|
|
@ -594,6 +631,7 @@
|
|||
$screen.find("#payment-info-next").on('click', next);
|
||||
$shippingAsBilling.on('ifChanged', toggleShippingAsBilling);
|
||||
$reuseExistingCardChk.on('ifChanged', toggleReuseExistingCard);
|
||||
$alreadyEnteredJamTrackPrompt.find('.change-payment-info').on('click', changeBillingInfo)
|
||||
}
|
||||
|
||||
function reset() {
|
||||
|
|
@ -650,6 +688,7 @@
|
|||
$newCardInfo = $paymentInfoPanel.find('.new-card-info')
|
||||
$freeJamTrackPrompt = $screen.find('.payment-prompt.free-jamtrack')
|
||||
$noFreeJamTrackPrompt = $screen.find('.payment-prompt.no-free-jamtrack')
|
||||
$alreadyEnteredJamTrackPrompt = $screen.find('.payment-prompt.already-entered')
|
||||
|
||||
|
||||
if($screen.length == 0) throw "$screen must be specified";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
$ = jQuery
|
||||
context = window
|
||||
context.JK ||= {};
|
||||
|
||||
class CheckoutUtils
|
||||
constructor: () ->
|
||||
@logger = context.JK.logger
|
||||
@rest = new context.JK.Rest();
|
||||
@cookie_name = "preserve_billing"
|
||||
init: () =>
|
||||
|
||||
refreshPreserveBillingInfo:() =>
|
||||
if @shouldPreserveBillingInfo
|
||||
@logger.debug("refreshing preserve billing info timer")
|
||||
@setPreserveBillingInfo()
|
||||
|
||||
setPreserveBillingInfo:() =>
|
||||
date = new Date();
|
||||
minutes = 1;
|
||||
date.setTime(date.getTime() + (minutes * 60 * 1000))
|
||||
$.removeCookie(@cookie_name, { path: '/' })
|
||||
$.cookie(@cookie_name, "jam", { expires: date, path: '/' })
|
||||
|
||||
deletePreserveBillingInfo:() =>
|
||||
$.removeCookie(@cookie_name, { path: '/' })
|
||||
|
||||
@logger.debug("deleted preserve billing");
|
||||
|
||||
unless $.cookie(@cookie_name)?
|
||||
@logger.error("after deleting the preserve billing cookie, it still exists!")
|
||||
|
||||
|
||||
# existance of cookie means we should preserve billing
|
||||
shouldPreserveBillingInfo:() =>
|
||||
value = $.cookie(@cookie_name)
|
||||
value?
|
||||
|
||||
|
||||
|
||||
# global instance
|
||||
context.JK.CheckoutUtilsInstance = new CheckoutUtils()
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
@import "client/common.css.scss";
|
||||
#checkoutOrderScreen {
|
||||
|
||||
|
||||
p {
|
||||
font-size:12px;
|
||||
margin:0;
|
||||
|
|
@ -25,8 +24,6 @@
|
|||
text-align:left;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.action-bar {
|
||||
margin-top:20px;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,13 @@
|
|||
line-height:125%;
|
||||
}
|
||||
|
||||
|
||||
.change-payment-info-holder {
|
||||
display:block;
|
||||
text-align:center;
|
||||
margin:40px 0;
|
||||
}
|
||||
|
||||
.field.error {
|
||||
background-color: transparent !important;
|
||||
padding: 0 !important;
|
||||
|
|
@ -57,6 +64,9 @@
|
|||
padding-bottom: 10px;
|
||||
margin-bottom: 20px;
|
||||
|
||||
&.hidden {
|
||||
display:none;
|
||||
}
|
||||
input[type="text"], input[type="password"] {
|
||||
width: 90%;
|
||||
@include border_box_sizing;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,10 @@
|
|||
float:left;
|
||||
margin-left:20px;
|
||||
}
|
||||
|
||||
.jam-track-get-ready {
|
||||
display:none;
|
||||
}
|
||||
}
|
||||
|
||||
.recording-position {
|
||||
|
|
|
|||
|
|
@ -16,8 +16,11 @@ div layout="screen" layout-id="checkoutPayment" id="checkoutPaymentScreen" class
|
|||
| There are no "hidden" charges or fees, thank you!
|
||||
p.payment-prompt.no-free-jamtrack.hidden
|
||||
| Please enter your billing address and payment information below.
|
||||
|
||||
form class="payment-info" id="checkout-payment-info"
|
||||
p.payment-prompt.already-entered.hidden
|
||||
| You recently entered payment info successfully. If you want to change your payment info, click the CHANGE PAYMENT INFO button. Otherwise, click the NEXT button to checkout.
|
||||
span.change-payment-info-holder
|
||||
a.button-orange.change-payment-info href='#' CHANGE PAYMENT INFO
|
||||
form.hidden class="payment-info" id="checkout-payment-info"
|
||||
.row.first
|
||||
.left-side
|
||||
.billing-address
|
||||
|
|
|
|||
|
|
@ -265,6 +265,7 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
|
|||
find('p.payment-prompt.free-jamtrack')
|
||||
|
||||
expect(page).to_not have_selector('.jamkazam-account-signup')
|
||||
expect(page).to_not have_selector('.payment-prompt.already-entered')
|
||||
|
||||
# fill out all billing info, but not account info
|
||||
fill_in 'billing-first-name', with: 'Seth'
|
||||
|
|
@ -283,6 +284,14 @@ describe "Checkout", :js => true, :type => :feature, :capybara_feature => true d
|
|||
# find empty shopping cart prompt notice
|
||||
find('p.empty-cart-prompt')
|
||||
|
||||
# sneak in an extra test... let's hit BACK and confirm that the temporary 'just entered billing info' screen is showing
|
||||
visit '/client#/checkoutPayment'
|
||||
find('.payment-prompt.already-entered')
|
||||
expect(page).to_not have_selector('.payment-prompt.no-free-jamtrack')
|
||||
expect(page).to_not have_selector('.payment-prompt.free-jamtrack')
|
||||
expect(page).to_not have_selector('#checkout-payment-info')
|
||||
|
||||
|
||||
user.reload
|
||||
user.reuse_card.should be_false
|
||||
end
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ bputs "before register capybara"
|
|||
config.include Requests::FeatureHelpers, type: :feature
|
||||
|
||||
# Use the specified formatter
|
||||
#config.formatter = :documentation
|
||||
config.formatter = :documentation
|
||||
|
||||
config.before(:suite) do
|
||||
tests_started = true
|
||||
|
|
|
|||
|
|
@ -82,6 +82,10 @@ def web_config
|
|||
def one_free_jamtrack_per_user
|
||||
true
|
||||
end
|
||||
|
||||
def secret_token
|
||||
'ced345e01611593c1b783bae98e4e56dbaee787747e92a141565f7c61d0ab2c6f98f7396fb4b178258301e2713816e158461af58c14b695901692f91e72b6200'
|
||||
end
|
||||
end
|
||||
klass.new
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue