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(payment-link): alternate text for manual captures #7574

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mrudulvajpayee4935
Copy link
Contributor

Type of Change

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

Description

Payment links will have Add Payment Method as the button text in case of manual captures payments. Payment button text is localised and will have value according to locale used.

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?

Curl:

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_MEIFMzxdOieBrD6NfMq5fkdKPlnh9EGSk4qgFWZ2Zv7cAR3eleriFFmTmJnfu2bI' \
--header 'Accept-Language: de' \
--data '{
    "amount": 700,
    "customer_id": "cus_5CPXeuPb98HjRkbQifzd",
    "currency": "USD",
    "payment_link": true,
    "session_expiry": 1000000,
    "return_url": "https://google.com",
    "payment_link_config": {
        "logo": "https://cdn.pixabay.com/photo/2021/08/28/08/48/deer-geface-6580415_1280.png",
        "seller_name": "Cookie Inc."
    }
}'

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

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/core/payment_link/payment_link_initiate/payment_link.js  2% smaller
  crates/router/src/core/payment_link/locale.js  0% smaller

@mrudulvajpayee4935 mrudulvajpayee4935 linked an issue Mar 19, 2025 that may be closed by this pull request
@@ -319,7 +319,7 @@ function initializeEventListeners(paymentDetails) {
var payNowButtonText = document.createElement("div");
var payNowButtonText = document.getElementById('submit-button-text');
if (payNowButtonText) {
payNowButtonText.textContent = paymentDetails.payment_button_text || translations.payNow;
payNowButtonText.textContent = paymentDetails.amount==0 ? translations.addPaymentMethod : paymentDetails.payment_button_text || translations.payNow;
Copy link
Contributor

Choose a reason for hiding this comment

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

Give precedence to paymentDetails.payment_button_text

And use strict check (===) for equality statement, since this is JS ..

Better to use if else for readability, since we have 3 variables involved now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Alternate text for Pay Now button for manual captures
3 participants