diff --git a/build/recurly.js b/build/recurly.js index 076db5f5c..18550796c 100644 --- a/build/recurly.js +++ b/build/recurly.js @@ -1205,6 +1205,7 @@ var preFillMap = { } , subscription: { couponCode: '.subscription > .coupon > .coupon_code > input' + , quantity: '.subscription > .plan > .quantity > input' } }; diff --git a/build/recurly.min.js b/build/recurly.min.js index 731c693fc..d144e6b3d 100644 --- a/build/recurly.min.js +++ b/build/recurly.min.js @@ -1 +1 @@ -(function(f){function v(D){function C(){}C.prototype=D||this;return new C()}var h={};h.settings={enableGeoIP:true,acceptedCards:["visa","mastercard","discover","american_express"],oneErrorPerField:true};h.version="2.2.4";h.dom={};h.Error={toString:function(){return"RecurlyJS Error: "+this.message}};h.raiseError=function(C){var D=v(h.Error);D.message=C;throw D};h.config=function(C){f.extend(true,h.settings,C);if(!C.baseURL){var D=h.settings.subdomain||h.raiseError("company subdomain not configured");h.settings.baseURL="https://"+D+".recurly.com/jsonp/"+D+"/"}};function u(D,C){if(D==1){return C.substr(0,C.length-1)}return""+D+" "+C}(h.Cost=function(C){this._cents=C||0}).prototype={toString:function(){return h.formatCurrency(this.dollars())},cents:function(C){if(C===undefined){return this._cents}return new h.Cost(C)},dollars:function(C){if(C===undefined){return this._cents/100}return new h.Cost(C*100)},mult:function(C){return new h.Cost(this._cents*C)},add:function(C){if(C.cents){C=C.cents()}return new h.Cost(this._cents+C)},sub:function(C){if(C.cents){C=C.cents()}return new h.Cost(this._cents-C)}};h.Cost.FREE=new h.Cost(0);(h.TimePeriod=function(D,C){this.length=D;this.unit=C}).prototype={toString:function(){return""+u(this.length,this.unit)},toDate:function(){var C=new Date();switch(this.unit){case"month":C.setMonth(C.getMonth()+this.length);break;case"day":C.setDay(C.getDay()+this.length);break}return C},clone:function(){return new h.TimePeriod(this.length,this.unit)}};(h.RecurringCost=function(D,C){this.cost=D;this.interval=C}).prototype={toString:function(){return""+this.cost+" every "+this.interval},clone:function(){return new h.TimePeriod(this.length,this.unit)}};h.RecurringCost.FREE=new h.RecurringCost(0,null);(h.RecurringCostStage=function(C,D){this.recurringCost=C;this.duration=D}).prototype={toString:function(){this.recurringCost.toString()+" for "+this.duration.toString()}};h.locale={};h.locale.errors={emptyField:"Required field",missingFullAddress:"Please enter your full address.",invalidEmail:"Invalid",invalidCC:"Invalid",invalidCVV:"Invalid",invalidCoupon:"Invalid",cardDeclined:"Transaction declined",acceptTOS:"Please accept the Terms of Service.",invalidQuantity:"Invalid quantity"};h.locale.currencies={};h.locale.currency={format:"%u%n",separator:".",delimiter:",",precision:2};function s(C,D){var F=h.locale.currencies[C]=v(h.locale.currency);for(var E in D){F[E]=D[E]}}s("USD",{symbol:"$"});s("AUD",{symbol:"$"});s("CAD",{symbol:"$"});s("EUR",{symbol:"\u20ac"});s("GBP",{symbol:"\u00a3"});s("CZK",{symbol:"\u004b"});s("DKK",{symbol:"\u006b\u0072"});s("HUF",{symbol:"Ft"});s("JPY",{symbol:"\u00a5"});s("NOK",{symbol:"kr"});s("NZD",{symbol:"$"});s("PLN",{symbol:"\u007a"});s("SGD",{symbol:"$"});s("SEK",{symbol:"kr"});s("CHF",{symbol:"Fr"});s("ZAR",{symbol:"R"});h.settings.locale=h.locale;h.knownCards={visa:{prefixes:[4],name:"Visa"},mastercard:{prefixes:[51,52,53,54,55],name:"MasterCard"},american_express:{prefixes:[34,37],name:"American Express"},discover:{prefixes:[6011,62,64,65],name:"Discover"},diners_club:{prefixes:[305,36,38],name:"Diners Club"},carte_blanche:{prefixes:[300,301,302,303,304,305]},jcb:{prefixes:[35],name:"JCB"},enroute:{prefixes:[2014,2149],name:"EnRoute"},maestro:{prefixes:[5018,5020,5038,6304,6759,6761],name:"Maestro"},laser:{prefixes:[6304,6706,6771,6709],name:"Laser"}};h.detectCardType=function(E){E=E.replace(/\D/g,"");var H=h.knownCards;for(var C in H){if(H.hasOwnProperty(C)){var I=H[C];for(var G=0,D=I.prefixes.length;G").hide();F.attr("action",D).attr("method","POST").attr("enctype","application/x-www-form-urlencoded");f('').attr({name:"recurly_token",value:E}).appendTo(F);f("body").append(F);F.submit()};function k(F){var E=f("");for(var D in F){if(F.hasOwnProperty(D)){var C=F[D];E.append(""+C+"")}}return E}h.enforce=function(C){return{enforced:C,hidden:false,hide:function(){this.hidden=true;return this}}};function r(D){D=D||this;if(typeof D=="string"){return D.replace(/([a-z])([A-Z])/g,function(F,E,G){return E+"_"+G}).toLowerCase()}else{for(var C in D){if(D.hasOwnProperty(C)){}}}}function n(F){var E={};for(var D in F){var C=F[D];if(f.isPlainObject(C)){E[D]=n(C)}else{if(typeof C!=="undefined"){E[D]=C}}}return E}h.ajax=function(C){C.data=f.extend({js_version:h.version},C.data);C.data=n(C.data);if(C.data.billing_info&&C.data.billing_info.payment_method=="paypal"){return h.paypal.start(C)}return f.ajax(C)};function w(C){f("body").append(h.dom.error_dialog)}(h.isValidCC=function(I){var D=I.val();D=D.replace(/\D/g,"");if(D==""){return false}var G=0,F=0,C=false;for(var H=D.length-1;H>=0;H--){var E=D.charAt(H);var F=parseInt(E,10);if(C){if((F*=2)>9){F-=9}}G+=F;C=!C}return(G%10)==0}).defaultErrorKey="invalidCC";(h.isValidEmail=function(D){var C=D.val();return/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(C)}).defaultErrorKey="invalidEmail";function b(C){return/^[0-9]+$/.test(C)}(h.isValidCVV=function(D){var C=D.val();return(C.length==3||C.length==4)&&b(C)}).defaultErrorKey="invalidCVV";(h.isNotEmpty=function(D){var C=D.val();if(D.is("select")){if(C=="-"||C=="--"){return false}}return !!C}).defaultErrorKey="emptyField";(h.isNotEmptyState=function(D){var C=D.val();if(D.is("select")){if(C=="-"||C=="--"){return false}}return true}).defaultErrorKey="emptyField";(h.isChecked=function(C){return C.is(":checked")}).defaultErrorKey="acceptTOS";(h.isValidQuantity=function(C){return/^[0-9]*$/.test(C.val())}).defaultErrorKey="invalidQuantity";h.Plan={create:v,fromJSON:function(F){var G=this.create();G.name=F.name;G.code=F.plan_code;G.currency=F.currency;G.cost=new h.Cost(F.unit_amount_in_cents);G.displayQuantity=F.display_quantity;G.interval=new h.TimePeriod(F.plan_interval_length,F.plan_interval_unit);if(F.trial_interval_length){G.trial=new h.TimePeriod(F.trial_interval_length,F.trial_interval_unit)}if(F.setup_fee_in_cents){G.setupFee=new h.Cost(F.setup_fee_in_cents)}if(F.vat_percentage){h.settings.VATPercent=parseFloat(F.vat_percentage)}if(F.merchant_country){h.settings.country=F.merchant_country}G.addOns=[];if(F.add_ons){for(var D=F.add_ons.length,E=0;E');C.text(F);C.appendTo(H.parent());H.addClass("invalid");H.bind("change keyup",function E(I){if(D(H)){H.removeClass("invalid");C.remove();H.unbind(I)}})}function B(E,G){var D=false;var C={field:function(H,J,I){I=Array.prototype.slice.call(arguments,2);return z(H,J,I,function K(L){if(!D){L.element.focus()}x(L);D=true;if(h.settings.oneErrorPerForm){throw {stopPulling:true}}})}};try{E(C)}catch(F){if(!F.stopPulling){throw F}}if(!D){G()}}function z(K,F,D,H){var I=K.find(F+" input");if(I.length==0){I=K.find(F+" select")}if(I.length==0){return undefined}var C=I.val();for(var G=0,E=D.length;G');E.text(H[G]);F.append(E)}}}var j={account:{firstName:".contact_info > .full_name > .first_name > input",lastName:".contact_info > .full_name > .last_name > input",email:".contact_info > .email > input",phone:".contact_info > .phone > input",companyName:".contact_info > .company_name > input"},billingInfo:{firstName:".billing_info > .first_name > input",lastName:".billing_info > .last_name > input",address1:".billing_info > .address > .address1 > input",address2:".billing_info > .address > .address2 > input",country:".billing_info > .address > .country > select",city:".billing_info > .address > .city > input",state:".billing_info > .address > .state_zip > .state > input",zip:".billing_info > .address > .state_zip > .zip > input",vatNumber:".billing_info > .vat_number > input",cardNumber:".billing_info .card_number > input",CVV:".billing_info .cvv > input"},subscription:{couponCode:".subscription > .coupon > .coupon_code > input"}};function o(C,D,F){(function E(H,G,K){if(!H){return}for(var J in H){if(H.hasOwnProperty(J)&&G.hasOwnProperty(J)){var N=H[J];var I=G[J];var O=r(J);var L=K?(K+"."+O):O;if(typeof I=="string"){var M=C.find(I);M.val(N).change()}else{if(typeof I=="object"){E(N,I,L)}}}}})(D,F)}function l(C,D){if(!D.collectPhone){C.find(".phone").remove()}if(!D.collectCompany){C.find(".company_name").remove()}C.delegate(".placeholder","click",function(){var E=f(this);var F=f(this).parent();F.find("input").focus()});C.delegate("input","change keyup",function(){var F=f(this);var E=f(this).parent();if(F.val().length>0){E.find(".placeholder").css({display:"none"})}else{E.find(".placeholder").css({display:"block"})}});C.delegate("input","focus",function(){f(this).parent().addClass("focus")});C.delegate("input","blur",function(){f(this).parent().removeClass("focus")});C.delegate("input","keydown",function(E){if(E.keyCode>=48&&E.keyCode<=90){f(this).parent().find(".placeholder").hide()}});o(C,D,j)}function g(E,F){if(F.distinguishContactFromBillingInfo){var D=E.find(".contact_info .first_name input");var G=E.find(".contact_info .last_name input");var H=D.val();var C=G.val();E.find(".contact_info .first_name input").change(function(){var I=E.find(".billing_info .first_name input");if(I.val()==H){I.val(f(this).val()).change()}H=D.val()});E.find(".contact_info .last_name input").change(function(){var I=E.find(".billing_info .last_name input");if(I.val()==C){I.val(f(this).val()).change()}C=G.val()})}else{E.find(".billing_info .first_name, .billing_info .last_name").remove()}}function e(M,I){var E=M.find(".country select");var ab=M.find(".state");var af=ab.find("input");var W=ab.children();var R={};var P=h.states;var O=E.val();if(I.acceptedCards&&I.acceptPaypal){var N=M.find(".payment_method");var G=N.find("input");var V=M.find("button.submit");var D=V.text();N.on("click",".payment_option",function(){var ah=f(this);N.find(".selected").removeClass("selected");ah.addClass("selected");N.find("input[type=radio]:checked").prop("checked",false);ah.find("input[type=radio]").prop("checked",true);if(ah.is(".card_option")){M.find(".credit_card").css({display:"block"});M.find(".paypal").css({display:"none"});G.val("");V.text(D)}else{if(ah.is(".paypal_option")){M.find(".credit_card").css({display:"none"});M.find(".paypal").css({display:"block"});G.val("paypal");V.text(D+" with PayPal")}}});M.find(".payment_option").first().click()}else{M.find(".payment_method").removeClass("multiple");if(I.acceptedCards){M.find(".paypal_option").remove();M.find(".paypal").remove()}else{if(I.acceptPaypal){M.find(".payment_method input").val("paypal");M.find(".card_option").remove();M.find(".credit_card").remove()}}}function T(al,aj){var ak=P[al];aj=f.trim(aj.toUpperCase());if(ak.hasOwnProperty(aj)){return aj}for(var ai in ak){if(ak.hasOwnProperty(ai)){var ah=ak[ai];if(aj==ah.toUpperCase()){return ai}}}return false}function ag(ak,ah){var aj=ab.hasClass("select_mode");if(ak=="US"||ak=="CA"){if(!aj||O!=ak){var ai=ab.find("input").val();if(ai!=undefined&&ai!=""){ah=T(ak,ai);if(!ah){return false}}ab.addClass("select_mode");ab.children().detach();R[ak]=R[ak]||k(P[ak]);ab.append(R[ak]);if(ah){ab.find("select").val(ah)}}}else{if(aj){ab.empty().append(W).removeClass("select_mode")}}}af.bind("change keyup",function(){ag(O)});E.change(function(){var ah=f(this).val();ag(ah);O=ah});function K(aj,ah){var ai=aj.val();if(!ah||ah==""){return false}if(ai&&ai!=""&&ai!="-"){return false}return aj.val(ah).change()}if(I.enableGeoIP){f.ajax({url:h.settings.baseURL+"location",dataType:"jsonp",jsonp:"callback",success:function(ah){if(ah.country){K(E,ah.country);ag(ah.country,ah.state)}}})}else{if(h.settings.country){var Y=M.find(".country option[value="+h.settings.country+"]");if(Y.length){Y.attr("selected",true).change()}}}var H=new Date();var Q=H.getFullYear();var ac=H.getMonth();var aa=M.find(".year select");var C=M.find(".month select");for(var X=Q;X<=Q+10;++X){var J=f(''+X+"");J.appendTo(aa)}aa.val(Q+1);function Z(){if(aa.val()==Q){var ah=false;if(C.val()>ac){ah=true}C.find("option").each(function(){if(f(this).val()<=ac){f(this).attr("disabled",true)}else{f(this).removeAttr("disabled");if(!ah){f(this).attr("selected",true);ah=true}}})}else{C.find("option").removeAttr("disabled")}}Z();aa.change(Z);if(I.addressRequirement=="none"){M.find(".address").remove()}else{if(I.addressRequirement=="zip"){M.find(".address").addClass("only_zip");M.find(".address1, .address2, .city, .state").remove();if(!h.settings.VATPercent){M.find(".country").remove()}}else{if(I.addressRequirement=="zipstreet"){M.find(".address").addClass("only_zipstreet");M.find(".city, .state").remove();if(!h.settings.VATPercent){M.find(".country").remove()}}else{if(I.addressRequirement=="full"){M.find(".address").addClass("full")}else{if(I.addressRequirement=="only_country"){M.find(".address").addClass("only_country")}}}}}var S=M.find(".accepted_cards");if(I.acceptedCards){var ad=I.acceptedCards,U=ad.length;for(var X=0;X');var F=h.knownCards[ae];if(F&&F.name){L.text(F.name)}S.append(L)}}M.find(".card_number input").bind("change keyup",function(){var ah=h.detectCardType(f(this).val());if(ah){S.find(".card").each(function(){f(this).toggleClass("match",f(this).hasClass(ah));f(this).toggleClass("no_match",!f(this).hasClass(ah))})}else{S.find(".card").removeClass("match no_match")}})}function i(C,F,D,E){F.firstName=E.field(C,".contact_info .first_name",c(h.isNotEmpty));F.lastName=E.field(C,".contact_info .last_name",c(h.isNotEmpty));F.companyName=E.field(C,".contact_info .company_name");F.email=E.field(C,".email",c(h.isNotEmpty),c(h.isValidEmail));F.code=D.accountCode||(D.account&&(D.account.code||D.account.accountCode))}function d(C,F,D,E){F.paymentMethod=E.field(C,".payment_method");if(F.paymentMethod!=="paypal"){F.firstName=E.field(C,".billing_info .first_name",c(h.isNotEmpty));F.lastName=E.field(C,".billing_info .last_name",c(h.isNotEmpty));F.number=E.field(C,".card_number",c(h.isNotEmpty),c(h.isValidCC));F.cvv=E.field(C,".cvv",c(h.isNotEmpty),c(h.isValidCVV));F.month=E.field(C,".month");F.year=E.field(C,".year")}F.phone=E.field(C,".phone");F.address1=E.field(C,".address1",c(h.isNotEmpty));F.address2=E.field(C,".address2");F.city=E.field(C,".city",c(h.isNotEmpty));F.state=E.field(C,".state",c(h.isNotEmptyState));F.zip=E.field(C,".zip",c(h.isNotEmpty));F.country=E.field(C,".country",c(h.isNotEmpty))}function q(C,F,D,E){var G=E.field(C,".plan .quantity",c(h.isValidQuantity));F.quantity=G||1}function y(C,D){D.field(C,".accept_tos",c(h.isChecked))}h.buildBillingInfoForm=h.buildBillingInfoUpdateForm=function(D){var F={addressRequirement:"full",collectContactInfo:false,distinguishContactFromBillingInfo:true};D.successHandler=D.successHandler||D.afterUpdate;D=f.extend(v(h.settings),F,D);if(!D.accountCode){h.raiseError("accountCode missing")}if(!D.signature){h.raiseError("signature missing")}var G=h.BillingInfo.create(),E=h.Account.create();G.account=E;var C=f(h.dom.update_billing_info_form);if(D.collectContactInfo){C.find(".contact_info").html(h.dom.contact_info_fields)}else{C.find(".contact_info").remove()}C.find(".billing_info").html(h.dom.billing_info_fields);l(C,D);g(C,D);e(C,D);C.submit(function(H){H.preventDefault();a(C);C.find(".error").remove();C.find(".invalid").removeClass("invalid");B(function(I){d(C,G,D,I);i(C,E,D,I)},function(){C.addClass("submitting");var I=C.find("button.submit").text();C.find("button.submit").attr("disabled",true).text("Please Wait");G.save({signature:D.signature,distinguishContactFromBillingInfo:D.distinguishContactFromBillingInfo,accountCode:D.accountCode,success:function(J){if(D.successHandler){D.successHandler(h.getToken(J))}if(D.successURL){var K=D.successURL;h.postResult(K,J,D)}},error:function(J){if(!D.onError||!D.onError(J)){p(C,J)}},complete:function(){C.removeClass("submitting");C.find("button.submit").removeAttr("disabled").text(I)}})})});if(D.beforeInject){D.beforeInject(C.get(0))}f(function(){var H=f(D.target);H.html(C);if(D.afterInject){D.afterInject(C.get(0))}})};function A(C,D){if(D.termsOfServiceURL||D.privacyPolicyURL){var E=C.find(".accept_tos").html(h.dom.terms_of_service);if(!(D.termsOfServiceURL&&D.privacyPolicyURL)){E.find("span.and").remove()}if(D.termsOfServiceURL){E.find("a.tos_link").attr("href",D.termsOfServiceURL)}else{E.find("a.tos_link").remove()}if(D.privacyPolicyURL){E.find("a.pp_link").attr("href",D.privacyPolicyURL)}else{E.find("a.pp_link").remove()}}else{C.find(".accept_tos").remove()}}h.buildTransactionForm=function(D){var F={addressRequirement:"full",distinguishContactFromBillingInfo:true,collectContactInfo:true};D.successHandler=D.successHandler||D.afterPay;D=f.extend(v(h.settings),F,D);if(!D.collectContactInfo&&!D.accountCode){h.raiseError("collectContactInfo is false, but no accountCode provided")}if(!D.signature){h.raiseError("signature missing")}var H=h.BillingInfo.create(),E=h.Account.create(),G=h.Transaction.create();G.account=E;G.billingInfo=H;G.currency=D.currency;G.cost=new h.Cost(D.amountInCents);var C=f(h.dom.one_time_transaction_form);if(D.collectContactInfo){C.find(".contact_info").html(h.dom.contact_info_fields)}else{C.find(".contact_info").remove()}C.find(".billing_info").html(h.dom.billing_info_fields);l(C,D);e(C,D);g(C,D);A(C,D);C.submit(function(I){I.preventDefault();a(C);C.find(".error").remove();C.find(".invalid").removeClass("invalid");B(function(J){i(C,E,D,J);d(C,H,D,J);y(C,J)},function(){C.addClass("submitting");var J=C.find("button.submit").text();C.find("button.submit").attr("disabled",true).text("Please Wait");G.save({signature:D.signature,accountCode:D.accountCode,success:function(K){if(D.successHandler){D.successHandler(h.getToken(K))}if(D.successURL){var L=D.successURL;h.postResult(L,K,D)}},error:function(K){if(!D.onError||!D.onError(K)){p(C,K)}},complete:function(){C.removeClass("submitting");C.find("button.submit").removeAttr("disabled").text(J)}})})});if(D.beforeInject){D.beforeInject(C.get(0))}f(function(){var I=f(D.target);I.html(C);if(D.afterInject){D.afterInject(C.get(0))}})};h.buildSubscriptionForm=function(D){var F={enableAddOns:true,enableCoupons:true,addressRequirement:"full",collectContactInfo:true,distinguishContactFromBillingInfo:false};D.successHandler=D.successHandler||D.afterSubscribe;D=f.extend(v(h.settings),F,D);if(!D.signature){h.raiseError("signature missing")}var C=f(h.dom.subscribe_form);if(D.collectContactInfo){C.find(".contact_info").html(h.dom.contact_info_fields)}else{C.find(".contact_info").remove()}C.find(".billing_info").html(h.dom.billing_info_fields);if(D.planCode){h.Plan.get(D.planCode,D.currency,E)}else{if(D.plan){E(D.plan)}}l(C,D);g(C,D);e(C,D);A(C,D);function E(G){if(D.filterPlan){G=D.filterPlan(G)||G}var V=G.createSubscription(),H=h.Account.create(),O=h.BillingInfo.create();V.account=H;V.billingInfo=O;O.account=H;O.subscription=V;if(D.filterSubscription){V=D.filterSubscription(V)||V}if(!G.displayQuantity){C.find(".plan .quantity").remove()}if(G.setupFee){C.find(".subscription").addClass("with_setup_fee");C.find(".plan .setup_fee .cost").text(""+G.setupFee)}else{C.find(".plan .setup_fee").remove()}if(G.trial){C.find(".subscription").addClass("with_trial");C.find(".plan .free_trial").text("First "+G.trial+" free")}else{C.find(".plan .free_trial").remove()}function M(){var Y=V.calculateTotals();C.find(".plan .recurring_cost .cost").text(""+Y.plan);C.find(".due_now .cost").text(""+Y.stages.now);C.find(".coupon .discount").text(""+(Y.coupon||""));C.find(".vat .cost").text(""+(Y.vat||""));C.find(".add_ons .add_on").each(function(){var Z=f(this).data("add_on");if(f(this).hasClass("selected")){var aa=Y.addOns[Z.code];f(this).find(".cost").text("+ "+aa)}else{f(this).find(".cost").text("+ "+Z.cost)}})}C.find(".plan .quantity input").bind("change keyup",function(){V.plan.quantity=parseInt(f(this).val(),10)||1;M()});C.find(".plan .name").text(G.name);C.find(".plan .recurring_cost .cost").text(""+G.cost);C.find(".plan .recurring_cost .interval").text("every "+G.interval);var K=C.find(".add_ons");if(D.enableAddOns){var S=G.addOns.length;if(S){K.removeClass("none").addClass("any");for(var T=0;T'+P.name+'Qty');if(!P.displayQuantity){J.find(".quantity").remove()}J.data("add_on",P);J.appendTo(K)}K.delegate(".quantity input","change keyup",function(ab){var Y=f(this).closest(".add_on");var aa=Y.data("add_on");var Z=parseInt(f(this).val(),10)||1;V.findAddOnByCode(aa.code).quantity=Z;M()});K.bind("selectstart",function(Y){if(f(Y.target).is(".add_on")){Y.preventDefault()}});K.delegate(".add_on","click",function(ac){if(f(ac.target).closest(".quantity").length){return}var aa=!f(this).hasClass("selected");f(this).toggleClass("selected",aa);var ab=f(this).data("add_on");if(aa){var Y=V.redeemAddOn(ab);var Z=f(this).find(".quantity input");Y.quantity=parseInt(Z.val(),10)||1;Z.focus()}else{V.removeAddOn(ab.code)}M()})}}else{K.remove()}var N=C.find(".coupon");var R=null;function W(){var Y=N.find("input").val();if(Y==R){return}R=Y;if(!Y){N.removeClass("invalid").removeClass("valid");N.find(".description").text("");V.coupon=undefined;M();return}N.addClass("checking");V.getCoupon(Y,function(Z){N.removeClass("checking");V.coupon=Z;N.removeClass("invalid").addClass("valid");N.find(".description").text(Z.description);M()},function(){V.coupon=undefined;N.removeClass("checking");N.removeClass("valid").addClass("invalid");N.find(".description").text(h.locale.errors.invalidCoupon);M()})}if(D.enableCoupons){N.find("input").bind("keyup change",function(Y){});N.find("input").keypress(function(Y){if(Y.charCode==13){Y.preventDefault();W()}});N.find(".check").click(function(){W()});N.find("input").blur(function(){N.find(".check").click()})}else{N.remove()}var I=C.find(".vat");var X=C.find(".vat_number");var Q=X.find("input");I.find(".title").text("VAT at "+h.settings.VATPercent+"%");function L(){var Z=C.find(".country select").val();var ab=h.isVATNumberApplicable(Z);X.toggleClass("applicable",ab);X.toggleClass("inapplicable",!ab);var aa=Q.val();var Y=h.isVATChargeApplicable(Z,aa);I.toggleClass("applicable",Y);I.toggleClass("inapplicable",!Y)}C.find(".country select").change(function(){O.country=f(this).val();M();L()}).change();Q.bind("keyup change",function(){O.vatNumber=f(this).val();M();L()});C.submit(function(Y){Y.preventDefault();a(C);C.find(".error").remove();C.find(".invalid").removeClass("invalid");B(function(Z){q(C,V.plan,D,Z);i(C,H,D,Z);d(C,O,D,Z);y(C,Z)},function(){C.addClass("submitting");var Z=C.find("button.submit").text();C.find("button.submit").attr("disabled",true).text("Please Wait");V.save({signature:D.signature,success:function(aa){if(D.successHandler){D.successHandler(h.getToken(aa))}if(D.successURL){var ab=D.successURL;h.postResult(ab,aa,D)}},error:function(aa){if(!D.onError||!D.onError(aa)){p(C,aa)}},complete:function(){C.removeClass("submitting");C.find("button.submit").removeAttr("disabled").text(Z)}})})});W();M();if(D.beforeInject){D.beforeInject(C.get(0))}f(function(){var Y=f(D.target);Y.html(C);if(D.afterInject){D.afterInject(C.get(0))}})}};h.paypal={start:function(G){var J=window.name;if(J.indexOf("recurly_result")>-1){window.name="";J=""}var H=f.extend(G.data,{post_message:true,referer:window.location.href}),E=G.url+"?"+f.param(H),C=window.open(E,"recurly_paypal","menubar=1,resizable=1");window.popup=C;f(window).on("message",I);var D=setInterval(function(){var L=decodeURIComponent(window.name),M=L.match(/recurly_result=(.*)[&$]?/),K=M&&f.parseJSON(M[1]);if(K){F(K);window.name=J}},1000);function F(K){try{C.close()}finally{G.success(K);G.complete();f(window).unbind("message",I);clearInterval(D)}}function I(M){var L=document.createElement("a");L.href=h.settings.baseURL;var K=L.protocol+"//"+L.host.replace(/:\d+$/,"");if(M.originalEvent.origin==K){F(M.originalEvent.data)}}}};h.states={};h.states.US={"-":"Select State","--":"------------",AK:"Alaska",AL:"Alabama",AP:"Armed Forces Pacific",AR:"Arkansas",AS:"American Samoa",AZ:"Arizona",CA:"California",CO:"Colorado",CT:"Connecticut",DC:"District of Columbia",DE:"Delaware",FL:"Florida",FM:"Federated States of Micronesia",GA:"Georgia",GU:"Guam",HI:"Hawaii",IA:"Iowa",ID:"Idaho",IL:"Illinois",IN:"Indiana",KS:"Kansas",KY:"Kentucky",LA:"Louisiana",MA:"Massachusetts",MD:"Maryland",ME:"Maine",MH:"Marshall Islands",MI:"Michigan",MN:"Minnesota",MO:"Missouri",MP:"Northern Mariana Islands",MS:"Mississippi",MT:"Montana",NC:"North Carolina",ND:"North Dakota",NE:"Nebraska",NH:"New Hampshire",NJ:"New Jersey",NM:"New Mexico",NV:"Nevada",NY:"New York",OH:"Ohio",OK:"Oklahoma",OR:"Oregon",PA:"Pennsylvania",PR:"Puerto Rico",PW:"Palau",RI:"Rhode Island",SC:"South Carolina",SD:"South Dakota",TN:"Tennessee",TX:"Texas",UT:"Utah",VA:"Virginia",VI:"Virgin Islands",VT:"Vermont",WA:"Washington",WV:"West Virginia",WI:"Wisconsin",WY:"Wyoming"};h.states.CA={"-":"Select State","--":"------------",AB:"Alberta",BC:"British Columbia",MB:"Manitoba",NB:"New Brunswick",NL:"Newfoundland",NS:"Nova Scotia",NU:"Nunavut",ON:"Ontario",PE:"Prince Edward Island",QC:"Quebec",SK:"Saskatchewan",NT:"Northwest Territories",YT:"Yukon Territory",AA:"Armed Forces Americas",AE:"Armed Forces Europe, Middle East, & Canada"};h.dom.contact_info_fields='Contact InfoFirst Name Last Name Email Phone NumberCompany/Organization Name';h.dom.billing_info_fields='Billing InfoFirst NameLast NameCredit Card NumberCVV Expires01 - January02 - February03 - March04 - April05 - May06 - June07 - July08 - August09 - September10 - October11 - November12 - DecemberAddressApt/SuiteCityState/ProvinceZip/PostalSelect Country--------------AfghanistanAlbaniaAlgeriaAmerican SamoaAndorraAngolaAnguillaAntarcticaAntigua and BarbudaArgentinaArmeniaArubaAscension IslandAustraliaAustriaAzerbaijanBahamasBahrainBangladeshBarbadosBelgiumBelizeBeninBermudaBhutanBoliviaBosnia and HerzegovinaBotswanaBouvet IslandBrazilBritish Antarctic TerritoryBritish Indian Ocean TerritoryBritish Virgin IslandsBruneiBulgariaBurkina FasoBurundiCambodiaCameroonCanadaCanary IslandsCanton and Enderbury IslandsCape VerdeCayman IslandsCentral African RepublicCeuta and MelillaChadChileChinaChristmas IslandClipperton IslandCocos [Keeling] IslandsColombiaComorosCongo [DRC]Cook IslandsCosta RicaCroatiaCubaCyprusCzech RepublicDenmarkDiego GarciaDjiboutiDominicaDominican RepublicDronning Maud LandEast TimorEcuadorEgyptEl SalvadorEstoniaEthiopiaFalkland Islands [Islas Malvinas]Faroe IslandsFijiFinlandFranceFrench GuianaFrench PolynesiaFrench Southern TerritoriesFrench Southern and Antarctic TerritoriesGabonGambiaGeorgiaGermanyGhanaGibraltarGreeceGreenlandGrenadaGuadeloupeGuamGuatemalaGuernseyGuinea-BissauGuyanaHaitiHeard Island and McDonald IslandsHondurasHong KongHungaryIcelandIndiaIndonesiaIrelandIsle of ManIsraelItalyJamaicaJapanJerseyJohnston IslandJordanKazakhstanKenyaKiribatiKuwaitKyrgyzstanLaosLatviaLesothoLibyaLiechtensteinLithuaniaLuxembourgMacauMacedonia [FYROM]MadagascarMalawiMalaysiaMaldivesMaliMaltaMarshall IslandsMartiniqueMauritaniaMauritiusMayotteMetropolitan FranceMexicoMicronesiaMidway IslandsMoldovaMonacoMongoliaMontenegroMontserratMoroccoMozambiqueNamibiaNauruNepalNetherlandsNetherlands AntillesNeutral ZoneNew CaledoniaNew ZealandNicaraguaNigerNigeriaNiueNorfolk IslandNorth VietnamNorthern Mariana IslandsNorwayOmanOutlying OceaniaPacific Islands Trust TerritoryPakistanPalauPalestinian TerritoriesPanamaPanama Canal ZoneParaguayPeople\'s Democratic Republic of YemenPeruPhilippinesPitcairn IslandsPolandPortugalPuerto RicoQatarRomaniaRussiaRwandaR\u00e9unionSaint Barth\u00e9lemySaint HelenaSaint Kitts and NevisSaint LuciaSaint MartinSaint Pierre and MiquelonSaint Vincent and the GrenadinesSamoaSan MarinoSaudi ArabiaSenegalSerbiaSerbia and MontenegroSeychellesSierra LeoneSingaporeSlovakiaSloveniaSolomon IslandsSouth AfricaSouth Georgia and the South Sandwich IslandsSouth KoreaSpainSri LankaSurinameSvalbard and Jan MayenSwazilandSwedenSwitzerlandS\u00e3o Tom\u00e9 and Pr\u00edncipeTaiwanTajikistanTanzaniaThailandTogoTokelauTongaTrinidad and TobagoTristan da CunhaTunisiaTurkeyTurkmenistanTurks and Caicos IslandsTuvaluU.S. Minor Outlying IslandsU.S. Miscellaneous Pacific IslandsU.S. Virgin IslandsUgandaUkraineUnited Arab EmiratesUnited KingdomUnited StatesUruguayUzbekistanVanuatuVatican CityVenezuelaVietnamWake IslandWallis and FutunaWestern SaharaYemenZambia\u00c5land IslandsVAT NumberYou will be taken to PayPal to authorize a billing agreement.Please make sure pop-ups aren\'t blocked.';h.dom.subscribe_form='QtySetup FeeCoupon CodeVATOrder Total';h.dom.update_billing_info_form='';h.dom.one_time_transaction_form='';h.dom.terms_of_service='I accept the Terms of Service and Privacy Policy';window.Recurly=h})(jQuery); \ No newline at end of file +(function(f){function v(D){function C(){}C.prototype=D||this;return new C()}var h={};h.settings={enableGeoIP:true,acceptedCards:["visa","mastercard","discover","american_express"],oneErrorPerField:true};h.version="2.2.4";h.dom={};h.Error={toString:function(){return"RecurlyJS Error: "+this.message}};h.raiseError=function(C){var D=v(h.Error);D.message=C;throw D};h.config=function(C){f.extend(true,h.settings,C);if(!C.baseURL){var D=h.settings.subdomain||h.raiseError("company subdomain not configured");h.settings.baseURL="https://"+D+".recurly.com/jsonp/"+D+"/"}};function u(D,C){if(D==1){return C.substr(0,C.length-1)}return""+D+" "+C}(h.Cost=function(C){this._cents=C||0}).prototype={toString:function(){return h.formatCurrency(this.dollars())},cents:function(C){if(C===undefined){return this._cents}return new h.Cost(C)},dollars:function(C){if(C===undefined){return this._cents/100}return new h.Cost(C*100)},mult:function(C){return new h.Cost(this._cents*C)},add:function(C){if(C.cents){C=C.cents()}return new h.Cost(this._cents+C)},sub:function(C){if(C.cents){C=C.cents()}return new h.Cost(this._cents-C)}};h.Cost.FREE=new h.Cost(0);(h.TimePeriod=function(D,C){this.length=D;this.unit=C}).prototype={toString:function(){return""+u(this.length,this.unit)},toDate:function(){var C=new Date();switch(this.unit){case"month":C.setMonth(C.getMonth()+this.length);break;case"day":C.setDay(C.getDay()+this.length);break}return C},clone:function(){return new h.TimePeriod(this.length,this.unit)}};(h.RecurringCost=function(D,C){this.cost=D;this.interval=C}).prototype={toString:function(){return""+this.cost+" every "+this.interval},clone:function(){return new h.TimePeriod(this.length,this.unit)}};h.RecurringCost.FREE=new h.RecurringCost(0,null);(h.RecurringCostStage=function(C,D){this.recurringCost=C;this.duration=D}).prototype={toString:function(){this.recurringCost.toString()+" for "+this.duration.toString()}};h.locale={};h.locale.errors={emptyField:"Required field",missingFullAddress:"Please enter your full address.",invalidEmail:"Invalid",invalidCC:"Invalid",invalidCVV:"Invalid",invalidCoupon:"Invalid",cardDeclined:"Transaction declined",acceptTOS:"Please accept the Terms of Service.",invalidQuantity:"Invalid quantity"};h.locale.currencies={};h.locale.currency={format:"%u%n",separator:".",delimiter:",",precision:2};function s(C,D){var F=h.locale.currencies[C]=v(h.locale.currency);for(var E in D){F[E]=D[E]}}s("USD",{symbol:"$"});s("AUD",{symbol:"$"});s("CAD",{symbol:"$"});s("EUR",{symbol:"\u20ac"});s("GBP",{symbol:"\u00a3"});s("CZK",{symbol:"\u004b"});s("DKK",{symbol:"\u006b\u0072"});s("HUF",{symbol:"Ft"});s("JPY",{symbol:"\u00a5"});s("NOK",{symbol:"kr"});s("NZD",{symbol:"$"});s("PLN",{symbol:"\u007a"});s("SGD",{symbol:"$"});s("SEK",{symbol:"kr"});s("CHF",{symbol:"Fr"});s("ZAR",{symbol:"R"});h.settings.locale=h.locale;h.knownCards={visa:{prefixes:[4],name:"Visa"},mastercard:{prefixes:[51,52,53,54,55],name:"MasterCard"},american_express:{prefixes:[34,37],name:"American Express"},discover:{prefixes:[6011,62,64,65],name:"Discover"},diners_club:{prefixes:[305,36,38],name:"Diners Club"},carte_blanche:{prefixes:[300,301,302,303,304,305]},jcb:{prefixes:[35],name:"JCB"},enroute:{prefixes:[2014,2149],name:"EnRoute"},maestro:{prefixes:[5018,5020,5038,6304,6759,6761],name:"Maestro"},laser:{prefixes:[6304,6706,6771,6709],name:"Laser"}};h.detectCardType=function(E){E=E.replace(/\D/g,"");var H=h.knownCards;for(var C in H){if(H.hasOwnProperty(C)){var I=H[C];for(var G=0,D=I.prefixes.length;G").hide();F.attr("action",D).attr("method","POST").attr("enctype","application/x-www-form-urlencoded");f('').attr({name:"recurly_token",value:E}).appendTo(F);f("body").append(F);F.submit()};function k(F){var E=f("");for(var D in F){if(F.hasOwnProperty(D)){var C=F[D];E.append(""+C+"")}}return E}h.enforce=function(C){return{enforced:C,hidden:false,hide:function(){this.hidden=true;return this}}};function r(D){D=D||this;if(typeof D=="string"){return D.replace(/([a-z])([A-Z])/g,function(F,E,G){return E+"_"+G}).toLowerCase()}else{for(var C in D){if(D.hasOwnProperty(C)){}}}}function n(F){var E={};for(var D in F){var C=F[D];if(f.isPlainObject(C)){E[D]=n(C)}else{if(typeof C!=="undefined"){E[D]=C}}}return E}h.ajax=function(C){C.data=f.extend({js_version:h.version},C.data);C.data=n(C.data);if(C.data.billing_info&&C.data.billing_info.payment_method=="paypal"){return h.paypal.start(C)}return f.ajax(C)};function w(C){f("body").append(h.dom.error_dialog)}(h.isValidCC=function(I){var D=I.val();D=D.replace(/\D/g,"");if(D==""){return false}var G=0,F=0,C=false;for(var H=D.length-1;H>=0;H--){var E=D.charAt(H);var F=parseInt(E,10);if(C){if((F*=2)>9){F-=9}}G+=F;C=!C}return(G%10)==0}).defaultErrorKey="invalidCC";(h.isValidEmail=function(D){var C=D.val();return/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(C)}).defaultErrorKey="invalidEmail";function b(C){return/^[0-9]+$/.test(C)}(h.isValidCVV=function(D){var C=D.val();return(C.length==3||C.length==4)&&b(C)}).defaultErrorKey="invalidCVV";(h.isNotEmpty=function(D){var C=D.val();if(D.is("select")){if(C=="-"||C=="--"){return false}}return !!C}).defaultErrorKey="emptyField";(h.isNotEmptyState=function(D){var C=D.val();if(D.is("select")){if(C=="-"||C=="--"){return false}}return true}).defaultErrorKey="emptyField";(h.isChecked=function(C){return C.is(":checked")}).defaultErrorKey="acceptTOS";(h.isValidQuantity=function(C){return/^[0-9]*$/.test(C.val())}).defaultErrorKey="invalidQuantity";h.Plan={create:v,fromJSON:function(F){var G=this.create();G.name=F.name;G.code=F.plan_code;G.currency=F.currency;G.cost=new h.Cost(F.unit_amount_in_cents);G.displayQuantity=F.display_quantity;G.interval=new h.TimePeriod(F.plan_interval_length,F.plan_interval_unit);if(F.trial_interval_length){G.trial=new h.TimePeriod(F.trial_interval_length,F.trial_interval_unit)}if(F.setup_fee_in_cents){G.setupFee=new h.Cost(F.setup_fee_in_cents)}if(F.vat_percentage){h.settings.VATPercent=parseFloat(F.vat_percentage)}if(F.merchant_country){h.settings.country=F.merchant_country}G.addOns=[];if(F.add_ons){for(var D=F.add_ons.length,E=0;E');C.text(F);C.appendTo(H.parent());H.addClass("invalid");H.bind("change keyup",function E(I){if(D(H)){H.removeClass("invalid");C.remove();H.unbind(I)}})}function B(E,G){var D=false;var C={field:function(H,J,I){I=Array.prototype.slice.call(arguments,2);return z(H,J,I,function K(L){if(!D){L.element.focus()}x(L);D=true;if(h.settings.oneErrorPerForm){throw {stopPulling:true}}})}};try{E(C)}catch(F){if(!F.stopPulling){throw F}}if(!D){G()}}function z(K,F,D,H){var I=K.find(F+" input");if(I.length==0){I=K.find(F+" select")}if(I.length==0){return undefined}var C=I.val();for(var G=0,E=D.length;G');E.text(H[G]);F.append(E)}}}var j={account:{firstName:".contact_info > .full_name > .first_name > input",lastName:".contact_info > .full_name > .last_name > input",email:".contact_info > .email > input",phone:".contact_info > .phone > input",companyName:".contact_info > .company_name > input"},billingInfo:{firstName:".billing_info > .first_name > input",lastName:".billing_info > .last_name > input",address1:".billing_info > .address > .address1 > input",address2:".billing_info > .address > .address2 > input",country:".billing_info > .address > .country > select",city:".billing_info > .address > .city > input",state:".billing_info > .address > .state_zip > .state > input",zip:".billing_info > .address > .state_zip > .zip > input",vatNumber:".billing_info > .vat_number > input",cardNumber:".billing_info .card_number > input",CVV:".billing_info .cvv > input"},subscription:{couponCode:".subscription > .coupon > .coupon_code > input",quantity:".subscription > .plan > .quantity > input"}};function o(C,D,F){(function E(H,G,K){if(!H){return}for(var J in H){if(H.hasOwnProperty(J)&&G.hasOwnProperty(J)){var N=H[J];var I=G[J];var O=r(J);var L=K?(K+"."+O):O;if(typeof I=="string"){var M=C.find(I);M.val(N).change()}else{if(typeof I=="object"){E(N,I,L)}}}}})(D,F)}function l(C,D){if(!D.collectPhone){C.find(".phone").remove()}if(!D.collectCompany){C.find(".company_name").remove()}C.delegate(".placeholder","click",function(){var E=f(this);var F=f(this).parent();F.find("input").focus()});C.delegate("input","change keyup",function(){var F=f(this);var E=f(this).parent();if(F.val().length>0){E.find(".placeholder").css({display:"none"})}else{E.find(".placeholder").css({display:"block"})}});C.delegate("input","focus",function(){f(this).parent().addClass("focus")});C.delegate("input","blur",function(){f(this).parent().removeClass("focus")});C.delegate("input","keydown",function(E){if(E.keyCode>=48&&E.keyCode<=90){f(this).parent().find(".placeholder").hide()}});o(C,D,j)}function g(E,F){if(F.distinguishContactFromBillingInfo){var D=E.find(".contact_info .first_name input");var G=E.find(".contact_info .last_name input");var H=D.val();var C=G.val();E.find(".contact_info .first_name input").change(function(){var I=E.find(".billing_info .first_name input");if(I.val()==H){I.val(f(this).val()).change()}H=D.val()});E.find(".contact_info .last_name input").change(function(){var I=E.find(".billing_info .last_name input");if(I.val()==C){I.val(f(this).val()).change()}C=G.val()})}else{E.find(".billing_info .first_name, .billing_info .last_name").remove()}}function e(M,I){var E=M.find(".country select");var ab=M.find(".state");var af=ab.find("input");var W=ab.children();var R={};var P=h.states;var O=E.val();if(I.acceptedCards&&I.acceptPaypal){var N=M.find(".payment_method");var G=N.find("input");var V=M.find("button.submit");var D=V.text();N.on("click",".payment_option",function(){var ah=f(this);N.find(".selected").removeClass("selected");ah.addClass("selected");N.find("input[type=radio]:checked").prop("checked",false);ah.find("input[type=radio]").prop("checked",true);if(ah.is(".card_option")){M.find(".credit_card").css({display:"block"});M.find(".paypal").css({display:"none"});G.val("");V.text(D)}else{if(ah.is(".paypal_option")){M.find(".credit_card").css({display:"none"});M.find(".paypal").css({display:"block"});G.val("paypal");V.text(D+" with PayPal")}}});M.find(".payment_option").first().click()}else{M.find(".payment_method").removeClass("multiple");if(I.acceptedCards){M.find(".paypal_option").remove();M.find(".paypal").remove()}else{if(I.acceptPaypal){M.find(".payment_method input").val("paypal");M.find(".card_option").remove();M.find(".credit_card").remove()}}}function T(al,aj){var ak=P[al];aj=f.trim(aj.toUpperCase());if(ak.hasOwnProperty(aj)){return aj}for(var ai in ak){if(ak.hasOwnProperty(ai)){var ah=ak[ai];if(aj==ah.toUpperCase()){return ai}}}return false}function ag(ak,ah){var aj=ab.hasClass("select_mode");if(ak=="US"||ak=="CA"){if(!aj||O!=ak){var ai=ab.find("input").val();if(ai!=undefined&&ai!=""){ah=T(ak,ai);if(!ah){return false}}ab.addClass("select_mode");ab.children().detach();R[ak]=R[ak]||k(P[ak]);ab.append(R[ak]);if(ah){ab.find("select").val(ah)}}}else{if(aj){ab.empty().append(W).removeClass("select_mode")}}}af.bind("change keyup",function(){ag(O)});E.change(function(){var ah=f(this).val();ag(ah);O=ah});function K(aj,ah){var ai=aj.val();if(!ah||ah==""){return false}if(ai&&ai!=""&&ai!="-"){return false}return aj.val(ah).change()}if(I.enableGeoIP){f.ajax({url:h.settings.baseURL+"location",dataType:"jsonp",jsonp:"callback",success:function(ah){if(ah.country){K(E,ah.country);ag(ah.country,ah.state)}}})}else{if(h.settings.country){var Y=M.find(".country option[value="+h.settings.country+"]");if(Y.length){Y.attr("selected",true).change()}}}var H=new Date();var Q=H.getFullYear();var ac=H.getMonth();var aa=M.find(".year select");var C=M.find(".month select");for(var X=Q;X<=Q+10;++X){var J=f(''+X+"");J.appendTo(aa)}aa.val(Q+1);function Z(){if(aa.val()==Q){var ah=false;if(C.val()>ac){ah=true}C.find("option").each(function(){if(f(this).val()<=ac){f(this).attr("disabled",true)}else{f(this).removeAttr("disabled");if(!ah){f(this).attr("selected",true);ah=true}}})}else{C.find("option").removeAttr("disabled")}}Z();aa.change(Z);if(I.addressRequirement=="none"){M.find(".address").remove()}else{if(I.addressRequirement=="zip"){M.find(".address").addClass("only_zip");M.find(".address1, .address2, .city, .state").remove();if(!h.settings.VATPercent){M.find(".country").remove()}}else{if(I.addressRequirement=="zipstreet"){M.find(".address").addClass("only_zipstreet");M.find(".city, .state").remove();if(!h.settings.VATPercent){M.find(".country").remove()}}else{if(I.addressRequirement=="full"){M.find(".address").addClass("full")}else{if(I.addressRequirement=="only_country"){M.find(".address").addClass("only_country")}}}}}var S=M.find(".accepted_cards");if(I.acceptedCards){var ad=I.acceptedCards,U=ad.length;for(var X=0;X');var F=h.knownCards[ae];if(F&&F.name){L.text(F.name)}S.append(L)}}M.find(".card_number input").bind("change keyup",function(){var ah=h.detectCardType(f(this).val());if(ah){S.find(".card").each(function(){f(this).toggleClass("match",f(this).hasClass(ah));f(this).toggleClass("no_match",!f(this).hasClass(ah))})}else{S.find(".card").removeClass("match no_match")}})}function i(C,F,D,E){F.firstName=E.field(C,".contact_info .first_name",c(h.isNotEmpty));F.lastName=E.field(C,".contact_info .last_name",c(h.isNotEmpty));F.companyName=E.field(C,".contact_info .company_name");F.email=E.field(C,".email",c(h.isNotEmpty),c(h.isValidEmail));F.code=D.accountCode||(D.account&&(D.account.code||D.account.accountCode))}function d(C,F,D,E){F.paymentMethod=E.field(C,".payment_method");if(F.paymentMethod!=="paypal"){F.firstName=E.field(C,".billing_info .first_name",c(h.isNotEmpty));F.lastName=E.field(C,".billing_info .last_name",c(h.isNotEmpty));F.number=E.field(C,".card_number",c(h.isNotEmpty),c(h.isValidCC));F.cvv=E.field(C,".cvv",c(h.isNotEmpty),c(h.isValidCVV));F.month=E.field(C,".month");F.year=E.field(C,".year")}F.phone=E.field(C,".phone");F.address1=E.field(C,".address1",c(h.isNotEmpty));F.address2=E.field(C,".address2");F.city=E.field(C,".city",c(h.isNotEmpty));F.state=E.field(C,".state",c(h.isNotEmptyState));F.zip=E.field(C,".zip",c(h.isNotEmpty));F.country=E.field(C,".country",c(h.isNotEmpty))}function q(C,F,D,E){var G=E.field(C,".plan .quantity",c(h.isValidQuantity));F.quantity=G||1}function y(C,D){D.field(C,".accept_tos",c(h.isChecked))}h.buildBillingInfoForm=h.buildBillingInfoUpdateForm=function(D){var F={addressRequirement:"full",collectContactInfo:false,distinguishContactFromBillingInfo:true};D.successHandler=D.successHandler||D.afterUpdate;D=f.extend(v(h.settings),F,D);if(!D.accountCode){h.raiseError("accountCode missing")}if(!D.signature){h.raiseError("signature missing")}var G=h.BillingInfo.create(),E=h.Account.create();G.account=E;var C=f(h.dom.update_billing_info_form);if(D.collectContactInfo){C.find(".contact_info").html(h.dom.contact_info_fields)}else{C.find(".contact_info").remove()}C.find(".billing_info").html(h.dom.billing_info_fields);l(C,D);g(C,D);e(C,D);C.submit(function(H){H.preventDefault();a(C);C.find(".error").remove();C.find(".invalid").removeClass("invalid");B(function(I){d(C,G,D,I);i(C,E,D,I)},function(){C.addClass("submitting");var I=C.find("button.submit").text();C.find("button.submit").attr("disabled",true).text("Please Wait");G.save({signature:D.signature,distinguishContactFromBillingInfo:D.distinguishContactFromBillingInfo,accountCode:D.accountCode,success:function(J){if(D.successHandler){D.successHandler(h.getToken(J))}if(D.successURL){var K=D.successURL;h.postResult(K,J,D)}},error:function(J){if(!D.onError||!D.onError(J)){p(C,J)}},complete:function(){C.removeClass("submitting");C.find("button.submit").removeAttr("disabled").text(I)}})})});if(D.beforeInject){D.beforeInject(C.get(0))}f(function(){var H=f(D.target);H.html(C);if(D.afterInject){D.afterInject(C.get(0))}})};function A(C,D){if(D.termsOfServiceURL||D.privacyPolicyURL){var E=C.find(".accept_tos").html(h.dom.terms_of_service);if(!(D.termsOfServiceURL&&D.privacyPolicyURL)){E.find("span.and").remove()}if(D.termsOfServiceURL){E.find("a.tos_link").attr("href",D.termsOfServiceURL)}else{E.find("a.tos_link").remove()}if(D.privacyPolicyURL){E.find("a.pp_link").attr("href",D.privacyPolicyURL)}else{E.find("a.pp_link").remove()}}else{C.find(".accept_tos").remove()}}h.buildTransactionForm=function(D){var F={addressRequirement:"full",distinguishContactFromBillingInfo:true,collectContactInfo:true};D.successHandler=D.successHandler||D.afterPay;D=f.extend(v(h.settings),F,D);if(!D.collectContactInfo&&!D.accountCode){h.raiseError("collectContactInfo is false, but no accountCode provided")}if(!D.signature){h.raiseError("signature missing")}var H=h.BillingInfo.create(),E=h.Account.create(),G=h.Transaction.create();G.account=E;G.billingInfo=H;G.currency=D.currency;G.cost=new h.Cost(D.amountInCents);var C=f(h.dom.one_time_transaction_form);if(D.collectContactInfo){C.find(".contact_info").html(h.dom.contact_info_fields)}else{C.find(".contact_info").remove()}C.find(".billing_info").html(h.dom.billing_info_fields);l(C,D);e(C,D);g(C,D);A(C,D);C.submit(function(I){I.preventDefault();a(C);C.find(".error").remove();C.find(".invalid").removeClass("invalid");B(function(J){i(C,E,D,J);d(C,H,D,J);y(C,J)},function(){C.addClass("submitting");var J=C.find("button.submit").text();C.find("button.submit").attr("disabled",true).text("Please Wait");G.save({signature:D.signature,accountCode:D.accountCode,success:function(K){if(D.successHandler){D.successHandler(h.getToken(K))}if(D.successURL){var L=D.successURL;h.postResult(L,K,D)}},error:function(K){if(!D.onError||!D.onError(K)){p(C,K)}},complete:function(){C.removeClass("submitting");C.find("button.submit").removeAttr("disabled").text(J)}})})});if(D.beforeInject){D.beforeInject(C.get(0))}f(function(){var I=f(D.target);I.html(C);if(D.afterInject){D.afterInject(C.get(0))}})};h.buildSubscriptionForm=function(D){var F={enableAddOns:true,enableCoupons:true,addressRequirement:"full",collectContactInfo:true,distinguishContactFromBillingInfo:false};D.successHandler=D.successHandler||D.afterSubscribe;D=f.extend(v(h.settings),F,D);if(!D.signature){h.raiseError("signature missing")}var C=f(h.dom.subscribe_form);if(D.collectContactInfo){C.find(".contact_info").html(h.dom.contact_info_fields)}else{C.find(".contact_info").remove()}C.find(".billing_info").html(h.dom.billing_info_fields);if(D.planCode){h.Plan.get(D.planCode,D.currency,E)}else{if(D.plan){E(D.plan)}}l(C,D);g(C,D);e(C,D);A(C,D);function E(G){if(D.filterPlan){G=D.filterPlan(G)||G}var V=G.createSubscription(),H=h.Account.create(),O=h.BillingInfo.create();V.account=H;V.billingInfo=O;O.account=H;O.subscription=V;if(D.filterSubscription){V=D.filterSubscription(V)||V}if(!G.displayQuantity){C.find(".plan .quantity").remove()}if(G.setupFee){C.find(".subscription").addClass("with_setup_fee");C.find(".plan .setup_fee .cost").text(""+G.setupFee)}else{C.find(".plan .setup_fee").remove()}if(G.trial){C.find(".subscription").addClass("with_trial");C.find(".plan .free_trial").text("First "+G.trial+" free")}else{C.find(".plan .free_trial").remove()}function M(){var Y=V.calculateTotals();C.find(".plan .recurring_cost .cost").text(""+Y.plan);C.find(".due_now .cost").text(""+Y.stages.now);C.find(".coupon .discount").text(""+(Y.coupon||""));C.find(".vat .cost").text(""+(Y.vat||""));C.find(".add_ons .add_on").each(function(){var Z=f(this).data("add_on");if(f(this).hasClass("selected")){var aa=Y.addOns[Z.code];f(this).find(".cost").text("+ "+aa)}else{f(this).find(".cost").text("+ "+Z.cost)}})}C.find(".plan .quantity input").bind("change keyup",function(){V.plan.quantity=parseInt(f(this).val(),10)||1;M()});C.find(".plan .name").text(G.name);C.find(".plan .recurring_cost .cost").text(""+G.cost);C.find(".plan .recurring_cost .interval").text("every "+G.interval);var K=C.find(".add_ons");if(D.enableAddOns){var S=G.addOns.length;if(S){K.removeClass("none").addClass("any");for(var T=0;T'+P.name+'Qty');if(!P.displayQuantity){J.find(".quantity").remove()}J.data("add_on",P);J.appendTo(K)}K.delegate(".quantity input","change keyup",function(ab){var Y=f(this).closest(".add_on");var aa=Y.data("add_on");var Z=parseInt(f(this).val(),10)||1;V.findAddOnByCode(aa.code).quantity=Z;M()});K.bind("selectstart",function(Y){if(f(Y.target).is(".add_on")){Y.preventDefault()}});K.delegate(".add_on","click",function(ac){if(f(ac.target).closest(".quantity").length){return}var aa=!f(this).hasClass("selected");f(this).toggleClass("selected",aa);var ab=f(this).data("add_on");if(aa){var Y=V.redeemAddOn(ab);var Z=f(this).find(".quantity input");Y.quantity=parseInt(Z.val(),10)||1;Z.focus()}else{V.removeAddOn(ab.code)}M()})}}else{K.remove()}var N=C.find(".coupon");var R=null;function W(){var Y=N.find("input").val();if(Y==R){return}R=Y;if(!Y){N.removeClass("invalid").removeClass("valid");N.find(".description").text("");V.coupon=undefined;M();return}N.addClass("checking");V.getCoupon(Y,function(Z){N.removeClass("checking");V.coupon=Z;N.removeClass("invalid").addClass("valid");N.find(".description").text(Z.description);M()},function(){V.coupon=undefined;N.removeClass("checking");N.removeClass("valid").addClass("invalid");N.find(".description").text(h.locale.errors.invalidCoupon);M()})}if(D.enableCoupons){N.find("input").bind("keyup change",function(Y){});N.find("input").keypress(function(Y){if(Y.charCode==13){Y.preventDefault();W()}});N.find(".check").click(function(){W()});N.find("input").blur(function(){N.find(".check").click()})}else{N.remove()}var I=C.find(".vat");var X=C.find(".vat_number");var Q=X.find("input");I.find(".title").text("VAT at "+h.settings.VATPercent+"%");function L(){var Z=C.find(".country select").val();var ab=h.isVATNumberApplicable(Z);X.toggleClass("applicable",ab);X.toggleClass("inapplicable",!ab);var aa=Q.val();var Y=h.isVATChargeApplicable(Z,aa);I.toggleClass("applicable",Y);I.toggleClass("inapplicable",!Y)}C.find(".country select").change(function(){O.country=f(this).val();M();L()}).change();Q.bind("keyup change",function(){O.vatNumber=f(this).val();M();L()});C.submit(function(Y){Y.preventDefault();a(C);C.find(".error").remove();C.find(".invalid").removeClass("invalid");B(function(Z){q(C,V.plan,D,Z);i(C,H,D,Z);d(C,O,D,Z);y(C,Z)},function(){C.addClass("submitting");var Z=C.find("button.submit").text();C.find("button.submit").attr("disabled",true).text("Please Wait");V.save({signature:D.signature,success:function(aa){if(D.successHandler){D.successHandler(h.getToken(aa))}if(D.successURL){var ab=D.successURL;h.postResult(ab,aa,D)}},error:function(aa){if(!D.onError||!D.onError(aa)){p(C,aa)}},complete:function(){C.removeClass("submitting");C.find("button.submit").removeAttr("disabled").text(Z)}})})});W();M();if(D.beforeInject){D.beforeInject(C.get(0))}f(function(){var Y=f(D.target);Y.html(C);if(D.afterInject){D.afterInject(C.get(0))}})}};h.paypal={start:function(G){var J=window.name;if(J.indexOf("recurly_result")>-1){window.name="";J=""}var H=f.extend(G.data,{post_message:true,referer:window.location.href}),E=G.url+"?"+f.param(H),C=window.open(E,"recurly_paypal","menubar=1,resizable=1");window.popup=C;f(window).on("message",I);var D=setInterval(function(){var L=decodeURIComponent(window.name),M=L.match(/recurly_result=(.*)[&$]?/),K=M&&f.parseJSON(M[1]);if(K){F(K);window.name=J}},1000);function F(K){try{C.close()}finally{G.success(K);G.complete();f(window).unbind("message",I);clearInterval(D)}}function I(M){var L=document.createElement("a");L.href=h.settings.baseURL;var K=L.protocol+"//"+L.host.replace(/:\d+$/,"");if(M.originalEvent.origin==K){F(M.originalEvent.data)}}}};h.states={};h.states.US={"-":"Select State","--":"------------",AK:"Alaska",AL:"Alabama",AP:"Armed Forces Pacific",AR:"Arkansas",AS:"American Samoa",AZ:"Arizona",CA:"California",CO:"Colorado",CT:"Connecticut",DC:"District of Columbia",DE:"Delaware",FL:"Florida",FM:"Federated States of Micronesia",GA:"Georgia",GU:"Guam",HI:"Hawaii",IA:"Iowa",ID:"Idaho",IL:"Illinois",IN:"Indiana",KS:"Kansas",KY:"Kentucky",LA:"Louisiana",MA:"Massachusetts",MD:"Maryland",ME:"Maine",MH:"Marshall Islands",MI:"Michigan",MN:"Minnesota",MO:"Missouri",MP:"Northern Mariana Islands",MS:"Mississippi",MT:"Montana",NC:"North Carolina",ND:"North Dakota",NE:"Nebraska",NH:"New Hampshire",NJ:"New Jersey",NM:"New Mexico",NV:"Nevada",NY:"New York",OH:"Ohio",OK:"Oklahoma",OR:"Oregon",PA:"Pennsylvania",PR:"Puerto Rico",PW:"Palau",RI:"Rhode Island",SC:"South Carolina",SD:"South Dakota",TN:"Tennessee",TX:"Texas",UT:"Utah",VA:"Virginia",VI:"Virgin Islands",VT:"Vermont",WA:"Washington",WV:"West Virginia",WI:"Wisconsin",WY:"Wyoming"};h.states.CA={"-":"Select State","--":"------------",AB:"Alberta",BC:"British Columbia",MB:"Manitoba",NB:"New Brunswick",NL:"Newfoundland",NS:"Nova Scotia",NU:"Nunavut",ON:"Ontario",PE:"Prince Edward Island",QC:"Quebec",SK:"Saskatchewan",NT:"Northwest Territories",YT:"Yukon Territory",AA:"Armed Forces Americas",AE:"Armed Forces Europe, Middle East, & Canada"};h.dom.contact_info_fields='Contact InfoFirst Name Last Name Email Phone NumberCompany/Organization Name';h.dom.billing_info_fields='Billing InfoFirst NameLast NameCredit Card NumberCVV Expires01 - January02 - February03 - March04 - April05 - May06 - June07 - July08 - August09 - September10 - October11 - November12 - DecemberAddressApt/SuiteCityState/ProvinceZip/PostalSelect Country--------------AfghanistanAlbaniaAlgeriaAmerican SamoaAndorraAngolaAnguillaAntarcticaAntigua and BarbudaArgentinaArmeniaArubaAscension IslandAustraliaAustriaAzerbaijanBahamasBahrainBangladeshBarbadosBelgiumBelizeBeninBermudaBhutanBoliviaBosnia and HerzegovinaBotswanaBouvet IslandBrazilBritish Antarctic TerritoryBritish Indian Ocean TerritoryBritish Virgin IslandsBruneiBulgariaBurkina FasoBurundiCambodiaCameroonCanadaCanary IslandsCanton and Enderbury IslandsCape VerdeCayman IslandsCentral African RepublicCeuta and MelillaChadChileChinaChristmas IslandClipperton IslandCocos [Keeling] IslandsColombiaComorosCongo [DRC]Cook IslandsCosta RicaCroatiaCubaCyprusCzech RepublicDenmarkDiego GarciaDjiboutiDominicaDominican RepublicDronning Maud LandEast TimorEcuadorEgyptEl SalvadorEstoniaEthiopiaFalkland Islands [Islas Malvinas]Faroe IslandsFijiFinlandFranceFrench GuianaFrench PolynesiaFrench Southern TerritoriesFrench Southern and Antarctic TerritoriesGabonGambiaGeorgiaGermanyGhanaGibraltarGreeceGreenlandGrenadaGuadeloupeGuamGuatemalaGuernseyGuinea-BissauGuyanaHaitiHeard Island and McDonald IslandsHondurasHong KongHungaryIcelandIndiaIndonesiaIrelandIsle of ManIsraelItalyJamaicaJapanJerseyJohnston IslandJordanKazakhstanKenyaKiribatiKuwaitKyrgyzstanLaosLatviaLesothoLibyaLiechtensteinLithuaniaLuxembourgMacauMacedonia [FYROM]MadagascarMalawiMalaysiaMaldivesMaliMaltaMarshall IslandsMartiniqueMauritaniaMauritiusMayotteMetropolitan FranceMexicoMicronesiaMidway IslandsMoldovaMonacoMongoliaMontenegroMontserratMoroccoMozambiqueNamibiaNauruNepalNetherlandsNetherlands AntillesNeutral ZoneNew CaledoniaNew ZealandNicaraguaNigerNigeriaNiueNorfolk IslandNorth VietnamNorthern Mariana IslandsNorwayOmanOutlying OceaniaPacific Islands Trust TerritoryPakistanPalauPalestinian TerritoriesPanamaPanama Canal ZoneParaguayPeople\'s Democratic Republic of YemenPeruPhilippinesPitcairn IslandsPolandPortugalPuerto RicoQatarRomaniaRussiaRwandaR\u00e9unionSaint Barth\u00e9lemySaint HelenaSaint Kitts and NevisSaint LuciaSaint MartinSaint Pierre and MiquelonSaint Vincent and the GrenadinesSamoaSan MarinoSaudi ArabiaSenegalSerbiaSerbia and MontenegroSeychellesSierra LeoneSingaporeSlovakiaSloveniaSolomon IslandsSouth AfricaSouth Georgia and the South Sandwich IslandsSouth KoreaSpainSri LankaSurinameSvalbard and Jan MayenSwazilandSwedenSwitzerlandS\u00e3o Tom\u00e9 and Pr\u00edncipeTaiwanTajikistanTanzaniaThailandTogoTokelauTongaTrinidad and TobagoTristan da CunhaTunisiaTurkeyTurkmenistanTurks and Caicos IslandsTuvaluU.S. Minor Outlying IslandsU.S. Miscellaneous Pacific IslandsU.S. Virgin IslandsUgandaUkraineUnited Arab EmiratesUnited KingdomUnited StatesUruguayUzbekistanVanuatuVatican CityVenezuelaVietnamWake IslandWallis and FutunaWestern SaharaYemenZambia\u00c5land IslandsVAT NumberYou will be taken to PayPal to authorize a billing agreement.Please make sure pop-ups aren\'t blocked.';h.dom.subscribe_form='QtySetup FeeCoupon CodeVATOrder Total';h.dom.update_billing_info_form='';h.dom.one_time_transaction_form='';h.dom.terms_of_service='I accept the Terms of Service and Privacy Policy';window.Recurly=h})(jQuery); \ No newline at end of file diff --git a/changelog.md b/changelog.md index ced2454c9..e4480960b 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,8 @@ #Recurly.js CHANGELOG +##Version 2.2.5 (Aug 23, 2013) +- Added default subscription: quantity option to buildSubscriptionForm + ##Version 2.2.4 (Aug 23, 2013) - Workaround a bug in jQuery 1.9 that throws style undefined exceptions. diff --git a/examples/subscribe.html b/examples/subscribe.html index 5db98e93a..d252a7e8e 100644 --- a/examples/subscribe.html +++ b/examples/subscribe.html @@ -20,7 +20,7 @@ // in client libraries. signature: 'needs-server-support-code', successURL: 'confirmation.html', - planCode: 'simpleplan', + planCode: 'complexplan', distinguishContactFromBillingInfo: true, collectCompany: true, collectContact: false, diff --git a/src/js/ui.js b/src/js/ui.js index 3cd490e11..6509d56e6 100644 --- a/src/js/ui.js +++ b/src/js/ui.js @@ -146,6 +146,7 @@ var preFillMap = { } , subscription: { couponCode: '.subscription > .coupon > .coupon_code > input' + , quantity: '.subscription > .plan > .quantity > input' } };