feat(cards): add credit card number validation (#889)

Co-authored-by: Sanchith Hegde <sanchith.hegde@juspay.in>
This commit is contained in:
phillyphil91
2023-05-09 16:30:50 +02:00
committed by GitHub
parent 0bb0437b7f
commit d6e71b959d
79 changed files with 381 additions and 684 deletions

View File

@ -33,3 +33,4 @@ common_utils = { version = "0.1.0", path = "../common_utils" }
masking = { version = "0.1.0", path = "../masking" }
router_derive = { version = "0.1.0", path = "../router_derive" }
common_enums = {path = "../common_enums"}
cards = { version = "0.1.0", path = "../cards" }

View File

@ -1,3 +1,4 @@
use cards::CardNumber;
use common_utils::pii;
use serde::de;
use utoipa::ToSchema;
@ -72,7 +73,7 @@ pub struct PaymentMethodUpdate {
pub struct CardDetail {
/// Card Number
#[schema(value_type = String,example = "4111111145551142")]
pub card_number: masking::Secret<String, pii::CardNumber>,
pub card_number: CardNumber,
/// Card Expiry Month
#[schema(value_type = String,example = "10")]
@ -142,7 +143,7 @@ pub struct CardDetailFromLocker {
pub last4_digits: Option<String>,
#[serde(skip)]
#[schema(value_type=Option<String>)]
pub card_number: Option<masking::Secret<String, pii::CardNumber>>,
pub card_number: Option<CardNumber>,
#[schema(value_type=Option<String>)]
pub expiry_month: Option<masking::Secret<String>>,

View File

@ -1,5 +1,6 @@
use std::num::NonZeroI64;
use cards::CardNumber;
use common_utils::{pii, pii::Email};
use masking::{PeekInterface, Secret};
use router_derive::Setter;
@ -415,7 +416,7 @@ pub struct OnlineMandate {
pub struct Card {
/// The card number
#[schema(value_type = String, example = "4242424242424242")]
pub card_number: Secret<String, pii::CardNumber>,
pub card_number: CardNumber,
/// The card's expiry month
#[schema(value_type = String, example = "24")]
@ -580,7 +581,7 @@ pub enum BankRedirectData {
BancontactCard {
/// The card number
#[schema(value_type = String, example = "4242424242424242")]
card_number: Secret<String, pii::CardNumber>,
card_number: CardNumber,
/// The card's expiry month
#[schema(value_type = String, example = "24")]
card_exp_month: Secret<String>,