Support a numeric CC month expiry date format
CiviCRM defaults to a credit card format that is 'M/Y', where M is the month name, rather than number.
I have always used 'm/Y', because (at least in Canada, but I suspect most other places), we always dictate the expiration date in the same way it's written on the card, which is in numeric form. Ex: '01/2038', not 'Jan/2038'.
To reproduce, change the creditCard
setting under : /civicrm/admin/setting/preferences/date?action=reset=1
to m Y
.
I have been applying this patch for a long time, but I don't know what could be a clean patch that would support both date formats.
diff --git a/vendor/civicrm/stripe/js/civicrm_stripe.js b/vendor/civicrm/stripe/js/civicrm_stripe.js
index f520c0da..644eaa03 100644
--- a/vendor/civicrm/stripe/js/civicrm_stripe.js
+++ b/vendor/civicrm/stripe/js/civicrm_stripe.js
@@ -314,7 +314,7 @@ CRM.$(function($) {
// Disable the submit button to prevent repeated clicks
$submit.prop('disabled', true);
- var cc_month = $form.find('#credit_card_exp_date_M').val();
+ var cc_month = $form.find('#credit_card_exp_date_m').val();
var cc_year = $form.find('#credit_card_exp_date_Y').val();
Stripe.card.createToken({
Any thoughts?
Worst case, something like this would work, but it's not very clean:
var cc_year = $form.find('#credit_card_exp_date_Y').val();
var cc_month = null;
if ($form.find('#credit_card_exp_date_m').size() > 0) {
cc_month = $form.find('#credit_card_exp_date_m').val();
}
else {
cc_month = $form.find('#credit_card_exp_date_M').val();
}