From 54be855cf97e00df02c2f404a80eec5bc15c0354 Mon Sep 17 00:00:00 2001 From: Mathieu Lutfy Date: Fri, 3 May 2013 15:09:17 -0400 Subject: [PATCH] CRM-12515: better credit card handling in contribution forms. --- css/civicrm.css | 18 +++-- i/cc-amex.gif | Bin 645 -> 0 bytes i/cc-amex.png | Bin 0 -> 1591 bytes i/cc-discover.gif | Bin 377 -> 0 bytes i/cc-discover.png | Bin 0 -> 1724 bytes i/cc-jcb.png | Bin 0 -> 1314 bytes i/cc-mastercard.gif | Bin 808 -> 0 bytes i/cc-mastercard.png | Bin 0 -> 2578 bytes i/cc-visa.gif | Bin 365 -> 0 bytes i/cc-visa.png | Bin 0 -> 2242 bytes templates/CRM/Core/BillingBlock.js | 103 +++++++++++++++++++---------- 11 files changed, 81 insertions(+), 40 deletions(-) delete mode 100644 i/cc-amex.gif create mode 100644 i/cc-amex.png delete mode 100644 i/cc-discover.gif create mode 100644 i/cc-discover.png create mode 100644 i/cc-jcb.png delete mode 100644 i/cc-mastercard.gif create mode 100644 i/cc-mastercard.png delete mode 100644 i/cc-visa.gif create mode 100644 i/cc-visa.png diff --git a/css/civicrm.css b/css/civicrm.css index 38eb1e5a55..314ce761aa 100644 --- a/css/civicrm.css +++ b/css/civicrm.css @@ -3962,29 +3962,37 @@ span.crm-status-icon { /* Styles for credit card payment logos (FIXME: replace with sprite?) */ #crm-container .credit_card_type-section .crm-credit_card_type-logos .crm-credit_card_type-logo-visa { - background: url(../i/cc-visa.gif) no-repeat 0 0 transparent; + background: url(../i/cc-visa.png) no-repeat 0 0 transparent; } #crm-container .credit_card_type-section .crm-credit_card_type-logos .crm-credit_card_type-logo-mastercard { - background: url(../i/cc-mastercard.gif) no-repeat 0 0 transparent; + background: url(../i/cc-mastercard.png) no-repeat 0 0 transparent; } #crm-container .credit_card_type-section .crm-credit_card_type-logos .crm-credit_card_type-logo-amex { - background: url(../i/cc-amex.gif) no-repeat 0 0 transparent; + background: url(../i/cc-amex.png) no-repeat 0 0 transparent; } #crm-container .credit_card_type-section .crm-credit_card_type-logos .crm-credit_card_type-logo-discover { - background: url(../i/cc-discover.gif) no-repeat 0 0 transparent; + background: url(../i/cc-discover.png) no-repeat 0 0 transparent; +} + +#crm-container .credit_card_type-section .crm-credit_card_type-logos .crm-credit_card_type-logo-jcb { + background: url(../i/cc-jcb.png) no-repeat 0 0 transparent; } #crm-container .credit_card_type-section .crm-credit_card_type-logos a { display: block; float: left; width: 50px; - height: 22px; + height: 30px; text-indent: -20000px; } +#crm-container .credit_card_type-section .crm-credit_card_type-logos a.crm-credit_card_type-logo-visa { + width: 90px; +} + /* Avoid weird border around the images */ #crm-container .credit_card_type-section .crm-credit_card_type-logos a, #crm-container .credit_card_type-section .crm-credit_card_type-logos a:link, diff --git a/i/cc-amex.gif b/i/cc-amex.gif deleted file mode 100644 index fd45ef04261ca4d4dfe75d30a407607e1f2a0112..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 645 zcmV;00($*NNk%w1VI=?+0M!5h)#&s9XSD!nwMD4ccg5?7yxl~Y%xJsh0CKrksMNOA z>Wj$d09&m9iN+>|!u9(8H>K8Hw&NCiyL-3W0+h{es@4Ag|2B=r>-PI&wci9@ovEBX{Xc=c)Dw_*Cc(v4sNwJp49a8^!E4oVVud{>hdU{)8X&;0DizkjlrS8 z-v9sqA^8LW002J#EC2ui03`qw000L6z~ApcD7ucV;vw=GKy(yJqrs~pt{#Clz!eIK z#-wuDgsh@dD>l3BdNbhSnCv`DscLq+5D-n1P6n#092c4w20ffC54EAOG!n2mk~E&u>is z$dF;6ih;$DRV+4E0S4vDm|?gI@C!#DEmsoh!KA4)gVU(Fp#B`XwW86aGi_+g#|!8+ fxM9auy#d3F+CpyY9-gUqan{7!C^ybrNDu%!L`@`- diff --git a/i/cc-amex.png b/i/cc-amex.png new file mode 100644 index 0000000000000000000000000000000000000000..a5ad9759f20cd15522e7c8ad506fb4de9bb29e0f GIT binary patch literal 1591 zcmV-72FUq|P)fY{| z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dEE4IGq=pR-isI3v++b;JW~DM<&7WC&vvu8u-=<=QUUKYvxP?IgL7js#D&%Na8|7x_)-`I%8(TokCAwndI#9}8insF+TE9<@6yZ+nHO@H&hElm=Nt1!&A8d|Gh;6E7NdO%xkZfzfcG8y{cBcv@e-r3Kq=r% z;+}G*W@>z7eoM$A<@cTVzG1pIh(!cRG3$qtg;Wp3bnqZrpJ`CA0jB<>K#{==E0udN z*L-lbFqm6?XNLi@|D9olevjTXmnnb$os$ssFY=(+UWVC#S`TC751jI$^zi$OuqeiT pvi*MMr`yq%v{FDfVrTAL?dH@fQQQlkCsIj17sNZn3&m^ctZFX9CPw=1Ne#pa#*?DxVf7;*)qd| zeElPf88~?o3zNC3Yk5PGT0DZ1ytM-uSa=qO76it|aod*)&*`f$HsJH}(BT)-$uT)< z$jq4^+01zkZvEg)r(bK`?z4?DM7(2^O87Q2fmGB8*J0Ch&CX#fBK diff --git a/i/cc-discover.png b/i/cc-discover.png new file mode 100644 index 0000000000000000000000000000000000000000..05311a864293c418c54734edad8bf37fe7bd893d GIT binary patch literal 1724 zcmV;t21EIYP)000JCNklmWiq>imguQ5M*>g4qJPgw-JVXT@q03No1tgC7(A&*p!HjV$|0 zCX;@@KNgFr)oQ(7uhnWrQJkKh&d<;1IL_noM5EEITes@Dzkd@vX^o6XOjJtKq=LM#?bAP`6-5=y1g zWHROCF zO5JX^)oQg^EQN)Ib#--=rs$0m^n(ie+a0v+XSAbU4EPExg^i7klu}Bm!{I0|FTZ~M zIsmiTY_(duySohrLtb7U&+|KX?(FI5>F@8SlscWxWo=lNmC0ls9UXSN{p87$wY9Z9 zJw5sP`GG*d?RM|qzyI{<(|*5yYHF&rwY93M>eQ)IIXO8)Lqiz+7^64nJMThg#!{F( zxyyF9wte`~hwr}^2n3?h=)HUQE?&Ht$z*go-JLskj7DQ3ksyRzxNxDOqGH2_4GRkk zH8nM_$s3O2c%FAUoeG7bySrO1mm3U*0|yRVxpHOSzJ0^P!_S{T4~0U_&COb^mg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be5989a96f71beee4698ac4fd12..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 808 zcmZ?wbhEHbRAmrlc$UWS{==7lT6`1Jts~w1|Az=f%J^Pjm6{-IeyBzD1C!v#1(FAk zUj1JuffpYA>{f90bzHqHy`7x{b zKYRXzTaRAYeDMF}&VQo3|4-!HpEU2^xr-Mg<^H{U|L@(Uf1e*V$2t6;Cvsu&rY2FF zi@l2XnZ*u*%vS@_@2_x}&a{!`#P7^Qr0 z{j7iWt^c@r9~_+YZ~o$gZZYYS?*HyRSX}G<@A206Pp|!ZdE|kG#Ct=#HRXm|IaUA1 z3qClu;Qv1V_xlSjoV&1T_1XtLG82p}FQ`~PsL@)(r}O^8)e9|?4=&yIV4Cdz&4%wE zoY=H%-u#6QC^dsiB4*mNjaYTklHI|VrRosls=e3(n{_>TTPXU^DZUN|Imr8g=5 z#$E-UXNGqU=_hS}uswRN;d4faxgpv^LT4dsf{L}r1O)|FMsAh~kv)xTSmk{T z*&obha_sNi8^QD`RJfQ|j=lKyn@o<{$V*0NQ?hEp64q>8Qhr0ohx1r&li|e&3b7U+ vc1;)MNK(>hT;|Zw>ak5(G@|f<17p}kogATtqyy>?nngP0_n+`lV6X-Ns<=sx diff --git a/i/cc-mastercard.png b/i/cc-mastercard.png new file mode 100644 index 0000000000000000000000000000000000000000..6254fb31cccdf5d691bc3c51c64e92a0bcc46b62 GIT binary patch literal 2578 zcmV+t3hniYP)?Dm#0nX@md(37<(s zK~z}7t(bdoROK1Qf9LGk`);zEd&vDBHWDsY3B+P?${kx7m0}UCccfUS5L;!&0Uc%p z3IcU%VMgPW);g6Lib`YAnYK(xAY6rzm5s;Vlt300O+!(seQP56!;CD7DF*yRF16Bma*Hy87)S(v6yMbK&y zB8vRX& z3OCD0(CNgrXAeDFwxEVWeAh^L{&|wut;0}M6#2o^2YtyDoc{VEK$PiQ`pW$?+tp)Ob3Fcg)6G<~+-hpf1jP%Xvv@YoTqfFWg!oe~9*tF`d;U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 z)zMH|8a1zFNY!A;ldn17@uo3#>6i^Dt$cMUx}La;Fu8> zxbFSLE?Gj_)~#sb;wFrxhE)d6hUq#4VQ-`cLX8HAIGDK&GM69-0)imixQn8O!*~uJ zq;vgxf*l*;>;P2BtU ze?QDQbC|SwGnU!2Bh{euD4g5?y*1yDMDC+7V`IeD2*RCr8Ud7%5r$8mq<6;-yq|q` zM|kG)a+24rBWC`5G#1PCb#8bVI;x;~=GF z_%OceY68v8g!}qXRTar@N1vaMxvY%Xg$vQ9rh+70+q?fip%M|4;jRd&@l9+&j5M)h o3n952G8Tf~9x18>;g)>=2lqG#;WN>|nE(I)07*qoM6N<$g0qCcegFUf literal 0 HcmV?d00001 diff --git a/i/cc-visa.gif b/i/cc-visa.gif deleted file mode 100644 index 7dc08c09bc7992d0867257551b53474413c29e61..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 365 zcmZ?wbhEHbRAmrlXpv-K2w%Wov{FBBt8ZRGd0Dh)%g&ZbK3RRoN*AAOUwdiSy6|61 zrN6AOTf6_ks+Z^ zi$R`2hXDvcb~3QOQc&qj$(*-h#@d|M`wZ3`E75f>n|HqI|EGPTu1YI!xJ*8tv@=1G zp~0Ey)(H=mfLEs`u3eWVaqQA2E(dK^4a3<}*IWu<=`L5$QIphLFySDR9(w@03#YiG zXiiPMg*Gn(o1kPtXaM7+046t`Mus$o;-2;ZF7c^h0X2P*MUvuaO#Tdck`58f!3;&K z*6e7K+`(DJ*{!=V((QmwMr3W_9QGqRRV(tdghZTjb0V28YA=oC)2=Xa>+?{A%pAM~>xWclI5$~h^2VP6|x|B@LVA6+;YtN|}( Br^WyP diff --git a/i/cc-visa.png b/i/cc-visa.png new file mode 100644 index 0000000000000000000000000000000000000000..31635ebbc97fde4bc3b635178dc3ab873c86dac9 GIT binary patch literal 2242 zcmV;z2tD_SP)rK2Re(kj|%SG zm{z({NBZb@D_cm4MgReTAj9ajiud;~;qPS_@KJPk-&D;x^R+fx-_X5Dr;hz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GKrzL2j06;3imM<2-(P45v zGAjR&jy5SlCUWw+#_`YpZRTqv1bX1rJh3&x`ZXtAC6$CRKq)6)dNHl@+}6Jzer`cr zl<4Z6(V2@4qg>SByC(qb*_tVr;cQ=%u8$`02lo%q!E3G7NS0x&sAD9>MTxfuTzno5 zj|t4$zb8-hvpn9wsMW(B9}!mcIEL>3O{0Xk ze^1IUPDb_3Ynvl#jM@IxeCg~IkEg6 zj}2b3C>#JTem8o%e@f7S(?RoyyT|Nef94T4|F#SRB6p71_$Mb_6-r}Hc5Tk!UX_#X zeu3-iwF16Yu?@^-9zDgxxFJb-vzmy+hE6sFV`cRX_P>uZIl$PiA-ZPDS2X z*xX)_qq%f#H0;&=dvdv2la(27VAAR1YYfRsuBWQKYN@R1I`QRzF-xu2D&k|M@+jO# z(RasYn%Znb7PoMtV$&M^jjqYZDOg1^;|bg}IhN#VA`C}Lk|KYhIxHM7Jgdvg6i+~I z_fLr?AgNk~dKQkGCIuaT)2(5fyE6<8mNkU47d!j1akgQb4NaiZu!(ssd zpB;IA^ICn6*>&Z6K}(jLD1U2T{<1}JG|h1N3qw)!$aG`dgGQO8=$6jOeJ?+O(eaX8 zO-hn@=ul|X6fKSmU2Ga~iDrd*?ft!OkKg7XQ4|sR7k?B80L4X#Jr}mWvMHU7HKGY% zZl;QDQZNj`F_irw2xRD^Q?*KN8BH@R6C=-#McL}IVqILU6hjdVL)dzG_m<3TLrj>* z;7HMIQN%EeQciFVrIZuB7q@?L;Z8$~^;Z9s-AT@P12oMLI2xlQ49UvXE0XqX&EQ%x z*ED4waTgjjT#}Ybus3#O&t+$E(E{_xG`~vtp`+vfKbilZWgd=sI382}3;ax)>CEEW QYybcN07*qoM6N<$f^s}cKmY&$ literal 0 HcmV?d00001 diff --git a/templates/CRM/Core/BillingBlock.js b/templates/CRM/Core/BillingBlock.js index 33fdad0f21..c67dd9f11c 100644 --- a/templates/CRM/Core/BillingBlock.js +++ b/templates/CRM/Core/BillingBlock.js @@ -1,49 +1,82 @@ // http://civicrm.org/licensing (function($) { - function civicrm_billingblock_add_cc_logos() { + civicrm_billingblock_creditcard_helper(); + + $('#crm-container').on('crmFormLoad', '*', function() { + civicrm_billingblock_creditcard_helper(); + }); + + /** + * Adds the logos of enabled credit cards + * Handles clicking on a logo. + * Changes the logo depending on the credit card number. + * Removes spaces and dashes from credit card numbers. + */ + function civicrm_billingblock_creditcard_helper() { $.each(CRM.config.creditCardTypes, function(key, val) { var html = '' + val + ''; $('.crm-credit_card_type-logos').append(html); - cj('.crm-credit_card_type-logo-' + key).click(function() { - cj('#crm-container .credit_card_type-section #credit_card_type').val(val); - cj('#crm-container .credit_card_type-section a').css('opacity', 0.4); - cj('#crm-container .credit_card_type-section .crm-credit_card_type-logo-' + key).css('opacity', 1); + $('.crm-credit_card_type-logo-' + key).click(function() { + $('#crm-container .credit_card_type-section #credit_card_type').val(val); + $('#crm-container .credit_card_type-section a').css('opacity', 0.25); + $('#crm-container .credit_card_type-section .crm-credit_card_type-logo-' + key).css('opacity', 1); return false; }); + }); - // Hide the CC type field (redundant) - $('#crm-container .credit_card_type-section select#credit_card_type').hide(); - $('#crm-container .credit_card_type-section .label').hide(); - - // Select according to the number entered - cj('#crm-container input#credit_card_number').change(function() { - var ccnumtype = cj(this).val().substr(0, 4); - - // Semi-hide all images, we will un-hide the right one afterwards - cj('#crm-container .credit_card_type-section a').css('opacity', 0.4); - cj('#credit_card_type').val(''); - - // https://en.wikipedia.org/wiki/Credit_card_numbers - if (ccnumtype.substr(0, 1) == '3') { - cj('#credit_card_type').val('Amex'); - cj('#crm-container .credit_card_type-section .crm-credit_card_type-logo-visa').css('opacity', 1); - } - else if (ccnumtype.substr(0, 2) >= '51' && ccnumtype.substr(0, 2) <= '55') { - cj('#credit_card_type').val('MasterCard'); - cj('#crm-container .credit_card_type-section .crm-credit_card_type-logo-mastercard').css('opacity', 1); - } - else if (ccnumtype.substr(0, 1) == '4') { - cj('#credit_card_type').val('Visa'); - cj('#crm-container .credit_card_type-section .crm-credit_card_type-logo-visa').css('opacity', 1); - } - }); + // Hide the CC type field (redundant) + $('#crm-container .credit_card_type-section select#credit_card_type').hide(); + $('#crm-container .credit_card_type-section .label').hide(); + + // Select according to the number entered + $('#crm-container input#credit_card_number').change(function() { + var ccnumber = cj(this).val(); + + // Remove spaces and dashes + ccnumber = ccnumber.replace(/[- ]/g, ''); + cj(this).val(ccnumber); + + // Semi-hide all images, we will un-hide the right one afterwards + $('#crm-container .credit_card_type-section a').css('opacity', 0.25); + $('#credit_card_type').val(''); + + civicrm_billingblock_set_card_type(ccnumber); }); } - civicrm_billingblock_add_cc_logos(); + function civicrm_billingblock_set_card_type(ccnumber) { + // Based on http://davidwalsh.name/validate-credit-cards + // See also https://en.wikipedia.org/wiki/Credit_card_numbers + var card_types = { + 'mastercard': '5[1-5][0-9]{14}', + 'visa': '4(?:[0-9]{12}|[0-9]{15})', + 'amex': '3[47][0-9]{13}', + 'dinersclub': '3(?:0[0-5][0-9]{11}|[68][0-9]{12})', + 'carteblanche': '3(?:0[0-5][0-9]{11}|[68][0-9]{12})', + 'discover': '6011[0-9]{12}', + 'jcb': '(?:3[0-9]{15}|(2131|1800)[0-9]{11})', + 'unionpay': '62(?:[0-9]{14}|[0-9]{17})' + } - $('#crm-container').on('crmFormLoad', '*', function() { - civicrm_billingblock_add_cc_logos(); - }); + var card_values = { + 'mastercard': 'MasterCard', + 'visa': 'Visa', + 'amex': 'Amex', + 'dinersclub': 'Diners Club', + 'carteblanche': 'Carte Blanche', + 'discover': 'Discover', + 'jcb': 'JCB', + 'unionpay': 'UnionPay' + } + + $.each(card_types, function(key, pattern) { + if (ccnumber.match('^' + pattern + '$')) { + var value = card_values[key]; + $('#crm-container .credit_card_type-section .crm-credit_card_type-logo-' + key).css('opacity', 1); + $('select#credit_card_type').val(value); + return false; + } + }); + } })(cj); -- 2.25.1