better register messages and stripe payments fix
This commit is contained in:
parent
e69764d294
commit
c4fd68a47f
@ -40,12 +40,12 @@ pub enum MnmlHttpError {
|
||||
BadRequest,
|
||||
#[fail(display="not found")]
|
||||
NotFound,
|
||||
#[fail(display="account name taken or invalid")]
|
||||
AccountNameNotProvided,
|
||||
#[fail(display="account name not provided")]
|
||||
AccountNotFound,
|
||||
AccountNameNotProvided,
|
||||
#[fail(display="account name unavailable")]
|
||||
AccountNameUnavailable,
|
||||
#[fail(display="account not found")]
|
||||
AccountNameTaken,
|
||||
AccountNotFound,
|
||||
#[fail(display="password does not match")]
|
||||
PasswordNotMatch,
|
||||
#[fail(display="password unacceptable. must be > 11 characters")]
|
||||
@ -66,7 +66,21 @@ impl From<bcrypt::BcryptError> for MnmlHttpError {
|
||||
impl From<postgres::Error> for MnmlHttpError {
|
||||
fn from(err: postgres::Error) -> Self {
|
||||
warn!("{:?}", err);
|
||||
MnmlHttpError::DbError
|
||||
|
||||
match err.as_db() {
|
||||
Some(db) => {
|
||||
let constraint = match db.constraint {
|
||||
Some(ref c) => c,
|
||||
None => return MnmlHttpError::DbError,
|
||||
};
|
||||
|
||||
match constraint.as_ref() {
|
||||
"accounts_name_unique" => MnmlHttpError::AccountNameUnavailable,
|
||||
_ => MnmlHttpError::DbError,
|
||||
}
|
||||
},
|
||||
_ => MnmlHttpError::DbError,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,7 +123,7 @@ impl From<MnmlHttpError> for IronError {
|
||||
MnmlHttpError::DbError => (m_err.compat(), status::InternalServerError),
|
||||
|
||||
MnmlHttpError::AccountNameNotProvided |
|
||||
MnmlHttpError::AccountNameTaken |
|
||||
MnmlHttpError::AccountNameUnavailable |
|
||||
MnmlHttpError::AccountNotFound |
|
||||
MnmlHttpError::BadRequest |
|
||||
MnmlHttpError::PasswordUnacceptable => (m_err.compat(), status::BadRequest),
|
||||
|
||||
@ -164,9 +164,15 @@ impl StripeData {
|
||||
Ok(self)
|
||||
},
|
||||
StripeData::Purchase { account, customer: _, amount, checkout: _ } => {
|
||||
let credits = amount
|
||||
let credits = match amount {
|
||||
500 => 50,
|
||||
1000 => 110,
|
||||
2000 => 250,
|
||||
5000 => 660,
|
||||
_ => amount
|
||||
.checked_div(CREDITS_COST_CENTS)
|
||||
.expect("credits cost 0");
|
||||
.expect("credits cost 0"),
|
||||
};
|
||||
|
||||
account::credit(tx, *account, credits)?;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user