return v4 uuid for paymentservice
This commit is contained in:
parent
cb6a105b51
commit
d37c0841ce
3 changed files with 10 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
|||
const cardValidator = require('simple-card-validator');
|
||||
const uuid = require('uuid/v4');
|
||||
|
||||
class CreditCardError extends Error {
|
||||
constructor(message) {
|
||||
|
@ -29,7 +30,7 @@ class ExpiredCreditCard extends CreditCardError {
|
|||
* Verifies the credit card number and (pretend) charges the card.
|
||||
*
|
||||
* @param {*} request
|
||||
* @return transaction_id - a random number.
|
||||
* @return transaction_id - a random uuid v4.
|
||||
*/
|
||||
module.exports = function charge(request) {
|
||||
const { amount, credit_card: creditCard } = request;
|
||||
|
@ -59,6 +60,6 @@ module.exports = function charge(request) {
|
|||
console.log(`Transaction processed: ${cardType} ending ${cardNumber.substr(-4)} \
|
||||
Amount: ${amount.currency_code}${amount.amount.decimal}.${amount.amount.fractional}`)
|
||||
|
||||
return { transaction_id: -1 }
|
||||
return { transaction_id: uuid() }
|
||||
}
|
||||
|
||||
|
|
5
src/paymentservice/package-lock.json
generated
5
src/paymentservice/package-lock.json
generated
|
@ -746,6 +746,11 @@
|
|||
"ansi-regex": "2.1.1"
|
||||
}
|
||||
},
|
||||
"uuid": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz",
|
||||
"integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA=="
|
||||
},
|
||||
"window-size": {
|
||||
"version": "0.1.4",
|
||||
"resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.4.tgz",
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
"dependencies": {
|
||||
"@grpc/proto-loader": "^0.1.0",
|
||||
"grpc": "^1.12.3",
|
||||
"simple-card-validator": "^1.1.0"
|
||||
"simple-card-validator": "^1.1.0",
|
||||
"uuid": "^3.2.1"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue