-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat(core): consume card details from billing connectors and first error codes and store them in payment intent table #8250
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
Changes from 85 commits
809da65
8f160b0
bd411f5
2e02b84
fd47398
4a82642
dd531f9
01d98a0
653cd5d
6cae8e1
787912a
a5c5d9a
da18869
f5d5294
826202a
d03c564
24dac12
a4262c7
71ec2bc
3b04911
44e5a18
75ef438
c53b310
0479693
4227dfb
69d5d24
6764550
2fe86f9
3142502
49f7a22
b4c7e71
a9899b5
e93d5a7
5aaaea6
da5a505
d75b207
c9f7aa6
9bebc57
86c9715
272c416
7378787
23ed82c
23e13fa
9e30a2a
eaf1e40
b154311
d2e3caa
1110062
7170f7a
79d8e64
964fd78
fda03ea
3e619b7
054bf7f
f916cb5
f0fe9d5
1fdab57
e1483a3
264766f
4c0503d
4386261
a4aac2a
1bdedf7
98aeceb
f478efb
38378f9
d4b6025
b7fc94e
ad3beaa
c6ed016
49e68b5
35eae6a
9770ff6
bd1913e
f89bf01
88671ca
ffd75fe
2b1d402
401c7b5
aa325bd
feb3f88
89405fb
5cead6b
5de0d97
1b768bf
ba0f74d
35fa8ce
f3475b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8684,9 +8684,41 @@ pub struct PaymentRevenueRecoveryMetadata { | |
/// The name of the payment connector through which the payment attempt was made. | ||
#[schema(value_type = Connector, example = "stripe")] | ||
pub connector: common_enums::connector_enums::Connector, | ||
#[schema(value_type = BillingConnectorPaymentMethodDetails)] | ||
/// Extra Payment Method Details that are needed to be stored | ||
pub billing_connector_payment_method_details: Option<BillingConnectorPaymentMethodDetails>, | ||
/// Invoice Next billing time | ||
#[serde(default, with = "common_utils::custom_serde::iso8601::option")] | ||
pub invoice_next_billing_time: Option<PrimitiveDateTime>, | ||
/// First Payment Attempt Payment Gateway Error Code | ||
#[schema(value_type = Option<String>, example = "card_declined")] | ||
pub first_payment_attempt_pg_error_code: Option<String>, | ||
/// First Payment Attempt Network Error Code | ||
#[schema(value_type = Option<String>, example = "05")] | ||
pub first_payment_attempt_network_decline_code: Option<String>, | ||
/// First Payment Attempt Network Advice Code | ||
#[schema(value_type = Option<String>, example = "02")] | ||
pub first_payment_attempt_network_advice_code: Option<String>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need network error message? if not, why are we not including ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Network decline code is Network error code |
||
} | ||
|
||
#[cfg(feature = "v2")] | ||
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, ToSchema)] | ||
#[serde(tag = "type", content = "value")] | ||
pub enum BillingConnectorPaymentMethodDetails { | ||
Card(BillingConnectorAdditionalCardInfo), | ||
} | ||
|
||
#[cfg(feature = "v2")] | ||
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, ToSchema)] | ||
pub struct BillingConnectorAdditionalCardInfo { | ||
#[schema(value_type = CardNetwork, example = "Visa")] | ||
/// Card Network | ||
pub card_network: Option<common_enums::enums::CardNetwork>, | ||
#[schema(value_type = Option<String>, example = "JP MORGAN CHASE")] | ||
/// Card Issuer | ||
pub card_issuer: Option<String>, | ||
} | ||
|
||
#[cfg(feature = "v2")] | ||
impl PaymentRevenueRecoveryMetadata { | ||
pub fn set_payment_transmission_field_for_api_request( | ||
|
@@ -8800,6 +8832,14 @@ pub struct PaymentsAttemptRecordRequest { | |
/// source where the payment was triggered by | ||
#[schema(value_type = TriggeredBy, example = "internal" )] | ||
pub triggered_by: common_enums::TriggeredBy, | ||
|
||
#[schema(value_type = CardNetwork, example = "Visa" )] | ||
/// card_network | ||
pub card_network: Option<common_enums::CardNetwork>, | ||
jarnura marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#[schema(example = "Chase")] | ||
/// Card Issuer | ||
pub card_issuer: Option<String>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this bin or issuer name ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its issuer name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you please change relevent comment then |
||
} | ||
|
||
/// Error details for the payment | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -439,14 +439,15 @@ pub struct StripebillingLatestChargeData { | |
pub payment_method_details: StripePaymentMethodDetails, | ||
#[serde(rename = "invoice")] | ||
pub invoice_id: String, | ||
pub payment_intent: String, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
pub struct StripePaymentMethodDetails { | ||
#[serde(rename = "type")] | ||
pub type_of_payment_method: StripebillingPaymentMethod, | ||
#[serde(rename = "card")] | ||
pub card_funding_type: StripeCardFundingTypeDetails, | ||
pub card_details: StripeBillingCardDetails, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone, Copy)] | ||
|
@@ -456,10 +457,31 @@ pub enum StripebillingPaymentMethod { | |
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
pub struct StripeCardFundingTypeDetails { | ||
pub struct StripeBillingCardDetails { | ||
pub network: StripebillingCardNetwork, | ||
pub funding: StripebillingFundingTypes, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone, Copy)] | ||
#[serde(rename_all = "snake_case")] | ||
pub enum StripebillingCardNetwork { | ||
Visa, | ||
Mastercard, | ||
AmericanExpress, | ||
JCB, | ||
DinersClub, | ||
Discover, | ||
CartesBancaires, | ||
UnionPay, | ||
Interac, | ||
RuPay, | ||
Maestro, | ||
Star, | ||
Pulse, | ||
Accel, | ||
Nyce, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone, Copy)] | ||
#[serde(rename = "snake_case")] | ||
pub enum StripebillingFundingTypes { | ||
|
@@ -509,7 +531,7 @@ impl | |
field_name: "invoice_id", | ||
})?; | ||
let connector_transaction_id = Some(common_utils::types::ConnectorTransactionId::from( | ||
charge_details.charge_id, | ||
charge_details.payment_intent, | ||
)); | ||
|
||
Ok(Self { | ||
|
@@ -529,14 +551,16 @@ impl | |
connector_customer_id: charge_details.customer, | ||
transaction_created_at: Some(charge_details.created), | ||
payment_method_sub_type: common_enums::PaymentMethodType::from( | ||
charge_details | ||
.payment_method_details | ||
.card_funding_type | ||
.funding, | ||
charge_details.payment_method_details.card_details.funding, | ||
), | ||
payment_method_type: common_enums::PaymentMethod::from( | ||
charge_details.payment_method_details.type_of_payment_method, | ||
), | ||
card_network: Some(common_enums::CardNetwork::from( | ||
charge_details.payment_method_details.card_details.network, | ||
)), | ||
// Todo: Fetch Card issuer details. Generally in the other billing connector we are getting card_issuer using the card bin info. But stripe dosent provide any such details. We should find a way for stripe billing case | ||
card_isin: None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add comment how we are planning to fetch card_isin ? |
||
}, | ||
), | ||
..item.data | ||
|
@@ -611,3 +635,25 @@ impl | |
}) | ||
} | ||
} | ||
|
||
impl From<StripebillingCardNetwork> for enums::CardNetwork { | ||
fn from(item: StripebillingCardNetwork) -> Self { | ||
match item { | ||
StripebillingCardNetwork::Visa => Self::Visa, | ||
StripebillingCardNetwork::Mastercard => Self::Mastercard, | ||
StripebillingCardNetwork::AmericanExpress => Self::AmericanExpress, | ||
StripebillingCardNetwork::JCB => Self::JCB, | ||
StripebillingCardNetwork::DinersClub => Self::DinersClub, | ||
StripebillingCardNetwork::Discover => Self::Discover, | ||
StripebillingCardNetwork::CartesBancaires => Self::CartesBancaires, | ||
StripebillingCardNetwork::UnionPay => Self::UnionPay, | ||
StripebillingCardNetwork::Interac => Self::Interac, | ||
StripebillingCardNetwork::RuPay => Self::RuPay, | ||
StripebillingCardNetwork::Maestro => Self::Maestro, | ||
StripebillingCardNetwork::Star => Self::Star, | ||
StripebillingCardNetwork::Pulse => Self::Pulse, | ||
StripebillingCardNetwork::Accel => Self::Accel, | ||
StripebillingCardNetwork::Nyce => Self::Nyce, | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Align naming and description for network error code
The key
first_payment_attempt_network_decline_code
uses “decline” but the description reads “Network Error Code.” For consistency, either rename the field tofirst_payment_attempt_network_error_code
or adjust the description to “Network Decline Code.” Example renaming diff:📝 Committable suggestion
🤖 Prompt for AI Agents