@lightspeed/online-payments-sdk 1.4.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,9 @@ exports.isTokenValid = isTokenValid;
5
5
  var error_1 = require("./error");
6
6
  function decodePaymentSessionToContext(paymentSession) {
7
7
  try {
8
- var decoded = atob(paymentSession);
8
+ var binary = atob(paymentSession);
9
+ var bytes = Uint8Array.from(binary, function (c) { return c.charCodeAt(0); });
10
+ var decoded = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
9
11
  var jsonToken = JSON.parse(decoded);
10
12
  if (jsonToken && isTokenValid(jsonToken)) {
11
13
  return jsonToken;
@@ -92,10 +92,11 @@ function initStripe(context, theme) {
92
92
  * @param defaultValues - Default values for the payment element
93
93
  * @param theme - Theme configuration
94
94
  * @param hideNameField - Whether to hide the billing details name field (used when address element is present to avoid duplicates with ACH)
95
+ * @param businessName - Overrides the merchant name Stripe renders in mandate text (passed to `business.name`)
95
96
  */
96
- function createPaymentElementOptions(defaultValues, theme, hideNameField) {
97
+ function createPaymentElementOptions(defaultValues, theme, hideNameField, businessName) {
97
98
  if (hideNameField === void 0) { hideNameField = false; }
98
- var options = __assign(__assign({ wallets: {
99
+ var options = __assign(__assign(__assign({ wallets: {
99
100
  applePay: 'never',
100
101
  googlePay: 'never',
101
102
  link: 'never',
@@ -107,7 +108,7 @@ function createPaymentElementOptions(defaultValues, theme, hideNameField) {
107
108
  },
108
109
  })), { terms: {
109
110
  usBankAccount: 'never', // Hide Stripe's default T&Cs (shown for ACH payments)
110
- } });
111
+ } }), (businessName && { business: { name: businessName } }));
111
112
  if (defaultValues) {
112
113
  options.defaultValues = {
113
114
  billingDetails: {
@@ -163,11 +164,13 @@ function createCustomTermsElement() {
163
164
  var stripeTermsLink = "<a href=\"".concat(terms_1.ACH_TERMS_URL.STRIPE_ACH_AUTHORIZATION, "\" target=\"_blank\" rel=\"noopener noreferrer\">").concat(terms_1.ACH_TERMS_TEXT.STRIPE_TERMS_LINK_TEXT, "</a>");
164
165
  var expandableToggle = "<span class=\"stripe-expandable-terms-toggle\" role=\"button\" tabindex=\"0\" aria-expanded=\"false\">".concat(terms_1.ACH_TERMS_TEXT.EXPANDABLE_TERMS_LINK_TEXT, " ").concat(CHEVRON_DOWN_SVG, "</span>");
165
166
  termsText.innerHTML = "".concat(terms_1.ACH_TERMS_TEXT.TERMS_PREFIX, " ").concat(stripeTermsLink, " ").concat(terms_1.ACH_TERMS_TEXT.TERMS_CONJUNCTION, " ").concat(expandableToggle);
166
- // Create expandable terms content
167
+ // Create expandable terms content from plain-text paragraphs
167
168
  var expandableContent = document.createElement('div');
168
169
  expandableContent.className = 'stripe-expandable-terms-content';
169
170
  expandableContent.style.display = 'none';
170
- expandableContent.innerHTML = "<p>".concat(terms_1.ACH_TERMS_TEXT.EXPANDED_TERMS_CONTENT, "</p>");
171
+ var paragraphs = terms_1.ACH_TERMS_TEXT.EXPANDED_TERMS_PARAGRAPHS.map(function (text) { return "<p>".concat(text, "</p>"); }).join('');
172
+ var privacyLink = "<a href=\"".concat(terms_1.ACH_TERMS_URL.PRIVACY_POLICY, "\" target=\"_blank\" rel=\"noopener noreferrer\">").concat(terms_1.ACH_TERMS_TEXT.PRIVACY_POLICY_LINK_TEXT, "</a>");
173
+ expandableContent.innerHTML = "".concat(paragraphs, "<p>").concat(terms_1.ACH_TERMS_TEXT.EXPANDED_TERMS_PRIVACY_PREFIX, " ").concat(privacyLink, ".</p>");
171
174
  termsContainer.appendChild(termsText);
172
175
  termsContainer.appendChild(expandableContent);
173
176
  // Add click handler for expandable toggle
@@ -20,10 +20,24 @@ exports.ACH_TERMS_TEXT = {
20
20
  EXPANDABLE_TERMS_LINK_TEXT: 'these terms',
21
21
  /**
22
22
  * Expanded terms content for ACH authorization.
23
- * This is the detailed legal text shown when user expands "these terms".
23
+ * Each entry is a separate paragraph rendered when the user expands
24
+ * "these terms". Kept as plain text — HTML structure is built in code.
24
25
  */
25
- EXPANDED_TERMS_CONTENT: 'By providing your bank account details and confirming this payment, you authorize the merchant to debit your account for the amount shown. If you choose to save your bank account for future payments, this authorization will also apply to any future amounts owed for products or services provided by the merchant, until you cancel it. You also authorize the merchant to credit your account as necessary to correct any erroneous debits. You may revoke authorization at any time by contacting the merchant, allowing up to thirty (30) days for processing. You confirm that you are an authorized signer on the account and that sufficient funds will be available for each payment. ACH payments may take up to five (5) business days to complete, and you may be responsible for fees if a payment is returned.',
26
+ EXPANDED_TERMS_PARAGRAPHS: [
27
+ 'By providing your bank account details and confirming this payment, you authorize the merchant to debit your account for the amount shown.',
28
+ 'If you choose to save your bank account for future payments, this authorization will also apply to any amounts now or hereafter due and payable, including amounts previously invoiced, accrued, outstanding, or otherwise payable, in addition to current, and future payment obligations owed for products or services provided by the merchant, until you cancel it.',
29
+ 'You also authorize the merchant to credit your account as necessary to correct any erroneous debits.',
30
+ 'You may revoke authorization at any time by contacting the merchant, allowing up to thirty (30) days for processing.\nYou confirm that you are an authorized signer on the account and that sufficient funds will be available for each payment.\nACH payments may take up to five (5) business days to complete, and you may be responsible for fees if a payment is returned.',
31
+ ],
32
+ /**
33
+ * Final paragraph containing a link to the Privacy Policy.
34
+ * The link text and URL are defined separately so translators only
35
+ * localize the surrounding copy, not the URL.
36
+ */
37
+ EXPANDED_TERMS_PRIVACY_PREFIX: 'Lightspeed may collect or access certain payment-related information as described in the platform agreement and',
38
+ PRIVACY_POLICY_LINK_TEXT: 'Privacy Policy',
26
39
  };
27
40
  exports.ACH_TERMS_URL = {
28
41
  STRIPE_ACH_AUTHORIZATION: 'https://stripe.com/legal/ach-payments/authorization',
42
+ PRIVACY_POLICY: 'https://www.lightspeedhq.com/legal/privacy-policy/',
29
43
  };
@@ -50,7 +50,7 @@ function mountMotoWidget(mountElement, session, eventBroadcaster, defaultValues,
50
50
  case 0: return [4 /*yield*/, (0, shared_1.initStripe)(session.context, theme)];
51
51
  case 1:
52
52
  _a = _c.sent(), stripe = _a.stripe, elements = _a.elements;
53
- paymentOptions = (0, shared_1.createPaymentElementOptions)(defaultValues, theme);
53
+ paymentOptions = (0, shared_1.createPaymentElementOptions)(defaultValues, theme, false, session.context.businessName);
54
54
  _b = (0, shared_1.createPaymentElement)(elements, paymentOptions, mountElement, eventBroadcaster), paymentElement = _b.element, paymentContainer = _b.container, customTermsContainer = _b.customTermsContainer;
55
55
  // Setup change handler for payment element only (MOTO forms don't have address element)
56
56
  (0, shared_1.setupChangeEventHandler)(paymentElement, eventBroadcaster);
@@ -51,7 +51,7 @@ function mountPaymentWidget(mountElement, session, eventBroadcaster, defaultValu
51
51
  _a = _d.sent(), stripe = _a.stripe, elements = _a.elements;
52
52
  addressOptions = (0, shared_1.createAddressElementOptions)(defaultValues);
53
53
  _b = (0, shared_1.createAddressElement)(elements, addressOptions, mountElement), addressElement = _b.element, addressContainer = _b.container;
54
- paymentOptions = (0, shared_1.createPaymentElementOptions)(defaultValues, theme, true);
54
+ paymentOptions = (0, shared_1.createPaymentElementOptions)(defaultValues, theme, true, session.context.businessName);
55
55
  _c = (0, shared_1.createPaymentElement)(elements, paymentOptions, mountElement, eventBroadcaster), paymentElement = _c.element, paymentContainer = _c.container, customTermsContainer = _c.customTermsContainer;
56
56
  // Setup change handler that emits Complete only when both elements are complete
57
57
  (0, shared_1.setupChangeEventHandler)(paymentElement, eventBroadcaster, addressElement);
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
4
  // This file is auto-generated during the build process
5
5
  // DO NOT EDIT MANUALLY - Version is extracted from package.json
6
- exports.SDK_VERSION = '1.4.1';
6
+ exports.SDK_VERSION = '1.5.0';
@@ -1,7 +1,9 @@
1
1
  import { InvalidSessionPayloadError, InvalidSessionError } from './error';
2
2
  export function decodePaymentSessionToContext(paymentSession) {
3
3
  try {
4
- var decoded = atob(paymentSession);
4
+ var binary = atob(paymentSession);
5
+ var bytes = Uint8Array.from(binary, function (c) { return c.charCodeAt(0); });
6
+ var decoded = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
5
7
  var jsonToken = JSON.parse(decoded);
6
8
  if (jsonToken && isTokenValid(jsonToken)) {
7
9
  return jsonToken;
@@ -11,4 +11,5 @@ export type StripeContext = {
11
11
  intent: 'save-card' | 'payment';
12
12
  locale?: StripeElementLocale;
13
13
  redirectUrl?: string;
14
+ businessName?: string;
14
15
  };
@@ -21,8 +21,9 @@ export declare function initStripe(context: StripeContext, theme?: PaymentWidget
21
21
  * @param defaultValues - Default values for the payment element
22
22
  * @param theme - Theme configuration
23
23
  * @param hideNameField - Whether to hide the billing details name field (used when address element is present to avoid duplicates with ACH)
24
+ * @param businessName - Overrides the merchant name Stripe renders in mandate text (passed to `business.name`)
24
25
  */
25
- export declare function createPaymentElementOptions(defaultValues?: DefaultValues, theme?: PaymentWidgetTheme, hideNameField?: boolean): StripePaymentElementOptions;
26
+ export declare function createPaymentElementOptions(defaultValues?: DefaultValues, theme?: PaymentWidgetTheme, hideNameField?: boolean, businessName?: string): StripePaymentElementOptions;
26
27
  /**
27
28
  * Create address element options
28
29
  */
@@ -80,10 +80,11 @@ export function initStripe(context, theme) {
80
80
  * @param defaultValues - Default values for the payment element
81
81
  * @param theme - Theme configuration
82
82
  * @param hideNameField - Whether to hide the billing details name field (used when address element is present to avoid duplicates with ACH)
83
+ * @param businessName - Overrides the merchant name Stripe renders in mandate text (passed to `business.name`)
83
84
  */
84
- export function createPaymentElementOptions(defaultValues, theme, hideNameField) {
85
+ export function createPaymentElementOptions(defaultValues, theme, hideNameField, businessName) {
85
86
  if (hideNameField === void 0) { hideNameField = false; }
86
- var options = __assign(__assign({ wallets: {
87
+ var options = __assign(__assign(__assign({ wallets: {
87
88
  applePay: 'never',
88
89
  googlePay: 'never',
89
90
  link: 'never',
@@ -95,7 +96,7 @@ export function createPaymentElementOptions(defaultValues, theme, hideNameField)
95
96
  },
96
97
  })), { terms: {
97
98
  usBankAccount: 'never', // Hide Stripe's default T&Cs (shown for ACH payments)
98
- } });
99
+ } }), (businessName && { business: { name: businessName } }));
99
100
  if (defaultValues) {
100
101
  options.defaultValues = {
101
102
  billingDetails: {
@@ -151,11 +152,13 @@ function createCustomTermsElement() {
151
152
  var stripeTermsLink = "<a href=\"".concat(ACH_TERMS_URL.STRIPE_ACH_AUTHORIZATION, "\" target=\"_blank\" rel=\"noopener noreferrer\">").concat(ACH_TERMS_TEXT.STRIPE_TERMS_LINK_TEXT, "</a>");
152
153
  var expandableToggle = "<span class=\"stripe-expandable-terms-toggle\" role=\"button\" tabindex=\"0\" aria-expanded=\"false\">".concat(ACH_TERMS_TEXT.EXPANDABLE_TERMS_LINK_TEXT, " ").concat(CHEVRON_DOWN_SVG, "</span>");
153
154
  termsText.innerHTML = "".concat(ACH_TERMS_TEXT.TERMS_PREFIX, " ").concat(stripeTermsLink, " ").concat(ACH_TERMS_TEXT.TERMS_CONJUNCTION, " ").concat(expandableToggle);
154
- // Create expandable terms content
155
+ // Create expandable terms content from plain-text paragraphs
155
156
  var expandableContent = document.createElement('div');
156
157
  expandableContent.className = 'stripe-expandable-terms-content';
157
158
  expandableContent.style.display = 'none';
158
- expandableContent.innerHTML = "<p>".concat(ACH_TERMS_TEXT.EXPANDED_TERMS_CONTENT, "</p>");
159
+ var paragraphs = ACH_TERMS_TEXT.EXPANDED_TERMS_PARAGRAPHS.map(function (text) { return "<p>".concat(text, "</p>"); }).join('');
160
+ var privacyLink = "<a href=\"".concat(ACH_TERMS_URL.PRIVACY_POLICY, "\" target=\"_blank\" rel=\"noopener noreferrer\">").concat(ACH_TERMS_TEXT.PRIVACY_POLICY_LINK_TEXT, "</a>");
161
+ expandableContent.innerHTML = "".concat(paragraphs, "<p>").concat(ACH_TERMS_TEXT.EXPANDED_TERMS_PRIVACY_PREFIX, " ").concat(privacyLink, ".</p>");
159
162
  termsContainer.appendChild(termsText);
160
163
  termsContainer.appendChild(expandableContent);
161
164
  // Add click handler for expandable toggle
@@ -17,10 +17,19 @@ export declare const ACH_TERMS_TEXT: {
17
17
  readonly EXPANDABLE_TERMS_LINK_TEXT: "these terms";
18
18
  /**
19
19
  * Expanded terms content for ACH authorization.
20
- * This is the detailed legal text shown when user expands "these terms".
20
+ * Each entry is a separate paragraph rendered when the user expands
21
+ * "these terms". Kept as plain text — HTML structure is built in code.
21
22
  */
22
- readonly EXPANDED_TERMS_CONTENT: "By providing your bank account details and confirming this payment, you authorize the merchant to debit your account for the amount shown. If you choose to save your bank account for future payments, this authorization will also apply to any future amounts owed for products or services provided by the merchant, until you cancel it. You also authorize the merchant to credit your account as necessary to correct any erroneous debits. You may revoke authorization at any time by contacting the merchant, allowing up to thirty (30) days for processing. You confirm that you are an authorized signer on the account and that sufficient funds will be available for each payment. ACH payments may take up to five (5) business days to complete, and you may be responsible for fees if a payment is returned.";
23
+ readonly EXPANDED_TERMS_PARAGRAPHS: readonly ["By providing your bank account details and confirming this payment, you authorize the merchant to debit your account for the amount shown.", "If you choose to save your bank account for future payments, this authorization will also apply to any amounts now or hereafter due and payable, including amounts previously invoiced, accrued, outstanding, or otherwise payable, in addition to current, and future payment obligations owed for products or services provided by the merchant, until you cancel it.", "You also authorize the merchant to credit your account as necessary to correct any erroneous debits.", "You may revoke authorization at any time by contacting the merchant, allowing up to thirty (30) days for processing.\nYou confirm that you are an authorized signer on the account and that sufficient funds will be available for each payment.\nACH payments may take up to five (5) business days to complete, and you may be responsible for fees if a payment is returned."];
24
+ /**
25
+ * Final paragraph containing a link to the Privacy Policy.
26
+ * The link text and URL are defined separately so translators only
27
+ * localize the surrounding copy, not the URL.
28
+ */
29
+ readonly EXPANDED_TERMS_PRIVACY_PREFIX: "Lightspeed may collect or access certain payment-related information as described in the platform agreement and";
30
+ readonly PRIVACY_POLICY_LINK_TEXT: "Privacy Policy";
23
31
  };
24
32
  export declare const ACH_TERMS_URL: {
25
33
  readonly STRIPE_ACH_AUTHORIZATION: "https://stripe.com/legal/ach-payments/authorization";
34
+ readonly PRIVACY_POLICY: "https://www.lightspeedhq.com/legal/privacy-policy/";
26
35
  };
@@ -17,10 +17,24 @@ export var ACH_TERMS_TEXT = {
17
17
  EXPANDABLE_TERMS_LINK_TEXT: 'these terms',
18
18
  /**
19
19
  * Expanded terms content for ACH authorization.
20
- * This is the detailed legal text shown when user expands "these terms".
20
+ * Each entry is a separate paragraph rendered when the user expands
21
+ * "these terms". Kept as plain text — HTML structure is built in code.
21
22
  */
22
- EXPANDED_TERMS_CONTENT: 'By providing your bank account details and confirming this payment, you authorize the merchant to debit your account for the amount shown. If you choose to save your bank account for future payments, this authorization will also apply to any future amounts owed for products or services provided by the merchant, until you cancel it. You also authorize the merchant to credit your account as necessary to correct any erroneous debits. You may revoke authorization at any time by contacting the merchant, allowing up to thirty (30) days for processing. You confirm that you are an authorized signer on the account and that sufficient funds will be available for each payment. ACH payments may take up to five (5) business days to complete, and you may be responsible for fees if a payment is returned.',
23
+ EXPANDED_TERMS_PARAGRAPHS: [
24
+ 'By providing your bank account details and confirming this payment, you authorize the merchant to debit your account for the amount shown.',
25
+ 'If you choose to save your bank account for future payments, this authorization will also apply to any amounts now or hereafter due and payable, including amounts previously invoiced, accrued, outstanding, or otherwise payable, in addition to current, and future payment obligations owed for products or services provided by the merchant, until you cancel it.',
26
+ 'You also authorize the merchant to credit your account as necessary to correct any erroneous debits.',
27
+ 'You may revoke authorization at any time by contacting the merchant, allowing up to thirty (30) days for processing.\nYou confirm that you are an authorized signer on the account and that sufficient funds will be available for each payment.\nACH payments may take up to five (5) business days to complete, and you may be responsible for fees if a payment is returned.',
28
+ ],
29
+ /**
30
+ * Final paragraph containing a link to the Privacy Policy.
31
+ * The link text and URL are defined separately so translators only
32
+ * localize the surrounding copy, not the URL.
33
+ */
34
+ EXPANDED_TERMS_PRIVACY_PREFIX: 'Lightspeed may collect or access certain payment-related information as described in the platform agreement and',
35
+ PRIVACY_POLICY_LINK_TEXT: 'Privacy Policy',
23
36
  };
24
37
  export var ACH_TERMS_URL = {
25
38
  STRIPE_ACH_AUTHORIZATION: 'https://stripe.com/legal/ach-payments/authorization',
39
+ PRIVACY_POLICY: 'https://www.lightspeedhq.com/legal/privacy-policy/',
26
40
  };
@@ -47,7 +47,7 @@ export function mountMotoWidget(mountElement, session, eventBroadcaster, default
47
47
  case 0: return [4 /*yield*/, initStripe(session.context, theme)];
48
48
  case 1:
49
49
  _a = _c.sent(), stripe = _a.stripe, elements = _a.elements;
50
- paymentOptions = createPaymentElementOptions(defaultValues, theme);
50
+ paymentOptions = createPaymentElementOptions(defaultValues, theme, false, session.context.businessName);
51
51
  _b = createPaymentElement(elements, paymentOptions, mountElement, eventBroadcaster), paymentElement = _b.element, paymentContainer = _b.container, customTermsContainer = _b.customTermsContainer;
52
52
  // Setup change handler for payment element only (MOTO forms don't have address element)
53
53
  setupChangeEventHandler(paymentElement, eventBroadcaster);
@@ -48,7 +48,7 @@ export function mountPaymentWidget(mountElement, session, eventBroadcaster, defa
48
48
  _a = _d.sent(), stripe = _a.stripe, elements = _a.elements;
49
49
  addressOptions = createAddressElementOptions(defaultValues);
50
50
  _b = createAddressElement(elements, addressOptions, mountElement), addressElement = _b.element, addressContainer = _b.container;
51
- paymentOptions = createPaymentElementOptions(defaultValues, theme, true);
51
+ paymentOptions = createPaymentElementOptions(defaultValues, theme, true, session.context.businessName);
52
52
  _c = createPaymentElement(elements, paymentOptions, mountElement, eventBroadcaster), paymentElement = _c.element, paymentContainer = _c.container, customTermsContainer = _c.customTermsContainer;
53
53
  // Setup change handler that emits Complete only when both elements are complete
54
54
  setupChangeEventHandler(paymentElement, eventBroadcaster, addressElement);
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "1.4.1";
1
+ export declare const SDK_VERSION = "1.5.0";
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // This file is auto-generated during the build process
2
2
  // DO NOT EDIT MANUALLY - Version is extracted from package.json
3
- export var SDK_VERSION = '1.4.1';
3
+ export var SDK_VERSION = '1.5.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightspeed/online-payments-sdk",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "description": "Process online-payments with Lightspeed Payments",
5
5
  "author": "Lightspeed Commerce Inc.",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -19,7 +19,8 @@
19
19
  color: #30313d;
20
20
  }
21
21
 
22
- .stripe-custom-terms-text a {
22
+ .stripe-custom-terms-text a,
23
+ .stripe-expandable-terms-content a {
23
24
  color: #635bff;
24
25
  text-decoration: underline;
25
26
  }
@@ -78,6 +79,7 @@
78
79
  }
79
80
 
80
81
  .lsp-theme-invoicing .stripe-custom-terms-text a,
81
- .lsp-theme-invoicing .stripe-expandable-terms-toggle {
82
+ .lsp-theme-invoicing .stripe-expandable-terms-toggle,
83
+ .lsp-theme-invoicing .stripe-expandable-terms-content a {
82
84
  color: var(--accent-9, #635bff);
83
85
  }