Skip to content
This repository was archived by the owner on Mar 4, 2024. It is now read-only.

Commit d1a266c

Browse files
author
Arnoud ten Hoedt
committed
Version 0_1_19
* Fix reference to `window` in nodom implementation * Capture referrer page as part of the encrypted blob * Fix installation problem after relocations ( issue #33 ) because of wrong naming in bower.json * Generation time will now be validated * Fix card type detection on China Union Pay vs Maestro
1 parent 15715ed commit d1a266c

9 files changed

+192
-70
lines changed

Options.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The `createEncryption ( key , `*`options`*` )` and `createEncryptedForm ( form,
88

99
* **string `[fieldNameAttribute = 'data-encrypted-name']`** - *since version: 0_1_10*
1010

11-
Configure the attribute to identify fields to be encrypted. Useful when you have multiple payment options within the same form, and want to bind each set to its own CSE handler.
11+
Configure the attribute to identify fields to be encrypted. Useful when you have multiple payment options within the same form, and want to bind each set to it's own CSE handler.
1212

1313
* **boolean `[enableValidations = true] `**
1414

@@ -32,13 +32,13 @@ The `createEncryption ( key , `*`options`*` )` and `createEncryptedForm ( form,
3232

3333
Custom handler to be called on submit of the form.
3434

35-
The callback function will be executed after encryption has taken place, and will receive the original submit event as its first argument.
35+
The callback function will be executed after encryption has taken place, and will receive the original submit event as it's first argument.
3636

3737
* **function `[onvalidate]`**
3838

3939
Handler to be called after on validation of the form.
4040

41-
The callback function will be executed after the validation routine of the CSE form has been completed and will receive the validity status of the form as its first argument.
41+
The callback function will be execyted after the validation routine of the CSE form has been completed and will receive the validaty status of the form as it's first argument.
4242

4343
* **HTMLElement `[cardTypeElement]`**
4444

README.md

+33-21
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The library currently offers two integration methods:
1010
The library currently has three inclusion / loading styling:
1111
- Download `adyen.encrypt.min.js` and host it yourself. Both HTML based as JavaScript only integration is supported.
1212
- Download `adyen.encrypt.nodom.min.js` and host it yourself. Only supports JavaScript only integration.
13-
- Adyen Hosted version in which the public key is embedded in the JavaScript. This integration makes sure you always have the latest security patches, and don't have to keep your public key in sync with the Adyen servers manually. See [Adyen Hosted Form Based Integration](HostedCSE.md) for more details.
13+
- Adyen Hosted version in which the public key is embedded in the JavaScript. This integration makes sure you always have the latest security patches, and don't have to keep your public key in sync with the Adyen servers manually. See [Adyen Hosted Form Based Integration](HostedCSE.md) for more details.
1414

1515

1616
## HTML based integration
@@ -49,7 +49,7 @@ Enricht a form in your page with the CSE onSubmit and (optionally) validation be
4949
// The form element to encrypt
5050
var form = document.getElementById('adyen-encrypted-form');
5151
// The public key
52-
var key = "your key as retrieved from the Adyen Customer Area Web Service User page";
52+
var key = "your key as retrieved from the Adyen Customer Area Web Service User page";
5353
// Form and encryption options. See adyen.encrypt.simple.html for details
5454
var options = {};
5555
// Bind encryption to the form
@@ -80,7 +80,7 @@ require(['adyen/encrypt'], function(adyenEncrypt) {
8080
// The form element to encrypt
8181
var form = document.getElementById('adyen-encrypted-form');
8282
// The public key
83-
var key = "your key as retrieved from the Adyen Customer Area Web Service User page";
83+
var key = "your key as retrieved from the Adyen Customer Area Web Service User page";
8484
// Form and encryption options. See adyen.encrypt.simple.html for details
8585
var options = {};
8686
// Bind encryption to the form
@@ -99,15 +99,15 @@ In case the HTML integration is troublesome in your setup, the library has been
9999
<script type="text/javascript" src="js/adyen.encrypt.nodom.min.js"></script>
100100
<script type="text/javascript">
101101
(function() {
102-
var key = "your key as retrieved from the Adyen Customer Area Web Service User page";
102+
var key = "your key as retrieved from the Adyen Customer Area Web Service User page";
103103
var options = {}; // See adyen.encrypt.nodom.html for details
104104
105105
var cseInstance = adyen.encrypt.createEncryption(key, options);
106106
107107
function encryptMyData() {
108-
108+
109109
var postData = {};
110-
110+
111111
var cardData = {
112112
number : cardNumber,
113113
cvc : cvc,
@@ -116,12 +116,12 @@ In case the HTML integration is troublesome in your setup, the library has been
116116
expiryYear : expiryYear,
117117
generationtime : generationtime
118118
};
119-
119+
120120
postData['adyen-encrypted-data'] = cseInstance.encrypt(cardData);
121-
121+
122122
// Ajax Call or different handling of the post data
123123
}
124-
124+
125125
})();
126126
</script>
127127
````
@@ -140,7 +140,7 @@ Add to your `package.json`:
140140
For the current latest release use the following dependency:
141141
```
142142
"dependencies": {
143-
"adyen-cse-web": "git+https://github.com/Adyen/adyen-cse-web.git#v0.1.18"
143+
"adyen-cse-web": "git+https://github.com/Adyen/adyen-cse-web.git#v0.1.19"
144144
}
145145
```
146146

@@ -152,10 +152,22 @@ Now you can use adyen as a regular npm package:
152152
var adyenEncrypt = require('adyen-cse-web');
153153

154154
var cseInstance = adyenEncrypt.createEncryption(key, options);
155-
```
156155

157156
# Version History
158157

158+
JavaScript version 0_1_19
159+
-------
160+
161+
* Fix reference to `window` in nodom implementation
162+
163+
* Capture referrer page as part of the encrypted blob
164+
165+
* Fix installation problem after relocations ( issue #33 ) because of wrong naming in bower.json
166+
167+
* Generation time will now be validated
168+
169+
* Fix card type detection on China Union Pay vs Maestro
170+
159171
JavaScript version 0_1_18
160172
-------
161173

@@ -182,7 +194,7 @@ JavaScript version 0_1_16
182194
JavaScript version 0_1_15
183195
-------
184196

185-
* Add cardtype detection for three new card types
197+
* Add cardtype detection for three new card types
186198

187199
* Improve card type detection for dual branded cards (ELO)
188200

@@ -193,7 +205,7 @@ JavaScript version 0_1_15
193205
JavaScript version 0_1_14
194206
-------
195207

196-
* Clean up inconsistencies between the nodom Encryption and the UI engine
208+
* Clean up inconsistencies between the nodom Encryption and the UI engine
197209

198210
* Only validate fields that are only there. Removing CVC from the HTML (in case of mister cash) no longer fails validation.
199211

@@ -261,7 +273,7 @@ JavaScript version 0_1_5
261273
---
262274
263275
The 0_1_5 version of the JavaScript client-side encryption library upgrades the random number generator and the JSBN implementation.
264-
276+
265277
266278
JavaScript version 0_1_4
267279
---
@@ -270,7 +282,7 @@ JavaScript version 0_1_4
270282
All properties are configurable through the options object:
271283
272284
* ```options.enableValidations // default: true```
273-
285+
274286
Enable basic field validation (default is true)
275287
276288
The submit button will be disabled when fields proof to be invalid. The form submission will be prevented as well.
@@ -279,16 +291,16 @@ JavaScript version 0_1_4
279291
options.enableValidations = true;
280292
```
281293
* ```options.submitButtonAlwaysEnabled // default: false```
282-
294+
283295
Always have the submit button enabled, even in case of validation errors.
284-
296+
285297
```javascript
286298
options.submitButtonAlwaysEnabled = false;
287299
```
288300
* ```options.numberIgnoreNonNumeric // default: true```
289-
301+
290302
The payment handling ignores non-numeric characters for the card field.
291-
303+
292304
By default non-numeric characters will also be ignored while validating
293305
the card number field. This can be disabled for UX reasons.
294306
@@ -297,7 +309,7 @@ JavaScript version 0_1_4
297309
```
298310
299311
Patches
300-
312+
301313
* 0_1_4p1
302-
314+
303315
Remove unnecessary ```document.title``` assignment.

js/addOns/adyen.cardtype.js

+19-17
Original file line numberDiff line numberDiff line change
@@ -64,37 +64,39 @@
6464

6565
var currentCardType = null, currentMatchSize = 0;
6666

67+
console.log("Determining card type for " + variant);
68+
console.log("Variants", availableTypes);
69+
6770
for ( var i = Cards.size; i-- > 0; ) {
6871
var card = Cards[i];
6972

7073
if (!contains(availableTypes, card.cardtype)) {
74+
console.log(" CardType Skipped", card.cardtype);
7175
continue;
7276
}
7377

74-
if (card.setCardNumber(variant).isCardNumber()) {
78+
for (var c = 0; c < card.rules.size; c++) {
79+
var len = Math.min(variant.length, card.rules[c].length);
7580

76-
for (var c = 0; c < card.rules.size; c++) {
77-
var len = Math.min(variant.length, card.rules[c].length);
78-
79-
if (len < 3) {
80-
// Minimum length included because of collissions
81-
continue;
82-
}
83-
84-
if (variant.substring(0, len) === card.rules[c].substring(0, len)) {
85-
if (len > currentMatchSize) {
86-
currentCardType = card;
87-
currentMatchSize = len;
88-
}
89-
}
81+
if (len <= 1 || variant.length < card.rules[c].length) {
82+
// Minimum length included because of collissions on single number cardtypes
83+
continue;
9084
}
9185

92-
86+
if (variant.substring(0, len) === card.rules[c].substring(0, len)) {
87+
if (len > currentMatchSize) {
88+
console.log("Setting card type to ", card);
89+
currentCardType = card;
90+
currentMatchSize = len;
91+
}
92+
}
9393
}
94+
9495
card.setCardNumber(null);
9596
}
9697

9798
if (currentCardType === null) {
99+
console.log("Could not determine card type, so falling back to HPP implementation: " + variant)
98100
currentCardType = getBaseCard( variant, availableTypes );
99101
}
100102

@@ -133,7 +135,7 @@
133135
};
134136

135137
adyen.CardTypeDetection = {
136-
version : '0_1_18',
138+
version : '0_1_19',
137139
getHandler : function ( cardTypeElement ) {
138140
return function ( ev ) {
139141

js/addOns/adyen.cardtype.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)