-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat: PG Agnostic mandate using network_txns_id (Adyen, Authorizedotnet, Stripe) #855
Conversation
@@ -298,14 +298,20 @@ pub enum MandateTxnType { | |||
#[derive(Default, Eq, PartialEq, Debug, serde::Deserialize, serde::Serialize, Clone)] | |||
pub struct MandateIds { | |||
pub mandate_id: String, | |||
pub connector_mandate_id: Option<String>, | |||
pub mandate_reference_id: Option<MandateReferenceId>, |
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.
Add comments for the ids
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.
sure
crates/router/src/core/mandate.rs
Outdated
) { | ||
let connector = new_mandate_data.connector.clone(); | ||
logger::debug!("{:?}", new_mandate_data); | ||
resp.request | ||
.set_mandate_id(api_models::payments::MandateIds { | ||
mandate_id: new_mandate_data.mandate_id.clone(), | ||
connector_mandate_id: new_mandate_data.connector_mandate_id.clone(), | ||
mandate_reference_id: None, //This is not used further in case needed please handle |
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.
just pass the value based on match logic
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.
ok
api::PaymentMethodData::Card(ref ccard) => { | ||
let payment_details = PaymentDetails::CreditCard(CreditCardDetails { | ||
card_number: ccard.card_number.clone(), | ||
// expiration_date: format!("{expiry_year}-{expiry_month}").into(), |
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.
remove commented code
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.
sure, it was there before maybe for some reference
@@ -4,7 +4,7 @@ use reqwest::Url; | |||
use serde::{Deserialize, Serialize}; | |||
|
|||
use crate::{ | |||
connector::utils::PaymentsAuthorizeRequestData, | |||
connector::utils::{missing_field_err, PaymentsAuthorizeRequestData}, |
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.
Remove missing_field_err in imports and use like utils::missing_field_err
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.
done
expiry_month: card.card_exp_month.clone(), | ||
expiry_year: card.card_exp_year.clone(), | ||
cvc: None, | ||
brand: Some(CardBrand::Visa), //Fixme |
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.
Explain the problem for FIXME. If there is a issue already linked add the issue here.
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.
handled
expiry_month: card.card_exp_month.clone(), | ||
expiry_year: card.card_exp_year.clone(), | ||
cvc: None, | ||
brand: Some(CardBrand::Visa), //Fixme |
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.
And we can't go with Hard coding the CardBrand.
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.
@manoj-juspay there is a method get_card_issuer
in connector/utils check if that can solve this issue. if not add one in the existing utils to work for your case
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.
sure bro
@@ -246,6 +266,16 @@ pub struct AdyenCard { | |||
expiry_month: Secret<String>, | |||
expiry_year: Secret<String>, | |||
cvc: Option<Secret<String>>, | |||
brand: Option<CardBrand>, //Mandatory for mandate using network_txns_id | |||
network_payment_reference: Option<String>, // |
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.
remove empty comment
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.
ok
let customer_id = item | ||
.customer_id | ||
.to_owned() | ||
.ok_or_else(missing_field_err("customer_id"))?; |
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.
move this to src/connector/utils.rs RouterData
trait add a method get_customer_id which will throw error if it is not present
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.
sure
expiry_month: card.card_exp_month.clone(), | ||
expiry_year: card.card_exp_year.clone(), | ||
cvc: None, | ||
brand: Some(CardBrand::Visa), //Fixme |
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.
@manoj-juspay there is a method get_card_issuer
in connector/utils check if that can solve this issue. if not add one in the existing utils to work for your case
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.
Add required labels.
.connector_customer | ||
.connector_list | ||
.contains(&connector.connector_name); | ||
if connector_customer_filter { |
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.
Add comments for None and else cases.
Type of Change
Description
Implemented Adyen mandate using connector_mandate_id
https://juspay.atlassian.net/browse/HYP-37
Additional Changes
Motivation and Context
How did you test it?
Setup mandate followed by recurring payment
Checklist
cargo +nightly fmt --all
cargo clippy