Skip to content

Conversation

Sakilmostak
Copy link
Contributor

@Sakilmostak Sakilmostak commented May 12, 2025

Type of Change

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

Description

  • add vault_session_details field to session's response for vault sdk initiation
  • This is added for VGS as well as Hyperswitch Vault
  • add connector customer create call for session call, this is done inside sdk session call of payment to call the payment method service's customer for new customer creation
  • vault session create call is added to create session for generating client_secret and session_id, this is done in sdk session call of payments

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 an MCA with Hyperswitch Vault:

curl --location '{{baseUrl}}/v2/connector-accounts' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-merchant-id: cloth_seller_MD4LXpyyn4HhnQVe7xOR' \
--header 'x-profile-id: pro_xcjuaZHwgyfclYJFcHEC' \
--header 'Authorization: admin-api-key=test_admin' \
--data '{
    "connector_type": "vault_processor",
    "connector_name": "hyperswitch_vault",
    "connector_account_details": {
        "auth_type": "SignatureKey",
        "key1": "{{key1}}",
        "api_key": "{{api_key}}",
        "api_secret": "{{profile_id}}"
    },
    "payment_methods_enabled": [],
    "frm_configs": null,
    "connector_webhook_details": {
        "merchant_secret": ""
    },
    "profile_id": "pro_xcjuaZHwgyfclYJFcHEC",
    "metadata": {
        "proxy_url": "www.google.com"
    }
}'

Enable vault SDK through Business Profile:

curl --location --request PUT '{{baseUrl}}/v2/profiles/pro_xcjuaZHwgyfclYJFcHEC' \
--header 'x-merchant-id: cloth_seller_MD4LXpyyn4HhnQVe7xOR' \
--header 'Content-Type: application/json' \
--header 'Authorization: admin-api-key={{admin_api_key}}' \
--data-raw '{
    "profile_name": "Update",
    "return_url": "https://google.com/success",
    "enable_payment_response_hash": true,
    "redirect_to_merchant_with_http_post": false,
    "webhook_details": {
        "webhook_version": "1.0.1",
        "webhook_username": "ekart_retail",
        "webhook_password": "password_ekart@123",
        "webhook_url": "https://webhook.site",
        "payment_created_enabled": true,
        "payment_succeeded_enabled": true,
        "payment_failed_enabled": true
    },
    "metadata": null,
    "order_fulfillment_time": 900,
    "order_fulfillment_time_origin": "create",
    "applepay_verified_domains": null,
    "session_expiry": 900,
    "payment_link_config": null,
    "authentication_connector_details": null,
    "use_billing_as_payment_method_billing": true,
    "collect_shipping_details_from_wallet_connector_if_required": false,
    "collect_billing_details_from_wallet_connector_if_required": false,
    "always_collect_shipping_details_from_wallet_connector": false,
    "always_collect_billing_details_from_wallet_connector": false,
    "is_connector_agnostic_mit_enabled": false,
    "payout_link_config": null,
    "outgoing_webhook_custom_http_headers": null,
    "is_external_vault_enabled": true,
    "external_vault_connector_details": {
        
        "vault_connector_id": "{{mca_id}}",
        "vault_sdk": "vgs_sdk"
    }
}'

Create a Payment Intent:

curl --location '{{baseUrl}}/v2/payments/create-intent' \
--header 'api-key:{{api_key}}' \
--header 'Content-Type: application/json' \
--header 'x-profile-id: pro_xcjuaZHwgyfclYJFcHEC' \
--header 'Authorization: api-key={{api_key}}' \
--data-raw '{
    "amount_details": {
        "order_amount": 100,
        "currency": "USD"
    },
    "customer_id": "12345_cus_01973a9912107142b6ccf7f3817eb976",
    "capture_method":"manual",
    "authentication_type": "no_three_ds",
    "billing": {
        "address": {
            "first_name": "John",
            "last_name": "Dough"
        },
        "email": "[email protected]"
    },
    "shipping": {
        "address": {
            "first_name": "John",
            "last_name": "Dough",
            "city": "Karwar",
            "zip": "581301",
            "state": "Karnataka"
        },
        "email": "[email protected]"
    }
}'

Create SDK session call using the payment_id:

curl --location '{{baseUrl}}/v2/payments/12345_pay_01973ab796bb747199a143ace666de02/create-external-sdk-tokens' \
--header 'Content-Type: application/json' \
--header 'x-profile-id: pro_xcjuaZHwgyfclYJFcHEC' \
--header 'Authorization: publishable-key={{pub_key}},client-secret={{client_secret}}' \
--data '{}'

The response should look like below:

{
    "payment_id": "12345_pay_01973ab796bb747199a143ace666de02",
    "session_token": [],
    "vault_details": {
        "hyperswitch_vault": {
            "payment_method_session_id": "12345_pms_01973fcf134f78a3a4a2a2f3c9be336a",
            "client_secret": "cs_01973fcf134f78a3a4a2a30134958fc2",
            "publishable_key": "pk_dev_69b6efb6288b447b9770a1b34f34599d",
            "profile_id": "pro_y9cz7vEkbxytqdmltL3K"
        }
    }
}

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

Sakilmostak and others added 30 commits March 25, 2025 18:04
None,
merchant_context.get_merchant_key_store(),
profile.get_id(),
"", // This is a placeholder for the connector name, which is not used in this context
Copy link
Contributor

Choose a reason for hiding this comment

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

can we instead create a v2 fn with no connector_name in the input params?

pub async fn get_merchant_connector_account_v2(
state: &SessionState,
merchant_id: &id_type::MerchantId,
creds_identifier: Option<&str>,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: there's no creds_identitifer in V2 flows

@Sakilmostak Sakilmostak requested review from a team and removed request for a team June 6, 2025 08:24
@Gnanasundari24 Gnanasundari24 requested a review from a team June 6, 2025 10:19
@Sakilmostak Sakilmostak requested review from a team and removed request for a team June 6, 2025 10:32
@@ -176,15 +176,15 @@ pub struct ConnectorCustomerData {
pub phone: Option<Secret<String>>,
pub name: Option<Secret<String>>,
pub preprocessing_id: Option<String>,
pub payment_method_data: PaymentMethodData,
pub payment_method_data: Option<PaymentMethodData>,
Copy link
Contributor

Choose a reason for hiding this comment

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

You are moving mandate to Optional, if it is in the response, people would have already written conditions based on this. Can you verify if there is no changes in the api contract.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This struct is being used to propagate request data to connectors. The only place this is affecting is transformers.rs of facilitapay and the logic is added to handle in there

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Jun 6, 2025
Merged via the queue into main with commit d32c61a Jun 6, 2025
15 of 20 checks passed
@Gnanasundari24 Gnanasundari24 deleted the external_vault_sdk_session branch June 6, 2025 12:34
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)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-payment-methods Area: Payment Methods C-feature Category: Feature request or enhancement M-api-contract-changes Metadata: This PR involves API contract changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants