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(connector): [Iatapay] refactor authorize flow and fix payment status mapping #2409

Merged
merged 16 commits into from
Jan 25, 2024

Conversation

prasunna09
Copy link
Contributor

@prasunna09 prasunna09 commented Oct 1, 2023

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

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
Screenshot 2023-10-02 at 2 44 40 PM
Screenshot 2024-01-23 at 1 10 53 PM

Closes issue - 2439

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

How did you test it?

make a upi payment via iatapay, webhooks should work expected.
payment -
Screenshot 2024-01-12 at 4 05 07 PM
psync -
Screenshot 2024-01-12 at 4 06 54 PM
refund -
Screenshot 2024-01-12 at 4 07 19 PM
rsync -
Screenshot 2024-01-12 at 4 07 27 PM

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible
  • I added a CHANGELOG entry if applicable

@prasunna09 prasunna09 added A-connector-integration Area: Connector integration S-waiting-on-review Status: This PR has been implemented and needs to be reviewed C-refactor Category: Refactor labels Oct 1, 2023
@prasunna09 prasunna09 requested a review from a team as a code owner October 1, 2023 18:49
@prasunna09 prasunna09 self-assigned this Oct 1, 2023
@ArjunKarthik ArjunKarthik added S-waiting-on-author Status: This PR is incomplete or needs to address review comments S-needs-conflict-resolution Status: This PR needs conflicts to be resolved by the author labels Oct 23, 2023
.change_context(errors::ConnectorError::WebhookReferenceIdNotFound)?;
match notif {
iatapay::IatapayWebhookResponse::IatapayPaymentWebhookBody(wh_body) => {
Ok(api_models::webhooks::ObjectReferenceId::PaymentId(
Copy link
Contributor

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?

Copy link
Contributor Author

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),
Copy link
Contributor

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?

Copy link
Contributor Author

@prasunna09 prasunna09 Jan 18, 2024

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

crates/router/src/connector/iatapay.rs Outdated Show resolved Hide resolved
crates/router/src/connector/iatapay.rs Outdated Show resolved Hide resolved
crates/router/src/connector/iatapay.rs Outdated Show resolved Hide resolved
}
iatapay::IatapayWebhookResponse::IatapayRefundWebhookBody(wh_body) => {
match wh_body.status {
iatapay::IatapayWebhookStatus::Authorized => {
Copy link
Contributor

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?

Copy link
Contributor Author

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,
Copy link
Contributor

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

Copy link
Contributor Author

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,
Copy link
Contributor

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

@prasunna09 prasunna09 removed S-waiting-on-review Status: This PR has been implemented and needs to be reviewed S-needs-conflict-resolution Status: This PR needs conflicts to be resolved by the author labels Jan 18, 2024
iatapay::IatapayWebhookResponse::IatapayRefundWebhookBody(wh_body) => {
match wh_body.merchant_refund_id {
Some(merchant_refund_id) => {
Ok(api_models::webhooks::ObjectReferenceId::PaymentId(
Copy link
Contributor

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

ArjunKarthik
ArjunKarthik previously approved these changes Jan 23, 2024
@@ -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)?,
Copy link
Contributor

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 _

@likhinbopanna likhinbopanna added this pull request to the merge queue Jan 25, 2024
Merged via the queue into main with commit f0c7bb9 Jan 25, 2024
10 checks passed
@likhinbopanna likhinbopanna deleted the refactor-iatapay branch January 25, 2024 07:19
@SanchithHegde SanchithHegde removed the S-waiting-on-author Status: This PR is incomplete or needs to address review comments label Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-connector-integration Area: Connector integration C-refactor Category: Refactor
Projects
No open projects
Status: Under Development
Development

Successfully merging this pull request may close these issues.

5 participants