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