Skip to content

Commit

Permalink
Merge pull request #752 from recurly/cartes-bancaires
Browse files Browse the repository at this point in the history
Cartes Bancaires and Co-Branding support
  • Loading branch information
chrissrogers authored Oct 11, 2022
2 parents b16abeb + 1bea40f commit 1e0d6e2
Show file tree
Hide file tree
Showing 14 changed files with 397 additions and 29 deletions.
271 changes: 266 additions & 5 deletions lib/const/credit-card-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
"master": [
{
"lengths": [16],
"ranges": [
"ranges": [
[2221, 2720],
[51, 55]
]
],
"co_brands": {
"cartes_bancaires": [
[55555525, 55555525],
[527429, 527429]
]
}
}
],
"diners_club": [
Expand Down Expand Up @@ -55,7 +61,75 @@
"lengths": [13, 16],
"ranges": [
[4, 4]
]
],
"co_brands": {
"cartes_bancaires": [
[40000025, 40000025],
[405687, 405687],
[411890, 411890],
[413512, 413512],
[413517, 413517],
[413529, 413531],
[413533, 413533],
[413537, 413539],
[413543, 413543],
[413849, 413853],
[415062, 415062],
[420114, 420115],
[436000, 436000],
[439826, 439827],
[439829, 439829],
[439837, 439837],
[439840, 439842],
[439844, 439844],
[439846, 439846],
[449983, 449989],
[456242, 456242],
[456245619, 456245619],
[497000, 497000],
[497005, 497005],
[497036, 497036],
[497079, 497079],
[497102, 497102],
[49712020, 497120],
[4971615, 4971616],
[497175, 49717512],
[49717549, 49717549],
[497299, 497299],
[497302, 497302],
[497308, 497308],
[497310, 497311],
[497409, 497409],
[497460, 497460],
[497463, 497463],
[497469, 497469],
[497510, 497510],
[497515501, 497515502],
[4975165, 4975165],
[4975365, 4975365],
[4975565, 4975565],
[4975585, 4975585],
[4975765, 4975765],
[4975795, 4975795],
[4975815, 4975815],
[4975855, 4975855],
[4975857, 4975857],
[4975955, 4975955],
[4975965, 4975965],
[497717, 497718],
[497723, 497723],
[497726, 497727],
[497729, 497729],
[497740, 497742],
[497749, 497752],
[497758, 497760],
[497763, 497763],
[497771, 497772],
[497774, 497775],
[497779, 497779],
[497782, 497782]
]
}
}
],
"elo": [
Expand Down Expand Up @@ -106,7 +180,12 @@
[6282, 6289],
[6291, 6292],
[8100, 8171]
]
],
"co_brands": {
"cartes_bancaires": [
[627244, 627244]
]
}
}
],
"maestro": [
Expand Down Expand Up @@ -147,7 +226,189 @@
[650600, 650600],
[650610, 650610],
[66, 69]
]
],
"co_brands": {
"cartes_bancaires": [
[501767, 501767],
[507589, 507589003],
[50758901, 507589013],
[50758902, 507589023],
[50758903, 507589033],
[50758904, 507589043],
[50758905, 507589053],
[50758906, 507589063],
[50758908, 507589083],
[50758909, 507589093],
[50759, 50759007],
[5075901, 50759017],
[507593, 50759411],
[507595, 507595],
[50759701, 50759701],
[50759703, 50759703],
[560408, 560408],
[56120201, 56120201],
[56120211, 56120211],
[56120214, 56120216],
[56120218, 5612021],
[56120221, 56120221],
[56120226, 56120228],
[5612023, 56120230],
[56120232, 56120232],
[56120234, 56120234],
[56120237, 56120238],
[56120241, 56120243],
[56120246, 56120246],
[56120262, 56120263],
[56120265, 56120265],
[5612027, 56120270],
[56120273, 56120277],
[5612028, 56120280],
[56120284, 56120284],
[56120286, 56120286],
[56120288, 56120290],
[56120292, 56120293],
[56120296, 56120297],
[56120301, 56120301],
[56120311, 56120311],
[56120314, 56120316],
[56120318, 5612031],
[56120321, 56120321],
[56120326, 56120328],
[5612033, 56120330],
[56120332, 56120332],
[56120334, 56120334],
[56120337, 56120338],
[56120341, 56120343],
[56120346, 56120346],
[56120362, 56120363],
[56120365, 56120365],
[5612037, 56120370],
[56120373, 56120377],
[5612038, 56120380],
[56120384, 56120384],
[56120386, 56120386],
[56120388, 56120390],
[56120392, 56120393],
[56120396, 56120397],
[56120401, 56120401],
[56120411, 56120411],
[56120414, 56120416],
[56120418, 5612041],
[56120421, 56120421],
[56120426, 56120428],
[5612043, 56120430],
[56120432, 56120432],
[56120434, 56120434],
[56120437, 56120438],
[56120441, 56120443],
[56120446, 56120446],
[56120462, 56120463],
[56120465, 56120465],
[5612047, 56120470],
[56120473, 56120477],
[5612048, 56120480],
[56120484, 56120484],
[56120486, 56120486],
[56120488, 56120490],
[56120492, 56120493],
[56120496, 56120497],
[56120501, 56120501],
[56120511, 56120511],
[56120514, 56120516],
[56120518, 5612051],
[56120521, 56120521],
[56120526, 56120528],
[5612053, 56120530],
[56120532, 56120532],
[56120534, 56120534],
[56120537, 56120538],
[56120541, 56120543],
[56120546, 56120546],
[56120562, 56120563],
[56120565, 56120565],
[5612057, 56120570],
[56120573, 56120577],
[5612058, 56120580],
[56120584, 56120584],
[56120586, 56120586],
[56120588, 56120590],
[56120592, 56120593],
[56120596, 56120597],
[561206, 56120600],
[56124102, 56124102],
[5612411, 56124110],
[56124112, 56124113],
[56124117, 56124117],
[5612412, 56124120],
[56124122, 56124123],
[56124125, 56124125],
[56124129, 5612412],
[56124131, 56124131],
[56124133, 56124133],
[56124135, 56124136],
[56124139, 5612413],
[56124144, 56124145],
[56124147, 56124148],
[5612416, 56124161],
[56124166, 5612416],
[56124171, 56124172],
[56124178, 5612417],
[56124181, 56124183],
[56124187, 56124187],
[56124194, 56124195],
[56124198, 56124198],
[56125402, 56125402],
[5612541, 56125410],
[56125412, 56125413],
[56125417, 56125417],
[5612542, 56125420],
[56125422, 56125425],
[56125429, 5612542],
[56125431, 56125431],
[56125433, 56125433],
[56125435, 56125436],
[56125439, 56125440],
[56125444, 56125445],
[56125447, 56125448],
[5612546, 56125461],
[56125466, 5612546],
[56125471, 56125472],
[56125478, 5612547],
[56125481, 56125483],
[56125487, 56125487],
[56125491, 56125491],
[56125494, 56125495],
[56125498, 561254],
[5817, 581701],
[581703, 581706],
[581708, 581713],
[581719, 581720],
[581722, 581723],
[581725, 58172],
[581733, 581735],
[581752, 581754],
[581757, 581761],
[581763, 581763],
[581772, 581772],
[581774, 581777],
[581779, 581783],
[581785, 581785],
[581788, 58178],
[581792, 581793],
[581795, 581796],
[581798, 5817],
[585402, 585405],
[585501, 585505],
[585577, 585582],
[639014, 639024],
[639026, 639068],
[63907, 639092],
[639095, 639096],
[639098, 639098],
[6391, 63912],
[6751, 6756]
]
}
},
{
"lengths": [17, 18, 19],
Expand Down
7 changes: 7 additions & 0 deletions lib/recurly.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ const DEFAULTS = {
card: {
selector: '[data-recurly=card]',
style: {}
},
brand: {
selector: '[data-recurly=brand]',
style: {},
inputType: 'select',
}
}
};
Expand Down Expand Up @@ -244,6 +249,8 @@ export class Recurly extends Emitter {
this.config.currency = options.currency;
}

this.config.coBrands = options.coBrands || this.config.coBrands || [];

if ('cors' in options) {
this.config.cors = options.cors;
}
Expand Down
10 changes: 10 additions & 0 deletions lib/recurly/element/card-brand.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Element from './element';

export function factory (options) {
return new CardBrandElement({ ...options, inputType: 'select', elements: this });
}

export class CardBrandElement extends Element {
static type = 'brand';
static elementClassName = 'CardBrandElement';
}
6 changes: 4 additions & 2 deletions lib/recurly/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Emitter from 'component-emitter';
import errors from './errors';
import { factory as cardElementFactory, CardElement } from './element/card';
import { factory as cardNumberElementFactory, CardNumberElement } from './element/card-number';
import { factory as cardBrandElementFactory, CardBrandElement } from './element/card-brand';
import { factory as cardMonthElementFactory, CardMonthElement } from './element/card-month';
import { factory as cardYearElementFactory, CardYearElement } from './element/card-year';
import { factory as cardCvvElementFactory, CardCvvElement } from './element/card-cvv';
Expand All @@ -26,13 +27,14 @@ export function factory (options) {
export default class Elements extends Emitter {
CardElement = cardElementFactory;
CardNumberElement = cardNumberElementFactory;
CardBrandElement = cardBrandElementFactory;
CardMonthElement = cardMonthElementFactory;
CardYearElement = cardYearElementFactory;
CardCvvElement = cardCvvElementFactory;

static VALID_SETS = [
[ CardElement ],
[ CardNumberElement, CardMonthElement, CardYearElement, CardCvvElement ]
[ CardElement, CardBrandElement ],
[ CardNumberElement, CardBrandElement, CardMonthElement, CardYearElement, CardCvvElement ]
];

constructor ({ recurly }) {
Expand Down
2 changes: 1 addition & 1 deletion lib/recurly/hosted-fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { HostedField } from './hosted-field';

const debug = require('debug')('recurly:hostedFields');

export const FIELD_TYPES = ['number', 'month', 'year', 'cvv', 'card'];
export const FIELD_TYPES = ['number', 'month', 'year', 'cvv', 'card', 'brand'];

/**
* HostedFields
Expand Down
Loading

0 comments on commit 1e0d6e2

Please sign in to comment.