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(core): payment links - add support for custom background image and layout in details section #6725

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

Conversation

kashif-m
Copy link
Contributor

@kashif-m kashif-m commented Dec 3, 2024

Type of Change

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

Description

This PR introduces UI revamps to the payment links by including below changes - (described in #6711)

  • Introduce branding_visibility in business profile's payment link config
  • Introduce details_layout and background_image in both business profile and payments create API
  • Consume these values in payment link's template

Additional Changes

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

Motivation and Context

Helps configure details section for payment links, and fixes a few existing bugs around logos.

How did you test it?

Overview

Things to test and verify -

  1. Background image in details section
    • Provision for background images is added in the details section of the payment links
    • Below configs are provided for configuring the image
      • Image URL
      • Image width
      • Image positioning
  2. Feasibility of rectangular images as logo
    • Images with rectagular dimenstions can be used as merchant logo
  3. Branding visibility
    • HyperSwitch branding toggle in the payment links
  4. Layouts for details section
    • Multiple layouts for details section
    • Layout1
    • Layout2
Steps for testing

Details layout

  • Provision for configuring details_layout is at both profile level and at payments API level
1. Default layout (layout1)
  • Create a default payment link (without configuring details_layout)

cURL

curl --location --request POST 'http://localhost:8080/payments' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_CWKVSn8Qjyb1Qjt6AGNmivVRPm3mgmoS9GDhKPvTB7vVVAbktxV6wPnX3QcJNstt' \
    --data-raw '{"authentication_type":"three_ds","customer_id":"cus_rFGS1qK0MTSxdj0m5aqo","profile_id":"pro_r48ZhNBTND9A4PAc5rHT","amount":100,"currency":"HKD","payment_link":true,"setup_future_usage":"off_session","description":"This is my description of why this payment was requested.","connector":["adyen"],"capture_method":"automatic","billing":{"address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"CA","zip":"94122","country":"US","first_name":"John","last_name":"Doe"},"phone":{"number":"8056594427","country_code":"+91"}},"email":"[email protected]","session_expiry":100000,"return_url":"https://example.com","payment_link_config":{"theme":"#14356f","logo":"https://static.wikia.nocookie.net/logopedia/images/4/41/Zurich-1997-Horizontal.png","seller_name":"Hyperswitch Inc."}}'
Screenshot 2024-12-06 at 11 37 58 AM
  • Set layout1 in business profile config

cURL

curl --location --request POST 'http://localhost:8080/account/merchant_1733294735/business_profile/pro_r48ZhNBTND9A4PAc5rHT' \
    --header 'Content-Type: application/json' \
    --header 'api-key: test_admin' \
    --data '{"payment_link_config":{"allowed_domains":["*"],"enabled_saved_payment_method":true,"theme":"#1A1A1A","logo":"https://hyperswitch.io/favicon.ico","details_layout":"layout1"}}'
  • Create a payment link after configuring details_layout in business profile

cURL

curl --location --request POST 'http://localhost:8080/payments' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_CWKVSn8Qjyb1Qjt6AGNmivVRPm3mgmoS9GDhKPvTB7vVVAbktxV6wPnX3QcJNstt' \
    --data-raw '{"authentication_type":"three_ds","customer_id":"cus_rFGS1qK0MTSxdj0m5aqo","profile_id":"pro_r48ZhNBTND9A4PAc5rHT","amount":100,"currency":"HKD","payment_link":true,"setup_future_usage":"off_session","description":"This is my description of why this payment was requested.","connector":["adyen"],"capture_method":"automatic","billing":{"address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"CA","zip":"94122","country":"US","first_name":"John","last_name":"Doe"},"phone":{"number":"8056594427","country_code":"+91"}},"email":"[email protected]","session_expiry":100000,"return_url":"https://example.com","payment_link_config":{"theme":"#14356f","logo":"https://static.wikia.nocookie.net/logopedia/images/4/41/Zurich-1997-Horizontal.png","seller_name":"Hyperswitch Inc."}}'
Screenshot 2024-12-06 at 11 39 37 AM
  • Create a payment link using layout1 in the payments API

cURL

curl --location --request POST 'http://localhost:8080/payments' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_CWKVSn8Qjyb1Qjt6AGNmivVRPm3mgmoS9GDhKPvTB7vVVAbktxV6wPnX3QcJNstt' \
    --data-raw '{"authentication_type":"three_ds","customer_id":"cus_rFGS1qK0MTSxdj0m5aqo","profile_id":"pro_r48ZhNBTND9A4PAc5rHT","amount":100,"currency":"HKD","payment_link":true,"setup_future_usage":"off_session","description":"This is my description of why this payment was requested.","connector":["adyen"],"capture_method":"automatic","billing":{"address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"CA","zip":"94122","country":"US","first_name":"John","last_name":"Doe"},"phone":{"number":"8056594427","country_code":"+91"}},"email":"[email protected]","session_expiry":100000,"return_url":"https://example.com","payment_link_config":{"theme":"#14356f","logo":"https://static.wikia.nocookie.net/logopedia/images/4/41/Zurich-1997-Horizontal.png","seller_name":"Hyperswitch Inc.","details_layout":"layout1"}}'
Screenshot 2024-12-06 at 11 43 33 AM
2. Layout 2
  • Set layout2 in business profile config

cURL

curl --location --request POST 'http://localhost:8080/account/merchant_1733294735/business_profile/pro_r48ZhNBTND9A4PAc5rHT' \
    --header 'Content-Type: application/json' \
    --header 'api-key: test_admin' \
    --data '{"payment_link_config":{"allowed_domains":["*"],"enabled_saved_payment_method":true,"theme":"#1A1A1A","logo":"https://hyperswitch.io/favicon.ico","details_layout":"layout2","business_specific_configs":{"style1":{"enabled_saved_payment_method":true,"theme":"#FEFEFE","logo":"https://hyperswitch.io/favicon.ico"},"style2":{"enabled_saved_payment_method":true,"theme":"#1A1A1A","logo":"https://hyperswitch.io/favicon.ico"}}}}'
  • Create a payment link after configuring details_layout in business profile

cURL

curl --location --request POST 'http://localhost:8080/payments' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_CWKVSn8Qjyb1Qjt6AGNmivVRPm3mgmoS9GDhKPvTB7vVVAbktxV6wPnX3QcJNstt' \
    --data-raw '{"authentication_type":"three_ds","customer_id":"cus_rFGS1qK0MTSxdj0m5aqo","profile_id":"pro_r48ZhNBTND9A4PAc5rHT","amount":100,"currency":"HKD","payment_link":true,"setup_future_usage":"off_session","description":"This is my description of why this payment was requested.","connector":["adyen"],"capture_method":"automatic","billing":{"address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"CA","zip":"94122","country":"US","first_name":"John","last_name":"Doe"},"phone":{"number":"8056594427","country_code":"+91"}},"email":"[email protected]","session_expiry":100000,"return_url":"https://example.com","payment_link_config":{"theme":"#14356f","logo":"https://static.wikia.nocookie.net/logopedia/images/4/41/Zurich-1997-Horizontal.png","seller_name":"Hyperswitch Inc."}}'
Screenshot 2024-12-06 at 11 45 45 AM
  • Create a payment link using layout2 in the payments API

cURL

curl --location --request POST 'http://localhost:8080/payments' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_CWKVSn8Qjyb1Qjt6AGNmivVRPm3mgmoS9GDhKPvTB7vVVAbktxV6wPnX3QcJNstt' \
    --data-raw '{"authentication_type":"three_ds","customer_id":"cus_rFGS1qK0MTSxdj0m5aqo","profile_id":"pro_r48ZhNBTND9A4PAc5rHT","amount":100,"currency":"HKD","payment_link":true,"setup_future_usage":"off_session","description":"This is my description of why this payment was requested.","connector":["adyen"],"capture_method":"automatic","billing":{"address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"CA","zip":"94122","country":"US","first_name":"John","last_name":"Doe"},"phone":{"number":"8056594427","country_code":"+91"}},"email":"[email protected]","session_expiry":100000,"return_url":"https://example.com","payment_link_config":{"theme":"#14356f","logo":"https://static.wikia.nocookie.net/logopedia/images/4/41/Zurich-1997-Horizontal.png","seller_name":"Hyperswitch Inc.","details_layout":"layout2"}}'
Screenshot 2024-12-06 at 11 46 53 AM

Branding visibility

  • Provision for toggling branding visibility is at profile level
1. Default visibility
  • Create a payment link

cURL

curl --location --request POST 'http://localhost:8080/payments' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_CWKVSn8Qjyb1Qjt6AGNmivVRPm3mgmoS9GDhKPvTB7vVVAbktxV6wPnX3QcJNstt' \
    --data-raw '{"authentication_type":"three_ds","customer_id":"cus_rFGS1qK0MTSxdj0m5aqo","profile_id":"pro_r48ZhNBTND9A4PAc5rHT","amount":100,"currency":"HKD","payment_link":true,"setup_future_usage":"off_session","description":"This is my description of why this payment was requested.","connector":["adyen"],"capture_method":"automatic","billing":{"address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"CA","zip":"94122","country":"US","first_name":"John","last_name":"Doe"},"phone":{"number":"8056594427","country_code":"+91"}},"email":"[email protected]","session_expiry":100000,"return_url":"https://example.com","payment_link_config":{"theme":"#14356f","logo":"https://static.wikia.nocookie.net/logopedia/images/4/41/Zurich-1997-Horizontal.png","seller_name":"Hyperswitch Inc.","details_layout":"layout2"}}'
Screenshot 2024-12-06 at 12 27 30 PM
2. Hidden visibility
  • Set branding_visibility to true in business profile config

cURL

curl --location --request POST 'http://localhost:8080/account/merchant_1733294735/business_profile/pro_r48ZhNBTND9A4PAc5rHT' \
    --header 'Content-Type: application/json' \
    --header 'api-key: test_admin' \
    --data '{"payment_link_config":{"allowed_domains":["*"],"enabled_saved_payment_method":true,"theme":"#1A1A1A","logo":"https://hyperswitch.io/favicon.ico","branding_visibility":false,"business_specific_configs":{"style1":{"enabled_saved_payment_method":true,"theme":"#FEFEFE","logo":"https://hyperswitch.io/favicon.ico"},"style2":{"enabled_saved_payment_method":true,"theme":"#1A1A1A","logo":"https://hyperswitch.io/favicon.ico"}}}}'
  • Create a payment link

cURL

curl --location --request POST 'http://localhost:8080/payments' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_CWKVSn8Qjyb1Qjt6AGNmivVRPm3mgmoS9GDhKPvTB7vVVAbktxV6wPnX3QcJNstt' \
    --data-raw '{"authentication_type":"three_ds","customer_id":"cus_rFGS1qK0MTSxdj0m5aqo","profile_id":"pro_r48ZhNBTND9A4PAc5rHT","amount":100,"currency":"HKD","payment_link":true,"setup_future_usage":"off_session","description":"This is my description of why this payment was requested.","connector":["adyen"],"capture_method":"automatic","billing":{"address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"CA","zip":"94122","country":"US","first_name":"John","last_name":"Doe"},"phone":{"number":"8056594427","country_code":"+91"}},"email":"[email protected]","session_expiry":100000,"return_url":"https://example.com","payment_link_config":{"theme":"#14356f","logo":"https://static.wikia.nocookie.net/logopedia/images/4/41/Zurich-1997-Horizontal.png","seller_name":"Hyperswitch Inc.","details_layout":"layout2"}}'
Screenshot 2024-12-06 at 12 26 01 PM

Background image

  • Provision for setting background image is at both profile and payments API level
1. Background images in business profile
  • Set background image in business profile (url and size)

cURL

curl --location --request POST 'http://localhost:8080/account/merchant_1733294735/business_profile/pro_r48ZhNBTND9A4PAc5rHT' \
    --header 'Content-Type: application/json' \
    --header 'api-key: test_admin' \
    --data '{"payment_link_config":{"allowed_domains":["*"],"enabled_saved_payment_method":true,"theme":"#1A1A1A","logo":"https://hyperswitch.io/favicon.ico","background_image":{"url":"https://img.freepik.com/free-photo/hand-painted-watercolor-background-with-sky-clouds-shape_24972-1095.jpg","size":"cover"},"business_specific_configs":{"style1":{"enabled_saved_payment_method":true,"theme":"#FEFEFE","logo":"https://hyperswitch.io/favicon.ico"},"style2":{"enabled_saved_payment_method":true,"theme":"#1A1A1A","logo":"https://hyperswitch.io/favicon.ico"}}}}'
  • Create a payment link

cURL

curl --location --request POST 'http://localhost:8080/payments' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_CWKVSn8Qjyb1Qjt6AGNmivVRPm3mgmoS9GDhKPvTB7vVVAbktxV6wPnX3QcJNstt' \
    --data-raw '{"authentication_type":"three_ds","customer_id":"cus_rFGS1qK0MTSxdj0m5aqo","profile_id":"pro_r48ZhNBTND9A4PAc5rHT","amount":100,"currency":"HKD","payment_link":true,"setup_future_usage":"off_session","description":"This is my description of why this payment was requested.","connector":["adyen"],"capture_method":"automatic","billing":{"address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"CA","zip":"94122","country":"US","first_name":"John","last_name":"Doe"},"phone":{"number":"8056594427","country_code":"+91"}},"email":"[email protected]","session_expiry":100000,"return_url":"https://example.com","payment_link_config":{"theme":"#14356f","logo":"https://static.wikia.nocookie.net/logopedia/images/4/41/Zurich-1997-Horizontal.png","seller_name":"Hyperswitch Inc.","details_layout":"layout2"}}'
2. Background images in payments API
  • Send the background image in the payments API

cURL

curl --location --request POST 'http://localhost:8080/payments' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_CWKVSn8Qjyb1Qjt6AGNmivVRPm3mgmoS9GDhKPvTB7vVVAbktxV6wPnX3QcJNstt' \
    --data-raw '{"authentication_type":"three_ds","customer_id":"cus_rFGS1qK0MTSxdj0m5aqo","profile_id":"pro_r48ZhNBTND9A4PAc5rHT","amount":100,"currency":"HKD","payment_link":true,"setup_future_usage":"off_session","description":"This is my description of why this payment was requested.","connector":["adyen"],"capture_method":"automatic","billing":{"address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"CA","zip":"94122","country":"US","first_name":"John","last_name":"Doe"},"phone":{"number":"8056594427","country_code":"+91"}},"email":"[email protected]","session_expiry":100000,"return_url":"https://example.com","payment_link_config":{"theme":"#14356f","logo":"https://static.wikia.nocookie.net/logopedia/images/4/41/Zurich-1997-Horizontal.png","seller_name":"Hyperswitch Inc.","details_layout":"layout2","background_image":{"url":"https://img.freepik.com/free-photo/abstract-blue-geometric-shapes-background_24972-1841.jpg","size":"cover"}}}'
Screenshot 2024-12-06 at 1 36 15 PM

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

@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Dec 5, 2024
@kashif-m kashif-m force-pushed the 6711-payment-links-background-image branch from f091e02 to e5119b6 Compare December 5, 2024 20:53
@hyperswitch-bot hyperswitch-bot bot removed the M-api-contract-changes Metadata: This PR involves API contract changes label Dec 5, 2024
@kashif-m kashif-m linked an issue Dec 5, 2024 that may be closed by this pull request
2 tasks
@kashif-m kashif-m changed the title 6711 payment links background image feat(core): payment links - add support for custom background image and layout in details section Dec 5, 2024
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Dec 5, 2024
@kashif-m kashif-m force-pushed the 6711-payment-links-background-image branch 2 times, most recently from f47b37f to 2e235da Compare December 6, 2024 07:24
@kashif-m kashif-m marked this pull request as ready for review December 6, 2024 12:53
@kashif-m kashif-m requested review from a team as code owners December 6, 2024 12:53
@kashif-m kashif-m self-assigned this Dec 9, 2024
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.

[FEATURE] payment link background configurations
3 participants