Skip to content

Commit

Permalink
Altered to work as ActiveField widget
Browse files Browse the repository at this point in the history
Altered to work as ActiveField widget
  • Loading branch information
Andrew Blake committed Mar 22, 2016
1 parent a859dce commit 1559016
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 196 deletions.
7 changes: 7 additions & 0 deletions CHANGE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
version 1.0.3
=============
**Date:** 23-Mar-2016

1. Added classes CreditCardCVCode, CreditCardExpiry, and CreditCardNumber. These extend from \kartik\base\InputWidget and
are used as per README documentation.

version 1.0.2
=============
**Date:** 29-Aug-2015
Expand Down
168 changes: 0 additions & 168 deletions CreditCard.php

This file was deleted.

2 changes: 1 addition & 1 deletion CreditCardCVCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package andrewblake1\yii2-credit-card
* @license https://github.com/andrewblake1/yii2-credit-card/blob/master/LICENSE.md MIT License
* @link https://github.com/andrewblake1/yii2-credit-card
* @version 1.0.2
* @version 1.0.3
*/
namespace andrewblake1\creditcard;

Expand Down
2 changes: 1 addition & 1 deletion CreditCardExpiry.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package andrewblake1\yii2-credit-card
* @license https://github.com/andrewblake1/yii2-credit-card/blob/master/LICENSE.md MIT License
* @link https://github.com/andrewblake1/yii2-credit-card
* @version 1.0.2
* @version 1.0.3
*/
namespace andrewblake1\creditcard;

Expand Down
2 changes: 1 addition & 1 deletion CreditCardNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package andrewblake1\yii2-credit-card
* @license https://github.com/andrewblake1/yii2-credit-card/blob/master/LICENSE.md MIT License
* @link https://github.com/andrewblake1/yii2-credit-card
* @version 1.0.2
* @version 1.0.3
*/
namespace andrewblake1\creditcard;

Expand Down
41 changes: 20 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,10 @@ yii2-credit-card
[![Latest Stable Version](https://poser.pugx.org/andrewblake1/yii2-credit-card/v/stable)](https://packagist.org/packages/andrewblake1/yii2-credit-card)
[![License](https://poser.pugx.org/andrewblake1/yii2-credit-card/license)](https://packagist.org/packages/andrewblake1/yii2-credit-card)

Yii2 Bootstrap 3 component, providing client validated and masked credit card number, expiry and cvc fields with credit card icon changing to match credit card type when detectable.
Yii2 Bootstrap 3 components, providing client validated and masked credit card number, expiry and cvc fields with credit card icon changing to match credit card type when detectable.

Uses client validation courtesy of Stripe (https://github.com/stripe/jquery.payment) and works with validation in ActiveForm.

Options

- **form** ActiveForm the bootstrap/ActiveForm object, *required*.

- **numberAttribute** string Credit card number attribute name, *defaults to 'creditCard_number'*.

- **expiryAttribute** string Credit card number expiry attribute name, *defaults to 'creditCard_expirationDate'*.

- **cvcAttribute** string Credit card cvc/cvv/ccv attribute name, *defaults to 'creditCard_cvv'*.

In addition, the methods number(), expiry(), and cvc() accept an optional field configuration array as used by yii\bootstrap\ActiveForm::field.

### The future

1. Integrate first with Braintree and potentially Stripe e.g. any requirements to encode the fields when posting request etc.
Expand All @@ -46,23 +34,34 @@ to the `require` section of your `composer.json` file.

## Latest Release

> NOTE: The latest version of the module is v1.0.2. Refer the [CHANGE LOG](https://github.com/andrewblake1/yii2-credit-card/blob/master/CHANGE.md) for details.
> NOTE: The latest version of the module is v1.0.3. Refer the [CHANGE LOG](https://github.com/andrewblake1/yii2-credit-card/blob/master/CHANGE.md) for details.
## Usage in view

Note that the input names here have been chosen to fit work with the tuyakhov\braintree extension

```php
<?php
use yii\bootstrap\ActiveForm;
use andrewblake1\creditcard\CreditCard;
use andrewblake1\creditcard\CreditCardNumber;
use andrewblake1\creditcard\CreditCardExpiry;
use andrewblake1\creditcard\CreditCardCVCode;
?>

<?php $form = ActiveForm::begin() ?>
<div class="container">
<?php $creditCard = new CreditCard(['form' => $form]);?>
<div class="row"><div class="col-xs-12"><?= $creditCard->number() ?></div></div>
<div class="row"><div class="col-xs-12"><?= $creditCard->expiry() ?></div></div>
<div class="row"><div class="col-xs-12"><?= $creditCard->cvc() ?></div></div>
</div>
<div class="container">
<div id="card" class="row">
<div class="col-xs-7">
<?= $form->field($bookingForm, 'creditCard_number')->widget(CreditCardNumber::className(), ['name' => 'creditCard_number',]) ?>
</div>
<div class="col-xs-3">
<?= $form->field($bookingForm, 'creditCard_expirationDate')->widget(CreditCardExpiry::className(), ['name' => 'creditCard_expirationDate',]) ?>
</div>
<div class="col-xs-2">
<?= $form->field($bookingForm, 'creditCard_cvv')->widget(CreditCardCVCode::className(), ['name' => 'creditCard_cvv',]) ?>
</div>
</div>
</div>
<?php ActiveForm::end() ?>
```
## License
Expand Down
2 changes: 1 addition & 1 deletion assets/js/creditcard.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @package andrewblake1\yii2-credit-card
* @license http://opensource.org/licenses/MIT MIT License
* @link https://github.com/andrewblake1/yii2-credit-card
* @version 1.0.2
* @version 1.0.3
*/
(function($) {

Expand Down
2 changes: 1 addition & 1 deletion models/CreditCardModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package andrewblake1\yii2-credit-card
* @license http://opensource.org/licenses/MIT MIT License
* @link https://github.com/andrewblake1/yii2-credit-card
* @version 1.0.2
* @version 1.0.3
*/
namespace andrewblake1\creditcard\models;

Expand Down
2 changes: 1 addition & 1 deletion validators/CCCVCodeValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package andrewblake1\yii2-credit-card
* @license http://opensource.org/licenses/MIT MIT License
* @link https://github.com/andrewblake1/yii2-credit-card
* @version 1.0.2
* @version 1.0.3
*/
namespace andrewblake1\creditcard\validators;

Expand Down
2 changes: 1 addition & 1 deletion validators/CCNumberValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package andrewblake1\yii2-credit-card
* @license http://opensource.org/licenses/MIT MIT License
* @link https://github.com/andrewblake1/yii2-credit-card
* @version 1.0.2
* @version 1.0.3
*/
namespace andrewblake1\creditcard\validators;

Expand Down

0 comments on commit 1559016

Please sign in to comment.