Skip to content

Conversation

deepanshu-iiitu
Copy link
Contributor

@deepanshu-iiitu deepanshu-iiitu commented Dec 26, 2023

Type of Change

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

Description

We need to populate the merchant_defined_information for each payment with data coming from merchant in payment requests metadata.
VAS PR: https://github.com/juspay/hyperswitch-cloud/pull/3715

Additional Changes

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

Motivation and Context

https://github.com/juspay/hyperswitch-cloud/issues/3713

How did you test it?

Testing can be done by creating a card/gpay/applepay payment and by passing the following metadata in PAYMENTS-CREATE:
"metadata": { "count_tickets": 1, "transaction_number": "5590043" }

You should then be able to see the metadata on BOA dashboard for that payment:
Screenshot 2023-12-26 at 8 34 14 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

@deepanshu-iiitu deepanshu-iiitu requested review from a team as code owners December 26, 2023 15:01
@deepanshu-iiitu deepanshu-iiitu self-assigned this Dec 26, 2023
@deepanshu-iiitu deepanshu-iiitu added A-connector-integration Area: Connector integration C-feature Category: Feature request or enhancement labels Dec 26, 2023
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct MerchantDefinedInformation {
key: u64,
Copy link
Contributor

@ArjunKarthik ArjunKarthik Dec 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u8 is sufficient

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function vector.length() return length as u64 and that is why I have mapped it this way. Should I change it?

Copy link
Contributor

@ArjunKarthik ArjunKarthik Dec 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need vector.length(), you can declare a u8 variable initialize it to 1 and increment it while iterating through loop

fn foreign_from(metadata: Value) -> Self {
let m: HashMap<String, Value> =
serde_json::from_str(&metadata.to_string()).unwrap_or(HashMap::new());
let mut v: Self = Self::new();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use proper naming for the variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

let size = v.length() + 1;
v.push(MerchantDefinedInformation {
key: size,
value: format!("{key} = {value}"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use delimiter without space.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@ArjunKarthik ArjunKarthik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one minor comment

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Dec 27, 2023
Merged via the queue into main with commit 18eca7e Dec 27, 2023
@Gnanasundari24 Gnanasundari24 deleted the boa-cyb-add-meta branch December 27, 2023 13:19
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-feature Category: Feature request or enhancement
Projects
No open projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

4 participants