SB-6.1-PRE
This commit is contained in:
1 parent
690169a409
commit
358a25f522
3760 files changed
+300059
-36
No files matched your search
+37
@@ -0,0 +1,37 @@
|
||||
# cc
|
||||
|
||||
```js
|
||||
// usage
|
||||
chance.cc()
|
||||
chance.cc({type: 'Mastercard'})
|
||||
```
|
||||
|
||||
<p class="pullquote" data-pullquote='Somewhat obvious warning: Do not use this to hit live payment gateways...' markdown="1"></p>
|
||||
|
||||
Generate a random credit card number. This card number will pass the
|
||||
[Luhn algorithm][Luhn] so it looks like a legit card.
|
||||
|
||||
```js
|
||||
chance.cc();
|
||||
=> '6304038511073827'
|
||||
```
|
||||
|
||||
Optionally specify a particular type of card to return:
|
||||
|
||||
```js
|
||||
chance.cc({type: 'Mastercard'});
|
||||
=> '5171206237468496'
|
||||
```
|
||||
|
||||
The type can be specified by the long name, or by the short name:
|
||||
|
||||
```js
|
||||
chance.cc({type: 'mc'});
|
||||
=> '5103820202214116'
|
||||
```
|
||||
|
||||
|
||||
The [types][types] are enumerated below.
|
||||
|
||||
[Luhn]: http://en.wikipedia.org/wiki/Luhn_algorithm
|
||||
[types]: #cc_type
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
# cc_type
|
||||
|
||||
```js
|
||||
// usage
|
||||
chance.cc_type()
|
||||
chance.cc_type({raw: true})
|
||||
```
|
||||
|
||||
Return a random credit card type.
|
||||
|
||||
```js
|
||||
chance.cc_type();
|
||||
=> 'Visa'
|
||||
```
|
||||
|
||||
Default returns just the name. To return the entire object (consisting of name,
|
||||
short name, numeric prefix, and length), specify so with the raw flag.
|
||||
|
||||
```js
|
||||
chance.cc_type({raw: true});
|
||||
=> {name: 'Discover Card', short_name: 'discover', prefix: '6011', length: 16}
|
||||
```
|
||||
|
||||
The available types are (name - *short_name*):
|
||||
|
||||
* American Express - *amex*
|
||||
* Bankcard - *bankcard*
|
||||
* China UnionPay - *chinaunion*
|
||||
* Diners Club Carte Blanche - *dccarte*
|
||||
* Diners Club enRoute - *dcenroute*
|
||||
* Diners Club International - *dcintl*
|
||||
* Diners Club United States & Canada - *dcusc*
|
||||
* Discover Card - *discover*
|
||||
* InstaPayment - *instapay*
|
||||
* JCB - *jcb*
|
||||
* Laser - *laser*
|
||||
* Maestro - *maestro*
|
||||
* Mastercard - *mc*
|
||||
* Solo - *solo*
|
||||
* Switch - *switch*
|
||||
* Visa - *visa*
|
||||
* Visa Electron - *electron*
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
# currency
|
||||
|
||||
```js
|
||||
// usage
|
||||
chance.currency()
|
||||
```
|
||||
|
||||
Generate a random currency.
|
||||
|
||||
```js
|
||||
chance.currency();
|
||||
=> { code: "TVD", name: "Tuvalu Dollar" }
|
||||
```
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
# currency_pair
|
||||
|
||||
```js
|
||||
// usage
|
||||
chance.currency_pair()
|
||||
```
|
||||
|
||||
Generate a currency pair. Handy for simulating currency conversions. Guaranteed to return a unique pair (and not the same currency twice).
|
||||
|
||||
```js
|
||||
chance.currency_pair();
|
||||
=> [{ code: "ALL", name: "Albania Lek" }, { code: "ZWD", name: "Zimbabwe Dollar" }]
|
||||
```
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
# dollar
|
||||
|
||||
```js
|
||||
// usage
|
||||
chance.dollar()
|
||||
chance.dollar({max: 250})
|
||||
```
|
||||
|
||||
<p class="pullquote" data-pullquote="Dolla, dolla, bill ya'll" markdown="1"></p>
|
||||
|
||||
Return a random dollar amount.
|
||||
|
||||
```js
|
||||
chance.dollar();
|
||||
=> "$2560.27"
|
||||
|
||||
chance.dollar();
|
||||
=> "$750.99"
|
||||
```
|
||||
|
||||
By default returns dollar amount no larger than 10000. Optionally specify
|
||||
the max to make it larger (or smaller).
|
||||
|
||||
```js
|
||||
chance.dollar({max: 20});
|
||||
=> "$15.23"
|
||||
|
||||
chance.dollar({max: 10000000})
|
||||
=> "$5051205.49"
|
||||
```
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
# euro
|
||||
|
||||
```js
|
||||
// usage
|
||||
chance.euro()
|
||||
chance.euro({max: 250})
|
||||
```
|
||||
|
||||
Return a random euro amount. Formatting depends on the current locale (samples are displayed with european formatting)
|
||||
|
||||
```js
|
||||
chance.euro();
|
||||
=> "2.560,27€"
|
||||
|
||||
chance.euro();
|
||||
=> "750.99€"
|
||||
```
|
||||
|
||||
By default returns euro amount no larger than 10000. Optionally specify
|
||||
the max to make it larger (or smaller).
|
||||
|
||||
```js
|
||||
chance.euro({max: 20});
|
||||
=> "15,23€"
|
||||
|
||||
chance.euro({max: 10000000})
|
||||
=> "5.051.205,49€"
|
||||
```
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
# exp
|
||||
|
||||
```js
|
||||
// usage
|
||||
chance.exp()
|
||||
chance.exp({raw: true})
|
||||
```
|
||||
|
||||
Generate a random credit card expiration.
|
||||
|
||||
```js
|
||||
chance.exp();
|
||||
=> '10/2020'
|
||||
```
|
||||
|
||||
Optionally specify that a raw object be returned rather than a string
|
||||
|
||||
```js
|
||||
chance.exp({raw: true});
|
||||
=> {month: '11', year: '2017'}
|
||||
```
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
# exp_month
|
||||
|
||||
```js
|
||||
// usage
|
||||
chance.exp_month()
|
||||
chance.exp_month({future: true})
|
||||
```
|
||||
|
||||
Generate a random credit card expiration month.
|
||||
|
||||
```js
|
||||
chance.exp_month();
|
||||
=> '01'
|
||||
```
|
||||
|
||||
Optionally specify that it must be a later month than the current month.
|
||||
|
||||
```js
|
||||
chance.exp_month({future: true});
|
||||
=> '10'
|
||||
```
|
||||
|
||||
So if called in June, this would return a random month from July - Dec. If
|
||||
called in October, would return November or December.
|
||||
|
||||
This because many credit card sandboxes require an expiration date later
|
||||
than the current date so it's necessary when generating an expiration with the
|
||||
current year to generate a month later than the current month.
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
# exp_year
|
||||
|
||||
```js
|
||||
// usage
|
||||
chance.exp_year()
|
||||
```
|
||||
|
||||
Generate a random credit card expiration year.
|
||||
|
||||
```js
|
||||
chance.exp_year();
|
||||
=> '2018'
|
||||
```
|
||||
|
||||
Returns a random year between today and 10 years in the future.
|
||||
Reference in new issue
Block a user