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(payments): [Payment links] add configs for payment link #7340

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

cookieg13
Copy link
Contributor

@cookieg13 cookieg13 commented Feb 21, 2025

Type of Change

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

Description

  1. Added config display_status_screen in payment links to decide whether to show status screen after payment completion
  • If config is true, redirect user to status screen and then to return url
  • If config is false, or not passed user will be redirected to return url directly
  1. Added config background_color to customize background color for payment links
  2. Added config payment_button_text_color to customize text color for payment button in payment link

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 locally

Update business_profile configs (with display_status_screen as true)

curl --location --request POST 'http://localhost:8080/account/merchant_1740126811/business_profile/pro_FirWioMrQWWbdkcvq1V5' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
    "payment_link_config": {
        "allowed_domains": [
            "*"
        ],
        "payment_button_text": "PAY DG1",
        "display_status_screen": true
    }
}'

Create payment link

curl --location --request POST 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_SlhVlgngA1yBBe0SpxKfzDROCDxqTuFSAYA6Cg4SInxB3DpCODmTQJjHK5UEZqDJ' \
--data-raw '{
    "amount": 700,
    "currency": "USD",
    "payment_link": true,
    "session_expiry": 1000000,
    "return_url": "https://google.com",
    "payment_link_config": {
        "logo": "https://logosandtypes.com/wp-content/uploads/2020/08/zurich.svg",
        "seller_name": "Zurich Inc."
    }
}'

Payment link

Screen.Recording.2025-02-21.at.14.07.49.mov

Update business_profile configs (with display_status_screen as false)

curl --location --request POST 'http://localhost:8080/account/merchant_1740126811/business_profile/pro_FirWioMrQWWbdkcvq1V5' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
    "payment_link_config": {
        "allowed_domains": [
            "*"
        ],
        "payment_button_text": "PAY DG1",
        "display_status_screen": false
    }
}'

Create payment link

curl --location --request POST 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_SlhVlgngA1yBBe0SpxKfzDROCDxqTuFSAYA6Cg4SInxB3DpCODmTQJjHK5UEZqDJ' \
--data-raw '{
    "amount": 700,
    "currency": "USD",
    "payment_link": true,
    "session_expiry": 1000000,
    "return_url": "https://google.com",
    "payment_link_config": {
        "logo": "https://logosandtypes.com/wp-content/uploads/2020/08/zurich.svg",
        "seller_name": "Zurich Inc."
    }
}'

Payment link

Screen.Recording.2025-02-21.at.14.08.20.mov

Update business_profile configs (with background_color , payment_button_text_color)

curl --location --request POST 'http://localhost:8080/account/merchant_1740396251/business_profile/pro_BqO3rMoGzXliePMyBIY2' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
    "payment_link_config": {
        "allowed_domains": [
            "*"
        ],
        "payment_button_text": "PAY DG1",
        "display_status_screen": false,
        "background_color": "#afff7b",
        "payment_button_color": "#000000",
        "payment_button_text_color": "#ff0000"
    }
}'

Create payment link

curl --location --request POST 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_SlhVlgngA1yBBe0SpxKfzDROCDxqTuFSAYA6Cg4SInxB3DpCODmTQJjHK5UEZqDJ' \
--data-raw '{
    "amount": 700,
    "currency": "USD",
    "payment_link": true,
    "session_expiry": 1000000,
    "return_url": "https://google.com",
    "payment_link_config": {
        "logo": "https://logosandtypes.com/wp-content/uploads/2020/08/zurich.svg",
        "seller_name": "Zurich Inc."
    }
}'

Payment link
Screenshot 2025-02-25 at 10 27 58

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

@cookieg13 cookieg13 added this to the February 2025 Release milestone Feb 21, 2025
@cookieg13 cookieg13 self-assigned this Feb 21, 2025
@cookieg13 cookieg13 requested review from a team as code owners February 21, 2025 09:26
Copy link

semanticdiff-com bot commented Feb 21, 2025

@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Feb 21, 2025
@cookieg13 cookieg13 changed the title feat(payments): [Payment links] add display_status_screen config for … feat(payments): [Payment links] add configs for payment link Feb 24, 2025
@cookieg13 cookieg13 requested a review from kashif-m February 24, 2025 17:12
Copy link
Contributor

@kashif-m kashif-m left a comment

Choose a reason for hiding this comment

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

We should revert the field back to payment_button_colour as it's already being used.

@cookieg13 cookieg13 requested a review from a team as a code owner February 25, 2025 09:47
@cookieg13 cookieg13 requested review from kashif-m and removed request for a team February 25, 2025 09:49
kashif-m
kashif-m previously approved these changes Feb 25, 2025
SanchithHegde
SanchithHegde previously approved these changes Feb 25, 2025
@sahkal
Copy link
Contributor

sahkal commented Feb 25, 2025

Ideal behavior of a payment link is to have status page display, whereas this PR does the opposite. Can we have discussion regarding this before moving forward

@hyperswitch-bot hyperswitch-bot bot dismissed stale reviews from SanchithHegde and kashif-m via 4049e04 February 25, 2025 10:26
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.

4 participants