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

feat(connector): [BOA/CYB] Store AVS response in connector_metadata #3271

Merged
merged 16 commits into from
Jan 11, 2024

Conversation

deepanshu-iiitu
Copy link
Contributor

@deepanshu-iiitu deepanshu-iiitu commented Jan 8, 2024

Type of Change

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

Description

This PR contains the following changes for BOA/Cybersource:

  1. The AVS response being sent by BOA/Cybersource for authorize flow is being stored in connector_metadata
  2. In case of payments failing due to AVS check the failure reason will also contain the details of the AVS Check
  3. In case of general failures the response message is used to populate our error reason and response details is used to populate our error message.

Additional Changes

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

Motivation and Context

#3272

How did you test it?

  1. Create a successful payment and verify that avs_response is stored in connector_metadata in db for the payment
image

Curl for creating payment:

curl --location 'https://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: API_KEY_HERE' \
--data-raw '{
  "amount": 1404,
  "currency": "USD",
  "confirm": true,
  "capture_method": "automatic",
  "capture_on": "2022-09-10T10:11:12Z",
  "customer_id": "CustomerX",
  "email": "[email protected]",
  "authentication_type": "no_three_ds",
  "return_url": "https://google.com",
  "payment_method": "card",
  "payment_method_type": "credit",
  "payment_method_data": {
    "card": {
      "card_number": "4111111111111111",
      "card_exp_month": "12",
      "card_exp_year": "30",
      "card_holder_name": "joseph Doe",
      "card_cvc": "029"
    }
  },
  "billing": {
    "address": {
      "line1": "cq",
      "city": "dshcvjhdw",
      "state": "whecvjkcdv",
      "zip": "46205",
      "country": "MW",
      "first_name": "joseph",
      "last_name": "doe"
    },
    "phone": {
      "number": "12345",
      "country_code": "+93"
    }
  },
  "metadata": {
    "count_tickets": 1,
    "transaction_number": "12321"
  },
  "business_label": "food",
  "business_country": "US"
}'

connector_response:

Ok(Ok(Response { headers: Some({"cache-control": "no-cache, no-store, must-revalidate", "pragma": "no-cache", "expires": "-1", "strict-transport-security": "max-age=31536000", "content-type": "application/hal+json", "content-length": "1621", "x-response-time": "1481ms", "x-opnet-transaction-trace": "HIDDEN", "connection": "keep-alive", "v-c-correlation-id": "HIDDEN"}), response: b"{\"_links\":{\"void\":{\"method\":\"POST\",\"href\":\"/pts/v2/payments/7049799548496957104951/voids\"},\"self\":{\"method\":\"GET\",\"href\":\"/pts/v2/payments/7049799548496957104951\"}},\"clientReferenceInformation\":{\"code\":\"pay_D0hUwTOaupjcu8P2qqcH_1\"},\"consumerAuthenticationInformation\":{\"token\":\"HIDDEN"},\"id\":\"7049799548496957104951\",\"orderInformation\":{\"amountDetails\":{\"totalAmount\":\"14.04\",\"authorizedAmount\":\"14.04\",\"currency\":\"USD\"}},\"paymentAccountInformation\":{\"card\":{\"type\":\"001\"}},\"paymentInformation\":{\"tokenizedCard\":{\"type\":\"001\"},\"scheme\":\"VISA DEBIT\",\"bin\":\"411111\",\"accountType\":\"Visa Classic\",\"issuer\":\"HIDDEN SP. Z O.O\",\"card\":{\"type\":\"001\"},\"binCountry\":\"PL\"},\"processorInformation\":{\"systemTraceAuditNumber\":\"HIDDEN\",\"approvalCode\":\"HIDDEN\",\"cardVerification\":{\"resultCodeRaw\":\"M\",\"resultCode\":\"M\"},\"merchantAdvice\":{\"code\":\"01\",\"codeRaw\":\"M001\"},\"responseDetails\":\"ABC\",\"networkTransactionId\":\"HIDDEN\",\"retrievalReferenceNumber\":\"HIDDEN\",\"consumerAuthenticationResponse\":{\"code\":\"2\",\"codeRaw\":\"2\"},\"transactionId\":\"HIDDEN\",\"responseCode\":\"00\",**\"avs\":{\"code\":\"Y\",\"codeRaw\":\"Y\"}},**\"reconciliationId\":\"HIDDEN\",\"riskInformation\":{\"localTime\":\"15:32:34\",\"score\":{\"result\":\"68\",\"factorCodes\":[\"B\"],\"modelUsed\":\"default_cemea\"},\"infoCodes\":{\"address\":[\"MM-BIN\",\"UNV-ADDR\"],\"identityChange\":[\"ID-X-HPOS\"]},\"profile\":{\"earlyDecision\":\"ACCEPT\",\"name\":\"Standard mid-market profile\",\"selectorRule\":\"Default Active Profile\"}},\"status\":\"AUTHORIZED\",\"submitTimeUtc\":\"2024-01-11T13:32:35Z\"}", status_code: 201 }))
  1. Testing can be done by creating a AVS mismatch error for a payment. You should see the following details in the error_message.
    (AVS Mismatch can be triggered by enabling Fraud Rules on BOA/Cybersource Dashboard)
{
    "payment_id": "pay_p6jsWMZ0Rdi2eZTasuTm",
    "merchant_id": "merchant_1704716850",
    "status": "failed",
    "amount": 1404,
    "net_amount": 1404,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": "cybersource",
    "client_secret": "pay_p6jsWMZ0Rdi2eZTasuTm_secret_7P0lx3N6COfGLvS4yBRl",
    "created": "2024-01-11T13:37:01.254Z",
    "currency": "USD",
    "customer_id": "CustomerX",
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1111",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "411111",
            "card_exp_month": "12",
            "card_exp_year": "30",
            "card_holder_name": "joseph Doe"
        }
    },
    "payment_token": null,
    "shipping": null,
    "billing": {
        "address": {
            "city": "dshcvjhdw",
            "country": "MW",
            "line1": "cq",
            "line2": null,
            "line3": null,
            "zip": "46205",
            "state": "whecvjkcdv",
            "first_name": "joseph",
            "last_name": "doe"
        },
        "phone": {
            "number": "12345",
            "country_code": "+93"
        }
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "next_action": null,
    "cancellation_reason": null,
    "error_code": "DECISION_PROFILE_REJECT",
    "error_message": "The order has been rejected by Decision Manager , Fraud Score - Reject",
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "credit",
    "connector_label": "cybersource_US_food_default",
    "business_country": "US",
    "business_label": "food",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "CustomerX",
        "created_at": 1704980221,
        "expires": 1704983821,
        "secret": "epk_83a362750bd34f1f85c1a3303905bf4b"
    },
    "manual_retry_allowed": true,
    "connector_transaction_id": "7049802214936686604953",
    "frm_message": null,
    "metadata": {
        "count_tickets": 1,
        "transaction_number": "5590043"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_aLMwDWebJFLj05EIBPCm",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_x7psrN0rGR7OOaljMXC3",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null
}

Screenshot 2024-01-11 at 7 07 40 PM

  1. To create a general failure pass line1 as empty string. You should see the following error_message.
    Screenshot 2024-01-08 at 7 55 02 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 a review from a team as a code owner January 8, 2024 09:39
@deepanshu-iiitu deepanshu-iiitu self-assigned this Jan 8, 2024
@deepanshu-iiitu deepanshu-iiitu added A-connector-integration Area: Connector integration C-feature Category: Feature request or enhancement labels Jan 8, 2024
@deepanshu-iiitu deepanshu-iiitu linked an issue Jan 8, 2024 that may be closed by this pull request
2 tasks
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.

Same comment applicable for cyber source as well

crates/router/src/connector/bankofamerica/transformers.rs Outdated Show resolved Hide resolved
crates/router/src/connector/bankofamerica/transformers.rs Outdated Show resolved Hide resolved
SamraatBansal
SamraatBansal previously approved these changes Jan 11, 2024
crates/router/src/connector/cybersource/transformers.rs Outdated Show resolved Hide resolved
crates/router/src/connector/bankofamerica/transformers.rs Outdated Show resolved Hide resolved
@deepanshu-iiitu deepanshu-iiitu added the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Jan 11, 2024
@deepanshu-iiitu deepanshu-iiitu removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Jan 11, 2024
@SanchithHegde SanchithHegde dismissed ArjunKarthik’s stale review January 11, 2024 13:46

The requested changes have been addressed, and the reviewer is unavailable currently

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Jan 11, 2024
Merged via the queue into main with commit e75b11e Jan 11, 2024
15 of 17 checks passed
@Gnanasundari24 Gnanasundari24 deleted the cyb-boa-avs branch January 11, 2024 14:00
pixincreate added a commit that referenced this pull request Jan 12, 2024
…-router

* 'main' of github.com:juspay/hyperswitch: (84 commits)
  chore(config): add merchant_secret config for webhooks for  cashtocode and volt in wasm dashboard (#3333)
  chore(version): 2024.01.12.0
  fix: update amount_capturable based on intent_status and payment flow (#3278)
  feat: add support for card extended bin in payment attempt (#3312)
  feat(connector): [cybersource] Implement 3DS flow for cards (#3290)
  chore: remove connector auth TOML files from `.gitignore` and `.dockerignore` (#3330)
  fix(refund): add merchant_connector_id in refund (#3303)
  feat(connector): [BOA/CYB] Store AVS response in connector_metadata (#3271)
  feat(outgoingwebhookevent): adding api for query to fetch outgoing webhook events log (#3310)
  feat(router): payment_method block (#3056)
  feat(connector): [Volt] Add support for refund webhooks  (#3326)
  feat(users): invite user without email (#3328)
  feat(euclid_wasm): config changes for NMI (#3329)
  refactor(router): restricted list payment method Customer to api-key based (#3100)
  feat(connector): [BOA/Cyb] Include merchant metadata in capture and void requests (#3308)
  fix(router): add config to avoid connector tokenization for `apple pay` `simplified flow` (#3234)
  refactor(router): flagged order_details validation to skip validation (#3116)
  fix(core): surcharge with saved card failure (#3318)
  feat(payment_link): Added sdk layout option payment link (#3207)
  chore(version): 2024.01.11.0
  ...
pixincreate added a commit that referenced this pull request Jan 13, 2024
* 'main' of github.com:juspay/hyperswitch: (22 commits)
  chore(version): 2024.01.12.1
  chore: add api reference for blocklist (#3336)
  chore(config): add merchant_secret config for webhooks for  cashtocode and volt in wasm dashboard (#3333)
  chore(version): 2024.01.12.0
  fix: update amount_capturable based on intent_status and payment flow (#3278)
  feat: add support for card extended bin in payment attempt (#3312)
  feat(connector): [cybersource] Implement 3DS flow for cards (#3290)
  chore: remove connector auth TOML files from `.gitignore` and `.dockerignore` (#3330)
  fix(refund): add merchant_connector_id in refund (#3303)
  feat(connector): [BOA/CYB] Store AVS response in connector_metadata (#3271)
  feat(outgoingwebhookevent): adding api for query to fetch outgoing webhook events log (#3310)
  feat(router): payment_method block (#3056)
  feat(connector): [Volt] Add support for refund webhooks  (#3326)
  feat(users): invite user without email (#3328)
  feat(euclid_wasm): config changes for NMI (#3329)
  refactor(router): restricted list payment method Customer to api-key based (#3100)
  feat(connector): [BOA/Cyb] Include merchant metadata in capture and void requests (#3308)
  fix(router): add config to avoid connector tokenization for `apple pay` `simplified flow` (#3234)
  refactor(router): flagged order_details validation to skip validation (#3116)
  fix(core): surcharge with saved card failure (#3318)
  ...
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
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] [BOA/Cybersource] Store AVS Response in connector metadata
5 participants