Skip to content

feat(connector): [NMI] Add mandates flow #8652

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

Merged
merged 10 commits into from
Aug 5, 2025
Merged

feat(connector): [NMI] Add mandates flow #8652

merged 10 commits into from
Aug 5, 2025

Conversation

deepanshu-iiitu
Copy link
Contributor

@deepanshu-iiitu deepanshu-iiitu commented Jul 15, 2025

Type of Change

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

Description

Mandate payments support has been added to NMI.
https://support.nmi.com/hc/en-gb/articles/13923047779729-Using-the-Customer-Vault

Additional Changes

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

Motivation and Context

#8291 #8653

How did you test it?

Tested and added relevant cypress tests.
CIT:
Request:

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_6Qh8tlhJxGnzCnYSgZLYUcZg3se94a12xetjLpMLCE3srm2F6E3szTR3vJ8IRzxA' \
--data-raw '{
    "amount": 1122,
    "currency": "USD",
    "confirm": true,
    "profile_id": "pro_prQtzjS2YNKFt8NTnPhS",
    "authentication_type": "no_three_ds",
    "email": "[email protected]",
    "customer_id": "vaily",
    "return_url": "https://google.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4532111111111112",
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_cvc": "123"
        }
    },
    "setup_future_usage": "off_session",
    "customer_acceptance": {
        "acceptance_type": "online"
    }
}'

Response:

{
    "payment_id": "pay_VosL2oOd5lEpfI5PFdAF",
    "merchant_id": "merchant_1754040245",
    "status": "succeeded",
    "amount": 1122,
    "net_amount": 1122,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 1122,
    "connector": "nmi",
    "client_secret": "pay_VosL2oOd5lEpfI5PFdAF_secret_pwdKA6SfrJQA90LvmvQD",
    "created": "2025-08-01T10:36:17.871Z",
    "currency": "USD",
    "customer_id": "vaily",
    "customer": {
        "id": "vaily",
        "name": null,
        "email": "[email protected]",
        "phone": null,
        "phone_country_code": null
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": "off_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": null,
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1112",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "453211",
            "card_extended_bin": null,
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": null,
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": "token_4z27khJu7gCT1bLHEHse",
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": "[email protected]",
    "name": null,
    "phone": null,
    "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": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "credit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "vaily",
        "created_at": 1754044577,
        "expires": 1754048177,
        "secret": "epk_554d3664984344ca9fe39c48ff4ff5ef"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "10979926051",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_VosL2oOd5lEpfI5PFdAF_1",
    "payment_link": null,
    "profile_id": "pro_prQtzjS2YNKFt8NTnPhS",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_PbTIQbItUvYnnqZyRRrC",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-08-01T10:51:17.871Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_MFTGiuZQ7jQOCCsyzy8p",
    "payment_method_status": "active",
    "updated": "2025-08-01T10:36:20.930Z",
    "split_payments": null,
    "frm_metadata": null,
    "extended_authorization_applied": null,
    "capture_before": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": "212727464",
    "card_discovery": "manual",
    "force_3ds_challenge": false,
    "force_3ds_challenge_trigger": false,
    "issuer_error_code": null,
    "issuer_error_message": null,
    "is_iframe_redirection_enabled": null,
    "whole_connector_response": null
}

MIT:
Request:

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_6Qh8tlhJxGnzCnYSgZLYUcZg3se94a12xetjLpMLCE3srm2F6E3szTR3vJ8IRzxA' \
--data '{
    "amount": 1212,
    "currency": "USD",
    "confirm": true,
    "capture_method": "manual",
    "customer_id": "vaily2",
    "recurring_details": {
        "type": "payment_method_id",
        "data": "pm_A6hbrqOFGArsNKgjkC9g"
    },
    "off_session": true
}'

Response:

{
    "payment_id": "pay_vi4nShu5q4lHUEMgOnr3",
    "merchant_id": "merchant_1754040245",
    "status": "requires_capture",
    "amount": 1212,
    "net_amount": 1212,
    "shipping_cost": null,
    "amount_capturable": 1212,
    "amount_received": null,
    "connector": "nmi",
    "client_secret": "pay_vi4nShu5q4lHUEMgOnr3_secret_j3hvcXvZE1amCwsXIEqZ",
    "created": "2025-08-01T11:40:10.511Z",
    "currency": "USD",
    "customer_id": "vaily2",
    "customer": {
        "id": "vaily2",
        "name": null,
        "email": "[email protected]",
        "phone": null,
        "phone_country_code": null
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": true,
    "capture_on": null,
    "capture_method": "manual",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1112",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "453211",
            "card_extended_bin": null,
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": null,
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": "[email protected]",
    "name": null,
    "phone": null,
    "return_url": null,
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "credit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "vaily2",
        "created_at": 1754048410,
        "expires": 1754052010,
        "secret": "epk_a9715d624aea41ec9f9428eaaaf8a6a6"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "10980179170",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_vi4nShu5q4lHUEMgOnr3_1",
    "payment_link": null,
    "profile_id": "pro_prQtzjS2YNKFt8NTnPhS",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_PbTIQbItUvYnnqZyRRrC",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-08-01T11:55:10.511Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_A6hbrqOFGArsNKgjkC9g",
    "payment_method_status": "active",
    "updated": "2025-08-01T11:40:13.459Z",
    "split_payments": null,
    "frm_metadata": null,
    "extended_authorization_applied": null,
    "capture_before": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": "1452310032",
    "card_discovery": "manual",
    "force_3ds_challenge": false,
    "force_3ds_challenge_trigger": false,
    "issuer_error_code": null,
    "issuer_error_message": null,
    "is_iframe_redirection_enabled": null,
    "whole_connector_response": null
}

Zero Dollar CIT:
Request:

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_uOYRh8w3a91uu4wD3LFPEXGKB1TqAk6Vi1weDW4da6jde8CnAIK9pjlmixcwDqmk' \
--data-raw '{
    "amount": 0,
    "currency": "USD",
    "confirm": true,
    "profile_id": "null",
    "authentication_type": "no_three_ds",
    "email": "[email protected]",
    "customer_id": "email",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4532111111111112",
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_cvc": "123"
        }
    },
    "setup_future_usage": "off_session",
    "customer_acceptance": {
        "acceptance_type": "online"
    },
    "payment_type": "setup_mandate"
}'

Response:

{
    "payment_id": "pay_ZMLElkI1TmhSqv7gIOO5",
    "merchant_id": "merchant_1754412298",
    "status": "succeeded",
    "amount": 0,
    "net_amount": 0,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": "nmi",
    "client_secret": "pay_ZMLElkI1TmhSqv7gIOO5_secret_u5yYt4m3R8cDkutUIEV5",
    "created": "2025-08-05T16:46:39.306Z",
    "currency": "USD",
    "customer_id": "email",
    "customer": {
        "id": "email",
        "name": null,
        "email": "[email protected]",
        "phone": null,
        "phone_country_code": null
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": "off_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": null,
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1112",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "453211",
            "card_extended_bin": null,
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": null,
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": "token_QK0QtaO95lHS7dKGUTDd",
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": "[email protected]",
    "name": null,
    "phone": null,
    "return_url": null,
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "credit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "email",
        "created_at": 1754412399,
        "expires": 1754415999,
        "secret": "epk_3d19001aea854585ac6ac597d4c31854"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "10996495844",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_ZMLElkI1TmhSqv7gIOO5_1",
    "payment_link": null,
    "profile_id": "pro_IR3qBTXCy9Mf2JnwgGx9",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_a2TxMLhdzJcO8xG0qDSD",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-08-05T17:01:39.305Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_channel": null,
    "payment_method_id": "pm_w2iyEnG6GTv00S35UfKn",
    "network_transaction_id": null,
    "payment_method_status": "active",
    "updated": "2025-08-05T16:46:42.940Z",
    "split_payments": null,
    "frm_metadata": null,
    "extended_authorization_applied": null,
    "capture_before": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": "231615292",
    "card_discovery": "manual",
    "force_3ds_challenge": false,
    "force_3ds_challenge_trigger": false,
    "issuer_error_code": null,
    "issuer_error_message": null,
    "is_iframe_redirection_enabled": null,
    "whole_connector_response": null
}

Cypress Tests:
image

image

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

@deepanshu-iiitu deepanshu-iiitu self-assigned this Jul 15, 2025
@deepanshu-iiitu deepanshu-iiitu requested a review from a team as a code owner July 15, 2025 11:32
@deepanshu-iiitu deepanshu-iiitu added A-connector-integration Area: Connector integration C-feature Category: Feature request or enhancement labels Jul 15, 2025
Copy link

semanticdiff-com bot commented Jul 15, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/hyperswitch_connectors/src/connectors/nmi/transformers.rs  36% smaller
  crates/hyperswitch_connectors/src/connectors/nmi.rs  0% smaller
  cypress-tests/cypress/e2e/configs/Payment/Nmi.js  0% smaller

@deepanshu-iiitu deepanshu-iiitu linked an issue Jul 15, 2025 that may be closed by this pull request
@deepanshu-iiitu deepanshu-iiitu requested a review from a team as a code owner August 1, 2025 12:13
AkshayaFoiger
AkshayaFoiger previously approved these changes Aug 1, 2025
pixincreate
pixincreate previously approved these changes Aug 1, 2025
AkshayaFoiger
AkshayaFoiger previously approved these changes Aug 5, 2025
@likhinbopanna likhinbopanna added this pull request to the merge queue Aug 5, 2025
Merged via the queue into main with commit 6d235d7 Aug 5, 2025
18 of 22 checks passed
@likhinbopanna likhinbopanna deleted the nmi-mandates branch August 5, 2025 10:47
pixincreate added a commit that referenced this pull request Aug 6, 2025
…ordea-sepa

* 'main' of github.com:juspay/hyperswitch: (89 commits)
  feat(router): [worldpayvantiv] add dispute list sync and implement dispute (#8830)
  feat(core): Add support for Void after Capture (#8839)
  fix(wasm): [FISERV] Added GooglePay Payment Method Type (#8832)
  feat(connector): [Barclaycard] Add Google Pay Payment Method (#8786)
  chore(version): 2025.08.06.0
  feat(core): Added additional authentication fields for 3ds external authentication (#8758)
  refactor(core): propagate network_transaction_id in response of payment (#8829)
  fix(core): add fix for stopping multiple event locking idempotent logs (#8034)
  feat(connector): [AUTHORIZEDOTNET] create connector customer flow added (#8774)
  feat(core): Add L2_L3 Data Support  (#8828)
  feat(connector): [NMI] Add mandates flow (#8652)
  fix(connector): [Wise] send uuid as connector_transaction_id (#8836)
  feat(core): populate UCS status_code in response headers (#8788)
  feat(external_services): Fixed Url for Unified Connector Service gRPC Client (#8587)
  chore: reorder v2 migrations folders (#8671)
  fix(router): Take merchant ID from headers in API Key - Revoke (v2) (#8808)
  fix(connector): (payload) currency auth key wasm changes (#8825)
  feat(payment-methods): add filtering logic for payment method list v2 (#8606)
  feat(router): add support for apple pay pre-decrypted token in the payments confirm call (#8815)
  chore(version): 2025.08.05.0
  ...
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.

Recurring on NMI
4 participants