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 config for changing button text for payment links #6860

Merged
merged 2 commits into from
Dec 19, 2024

Conversation

cookieg13
Copy link
Contributor

@cookieg13 cookieg13 commented Dec 17, 2024

Type of Change

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

Description

Added config for changing text of confirm button for payment links

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?

1. Update `allowed_domains` in business profile (Expand to see details)
curl --location --request POST 'http://localhost:8080/account/merchant_1734440294/business_profile/pro_DD9djS7uH6B6uB9A8Nl4' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
    "payment_link_config": {
        "allowed_domains": [
            "*"
        ],
        "enabled_saved_payment_method": true,
        "hide_card_nickname_field": true
    }
}'
2. Create a payment link with `payment_button_text` (Expand to see details)
curl --location --request POST 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_apDeSrDBnIV37SLkVVFFxmJogw3H1KslEXeeAPIqQCamCS6vKk71qkgZlvB1CLUZ' \
--header 'Accept-Language: zh-Hant' \
--data-raw '{
    "amount": 100,
    "currency": "EUR",
    "payment_link": true,
    "connector": [
        "novalnet"
    ],
    "session_expiry": 1000000,
    "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.",
        "payment_button_text": "Pay Now DG"
    }
}'

Response of /payments
{ "payment_id": "pay_uWGKvq0GhsPOLazRZCaj", "merchant_id": "merchant_1734440294", "status": "requires_payment_method", "amount": 100, "net_amount": 100, "shipping_cost": null, "amount_capturable": 100, "amount_received": null, "connector": null, "client_secret": "pay_uWGKvq0GhsPOLazRZCaj_secret_33a1Sy4E5rs7Tv53I4Is", "created": "2024-12-18T08:00:55.515Z", "currency": "EUR", "customer_id": null, "customer": null, "description": null, "refunds": null, "disputes": null, "mandate_id": null, "mandate_data": null, "setup_future_usage": null, "off_session": null, "capture_on": null, "capture_method": null, "payment_method": null, "payment_method_data": null, "payment_token": null, "shipping": null, "billing": null, "order_details": null, "email": null, "name": null, "phone": null, "return_url": "http://127.0.0.1:5500/src/pl_iframe.html", "authentication_type": null, "statement_descriptor_name": null, "statement_descriptor_suffix": null, "next_action": null, "cancellation_reason": null, "error_code": null, "error_message": null, "unified_code": null, "unified_message": null, "payment_experience": null, "payment_method_type": null, "connector_label": null, "business_country": null, "business_label": "default", "business_sub_label": null, "allowed_payment_method_types": null, "ephemeral_key": null, "manual_retry_allowed": null, "connector_transaction_id": null, "frm_message": null, "metadata": null, "connector_metadata": null, "feature_metadata": null, "reference_id": null, "payment_link": { "link": "http://localhost:8080/payment_link/merchant_1734440294/pay_uWGKvq0GhsPOLazRZCaj?locale=zh-Hant", "secure_link": "http://localhost:8080/payment_link/s/merchant_1734440294/pay_uWGKvq0GhsPOLazRZCaj?locale=zh-Hant", "payment_link_id": "plink_ETWyoDZsOyC4f68LRjdS" }, "profile_id": "pro_DD9djS7uH6B6uB9A8Nl4", "surcharge_details": null, "attempt_count": 1, "merchant_decision": null, "merchant_connector_id": null, "incremental_authorization_allowed": null, "authorization_count": null, "incremental_authorizations": null, "external_authentication_details": null, "external_3ds_authentication_attempted": false, "expires_on": "2024-12-29T21:47:35.508Z", "fingerprint": null, "browser_info": null, "payment_method_id": null, "payment_method_status": null, "updated": "2024-12-18T08:00:55.532Z", "split_payments": null, "frm_metadata": null, "merchant_order_reference_id": null, "order_tax_amount": null, "connector_mandate_id": null }

3. Set `payment_button_text` in business profile config
curl --location --request POST 'http://localhost:8080/account/merchant_1734516409/business_profile/pro_Emk2IPwiF6HkSkjTZCIc' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
    "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"
        },
        "payment_button_text": "DG Pay now",
        "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 using /payments

cURL

curl --location --request POST 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_Wnu3HE7zA4MpImfglpdCnSqZ00fL0BVLCj1aNe9TPXldcqXvdHy9nP943V6ud3JB' \
--data-raw '{
    "authentication_type": "three_ds",
    "customer_id": "cus_rFGS1qK0MTSxdj0m5aqo",
    "profile_id": "pro_Emk2IPwiF6HkSkjTZCIc",
    "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": "john.doe@example.com",
    "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."
    }
}'
4. Screenshots (Expand to see details) Open the secure payment link (`secure_link` in API response) in an iframe for validating the functionality. For checking payment_link simply click on the payment_link (`payment_link` in API response)

Screenshot for payment link
Screenshot 2024-12-18 at 13 31 13

Screenshot for secured payment link
Screenshot 2024-12-18 at 13 31 54

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 requested review from a team as code owners December 17, 2024 11:38
Copy link

semanticdiff-com bot commented Dec 17, 2024

@cookieg13 cookieg13 self-assigned this Dec 17, 2024
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Dec 17, 2024
@cookieg13 cookieg13 changed the title add payment link support for SdkHandleConfirmPayment confirm feat(payments): [Payment links] Add support for SdkHandleConfirmPayment Dec 17, 2024
@cookieg13 cookieg13 force-pushed the sdkConfirmBtn branch 4 times, most recently from 477570e to ecdf862 Compare December 18, 2024 08:08
@cookieg13 cookieg13 changed the title feat(payments): [Payment links] Add support for SdkHandleConfirmPayment feat(payments): [Payment links] Add config for changing button text for payment links Dec 18, 2024
kashif-m
kashif-m previously approved these changes Dec 18, 2024
SanchithHegde
SanchithHegde previously approved these changes Dec 18, 2024
sahkal
sahkal previously approved these changes Dec 18, 2024
@likhinbopanna likhinbopanna added this pull request to the merge queue Dec 19, 2024
Merged via the queue into main with commit 46aad50 Dec 19, 2024
27 checks passed
@likhinbopanna likhinbopanna deleted the sdkConfirmBtn branch December 19, 2024 13:28
pixincreate added a commit that referenced this pull request Dec 20, 2024
…ete-pm

* 'main' of github.com:juspay/hyperswitch:
  refactor(dynamic_routing): add col payment_method_type in dynamic_routing_stats (#6853)
  refactor(customers_v2): include minor fixes for customer v2 flows (#6876)
  fix: cypress reports generation (#6894)
  fix(connector): Paypal BankRedirects (Ideal/EPS)  (#6864)
  chore(version): 2024.12.19.1
  fix(connector): [UNIFIED_AUTHENTICATION_SERVICE] change url path to `pre_authentication_processing` in pre-auth flow (#6885)
  refactor(users): move roles schema to global interface (#6862)
  feat(payment_methods): add support to pass apple pay recurring details to obtain apple pay merchant token (#6770)
  feat(payments): [Payment links] Add config for changing button text for payment links (#6860)
  feat(core): added customer phone_number and email to session token response for click to pay (#6863)
  FEAT(klarna): Klarna Kustom Checkout Integration (#6839)
  feat(users): handle email url for users in different tenancies (#6809)
  chore(version): 2024.12.19.0
  refactor(dynamic_routing): update the authentication for update config to include JWT type (#6785)
  chore(env): remove unified_authentication_service base_url from integ, sandbox and production toml (#6865)
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants