Merge pull request #11 from DavidSouther/regular-errors
Crash behavior for paymentservice
This commit is contained in:
commit
1e6379d45f
2 changed files with 7 additions and 1 deletions
|
@ -59,6 +59,10 @@ def addToCart(l):
|
||||||
|
|
||||||
def checkout(l):
|
def checkout(l):
|
||||||
addToCart(l)
|
addToCart(l)
|
||||||
|
# For five minutes every other hour, credit cards passed by the user will be
|
||||||
|
# invalid and the paymentservice will fail.
|
||||||
|
now = time.localtime()
|
||||||
|
expiration_year = '2015' if (now.tm_hour % 2) & (now.tm_min < 5) else '2060'
|
||||||
l.client.post("/cart/checkout", {
|
l.client.post("/cart/checkout", {
|
||||||
'email': 'someone@example.com',
|
'email': 'someone@example.com',
|
||||||
'street_address': '1600 Amphitheatre Parkway',
|
'street_address': '1600 Amphitheatre Parkway',
|
||||||
|
@ -68,7 +72,7 @@ def checkout(l):
|
||||||
'country': 'United States',
|
'country': 'United States',
|
||||||
'credit_card_number': '4432-8015-6152-0454',
|
'credit_card_number': '4432-8015-6152-0454',
|
||||||
'credit_card_expiration_month': '1',
|
'credit_card_expiration_month': '1',
|
||||||
'credit_card_expiration_year': '2039',
|
'credit_card_expiration_year': expiration_year,
|
||||||
'credit_card_cvv': '672',
|
'credit_card_cvv': '672',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
const cardValidator = require('simple-card-validator');
|
const cardValidator = require('simple-card-validator');
|
||||||
const uuid = require('uuid/v4');
|
const uuid = require('uuid/v4');
|
||||||
const pino = require('pino');
|
const pino = require('pino');
|
||||||
|
const grpc = require('grpc');
|
||||||
|
|
||||||
const logger = pino({
|
const logger = pino({
|
||||||
name: 'paymentservice-charge',
|
name: 'paymentservice-charge',
|
||||||
|
@ -28,6 +29,7 @@ class CreditCardError extends Error {
|
||||||
constructor (message) {
|
constructor (message) {
|
||||||
super(message);
|
super(message);
|
||||||
this.code = 400; // Invalid argument error
|
this.code = 400; // Invalid argument error
|
||||||
|
this.status = grpc.status.INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue