Skip to content

Commit

Permalink
Fixed StripeForm
Browse files Browse the repository at this point in the history
  • Loading branch information
ruskid committed Apr 15, 2015
1 parent 36cc8a6 commit deca6b5
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions StripeForm.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,21 @@ public function registerJqueryPaymentScripts() {
var $year = $("input[data-stripe=' . self::YEAR_ID . ']");
var cardType = $.payment.cardType($number.val());
$("#' . $this->brandContainerId . '").text(cardType);
$number.toggleInputError(!$.payment.validateCardNumber($number.val()));
$exp.toggleInputError(!$.payment.validateCardExpiry($exp.payment("cardExpiryVal")));
$cvc.toggleInputError(!$.payment.validateCardCVC($cvc.val(), cardType));
$month.toggleInputError(!$.payment.validateCardExpiry($month.val(), $year.val()));
$year.toggleInputError(!$.payment.validateCardExpiry($month.val(), $year.val()));
$("#' . $this->brandContainerId . '").text(cardType);
if ($exp.length) {
$exp.toggleInputError(!$.payment.validateCardExpiry($exp.payment("cardExpiryVal")));
var fullDate = $exp.val();
var res = fullDate.split(" / ", 2);
$month.val(res[0]);
$year.val(res[1]);
}else{
$month.toggleInputError(!$.payment.validateCardExpiry($month.val(), $year.val()));
$year.toggleInputError(!$.payment.validateCardExpiry($month.val(), $year.val()));
}
if($form.find(".' . $this->errorClass . '").length != 0){
e.preventDefault();
Expand Down Expand Up @@ -325,7 +332,7 @@ public function monthInput($options = []) {
}

/**
* Will generate month and year input. Like in Jquery Payment example.
* Will generate month and year input with 2 hidden inputs for month and year values.
* @param array $options
* @return string genetared input tag
*/
Expand All @@ -343,7 +350,11 @@ public function monthAndYearInput($options = []) {
StripeHelper::secCheck($options);
}
$options['data-stripe'] = self::MONTH_YEAR_ID;
return Html::input('text', null, null, $options);
$inputs = Html::input('text', null, null, $options);
//Append hidden year and month inputs that will get value from mixed and send to stripe
$inputs = $inputs . $this->monthInput(['type' => 'hidden']);
$inputs = $inputs . $this->yearInput(['type' => 'hidden']);
return $inputs;
}

}

0 comments on commit deca6b5

Please sign in to comment.