-
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
refactor(connector): [Iatapay] refactor authorize flow and fix payment status mapping #2409
Conversation
.change_context(errors::ConnectorError::WebhookReferenceIdNotFound)?; | ||
match notif { | ||
iatapay::IatapayWebhookResponse::IatapayPaymentWebhookBody(wh_body) => { | ||
Ok(api_models::webhooks::ObjectReferenceId::PaymentId( |
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.
do we get our payment reference In response?
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.
yes, I have updated with merchant_payment_id (our payment id) and fall back is the iatapay_payment_id
} | ||
iatapay::IatapayWebhookResponse::IatapayRefundWebhookBody(wh_body) => { | ||
Ok(api_models::webhooks::ObjectReferenceId::RefundId( | ||
api_models::webhooks::RefundIdType::ConnectorRefundId(wh_body.iata_refund_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.
do we get our refund reference In response?
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.
yes, I have updated with merchant_refund_id (our ref id) and fall back is the iatapay_refund_id
} | ||
iatapay::IatapayWebhookResponse::IatapayRefundWebhookBody(wh_body) => { | ||
match wh_body.status { | ||
iatapay::IatapayWebhookStatus::Authorized => { |
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.
refund and payment status seems alike, do we have separate status for both?
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.
yes, few status are same!
#[derive(Debug, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct IatapayPaymentWebhookBody { | ||
pub status: IatapayWebhookStatus, |
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.
incase of payment failure error_message, error_code and error_reason should be captured
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.
we are already doing this for payments!
#[derive(Debug, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct IatapayRefundWebhookBody { | ||
pub status: IatapayWebhookStatus, |
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.
incase of refund failure error_message, error_code and error_reason should be captured
iatapay::IatapayWebhookResponse::IatapayRefundWebhookBody(wh_body) => { | ||
match wh_body.merchant_refund_id { | ||
Some(merchant_refund_id) => { | ||
Ok(api_models::webhooks::ObjectReferenceId::PaymentId( |
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.
This should be RefundId not PaymentId
@@ -53,7 +55,7 @@ impl<T> | |||
), | |||
) -> Result<Self, Self::Error> { | |||
Ok(Self { | |||
amount: utils::to_currency_base_unit_asf64(_amount, _currency)?, | |||
amount: connector_util::to_currency_base_unit_asf64(_amount, _currency)?, |
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.
_
is used before an unused variable name, if we are consuming or passing it as an argument, it should not start with an _
Type of Change
Description
Test cases - 1. Make a payment, and refund, webhooks.
Fixed Payment Status mapping.
Note - Iatapay Payment Status is mapped to "Authorized", since they have mentioned that ticket can be issue once we get this status in docs
Closes issue - 2439
Additional Changes
Motivation and Context
How did you test it?
make a upi payment via iatapay, webhooks should work expected.
payment -
psync -
refund -
rsync -
Checklist
cargo +nightly fmt --all
cargo clippy