Skip to content

Commit

Permalink
refactor(core): Refactor customer pml for v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarthak1799 committed Jun 3, 2024
1 parent 971ef1f commit b88e259
Show file tree
Hide file tree
Showing 9 changed files with 362 additions and 136 deletions.
2 changes: 1 addition & 1 deletion crates/api_models/src/payment_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ pub struct CustomerDefaultPaymentMethodResponse {
pub struct CustomerPaymentMethod {
/// Token for payment method in temporary card locker which gets refreshed often
#[schema(example = "7ebf443f-a050-4067-84e5-e6f6d4800aef")]
pub payment_token: String,
pub payment_token: Option<String>,
/// The unique identifier of the customer.
#[schema(example = "pm_iouuy468iyuowqs")]
pub payment_method_id: String,
Expand Down
3 changes: 2 additions & 1 deletion crates/router/src/compatibility/stripe/customers/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,11 @@ impl From<api::CustomerPaymentMethodsListResponse> for CustomerPaymentMethodList
}
}

// Check this in review
impl From<api_types::CustomerPaymentMethod> for PaymentMethodData {
fn from(item: api_types::CustomerPaymentMethod) -> Self {
Self {
id: item.payment_token,
id: item.payment_token.unwrap_or("".to_string()),
object: "payment_method",
card: item.card.map(From::from),
created: item.created,
Expand Down
12 changes: 7 additions & 5 deletions crates/router/src/core/payment_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,13 @@ pub async fn retrieve_payment_method_with_token(
.unwrap_or_default()
}

storage::PaymentTokenData::WalletToken(_) => storage::PaymentMethodDataWithId {
payment_method: None,
payment_method_data: None,
payment_method_id: None,
},
storage::PaymentTokenData::WalletToken(_) | storage::PaymentTokenData::Null => {
storage::PaymentMethodDataWithId {
payment_method: None,
payment_method_data: None,
payment_method_id: None,
}
}
};
Ok(token)
}
Loading

0 comments on commit b88e259

Please sign in to comment.