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