Skip to content

Conversation

swetasharma03
Copy link
Contributor

@swetasharma03 swetasharma03 commented Jun 6, 2025

Type of Change

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

Description

Added recurring payments support for split payments in Stripe

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?

  1. Split payment CIT
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_uLWGMForUNGilTN7hh9dGsQS9WTLqQIrbFqImn4SaXdIApmtEM1G8rcr7hTbimpe' \
--data '
{
    "amount": 200,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "amount_to_capture": 200,
    "customer_id": "cus_6",
    "setup_future_usage": "off_session",
    "customer_acceptance": {
        "acceptance_type": "offline",
        "accepted_at": "1963-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "125.0.0.1",
            "user_agent": "amet irure esse"
        }
    },
    
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "payment_method": "card",
    "payment_method_type": "debit",
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242",
            "card_exp_month": "09",
            "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": "8056594427",
            "country_code": "+91"
        }
    },
  "split_payments": {
        "stripe_split_payment": {
            "charge_type": "destination",
            "application_fees": 100,
            "transfer_account_id": "acct_1PDftAIhl7EEkW0O"
        }
    },
    "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": "128.0.0.1"
    }
}
'

Response:

{
    "payment_id": "pay_kEEY34U6ECjUo9WOZe0w",
    "merchant_id": "merchant_1749032168",
    "status": "succeeded",
    "amount": 200,
    "net_amount": 200,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 200,
    "connector": "stripe",
    "client_secret": "pay_kEEY34U6ECjUo9WOZe0w_secret_OQfx3TDdISCFBLQQJn0N",
    "created": "2025-06-06T07:28:28.956Z",
    "currency": "USD",
    "customer_id": "cus_6",
    "customer": {
        "id": "cus_6",
        "name": "John Doe",
        "email": null,
        "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": "off_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": "09",
            "card_exp_year": "25",
            "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": null,
    "name": "John Doe",
    "phone": "999999999",
    "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": "debit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "cus_6",
        "created_at": 1749194908,
        "expires": 1749198508,
        "secret": "epk_66759cf801664cca82299592f2b145ac"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "pi_3RWuhWIVaesDjvMP2P4xrYGQ",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi_3RWuhWIVaesDjvMP2P4xrYGQ",
    "payment_link": null,
    "profile_id": "pro_E663efxYyhv29dozBbOJ",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_ktIVKfHV583ufBYSYrZM",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-06-06T07:43:28.955Z",
    "fingerprint": null,
    "browser_info": {
        "language": "nl-NL",
        "time_zone": 0,
        "ip_address": "128.0.0.1",
        "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_SwM8JpMtFj0OiinNxD0z",
    "payment_method_status": "active",
    "updated": "2025-06-06T07:28:31.378Z",
    "split_payments": {
        "stripe_split_payment": {
            "charge_id": "ch_3RWv4MIVaesDjvMP0Kkz11A8",
            "charge_type": "destination",
            "application_fees": 100,
            "transfer_account_id": "acct_1PDftAIhl7EEkW0O"
        }
    },
    "frm_metadata": null,
    "extended_authorization_applied": null,
    "capture_before": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": "pm_1RWuhWIVaesDjvMPj2276sZZ",
    "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
}
  1. MIT with corresponding payment_method_id
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_uLWGMForUNGilTN7hh9dGsQS9WTLqQIrbFqImn4SaXdIApmtEM1G8rcr7hTbimpe' \
--data '{
    "amount": 200,
    "currency": "USD",
    "customer_id": "cus_6",
    "description": "Subsequent Mandate Test Payment (MIT from New CIT Demo)",
    "confirm": true,
    "off_session": true,
    "recurring_details": {
        "type": "payment_method_id",
        "data": "pm_SwM8JpMtFj0OiinNxD0z"
    }
}'

Response

{
    "payment_id": "pay_v1AVWCpSd9smRvcecCZ6",
    "merchant_id": "merchant_1749032168",
    "status": "succeeded",
    "amount": 200,
    "net_amount": 200,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 200,
    "connector": "stripe",
    "client_secret": "pay_v1AVWCpSd9smRvcecCZ6_secret_KuDu34Dvmjca1WVnzvmX",
    "created": "2025-06-06T07:28:52.689Z",
    "currency": "USD",
    "customer_id": "cus_6",
    "customer": {
        "id": "cus_6",
        "name": "John Doe",
        "email": null,
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": "Subsequent Mandate Test Payment (MIT from New CIT Demo)",
    "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": "4242",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "424242",
            "card_extended_bin": null,
            "card_exp_month": "09",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": null,
    "name": "John Doe",
    "phone": "999999999",
    "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": "cus_6",
        "created_at": 1749194932,
        "expires": 1749198532,
        "secret": "epk_bd21a582aa7145e7a546ceaecd99c09e"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "pi_3RWuhtIVaesDjvMP1GQPCvAA",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi_3RWuhtIVaesDjvMP1GQPCvAA",
    "payment_link": null,
    "profile_id": "pro_E663efxYyhv29dozBbOJ",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_ktIVKfHV583ufBYSYrZM",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-06-06T07:43:52.689Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": "pm_SwM8JpMtFj0OiinNxD0z",
    "payment_method_status": "active",
    "updated": "2025-06-06T07:28:53.931Z",
    "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": "pm_1RWuhWIVaesDjvMPj2276sZZ",
    "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
}

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

@swetasharma03 swetasharma03 self-assigned this Jun 6, 2025
@swetasharma03 swetasharma03 requested a review from a team as a code owner June 6, 2025 07:31
@swetasharma03 swetasharma03 added the C-feature Category: Feature request or enhancement label Jun 6, 2025
@swetasharma03 swetasharma03 requested review from a team as code owners June 6, 2025 07:31
Copy link

semanticdiff-com bot commented Jun 6, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs  32% smaller
  crates/router/src/core/payments/transformers.rs  1% smaller

@swetasharma03 swetasharma03 changed the base branch from main to sc/one-off/tokenize June 6, 2025 13:25
deepanshu-iiitu
deepanshu-iiitu previously approved these changes Jun 6, 2025
@deepanshu-iiitu deepanshu-iiitu requested review from a team and removed request for a team June 6, 2025 13:31
Comment on lines 4371 to 4378
let is_off_session = match (
payment_data.mandate_id.as_ref(),
payment_data.payment_intent.off_session,
) {
(_, Some(false)) => Some(false),
(Some(_), _) | (_, Some(true)) => Some(true),
(None, None) => None,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this logic is being duplicated. Can be moved to a function

Base automatically changed from sc/one-off/tokenize to main June 7, 2025 14:48
@likhinbopanna likhinbopanna dismissed deepanshu-iiitu’s stale review June 7, 2025 14:48

The base branch was changed.

@swetasharma03 swetasharma03 force-pushed the stripe-split-recurring branch 2 times, most recently from 1450bf3 to 9e102fe Compare June 7, 2025 18:38
@swetasharma03 swetasharma03 force-pushed the stripe-split-recurring branch from 9e102fe to 40024b6 Compare June 7, 2025 18:41
@likhinbopanna likhinbopanna added this pull request to the merge queue Jun 8, 2025
Merged via the queue into main with commit 6f75c4b Jun 8, 2025
15 of 20 checks passed
@likhinbopanna likhinbopanna deleted the stripe-split-recurring branch June 8, 2025 12:57
bsayak03 pushed a commit that referenced this pull request Jun 9, 2025
pixincreate added a commit that referenced this pull request Jun 9, 2025
…nktransfer

* 'main' of github.com:juspay/hyperswitch: (211 commits)
  feat(tokenio): Add OpenBanking Redirection Flow (#8152)
  fix: Unified scarf setup (#8238)
  feat(health): Health check for Decision engine (#8243)
  chore: Update apple pay currency filter configs (#8217)
  refactor(customers_v2): Remove merchant reference id from v2 customer update (#7879)
  chore(version): 2025.06.09.0
  chore(postman): update Postman collection files
  ci(postman): add tunnel collection to postman tests (#8269)
  feat(connector): Added recurring payments support for split payments in Stripe (#8271)
  feat(connector): [STRIPE] Added Connector Tokenization Flow for Cards (#8248)
  refactor(core): introduce new field in payment_intent to handle longer return_url (#8135)
  fix(connector): [AUTHORIZEDOTNET] Remove country PM filters (#8278)
  refactor(config): redact config urls for hyperswitch vault (#8276)
  feat(vsaas): enable onboarding of Standard Merchant Accounts in Platform Organization (#8231)
  feat(router): add three_ds decision rule execute api (#8148)
  feat(router): Save payment method on payments confirm (V2) (#8090)
  ci(cypress): Add Airwallex Connector Test (#8187)
  feat(payment_methods): add `external_vault_details` for payments v2 sdk session call (#8003)
  fix(connector): [facilitapay] cpf is a required field (#8274)
  fix: Fixed spell check (#8227)
  ...
pixincreate added a commit that referenced this pull request Jun 10, 2025
…ordea-sepa

* 'main' of github.com:juspay/hyperswitch: (63 commits)
  feat(connector): [TRUSTPAY] Added Integrity Checks for PSync & RSync flows & Added New Variants in AttemptStatus & IntentStatus (#8096)
  fix(connector): [STRIPE] Throwing Missing Required Field Error if connector_customer is not present (#8309)
  refactor(connectors): [worldpayvantiv] replace sandbox url with pre-live url and fix typo (#8286)
  fix: payment link styling for dynamic classes (#8273)
  feat(core): Make installment_payment_enabled,recurring_enabled Optional (#8201)
  fix(cypress): fix itaubank, datatrans and facilitapay (#8229)
  fix(connector): [jpmorgan] 5xx during payment authorize and `cancellation_reason` (#8282)
  revert(connector): [Worldpay] add root CA certificate (#8224)
  ci(cypress): fix fiuu, fiservemea , paybox and worldpay connector (#8209)
  fix(connector): removed forked josekit dependency from payout connector Nomupay (#8183)
  chore(version): 2025.06.10.0
  feat(tokenio): Add OpenBanking Redirection Flow (#8152)
  fix: Unified scarf setup (#8238)
  feat(health): Health check for Decision engine (#8243)
  chore: Update apple pay currency filter configs (#8217)
  refactor(customers_v2): Remove merchant reference id from v2 customer update (#7879)
  chore(version): 2025.06.09.0
  chore(postman): update Postman collection files
  ci(postman): add tunnel collection to postman tests (#8269)
  feat(connector): Added recurring payments support for split payments in Stripe (#8271)
  ...
pixincreate added a commit that referenced this pull request Jun 10, 2025
…ordea-sepa

* 'main' of github.com:juspay/hyperswitch: (63 commits)
  feat(connector): [TRUSTPAY] Added Integrity Checks for PSync & RSync flows & Added New Variants in AttemptStatus & IntentStatus (#8096)
  fix(connector): [STRIPE] Throwing Missing Required Field Error if connector_customer is not present (#8309)
  refactor(connectors): [worldpayvantiv] replace sandbox url with pre-live url and fix typo (#8286)
  fix: payment link styling for dynamic classes (#8273)
  feat(core): Make installment_payment_enabled,recurring_enabled Optional (#8201)
  fix(cypress): fix itaubank, datatrans and facilitapay (#8229)
  fix(connector): [jpmorgan] 5xx during payment authorize and `cancellation_reason` (#8282)
  revert(connector): [Worldpay] add root CA certificate (#8224)
  ci(cypress): fix fiuu, fiservemea , paybox and worldpay connector (#8209)
  fix(connector): removed forked josekit dependency from payout connector Nomupay (#8183)
  chore(version): 2025.06.10.0
  feat(tokenio): Add OpenBanking Redirection Flow (#8152)
  fix: Unified scarf setup (#8238)
  feat(health): Health check for Decision engine (#8243)
  chore: Update apple pay currency filter configs (#8217)
  refactor(customers_v2): Remove merchant reference id from v2 customer update (#7879)
  chore(version): 2025.06.09.0
  chore(postman): update Postman collection files
  ci(postman): add tunnel collection to postman tests (#8269)
  feat(connector): Added recurring payments support for split payments in Stripe (#8271)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature Category: Feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants