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 1 commit into
base: main
Choose a base branch
from

Conversation

cookieg13
Copy link
Contributor

@cookieg13 cookieg13 commented Feb 21, 2025

…payment links

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,
        "theme": "#6518a3",
        "payment_button_color": "yellow",
        "background_color": "blue",
        "payment_button_text_color": "black"
    }
}'

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-24 at 22 40 48

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
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.

1 participant