Skip to content

feat(core): Add amount_capturable field to manual update api#10013

Merged
likhinbopanna merged 2 commits intomainfrom
add-amount-to-capture-inmaunal-update
Oct 29, 2025
Merged

feat(core): Add amount_capturable field to manual update api#10013
likhinbopanna merged 2 commits intomainfrom
add-amount-to-capture-inmaunal-update

Conversation

@awasthi21
Copy link
Contributor

@awasthi21 awasthi21 commented Oct 27, 2025

Type of Change

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

Description

This PR introduces support for updating the amount capturable in the Payments Manual Update API.

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?

Payments Create(Manual)
request

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_X22XAGDz0wGb4sHQEHDqSTnEOmG442PRGk0o75GBrYy0spt7rTUsBCGzRKilPZ0I' \
--data-raw '{
    "amount": 2009,
    "currency": "USD",
    "confirm": true,
    "capture_method": "manual",
    "customer_id": "StripeCustomer",
    "email": "guest@example.com",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4000020000000000",
            "card_exp_month": "03",
            "card_exp_year": "30",
            "card_holder_name": "joseph Doe",
            "card_cvc": "737"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "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"
    },
    "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": "13.232.74.226"
    }
}'

Response

{
    "payment_id": "pay_Vn6ZF9aoxdVXeTBtwLbp",
    "merchant_id": "postman_merchant_GHAction_f006a857-ea49-49f2-b70e-a81a9d511eb7",
    "status": "processing",
    "amount": 2009,
    "net_amount": 2009,
    "shipping_cost": null,
    "amount_capturable": 2009,
    "amount_received": null,
    "connector": "worldpayvantiv",
    "client_secret": "pay_Vn6ZF9aoxdVXeTBtwLbp_secret_JWf1X4b7S9NjxNijxn73",
    "created": "2025-10-29T06:35:11.986Z",
    "currency": "USD",
    "customer_id": "StripeCustomer",
    "customer": {
        "id": "StripeCustomer",
        "name": null,
        "email": "guest@example.com",
        "phone": null,
        "phone_country_code": null
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "manual",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "0000",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "400002",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "30",
            "card_holder_name": "joseph Doe",
            "payment_checks": {
                "avs_result": "00",
                "advanced_a_v_s_result": null,
                "authentication_result": null,
                "card_validation_result": "M"
            },
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe",
            "origin_zip": null
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe",
            "origin_zip": null
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": null,
    "phone": null,
    "return_url": "https://google.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "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": "StripeCustomer",
        "created_at": 1761719711,
        "expires": 1761723311,
        "secret": "epk_7f4d34b673954add857687863bd31b31"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": "84085923232164090",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": {
        "apple_pay": null,
        "airwallex": null,
        "noon": null,
        "braintree": null,
        "adyen": {
            "testing": {
                "holder_name": null
            }
        }
    },
    "feature_metadata": {
        "redirect_response": null,
        "search_tags": null,
        "apple_pay_recurring_details": null,
        "gateway_system": "direct"
    },
    "reference_id": "4EvgAHZxXOoiMEgJ_g_k3WMmTOcs",
    "payment_link": null,
    "profile_id": "pro_nnr0FPwyWF5VNVYmrt7x",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_gO63RI9uvU1s7ux2XxAi",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-10-29T06:50:11.985Z",
    "fingerprint": null,
    "browser_info": {
        "language": "nl-NL",
        "time_zone": 0,
        "ip_address": "13.232.74.226",
        "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",
        "color_depth": 24,
        "java_enabled": true,
        "screen_width": 1536,
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "screen_height": 723,
        "java_script_enabled": true
    },
    "payment_channel": null,
    "payment_method_id": null,
    "network_transaction_id": "500140000200000",
    "payment_method_status": null,
    "updated": "2025-10-29T06:35:17.085Z",
    "split_payments": null,
    "frm_metadata": null,
    "extended_authorization_applied": null,
    "request_extended_authorization": null,
    "capture_before": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null,
    "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,
    "enable_partial_authorization": null,
    "enable_overcapture": null,
    "is_overcapture_enabled": null,
    "network_details": null,
    "is_stored_credential": null,
    "mit_category": null
}

Failing it via the (Manual Update API)
Request

curl --location --request PUT 'http://localhost:8080/payments/pay_Vn6ZF9aoxdVXeTBtwLbp/manual-update' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'X-Merchant-Id: postman_merchant_GHAction_f006a857-ea49-49f2-b70e-a81a9d511eb7' \
--header 'x-cug-user: true' \
--header 'api-key: test_admin' \
--data '{
    "attempt_id": "pay_Vn6ZF9aoxdVXeTBtwLbp_1",
    "merchant_id": "postman_merchant_GHAction_f006a857-ea49-49f2-b70e-a81a9d511eb7",
    "attempt_status": "failure"
    
}
'

Response

{
    "payment_id": "pay_Vn6ZF9aoxdVXeTBtwLbp",
    "attempt_id": "pay_Vn6ZF9aoxdVXeTBtwLbp_1",
    "merchant_id": "postman_merchant_GHAction_f006a857-ea49-49f2-b70e-a81a9d511eb7",
    "attempt_status": "failure",
    "error_code": null,
    "error_message": null,
    "error_reason": null,
    "connector_transaction_id": "84085923232164090",
    "amount_capturable": 2009
}

Changed the Status to Processing and Amount Capturable updated

curl --location --request PUT 'http://localhost:8080/payments/pay_Vn6ZF9aoxdVXeTBtwLbp/manual-update' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'X-Merchant-Id: postman_merchant_GHAction_f006a857-ea49-49f2-b70e-a81a9d511eb7' \
--header 'x-cug-user: true' \
--header 'api-key: test_admin' \
--data '{
    "attempt_id": "pay_Vn6ZF9aoxdVXeTBtwLbp_1",
    "merchant_id": "postman_merchant_GHAction_f006a857-ea49-49f2-b70e-a81a9d511eb7",
    "attempt_status": "pending",
    "amount_capturable":2009
}

'

Response

{
    "payment_id": "pay_Vn6ZF9aoxdVXeTBtwLbp",
    "attempt_id": "pay_Vn6ZF9aoxdVXeTBtwLbp_1",
    "merchant_id": "postman_merchant_GHAction_f006a857-ea49-49f2-b70e-a81a9d511eb7",
    "attempt_status": "pending",
    "error_code": null,
    "error_message": null,
    "error_reason": null,
    "connector_transaction_id": "84085923232164090",
    "amount_capturable": 2009
}

Further we can do the Psync (force_sync)
request

curl --location 'http://localhost:8080/payments/pay_Vn6ZF9aoxdVXeTBtwLbp?force_sync=true' \
--header 'Accept: application/json' \
--header 'api-key: dev_X22XAGDz0wGb4sHQEHDqSTnEOmG442PRGk0o75GBrYy0spt7rTUsBCGzRKilPZ0I' \
--data ''

Response

{
    "payment_id": "pay_Vn6ZF9aoxdVXeTBtwLbp",
    "merchant_id": "postman_merchant_GHAction_f006a857-ea49-49f2-b70e-a81a9d511eb7",
    "status": "requires_capture",
    "amount": 2009,
    "net_amount": 2009,
    "shipping_cost": null,
    "amount_capturable": 2009,
    "amount_received": null,
    "connector": "worldpayvantiv",
    "client_secret": "pay_Vn6ZF9aoxdVXeTBtwLbp_secret_JWf1X4b7S9NjxNijxn73",
    "created": "2025-10-29T06:35:11.986Z",
    "currency": "USD",
    "customer_id": "StripeCustomer",
    "customer": {
        "id": "StripeCustomer",
        "name": null,
        "email": "guest@example.com",
        "phone": null,
        "phone_country_code": null
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "manual",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "0000",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "400002",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "30",
            "card_holder_name": "joseph Doe",
            "payment_checks": {
                "avs_result": "00",
                "advanced_a_v_s_result": null,
                "authentication_result": null,
                "card_validation_result": "M"
            },
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe",
            "origin_zip": null
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe",
            "origin_zip": null
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": null,
    "phone": null,
    "return_url": "https://google.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "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": null,
    "manual_retry_allowed": null,
    "connector_transaction_id": "84085923232164090",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": {
        "apple_pay": null,
        "airwallex": null,
        "noon": null,
        "braintree": null,
        "adyen": {
            "testing": {
                "holder_name": null
            }
        }
    },
    "feature_metadata": {
        "redirect_response": null,
        "search_tags": null,
        "apple_pay_recurring_details": null,
        "gateway_system": "direct"
    },
    "reference_id": "4EvgAHZxXOoiMEgJ_g_k3WMmTOcs",
    "payment_link": null,
    "profile_id": "pro_nnr0FPwyWF5VNVYmrt7x",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_gO63RI9uvU1s7ux2XxAi",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-10-29T06:50:11.985Z",
    "fingerprint": null,
    "browser_info": {
        "language": "nl-NL",
        "time_zone": 0,
        "ip_address": "13.232.74.226",
        "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",
        "color_depth": 24,
        "java_enabled": true,
        "screen_width": 1536,
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "screen_height": 723,
        "java_script_enabled": true
    },
    "payment_channel": null,
    "payment_method_id": null,
    "network_transaction_id": "500140000200000",
    "payment_method_status": null,
    "updated": "2025-10-29T06:40:33.443Z",
    "split_payments": null,
    "frm_metadata": null,
    "extended_authorization_applied": null,
    "request_extended_authorization": null,
    "capture_before": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null,
    "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,
    "enable_partial_authorization": null,
    "enable_overcapture": null,
    "is_overcapture_enabled": null,
    "network_details": null,
    "is_stored_credential": null,
    "mit_category": null
}

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

@awasthi21 awasthi21 self-assigned this Oct 27, 2025
@awasthi21 awasthi21 requested review from a team as code owners October 27, 2025 10:26
@semanticdiff-com
Copy link

semanticdiff-com bot commented Oct 27, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/api_models/src/payments.rs  0% smaller
  crates/diesel_models/src/payment_attempt.rs  0% smaller
  crates/hyperswitch_domain_models/src/payments/payment_attempt.rs  0% smaller
  crates/router/src/core/payments.rs  0% smaller

@awasthi21 awasthi21 changed the title Initial commit feat(core): Add amount_capturable field to manual update api Oct 27, 2025
@awasthi21 awasthi21 force-pushed the add-amount-to-capture-inmaunal-update branch from 8eb8caa to 1428922 Compare October 27, 2025 10:35
@awasthi21 awasthi21 force-pushed the add-amount-to-capture-inmaunal-update branch from 728beae to f9d2234 Compare October 27, 2025 10:44
@codecov
Copy link

codecov bot commented Oct 27, 2025

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@4b0c96d). Learn more about missing BASE report.

Files with missing lines Patch % Lines
crates/diesel_models/src/payment_attempt.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10013   +/-   ##
=======================================
  Coverage        ?    3.93%           
=======================================
  Files           ?     1223           
  Lines           ?   299441           
  Branches        ?        0           
=======================================
  Hits            ?    11795           
  Misses          ?   287646           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@likhinbopanna likhinbopanna added this pull request to the merge queue Oct 29, 2025
Merged via the queue into main with commit 34cd79d Oct 29, 2025
29 of 31 checks passed
@likhinbopanna likhinbopanna deleted the add-amount-to-capture-inmaunal-update branch October 29, 2025 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants