Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(core): Refactor customer payment method list for v2 #4856

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Next Next commit
refactor(core): Refactor customer pml for v2
  • Loading branch information
Sarthak1799 committed Jun 3, 2024
commit b88e259ccf8026f0d9b9701479044c5db10a2723
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()),
Sarthak1799 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading