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(core): Amount capturable remain same for processing status in capture #4229

Merged
merged 1 commit into from
Mar 27, 2024

Conversation

Sakilmostak
Copy link
Contributor

Type of Change

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

Description

Amount capturable should remain same in case of processing status in manual capture

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?

Tested through Postman:

Create a manual capture through NMI:

{
    "amount": 254,
    "currency": "USD",
    "confirm": true,
    "amount_to_capture": 254,
    "capture_method": "manual",
    "capture_on": "2022-09-10T10:11:12Z",
    "customer_id": "StripeCustomer",
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "authentication_type": "three_ds",
    "return_url": "https://google.com",
    "setup_future_usage": "on_session",
    "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": {
            "zip": "94122",
            "country": "US",
            "first_name": "John",
            "last_name": "Doe"
        }
    },
    "routing": {
        "type": "single",
        "data": "nmi"
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4000000000002503",
            "card_exp_month": "08",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "card_cvc": "999"
        }
    },
    "billing": {
        "address": {
            "zip": "560095",
            "country": "IN",
            "first_name": "Tinu",
            "last_name": "Hareesswar"
        }
    }
}

Do a Payment Sync: The status should be requires_capture

Do a Capture: The status should be processing and the amount_capturable field should be equal to amount field.

Eg Response of Capture:

{
    "payment_id": "pay_69uD11O6WLggb2KfmQMx",
    "merchant_id": "merchant_1711525934",
    "status": "processing",
    "amount": 254,
    "net_amount": 254,
    "amount_capturable": 254,
    "amount_received": null,
    "connector": "nmi",
    "client_secret": "pay_69uD11O6WLggb2KfmQMx_secret_eSmzsZNfWMZmq5FT1Q07",
    "created": "2024-03-27T07:55:12.144Z",
    "currency": "USD",
    "customer_id": "StripeCustomer",
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": "on_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "manual",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "2503",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "400000",
            "card_extended_bin": "40000000",
            "card_exp_month": "08",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": "token_qAdLTKI1S1SqiBkVDk4J",
    "shipping": {
        "address": {
            "city": null,
            "country": "US",
            "line1": null,
            "line2": null,
            "line3": null,
            "zip": "94122",
            "state": null,
            "first_name": "John",
            "last_name": "Doe"
        },
        "phone": null,
        "email": null
    },
    "billing": {
        "address": {
            "city": null,
            "country": "IN",
            "line1": null,
            "line2": null,
            "line3": null,
            "zip": "560095",
            "state": null,
            "first_name": "Tinu",
            "last_name": "Hareesswar"
        },
        "phone": null,
        "email": null
    },
    "order_details": null,
    "email": "[email protected]",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://google.com/",
    "authentication_type": "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": false,
    "connector_transaction_id": "9352395215",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_69uD11O6WLggb2KfmQMx_1",
    "payment_link": null,
    "profile_id": "pro_g26r7wsMMP3j2c6gkcD7",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_NOMhnpiK7xZ5AaEBSBro",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2024-03-27T08:10:12.144Z",
    "fingerprint": null,
    "payment_method_id": null,
    "payment_method_status": null
}

Note: This affect manual capture only when the status is processing

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-core Area: Core flows C-bug Category: Bug labels Mar 27, 2024
@Sakilmostak Sakilmostak self-assigned this Mar 27, 2024
@Sakilmostak Sakilmostak requested a review from a team as a code owner March 27, 2024 09:30
@likhinbopanna likhinbopanna added this pull request to the merge queue Mar 27, 2024
Merged via the queue into main with commit 9523cf4 Mar 27, 2024
10 of 12 checks passed
@likhinbopanna likhinbopanna deleted the capture_for_processing branch March 27, 2024 13:32
pixincreate added a commit that referenced this pull request Apr 1, 2024
* 'main' of github.com:juspay/hyperswitch:
  refactor(core): removed the processing status for payment_method_status (#4213)
  docs(README): remove link to outdated early access form
  build(deps): bump `error-stack` from version `0.3.1` to `0.4.1` (#4188)
  chore(version): 2024.04.01.0
  feat(mandates): allow off-session payments using `payment_method_id` (#4132)
  ci(CI-pr): determine modified crates more deterministically (#4233)
  chore(config): add billwerk base URL in deployment configs (#4243)
  feat(payment_method): API to list countries and currencies supported by a country and payment method type (#4126)
  chore(version): 2024.03.28.0
  refactor(config): allow wildcard origin for development and Docker Compose setups (#4231)
  fix(core): Amount capturable remain same for `processing` status in capture (#4229)
  fix(euclid_wasm): checkout wasm metadata issue (#4198)
  fix(trustpay): [Trustpay] Add error code mapping '800.100.100'  (#4224)
  feat(connector): [billwerk] add connector template code (#4123)
  fix(connectors): fix wallet token deserialization error  (#4133)
  fix(log): adding span metadata to `tokio` spawned futures (#4118)
  chore(version): 2024.03.27.0
  fix(connector): [CRYPTOPAY] Skip metadata serialization if none (#4205)
  fix(connector): [Trustpay] fix deserialization error for incoming webhook response for trustpay and add error code mapping '800.100.203' (#4199)
  fix(core): make eci in AuthenticationData optional (#4187)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows C-bug Category: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants