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

fix(connector): [Adyen] ErrorHandling in case of Balance Check for Gift Cards #1976

Merged
merged 13 commits into from
Nov 28, 2023

Conversation

Sakilmostak
Copy link
Contributor

@Sakilmostak Sakilmostak commented Aug 21, 2023

## Type of Change

  • Bugfix

Description

5xx error was being thrown in case of low balance which was unable to show the error to the merchant. Fix include failing the payment along with the error message in case of low balance

How did you test it?

Test cases added:
Success Case:
{ "amount": 4100, "currency": "EUR", "confirm": true, "capture_method": "automatic", "capture_on": "2022-09-10T10:11:12Z", "amount_to_capture": 100, "customer_id": "StripeCustomer", "email": "[email protected]", "name": "John Doe", "phone": "999999999", "phone_country_code": "+1", "description": "Its my first payment request", "authentication_type": "no_three_ds", "return_url": "https://google.com", "payment_method": "gift_card", "payment_method_type": "givex", "payment_method_data": { "gift_card": { "givex": { "number": "6364530000000000", "cvc": "122222" } } }, "billing": { "address": { "line1": "1467", "line2": "Harrison Street", "line3": "Harrison Street", "city": "San Fransico", "state": "California", "zip": "94122", "country": "GB", "first_name": "joseph", "last_name": "Doe" }, "phone": { "number": "8056594427", "country_code": "+91" } }, "browser_info": { "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36", "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "language": "nl-NL", "color_depth": 24, "screen_height": 723, "screen_width": 1536, "time_zone": 0, "java_enabled": true, "java_script_enabled": true, "ip_address": "127.0.0.1" }, "shipping": { "address": { "line1": "1467", "line2": "Harrison Street", "line3": "Harrison Street", "city": "San Fransico", "state": "California", "zip": "94122", "country": "GB", "first_name": "joseph", "last_name": "Doe" }, "phone": { "number": "8056594427", "country_code": "+91" } }, "statement_descriptor_name": "joseph", "statement_descriptor_suffix": "JS", "metadata": { "udf1": "value1", "new_customer": "true", "login_date": "2019-09-10T10:11:12Z" } }
Failure Case:
{ "amount": 14100, "currency": "EUR", "confirm": true, "capture_method": "automatic", "capture_on": "2022-09-10T10:11:12Z", "amount_to_capture": 100, "customer_id": "StripeCustomer", "email": "[email protected]", "name": "John Doe", "phone": "999999999", "phone_country_code": "+1", "description": "Its my first payment request", "authentication_type": "no_three_ds", "return_url": "https://google.com", "payment_method": "gift_card", "payment_method_type": "givex", "payment_method_data": { "gift_card": { "givex": { "number": "6364530000000000", "cvc": "122222" } } }, "billing": { "address": { "line1": "1467", "line2": "Harrison Street", "line3": "Harrison Street", "city": "San Fransico", "state": "California", "zip": "94122", "country": "GB", "first_name": "joseph", "last_name": "Doe" }, "phone": { "number": "8056594427", "country_code": "+91" } }, "browser_info": { "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36", "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "language": "nl-NL", "color_depth": 24, "screen_height": 723, "screen_width": 1536, "time_zone": 0, "java_enabled": true, "java_script_enabled": true, "ip_address": "127.0.0.1" }, "shipping": { "address": { "line1": "1467", "line2": "Harrison Street", "line3": "Harrison Street", "city": "San Fransico", "state": "California", "zip": "94122", "country": "GB", "first_name": "joseph", "last_name": "Doe" }, "phone": { "number": "8056594427", "country_code": "+91" } }, "statement_descriptor_name": "joseph", "statement_descriptor_suffix": "JS", "metadata": { "udf1": "value1", "new_customer": "true", "login_date": "2019-09-10T10:11:12Z" } }
Screenshot 2023-10-05 at 7 29 41 PM
Screenshot 2023-10-05 at 7 29 48 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

@Sakilmostak Sakilmostak added A-connector-integration Area: Connector integration A-core Area: Core flows C-bug Category: Bug A-errors Area: error messages, structure & logging R-waiting-on-L1 Review: Waiting on L1 reviewer labels Aug 21, 2023
@Sakilmostak Sakilmostak self-assigned this Aug 21, 2023
@Sakilmostak Sakilmostak requested review from a team as code owners August 21, 2023 12:59
@ArjunKarthik ArjunKarthik added the S-waiting-on-author Status: This PR is incomplete or needs to address review comments label Sep 27, 2023
@ArjunKarthik
Copy link
Contributor

Please fix the conflicts and add test screenshots

@Sakilmostak Sakilmostak added S-waiting-on-review Status: This PR has been implemented and needs to be reviewed and removed S-waiting-on-author Status: This PR is incomplete or needs to address review comments labels Oct 5, 2023
crates/router/src/connector/adyen/transformers.rs Outdated Show resolved Hide resolved
crates/router/src/connector/adyen.rs Outdated Show resolved Hide resolved
crates/router/src/connector/adyen.rs Outdated Show resolved Hide resolved
crates/router/src/consts.rs Outdated Show resolved Hide resolved
@ArjunKarthik ArjunKarthik added this to the October 2023 Milestone milestone Oct 17, 2023
@ArjunKarthik ArjunKarthik added the S-waiting-on-author Status: This PR is incomplete or needs to address review comments label Oct 23, 2023
ArjunKarthik
ArjunKarthik previously approved these changes Oct 27, 2023
@@ -2867,7 +2879,7 @@ impl TryFrom<types::PaymentsBalanceResponseRouterData<AdyenBalanceResponse>>
}),
payment_method_balance: Some(types::PaymentMethodBalance {
amount: item.response.balance.value,
currency: item.response.balance.currency,
currency: item.response.balance.currency.to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be also changed to storage_enums::Currency

srujanchikke
srujanchikke previously approved these changes Oct 31, 2023
message: consts::NO_ERROR_MESSAGE.to_string(),
reason: Some(consts::LOW_BALANCE_ERROR_MESSAGE.to_string()),
status_code: res.status_code,
attempt_status: None,
Copy link
Contributor

Choose a reason for hiding this comment

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

send failed status

@ArjunKarthik ArjunKarthik removed the S-waiting-on-author Status: This PR is incomplete or needs to address review comments label Nov 28, 2023
@likhinbopanna likhinbopanna added this pull request to the merge queue Nov 28, 2023
@likhinbopanna likhinbopanna removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Nov 28, 2023
Merged via the queue into main with commit bd889c8 Nov 28, 2023
10 of 12 checks passed
@likhinbopanna likhinbopanna deleted the adyen_check_balance branch November 28, 2023 12:21
@SanchithHegde SanchithHegde removed the R-waiting-on-L1 Review: Waiting on L1 reviewer label Dec 3, 2023
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 A-core Area: Core flows A-errors Area: error messages, structure & logging C-bug Category: Bug
Projects
No open projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

6 participants