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(router): add adyen split payments support #6952

Merged
merged 56 commits into from
Feb 10, 2025
Merged

Conversation

AkshayaFoiger
Copy link
Contributor

@AkshayaFoiger AkshayaFoiger commented Dec 27, 2024

Type of Change

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

Description

This PR adds, adyen split payment support.
Changes taken up in this PR

  1. Add adyen split request to PaymentRequest
     "split_payments": {
        "adyen_split_payment": {
            "store": "4935y84385736",
            "split_items":  [{
            "split_type": "BalanceAccount",
            "amount": 900,
            "account": "*********",
            "reference":"7823648726",
            "description": "adyen split test"
        },
        {
            "split_type": "Commission",
            "amount": 100,
            "account": "************",
            "reference":"7823648726",
            "description": "adyen split test"
        }]
        }
    },
  1. Add adyen split payment response to PaymentsResponse
    "split_payments": {
        "AdyenSplitPayment": {
            "store": "4935y84385736",
            "split_items": [
                {
                    "amount": 900,
                    "split_type": "BalanceAccount",
                    "account": "*****************",
                    "reference": "7823648726",
                    "description": "adyen split test"
                },
                {
                    "amount": 100,
                    "split_type": "Commission",
                    "account": "**************",
                    "reference": "7823648726",
                    "description": "adyen split test"
                }
            ]
        }
    },
  1. Add charges object to PaymentAttempt table
    -> For stripe split payments
{"StripeSplitPayment": {"charge_id": "ch_3Qjb8SIVaesDjvMP2WsSoedi", "charge_type": "destination", "application_fees": 100, "transfer_account_id": "*****"}}

-> For Adyen split payments

{"AdyenSplitPayment": {"store": "4935y84385736", "split_items": [{"amount": 900, "account": "**********", "reference": "7823648726", "split_type": "BalanceAccount", "description": "adyen split test"}, {"amount": 100, "account": "***********", "reference": "7823648726", "split_type": "Commission", "description": "adyen split test"}]}}
  1. Remove charge_id from payment_attempt_new
  2. Remove charge_id PaymentAttempt::ResponseUpdate and PaymentAttempt::ConnectorResponse

Additional Changes

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

How did you test it?

Note: Adyen split payment cannot be tested. As it has to be enabled by adyen.

Sanity tests

  1. Create a split payment with stripe
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_cYluhoyneX1Ox3L8Ayl8Q6zwBvgClrsqBa74tgM7amPSCNlkQ8NMaSFto6jNeDRl' \
--data-raw '{
    "amount": 1000,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "customer_id": "cust_no_pm",
    "authentication_type": "no_three_ds",
      "email": "[email protected]",
    "payment_method": "card",
    "payment_method_type": "debit",
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242", 
            "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"
        }
    },
    "split_payments": {
        "stripe_split_payment": {
            "charge_type": "destination",
            "application_fees": 100,
            "transfer_account_id": "************"
        }
    },
    "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"
    },
    "customer_acceptance": {
        "acceptance_type": "online",
        "accepted_at": "1963-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "127.0.0.1",
            "user_agent": "amet irure esse"
        }
    },
    "setup_future_usage": "on_session"

    
}'

Response

{
    "payment_id": "pay_EFGfA344K1grbrlOjYM6",
    "merchant_id": "postman_merchant_GHAction_18b47f97-bc18-4ee5-9482-027410bdbbb0",
    "status": "succeeded",
    "amount": 1000,
    "net_amount": 1000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 1000,
    "connector": "stripe",
    "client_secret": "pay_EFGfA344K1grbrlOjYM6_secret_AkcUZ7QHdI8PAO7hIQhG",
    "created": "2025-01-21T07:06:51.643Z",
    "currency": "USD",
    "customer_id": "cust_no_pm",
    "customer": {
        "id": "cust_no_pm",
        "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": "on_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "4242",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "424242",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "30",
            "card_holder_name": "joseph Doe",
            "payment_checks": {
                "cvc_check": "pass",
                "address_line1_check": "pass",
                "address_postal_code_check": "pass"
            },
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": 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": "8056594427",
            "country_code": "+91"
        },
        "email": 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": "debit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "cust_no_pm",
        "created_at": 1737443211,
        "expires": 1737446811,
        "secret": "epk_e713b43b065a4203bf10e1bfbf7387da"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "pi_3QjbY0IVaesDjvMP0eJ9xBzq",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi_3QjbY0IVaesDjvMP0eJ9xBzq",
    "payment_link": null,
    "profile_id": "pro_HoToufDVbGWNz1DJJNCQ",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_8eCyKFFWISlH6t1VAnz0",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-21T07:21:51.643Z",
    "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_method_id": null,
    "payment_method_status": null,
    "updated": "2025-01-21T07:06:53.776Z",
    "split_payments": {
        "StripeSplitPayment": {
            "charge_id": "ch_3QjbY0IVaesDjvMP08wX05tt",
            "charge_type": "destination",
            "application_fees": 100,
            "transfer_account_id": "*****"
        }
    },
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}

Payment Sync

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

Response

{
    "payment_id": "pay_EFGfA344K1grbrlOjYM6",
    "merchant_id": "postman_merchant_GHAction_18b47f97-bc18-4ee5-9482-027410bdbbb0",
    "status": "succeeded",
    "amount": 1000,
    "net_amount": 1000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 1000,
    "connector": "stripe",
    "client_secret": "pay_EFGfA344K1grbrlOjYM6_secret_AkcUZ7QHdI8PAO7hIQhG",
    "created": "2025-01-21T07:06:51.643Z",
    "currency": "USD",
    "customer_id": "cust_no_pm",
    "customer": {
        "id": "cust_no_pm",
        "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": "on_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "4242",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "424242",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "30",
            "card_holder_name": "joseph Doe",
            "payment_checks": {
                "cvc_check": "pass",
                "address_line1_check": "pass",
                "address_postal_code_check": "pass"
            },
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": 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": "8056594427",
            "country_code": "+91"
        },
        "email": 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": "debit",
    "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": "pi_3QjbY0IVaesDjvMP0eJ9xBzq",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi_3QjbY0IVaesDjvMP0eJ9xBzq",
    "payment_link": null,
    "profile_id": "pro_HoToufDVbGWNz1DJJNCQ",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_8eCyKFFWISlH6t1VAnz0",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-21T07:21:51.643Z",
    "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_method_id": "pm_QI9gKH9qjNIjdJmQW3UW",
    "payment_method_status": "active",
    "updated": "2025-01-21T07:06:53.776Z",
    "split_payments": {
        "StripeSplitPayment": {
            "charge_id": "ch_3QjbY0IVaesDjvMP08wX05tt",
            "charge_type": "destination",
            "application_fees": 100,
            "transfer_account_id": "******"
        }
    },
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}

Create Refund

curl --location 'http://localhost:8080/refunds' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_cYluhoyneX1Ox3L8Ayl8Q6zwBvgClrsqBa74tgM7amPSCNlkQ8NMaSFto6jNeDRl' \
--data '{
    "payment_id": "pay_EFGfA344K1grbrlOjYM6",
    "amount": 1000,
    "reason": "Customer returned product",
    "refund_type": "instant",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
     "split_refunds": {
        "stripe_split_refund": {
            "revert_platform_fee": true,
            "revert_transfer": true
        }
    }
}'

Response

{
    "refund_id": "ref_kkylIvnJr2eG2x4IWr0x",
    "payment_id": "pay_EFGfA344K1grbrlOjYM6",
    "amount": 1000,
    "currency": "USD",
    "status": "succeeded",
    "reason": "Customer returned product",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "error_message": null,
    "error_code": null,
    "created_at": "2025-01-21T07:10:29.920Z",
    "updated_at": "2025-01-21T07:10:32.627Z",
    "connector": "stripe",
    "profile_id": "pro_HoToufDVbGWNz1DJJNCQ",
    "merchant_connector_id": "mca_8eCyKFFWISlH6t1VAnz0",
    "split_refunds": {
        "stripe_split_refund": {
            "revert_platform_fee": true,
            "revert_transfer": true
        }
    }
}

Refund Sync

curl --location 'http://localhost:8080/refunds/ref_kkylIvnJr2eG2x4IWr0x' \
--header 'Accept: application/json' \
--header 'api-key: dev_cYluhoyneX1Ox3L8Ayl8Q6zwBvgClrsqBa74tgM7amPSCNlkQ8NMaSFto6jNeDRl'

Response

{
    "refund_id": "ref_kkylIvnJr2eG2x4IWr0x",
    "payment_id": "pay_EFGfA344K1grbrlOjYM6",
    "amount": 1000,
    "currency": "USD",
    "status": "succeeded",
    "reason": "Customer returned product",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "error_message": null,
    "error_code": null,
    "created_at": "2025-01-21T07:10:29.920Z",
    "updated_at": "2025-01-21T07:10:32.627Z",
    "connector": "stripe",
    "profile_id": "pro_HoToufDVbGWNz1DJJNCQ",
    "merchant_connector_id": "mca_8eCyKFFWISlH6t1VAnz0",
    "split_refunds": {
        "stripe_split_refund": {
            "revert_platform_fee": true,
            "revert_transfer": true
        }
    }
}

Compatibility Test
Make a payment, storing the charge_id in payment intent (current main)

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_YI6n70QC5t9CBpD1LmASdS9RTvvVz0OjKyn9EO6ylzMntKEItV5O1MgvGd4739bo' \
--data-raw '{
    "amount": 1000,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    
    "customer_id": "cust_no_pm",
    "authentication_type": "no_three_ds",
    
    
    
    
    
      "email": "[email protected]",
    "payment_method": "card",
    "payment_method_type": "debit",
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242", 
            "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"
        }
    },
    "split_payments": {
        "stripe_split_payment": {
            "charge_type": "destination",
            "application_fees": 100,
            "transfer_account_id": "acct_1PfKWLROW2XALwca"
        }
    },
    "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"
    },
    "customer_acceptance": {
        "acceptance_type": "online",
        "accepted_at": "1963-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "127.0.0.1",
            "user_agent": "amet irure esse"
        }
    },
    "setup_future_usage": "on_session"

    
}'

Response

{
    "payment_id": "pay_fLYwcRo7ZgkknSNd23ej",
    "merchant_id": "postman_merchant_GHAction_c0d9d70c-412c-41aa-b196-b13fcd3fd4d4",
    "status": "succeeded",
    "amount": 1000,
    "net_amount": 1000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 1000,
    "connector": "stripe",
    "client_secret": "pay_fLYwcRo7ZgkknSNd23ej_secret_2CkUo80sKK4i9cMfHMlU",
    "created": "2025-01-28T10:42:34.741Z",
    "currency": "USD",
    "customer_id": "cust_no_pm",
    "customer": {
        "id": "cust_no_pm",
        "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": "on_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "4242",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "424242",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "30",
            "card_holder_name": "joseph Doe",
            "payment_checks": {
                "cvc_check": "pass",
                "address_line1_check": "pass",
                "address_postal_code_check": "pass"
            },
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": 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": "8056594427",
            "country_code": "+91"
        },
        "email": 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": "debit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "cust_no_pm",
        "created_at": 1738060954,
        "expires": 1738064554,
        "secret": "epk_1bc403b8712c4b90aa8f1afb835e17e0"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "pi_3QmCFbIVaesDjvMP2tujkeNv",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi_3QmCFbIVaesDjvMP2tujkeNv",
    "payment_link": null,
    "profile_id": "pro_cPPonA2IgvSNz8qCQpQK",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_02JJmlfo1vAxElLj4zxh",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-28T10:57:34.741Z",
    "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_method_id": null,
    "payment_method_status": null,
    "updated": "2025-01-28T10:42:37.813Z",
    "split_payments": {
        "stripe_split_payment": {
            "charge_id": "ch_3QmCFbIVaesDjvMP2CoW9ggX",
            "charge_type": "destination",
            "application_fees": 100,
            "transfer_account_id": "acct_1PfKWLROW2XALwca"
        }
    },
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}

Refund using the current version

curl --location 'http://localhost:8080/refunds' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_YI6n70QC5t9CBpD1LmASdS9RTvvVz0OjKyn9EO6ylzMntKEItV5O1MgvGd4739bo' \
--data '{
    "payment_id": "pay_fLYwcRo7ZgkknSNd23ej",
    "amount": 900,
    "reason": "Customer returned product",
    "refund_type": "instant",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
     "split_refunds": {
        "stripe_split_refund": {
            "revert_platform_fee": true,
            "revert_transfer": true
        }
    
    }
}'

Response

{
    "refund_id": "ref_Zo15sSj608ssWDp48CCR",
    "payment_id": "pay_fLYwcRo7ZgkknSNd23ej",
    "amount": 900,
    "currency": "USD",
    "status": "succeeded",
    "reason": "Customer returned product",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "error_message": null,
    "error_code": null,
    "unified_code": null,
    "unified_message": null,
    "created_at": "2025-01-28T10:57:52.930Z",
    "updated_at": "2025-01-28T10:57:55.762Z",
    "connector": "stripe",
    "profile_id": "pro_cPPonA2IgvSNz8qCQpQK",
    "merchant_connector_id": "mca_02JJmlfo1vAxElLj4zxh",
    "split_refunds": {
        "stripe_split_refund": {
            "revert_platform_fee": true,
            "revert_transfer": true
        }
    }
}

This issue already exists and is tracked at https://github.com/juspay/hyperswitch-cloud/issues/8373. It was not caused by this PR.

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

@AkshayaFoiger AkshayaFoiger requested review from a team as code owners December 27, 2024 10:19
Copy link

semanticdiff-com bot commented Dec 27, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/connector/stripe.rs  79% smaller
  crates/openapi/src/openapi_v2.rs  35% smaller
  crates/router/src/core/refunds.rs  32% smaller
  crates/openapi/src/openapi.rs  31% smaller
  crates/common_types/src/payments.rs  31% smaller
  crates/router/src/core/refunds/validator.rs  31% smaller
  api-reference-v2/openapi_spec.json  20% smaller
  api-reference/openapi_spec.json  20% smaller
  crates/hyperswitch_domain_models/src/router_response_types.rs  18% smaller
  crates/router/src/connector/stripe/transformers.rs  9% smaller
  crates/diesel_models/src/schema_v2.rs  9% smaller
  crates/router/src/core/refunds/transformers.rs  8% smaller
  crates/router/src/core/payments/helpers.rs  7% smaller
  crates/api_models/src/payments.rs  5% smaller
  crates/router/src/core/payments/transformers.rs  2% smaller
  connector-template/transformers.rs Unsupported file format
  crates/common_enums/src/enums.rs  0% smaller
  crates/common_types/src/domain.rs  0% smaller
  crates/common_types/src/lib.rs  0% smaller
  crates/common_types/src/refunds.rs  0% smaller
  crates/diesel_models/src/payment_attempt.rs  0% smaller
  crates/diesel_models/src/schema.rs  0% smaller
  crates/diesel_models/src/user/sample_data.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/aci/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/airwallex/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/amazonpay/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/bambora/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/bamboraapac/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/bankofamerica/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/billwerk/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/bitpay/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/bluesnap.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/bluesnap/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/boku/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/braintree/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/cashtocode/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/chargebee/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/coinbase/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/coingate/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/cryptopay/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/datatrans/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/digitalvirgo/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/dlocal/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/elavon/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/fiserv/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/fiservemea/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/forte/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/globalpay/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/globepay/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/gocardless/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/helcim/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/iatapay/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/inespay/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/itaubank/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/jpmorgan/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/klarna/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/mifinity/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/mollie/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/multisafepay/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/nexinets/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/nexixpay/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/nomupay/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/nuvei/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/paybox/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/payeezy/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/payu/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/placetopay/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/powertranz/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/prophetpay/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/rapyd/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/razorpay/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/redsys/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/shift4/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/square/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/stax/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/thunes/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/tsys/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/volt/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/wellsfargo/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/worldline/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/worldpay.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/xendit/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/zen/transformers.rs  0% smaller
  crates/hyperswitch_connectors/src/connectors/zsl/transformers.rs  0% smaller
  crates/hyperswitch_domain_models/src/payments/payment_attempt.rs  0% smaller
  crates/hyperswitch_domain_models/src/router_data.rs  0% smaller
  crates/hyperswitch_domain_models/src/router_request_types.rs  0% smaller
  crates/router/src/connector/adyen/transformers.rs  0% smaller
  crates/router/src/connector/authorizedotnet/transformers.rs  0% smaller
  crates/router/src/connector/checkout/transformers.rs  0% smaller
  crates/router/src/connector/dummyconnector/transformers.rs  0% smaller
  crates/router/src/connector/nmi/transformers.rs  0% smaller
  crates/router/src/connector/noon/transformers.rs  0% smaller
  crates/router/src/connector/opayo/transformers.rs  0% smaller
  crates/router/src/connector/opennode/transformers.rs  0% smaller
  crates/router/src/connector/payme/transformers.rs  0% smaller
  crates/router/src/connector/paypal.rs  0% smaller
  crates/router/src/connector/paypal/transformers.rs  0% smaller
  crates/router/src/connector/plaid/transformers.rs  0% smaller
  crates/router/src/connector/trustpay/transformers.rs  0% smaller
  crates/router/src/connector/utils.rs  0% smaller
  crates/router/src/connector/wellsfargopayout/transformers.rs  0% smaller
  crates/router/src/core/payments/operations/payment_create.rs  0% smaller
  crates/router/src/core/payments/operations/payment_response.rs  0% smaller
  crates/router/src/core/payments/retry.rs  0% smaller
  crates/router/src/core/utils.rs  0% smaller
  crates/router/src/types/storage/payment_attempt.rs  0% smaller
  crates/router/tests/connectors/utils.rs  0% smaller
  crates/storage_impl/src/mock_db/payment_attempt.rs  0% smaller
  crates/storage_impl/src/payments/payment_attempt.rs  0% smaller
  migrations/2025-01-14-832737_add_charges_to_payment_attempt/down.sql Unsupported file format
  migrations/2025-01-14-832737_add_charges_to_payment_attempt/up.sql Unsupported file format
  v2_migrations/2024-11-08-081847_drop_v1_columns/down.sql Unsupported file format
  v2_migrations/2024-11-08-081847_drop_v1_columns/up.sql Unsupported file format

@AkshayaFoiger AkshayaFoiger marked this pull request as draft December 27, 2024 10:19
@AkshayaFoiger AkshayaFoiger self-assigned this Jan 9, 2025
@AkshayaFoiger AkshayaFoiger marked this pull request as ready for review January 17, 2025 04:07
@hyperswitch-bot hyperswitch-bot bot added M-database-changes Metadata: This PR involves database schema changes M-api-contract-changes Metadata: This PR involves API contract changes labels Jan 17, 2025
@AkshayaFoiger AkshayaFoiger added A-connector-integration Area: Connector integration A-core Area: Core flows labels Jan 17, 2025
swangi-kumari
swangi-kumari previously approved these changes Feb 7, 2025
Narayanbhat166
Narayanbhat166 previously approved these changes Feb 7, 2025
deepanshu-iiitu
deepanshu-iiitu previously approved these changes Feb 7, 2025
ThisIsMani
ThisIsMani previously approved these changes Feb 7, 2025
SanchithHegde
SanchithHegde previously approved these changes Feb 7, 2025
@likhinbopanna likhinbopanna added this pull request to the merge queue Feb 10, 2025
auto-merge was automatically disabled February 10, 2025 07:03

Pull Request is not mergeable

Merged via the queue into main with commit 323d763 Feb 10, 2025
17 of 20 checks passed
@likhinbopanna likhinbopanna deleted the adyen-split-payments branch February 10, 2025 07:12
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 A-core Area: Core flows M-api-contract-changes Metadata: This PR involves API contract changes M-database-changes Metadata: This PR involves database schema changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants