/*! Moip.js - build date: 2015-03-04 */ !function(a){function b(a){return a+="",a.replace(/[\s+|\.|\-]/g,"")}function c(){return this instanceof c?void 0:new c}var d=a.moip||{};a.moip=d,c.prototype={isValid:function(a){var d=c.prototype.cardType(a);if(a=b(a),d){if("HIPERCARD"===d.brand)return!0;for(var e=0,f=2-a.length%2;f<=a.length;f+=2)e+=parseInt(a.charAt(f-1),10);for(f=a.length%2+1;fg?g:g-9}return e%10===0?!0:!1}return!1},cardType:function(a,c){var d={VISA:{matches:function(a){return/^4\d{15}$/.test(a)}},MASTERCARD:{matches:function(a){return/^5[1-5]\d{14}$/.test(a)}},AMEX:{matches:function(a){return/^3[4,7]\d{13}$/.test(a)}},DINERS:{matches:function(a){return/^3[0,6,8]\d{12}$/.test(a)}},HIPERCARD:{matches:function(a){return/^(606282\d{10}(\d{3})?)|(3841\d{15})$/.test(a)}},ELO:{matches:function(a){var b=["50670","50671","50672","50673","50674","50675","50676","50900","50901","50902","50903","50904","50905","50906","50907","401178","401179","431274","438935","451416","457393","457631","457632","504175","506699","506770","506771","506772","506773","506774","506775","506776","506777","506778","509080","509081","509082","509083","627780","636297"];return null===a||16!=a.length?!1:b.indexOf(a.substring(0,6))>-1||b.indexOf(a.substring(0,5))>-1}}},e={VISA:{matches:function(a){return/^4\d{3}\d*$/.test(a)}},MASTERCARD:{matches:function(a){return/^5[1-5]\d{4}\d*$/.test(a)}},AMEX:{matches:function(a){return/^3[4,7]\d{2}\d*$/.test(a)}},DINERS:{matches:function(a){return/^3(?:0[0-5]|[68][0-9])+\d*$/.test(a)}},HIPERCARD:{matches:function(a){return/^(606282|3841\d{2})\d*$/.test(a)}},ELO:{matches:function(a){var b=["50670","50671","50672","50673","50674","50675","50676","50900","50901","50902","50903","50904","50905","50906","50907","401178","401179","431274","438935","451416","457393","457631","457632","504175","506699","506770","506771","506772","506773","506774","506775","506776","506777","506778","509080","509081","509082","509083","627780","636297"];return null===a||a.length<6?!1:b.indexOf(a.substring(0,6))>-1||b.indexOf(a.substring(0,5))>-1}}};return a=b(a),c&&(d=e),d.ELO.matches(a)?{brand:"ELO"}:d.VISA.matches(a)?{brand:"VISA"}:d.MASTERCARD.matches(a)?{brand:"MASTERCARD"}:d.AMEX.matches(a)?{brand:"AMEX"}:d.HIPERCARD.matches(a)?{brand:"HIPERCARD"}:d.DINERS.matches(a)?{brand:"DINERS"}:null},isSecurityCodeValid:function(a,b){var c,e=d.creditCard.cardType(a);c="AMEX"===e.brand?4:3;var f=new RegExp("[0-9]{"+c+"}");return b.length===c&&f.test(b)},isExpiryDateValid:function(a,b){return a=parseInt(a,10),b=parseInt(b,10),1>a||a>12?!1:2!==(b+"").length&&4!==(b+"").length?!1:(2===(b+"").length&&(b=b>80?"19"+b:"20"+b),1e3>b||b>=3e3?!1:!c.prototype.isExpiredDate(a,b))},isExpiredDate:function(a,b){var c=new Date,d=("0"+(c.getMonth()+1)).slice(-2),e=c.getFullYear();if(a=("0"+a).slice(-2),2===b.toString().length){if(b>80)return!0;b="20"+b}var f=e+d,g=b+a;return parseInt(g,10)=g;g++)c[g]=this._calculateInstallmentValue(a.amount,g+1),d[g]=this._calculateAntecipationPercentage(b,a,g,a.amount),e[g]=this._calculateTotalTax(d[g],b),f[g]=this._calculateLiquidValue(a.amount,e[g]);return{amount:a.amount,transaction_tax:b,antecipation_percentage:d,total_tax:e,liquid_value:f,installment_value:c}}return f=this._calculateLiquidValue(a.amount,b),{amount:a.amount,transaction_tax:b,liquid_value:f}},pricingWithInterest:function(a){for(var b=[],c=[],d=[],e=[],f=[],g=[],h=[],i=1;12>=i;i++)b[i-1]=this._calculateInterestRate(a.amount,a.interest_rate,i),c[i-1]=this._calculateAmount(b[i-1],i),d[i-1]=this._calculateTransactionTax(c[i-1],a.transaction_percentage,a.fixed),e[i-1]=this._calculateAntecipationPercentage(d[i-1],a,i-1,c[i-1]),f[i-1]=this._calculateAntecipationPercentageFromAmount(c[i-1],e[i-1]),g[i-1]=this._calculateTotalTax(e[i-1],d[i-1]),h[i-1]=this._calculateLiquidValue(c[i-1],g[i-1]);return{amount:c,transaction_tax:d,antecipation_percentage:f,total_tax:g,liquid_value:h,installment_value:b}},_calculateAntecipationPercentageFromAmount:function(a,b){return parseFloat(100*b/(a/100)).toFixed(2)},_calculateTransactionTax:function(a,b,c){return parseFloat(((a*(b/100)+c)/100).toFixed(2))},_calculateAntecipationPercentage:function(a,b,c,d){return parseFloat((parseFloat(b.antecipation_percentage/100/30*(30+15*c-b.floating))*parseFloat(d/100-a)).toFixed(2))},_calculateTotalTax:function(a,b){return parseFloat((a+b).toFixed(2))},_calculateLiquidValue:function(a,b){return parseFloat((a/100-parseFloat(b)).toFixed(2))},_calculateInstallmentValue:function(a,b){return parseFloat((a/b/100).toFixed(2))},_calculateInterestRate:function(a,b,c){return parseFloat(1===c?a/100:(this._coefficient(b,c)*(a/100)).toFixed(2))},_calculateAmount:function(a,b){return parseFloat(100*(a*b).toFixed(2))},_coefficient:function(a,b){return parseFloat((a/100/(1-1/Math.pow(a/100+1,b))).toFixed(10))}}}(window);