hyperswitch
fix(connector): [BRAINTREE] Changed Attempt Status Mapping for Braintree
#7471
Merged

fix(connector): [BRAINTREE] Changed Attempt Status Mapping for Braintree #7471

likhinbopanna merged 3 commits into main from fix/braintree-status-mapping
Debarshi-Gupta
Debarshi-Gupta31 days ago (edited 31 days ago)

Type of Change

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

Description

Changed the Attempt Status Mapping of SubmittedForSettlement and SettlementPending to Charged

Additional Changes

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

Motivation and Context

Issue Link: #7472

How did you test it?

Postman Tests

1. Create Payment (AutoCapture)

-Request

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_ekPGg1GI2tBzBI98TAEWKy1FHsIxlwJVA7L9mNtIZPs3UpODWkCzDpUDE2dFM46T' \
--data-raw '{
    "amount": 2500,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "amount_to_capture": 2500,
    "customer_id": "abcdef",
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "authentication_type": "three_ds",
    "return_url": "https://duck.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "5200000000001096",
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "card_cvc": "123"
        }
    },
    "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": "9123456789",
            "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": "9123456789",
            "country_code": "+91"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
        
        
    }
}'

-Response

{
    "payment_id": "pay_hYJdApy6q8OT0GtFPABl",
    "merchant_id": "postman_merchant_GHAction_e5df8f0f-fb19-466e-9a99-d823823a6903",
    "status": "requires_customer_action",
    "amount": 2500,
    "net_amount": 2500,
    "shipping_cost": null,
    "amount_capturable": 2500,
    "amount_received": null,
    "connector": "braintree",
    "client_secret": "pay_hYJdApy6q8OT0GtFPABl_secret_A7ufMzE2HZOSeygaSOmD",
    "created": "2025-03-10T11:51:31.336Z",
    "currency": "USD",
    "customer_id": "abcdef",
    "customer": {
        "id": "abcdef",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "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": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1096",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "520000",
            "card_extended_bin": null,
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "payment_checks": null,
            "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"
        },
        "phone": {
            "number": "9123456789",
            "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"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://duck.com/",
    "authentication_type": "three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": {
        "type": "redirect_to_url",
        "redirect_to_url": "http://localhost:8080/payments/redirect/pay_hYJdApy6q8OT0GtFPABl/postman_merchant_GHAction_e5df8f0f-fb19-466e-9a99-d823823a6903/pay_hYJdApy6q8OT0GtFPABl_1"
    },
    "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": "abcdef",
        "created_at": 1741607491,
        "expires": 1741611091,
        "secret": "epk_fb5c83ed19434ae4bae82b3467ce3dab"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": null,
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_7Gok9MiuK8INR4GaonVo",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_BmvFPXpGhBGtxOKNQ9CY",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-03-10T12:06:31.336Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-03-10T11:51:33.825Z",
    "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": null,
    "card_discovery": "manual"
}

2. PSync

-Request

curl --location 'http://localhost:8080/payments/pay_hYJdApy6q8OT0GtFPABl' \
--header 'Accept: application/json' \
--header 'api-key: dev_ekPGg1GI2tBzBI98TAEWKy1FHsIxlwJVA7L9mNtIZPs3UpODWkCzDpUDE2dFM46T'

-Response

{
    "payment_id": "pay_hYJdApy6q8OT0GtFPABl",
    "merchant_id": "postman_merchant_GHAction_e5df8f0f-fb19-466e-9a99-d823823a6903",
    "status": "succeeded",
    "amount": 2500,
    "net_amount": 2500,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 2500,
    "connector": "braintree",
    "client_secret": "pay_hYJdApy6q8OT0GtFPABl_secret_A7ufMzE2HZOSeygaSOmD",
    "created": "2025-03-10T11:51:31.336Z",
    "currency": "USD",
    "customer_id": "abcdef",
    "customer": {
        "id": "abcdef",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "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": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1096",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "520000",
            "card_extended_bin": null,
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "payment_checks": null,
            "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"
        },
        "phone": {
            "number": "9123456789",
            "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"
        },
        "phone": {
            "number": "9123456789",
            "country_code": "+91"
        },
        "email": null
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": "https://duck.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": "dHJhbnNhY3Rpb25fcHBzZHQ5dmQ",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_7Gok9MiuK8INR4GaonVo",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_BmvFPXpGhBGtxOKNQ9CY",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-03-10T12:06:31.336Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-03-10T11:51:59.696Z",
    "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": null,
    "card_discovery": "manual"
}

3. CIT

-Request

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_ekPGg1GI2tBzBI98TAEWKy1FHsIxlwJVA7L9mNtIZPs3UpODWkCzDpUDE2dFM46T' \
--data-raw '{
    "amount": 1650,
    "currency": "USD",
    "confirm": true,
    "customer_id": "customer123",
    "setup_future_usage": "off_session",
    "authentication_type": "three_ds",
    "payment_method_type": "debit",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "card_number": "5200000000001096",
            "card_exp_month": "03",
            "card_exp_year": "30",
            "card_holder_name": "joseph Doe",
            "card_cvc": "737"
        }
    },
    "billing": {
        "address": {
            "first_name": "joseph",
            "last_name": "Doe"
        }
    },
    "email": "something@example.com",
    "customer_acceptance": {
        "acceptance_type": "offline"
    }
}'

-Response

{
    "payment_id": "pay_KBOPJsZlEw535w5l73M0",
    "merchant_id": "postman_merchant_GHAction_e5df8f0f-fb19-466e-9a99-d823823a6903",
    "status": "requires_customer_action",
    "amount": 1650,
    "net_amount": 1650,
    "shipping_cost": null,
    "amount_capturable": 1650,
    "amount_received": null,
    "connector": "braintree",
    "client_secret": "pay_KBOPJsZlEw535w5l73M0_secret_DqOaltGsxi41h0T3sYKA",
    "created": "2025-03-10T11:52:33.914Z",
    "currency": "USD",
    "customer_id": "customer123",
    "customer": {
        "id": "customer123",
        "name": null,
        "email": "something@example.com",
        "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": "1096",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "520000",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "30",
            "card_holder_name": "joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": {
        "address": {
            "city": null,
            "country": null,
            "line1": null,
            "line2": null,
            "line3": null,
            "zip": null,
            "state": null,
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": null,
        "email": null
    },
    "order_details": null,
    "email": "something@example.com",
    "name": null,
    "phone": null,
    "return_url": null,
    "authentication_type": "three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "next_action": {
        "type": "redirect_to_url",
        "redirect_to_url": "http://localhost:8080/payments/redirect/pay_KBOPJsZlEw535w5l73M0/postman_merchant_GHAction_e5df8f0f-fb19-466e-9a99-d823823a6903/pay_KBOPJsZlEw535w5l73M0_1"
    },
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "debit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "customer123",
        "created_at": 1741607553,
        "expires": 1741611153,
        "secret": "epk_c9d3479f0d864de1bffdd770239b4990"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": null,
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_7Gok9MiuK8INR4GaonVo",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_BmvFPXpGhBGtxOKNQ9CY",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-03-10T12:07:33.913Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_cvaZra9OH2u9zLswzrYb",
    "payment_method_status": "inactive",
    "updated": "2025-03-10T11:52:35.087Z",
    "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": null,
    "card_discovery": "manual"
}

4. MIT

-Request

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_ekPGg1GI2tBzBI98TAEWKy1FHsIxlwJVA7L9mNtIZPs3UpODWkCzDpUDE2dFM46T' \
--data '{
    "amount": 179,
    "currency": "USD",
    "confirm": true,
    "customer_id": "customer123",
    "recurring_details": {
        "type": "payment_method_id",
        "data": "pm_cvaZra9OH2u9zLswzrYb"
    },
    "off_session": true
}'

-Response

{
    "payment_id": "pay_Guzu7VLXJ56WRrco8Mgd",
    "merchant_id": "postman_merchant_GHAction_e5df8f0f-fb19-466e-9a99-d823823a6903",
    "status": "succeeded",
    "amount": 179,
    "net_amount": 179,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 179,
    "connector": "braintree",
    "client_secret": "pay_Guzu7VLXJ56WRrco8Mgd_secret_YpCWnGkbFS3K7xXsAK6Z",
    "created": "2025-03-10T11:53:18.080Z",
    "currency": "USD",
    "customer_id": "customer123",
    "customer": {
        "id": "customer123",
        "name": null,
        "email": "something@example.com",
        "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": null,
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1096",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "520000",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "30",
            "card_holder_name": "joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": "something@example.com",
    "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": "debit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "customer123",
        "created_at": 1741607598,
        "expires": 1741611198,
        "secret": "epk_9f5c5a0dd8bd473b873df611b6c0e184"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "dHJhbnNhY3Rpb25fMnNncWhjbmE",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_7Gok9MiuK8INR4GaonVo",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_BmvFPXpGhBGtxOKNQ9CY",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-03-10T12:08:18.080Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_cvaZra9OH2u9zLswzrYb",
    "payment_method_status": "active",
    "updated": "2025-03-10T11:53:18.925Z",
    "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": "cGF5bWVudG1ldGhvZF9jY19idGY1dGFzcg",
    "card_discovery": "manual"
}

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
fix: Changed Attempt Status Mapping for Braintree
211eea98
Debarshi-Gupta Debarshi-Gupta requested a review 31 days ago
semanticdiff-com
semanticdiff-com31 days ago (edited 31 days ago)

Review changes with  SemanticDiff

Changed Files
File Status
  crates/hyperswitch_connectors/src/connectors/braintree/transformers.rs  45% smaller
Debarshi-Gupta Debarshi-Gupta changed the title fix: Changed Attempt Status Mapping for Braintree fix(connector): [BRAINTREE] Changed Attempt Status Mapping for Braintree 31 days ago
Debarshi-Gupta Debarshi-Gupta assigned Debarshi-Gupta Debarshi-Gupta 31 days ago
Debarshi-Gupta Debarshi-Gupta added A-connector-integration
Debarshi-Gupta Debarshi-Gupta added C-bug
deepanshu-iiitu
deepanshu-iiitu approved these changes on 2025-03-10
AkshayaFoiger
AkshayaFoiger approved these changes on 2025-03-10
Debarshi-Gupta Merge branch 'main' into fix/braintree-status-mapping
48d9467c
Debarshi-Gupta Merge branch 'main' into fix/braintree-status-mapping
15d70f6d
likhinbopanna likhinbopanna merged 69d8f351 into main 30 days ago
likhinbopanna likhinbopanna deleted the fix/braintree-status-mapping branch 30 days ago

Login to write a write a comment.

Login via GitHub

Assignees
Labels
Milestone