Skip to content

Conversation

mrudulvajpayee4935
Copy link
Contributor

@mrudulvajpayee4935 mrudulvajpayee4935 commented Mar 19, 2025

Type of Change

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

Description

Payment links will have Add Payment Method as button text in case merchant send is_setup_mandate_flow as true in payment_link_config, Authorize Payment in case of manual capture payments and Pay Now in automatic captures.
is_setup_mandate_flow field is only used to alter the text in payment button our core flow of setup mandate remains the same i.e setup mandate flow is used only if amount is zero other authorize flow is used in payments core.
Priority given according to below:

  1. Payment button text added while business profile creation.
  2. is_setup_mandate_flow passed in payment_link_config
  3. Zero amount setup mandate flow.
  4. Manual captures payment.
  5. Automatic captures.

Additional Changes

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

Motivation and Context

Payment links created with capture_method: manual - where the intention is to authorize the customer for some non zero amount, and capture the authorized amount at some later point in time. In such scenarios, the text Pay Now is incorrect as the user is not actually paying in that moment.

How did you test it?

Curls involved to test the flows:

Automatic captures:

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_qTm0pV0gtb4DRMB1eKS5h3EgUvdNvvSADkPjZMXyUY5rvEkvPUMdJBjMq0Y8M7MV' \
--data-raw '{
    "currency": "EUR",
    "amount": 10,
    "authentication_type": "three_ds",
    "description": "Joseph First Crypto",
    "email": "[email protected]",
    "setup_future_usage": "off_session",
    "connector_metadata": {
        "noon": {
            "order_category": "applepay"
        }
    },
    "payment_link": true,
    "return_url": "http://127.0.0.1:5500/src/pl_iframe.html",
    "payment_link_config": {
        "theme": "#14356f",
        "logo": "https://logosandtypes.com/wp-content/uploads/2020/08/zurich.svg",
        "seller_name": "Zurich Inc.",
        "setup_mandate": true
    },
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "customer_acceptance": null,
    "customer_id": "cus_CL6UOh3X35RCzaGNN24t"
}'
image

Manual Captures:

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_qTm0pV0gtb4DRMB1eKS5h3EgUvdNvvSADkPjZMXyUY5rvEkvPUMdJBjMq0Y8M7MV' \
--data-raw '{
    "currency": "EUR",
    "amount": 10,
    "authentication_type": "three_ds",
    "description": "Joseph First Crypto",
    "email": "[email protected]",
    "setup_future_usage": "off_session",
    "connector_metadata": {
        "noon": {
            "order_category": "applepay"
        }
    },
    "payment_link": true,
    "return_url": "http://127.0.0.1:5500/src/pl_iframe.html",
    "payment_link_config": {
        "theme": "#14356f",
        "logo": "https://logosandtypes.com/wp-content/uploads/2020/08/zurich.svg",
        "seller_name": "Zurich Inc."
    },
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "customer_acceptance": null,
    "capture_method": "manual",
    "customer_id": "cus_CL6UOh3X35RCzaGNN24t"
}'
image

setup_mandate_flow

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_qTm0pV0gtb4DRMB1eKS5h3EgUvdNvvSADkPjZMXyUY5rvEkvPUMdJBjMq0Y8M7MV' \
--data-raw '{
    "currency": "EUR",
    "amount": 10,
    "authentication_type": "three_ds",
    "description": "Joseph First Crypto",
    "email": "[email protected]",
    "setup_future_usage": "off_session",
    "connector_metadata": {
        "noon": {
            "order_category": "applepay"
        }
    },
    "payment_link": true,
    "return_url": "http://127.0.0.1:5500/src/pl_iframe.html",
    "payment_link_config": {
        "theme": "#14356f",
        "logo": "https://logosandtypes.com/wp-content/uploads/2020/08/zurich.svg",
        "seller_name": "Zurich Inc.",
        "is_setup_mandate_flow": true
    },
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "customer_acceptance": null,
    "capture_method": "manual",
    "customer_id": "cus_CL6UOh3X35RCzaGNN24t"
}'
image

setup_mandate_flow with zero amount

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_iwLbXyltixlkkaaEPH4Sa5HtJtXlDKZ9wOdiGGZV3RTDhgl24aD9lbghKEn9fz88' \
--data-raw '{
    "currency": "EUR",
    "amount": 0,
    "setup_future_usage": "off_session",
    "authentication_type": "three_ds",
    "description": "Joseph First Crypto",
    "email": "[email protected]",
    "connector_metadata": {
        "noon": {
            "order_category": "applepay"
        }
    },
    "payment_link": true,
    "return_url": "http://127.0.0.1:5500/src/pl_iframe.html",
    "payment_link_config": {
        "theme": "#14356f",
        "logo": "https://logosandtypes.com/wp-content/uploads/2020/08/zurich.svg",
        "seller_name": "Zurich Inc."
    },
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "customer_acceptance": null,
    "customer_id": "cus_CL6UOh3X35RCzaGNN24t"
}'
image

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

Copy link

semanticdiff-com bot commented Mar 19, 2025

@mrudulvajpayee4935 mrudulvajpayee4935 linked an issue Mar 19, 2025 that may be closed by this pull request
kashif-m
kashif-m previously approved these changes Mar 25, 2025
sahkal
sahkal previously approved these changes Mar 25, 2025
@mrudulvajpayee4935 mrudulvajpayee4935 dismissed stale reviews from sahkal and kashif-m via caba777 April 24, 2025 08:23
@mrudulvajpayee4935 mrudulvajpayee4935 force-pushed the alternate-text-for-manual-captures branch from f796402 to caba777 Compare April 24, 2025 08:23
@mrudulvajpayee4935 mrudulvajpayee4935 requested a review from a team as a code owner April 24, 2025 08:23
@mrudulvajpayee4935 mrudulvajpayee4935 force-pushed the alternate-text-for-manual-captures branch from caba777 to 7f9afb2 Compare April 24, 2025 08:24
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Apr 24, 2025
sahkal
sahkal previously approved these changes Apr 24, 2025
@mrudulvajpayee4935 mrudulvajpayee4935 force-pushed the alternate-text-for-manual-captures branch from 8d21c90 to a8b9748 Compare April 24, 2025 18:08
@hyperswitch-bot hyperswitch-bot bot removed the M-api-contract-changes Metadata: This PR involves API contract changes label Apr 24, 2025
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Apr 24, 2025
if (paymentDetails.payment_button_text) {
payNowButtonText.textContent = paymentDetails.payment_button_text;
} else if (paymentDetails.is_setup_mandate_flow || (paymentDetails.amount==="0.00" && paymentDetails.setup_future_usage_applied ==="off_session")) {
payNowButtonText.textContent = translations.addPaymentMethod;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally we should compute in rust code and send the computed value to JS bro,

Let's refactor in the subsequent PR

@likhinbopanna likhinbopanna added this pull request to the merge queue Apr 25, 2025
Merged via the queue into main with commit fa46593 Apr 25, 2025
16 of 20 checks passed
@likhinbopanna likhinbopanna deleted the alternate-text-for-manual-captures branch April 25, 2025 12:16
@Junjun13910
Copy link

Junjun13910 commented Apr 25, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M-api-contract-changes Metadata: This PR involves API contract changes Payment Links
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants