Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions ft-sdk/src/auth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,6 @@ fn get_debug_ud() -> Option<ft_sys::UserData> {
}
}

// This is hack to keep mobile number as email.
pub fn mobile_to_email(mobile_number: &str) -> String {
format!("{mobile_number}@mobile.fifthtry.com")
}
// This is hack to keep mobile number as email.
pub fn mobile_from_email(email: &str) -> Option<String> {
email
.strip_suffix("@mobile.fifthtry.com")
.map(|s| s.to_string())
}

#[derive(Debug, thiserror::Error)]
pub enum UserDataError {
#[error("no data found for the provider")]
Expand Down
9 changes: 8 additions & 1 deletion ft-stripe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub fn create_customer(
let user_data = ft_sdk::auth::ud_from_session_key(conn, session_id)?
.ok_or_else(|| CreateCustomerError::UserNotFound)?;

let body = match ft_sdk::auth::mobile_from_email(user_data.email.as_str()) {
let body = match mobile_from_email(user_data.email.as_str()) {
Some(phone) => serde_json::json!({"phone": phone}),
None => serde_json::json!({"email": user_data.email}),
};
Expand Down Expand Up @@ -65,3 +65,10 @@ pub enum CreateCustomerError {
#[error("Cannot create customer: {0}")]
CannotCreateCustomer(String),
}

// This is hack to keep mobile number as email. We need to soon remove this.
fn mobile_from_email(email: &str) -> Option<String> {
email
.strip_suffix("@mobile.fifthtry.com")
.map(|s| s.to_string())
}