@financial-times/n-conversion-forms 20.3.2 → 20.4.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.
Files changed (119) hide show
  1. package/.circleci/config.yml +7 -5
  2. package/.circleci/shared-helpers/helper-npm-install-peer-deps +6 -6
  3. package/.eslintignore +3 -0
  4. package/.github/workflows/gh-pages-deploy.yml +2 -1
  5. package/build-state/npm-shrinkwrap.json +47022 -9009
  6. package/components/__snapshots__/accept-terms.spec.js.snap +94 -6
  7. package/components/__snapshots__/delivery-address.spec.js.snap +2 -2
  8. package/components/__snapshots__/graduation-date.spec.js.snap +3 -3
  9. package/components/accept-terms.jsx +67 -9
  10. package/components/accept-terms.spec.js +12 -0
  11. package/components/app-banner.jsx +1 -1
  12. package/components/b2c-partnership-confirmation.jsx +2 -2
  13. package/components/b2c-partnership-payment-term.jsx +1 -1
  14. package/components/billing-city.jsx +1 -1
  15. package/components/billing-country.jsx +1 -1
  16. package/components/billing-postcode.jsx +1 -1
  17. package/components/company-name.jsx +1 -1
  18. package/components/confirmation.jsx +1 -1
  19. package/components/continue-reading.jsx +1 -1
  20. package/components/continue-reading.stories.js +1 -1
  21. package/components/country.jsx +1 -1
  22. package/components/customer-care.jsx +1 -1
  23. package/components/debug.jsx +1 -1
  24. package/components/decision-maker.jsx +1 -1
  25. package/components/decision-maker.spec.js +1 -1
  26. package/components/delivery-address-type.jsx +1 -1
  27. package/components/delivery-address.jsx +5 -5
  28. package/components/delivery-city.jsx +1 -1
  29. package/components/delivery-county.jsx +1 -1
  30. package/components/delivery-instructions.jsx +1 -1
  31. package/components/delivery-option.jsx +1 -1
  32. package/components/delivery-po-box.jsx +1 -1
  33. package/components/delivery-postcode.jsx +1 -1
  34. package/components/delivery-security-instructions.jsx +1 -1
  35. package/components/delivery-start-date.jsx +1 -1
  36. package/components/education-job-title.jsx +1 -1
  37. package/components/email.jsx +1 -1
  38. package/components/error-page.jsx +1 -1
  39. package/components/fieldset.jsx +1 -1
  40. package/components/first-name.jsx +1 -1
  41. package/components/form.jsx +1 -1
  42. package/components/google-sign-in.jsx +1 -1
  43. package/components/graduation-date.jsx +1 -1
  44. package/components/industry.jsx +1 -1
  45. package/components/job-title.jsx +1 -1
  46. package/components/last-name.jsx +1 -1
  47. package/components/licence-confirmation.jsx +1 -1
  48. package/components/licence-header.jsx +2 -2
  49. package/components/licence-sign-in.jsx +2 -2
  50. package/components/licence-title.jsx +2 -2
  51. package/components/lite-sub-confirmation.jsx +1 -1
  52. package/components/loader.jsx +1 -1
  53. package/components/message.jsx +1 -1
  54. package/components/organisation.jsx +1 -1
  55. package/components/package-change.jsx +1 -1
  56. package/components/password.jsx +1 -1
  57. package/components/payment-term.jsx +1 -1
  58. package/components/payment-type.jsx +2 -2
  59. package/components/personal-title.jsx +1 -1
  60. package/components/phone.jsx +1 -1
  61. package/components/position.jsx +1 -1
  62. package/components/progress-indicator.jsx +3 -3
  63. package/components/province.jsx +1 -1
  64. package/components/registration-confirmation.jsx +1 -1
  65. package/components/responsibility.jsx +1 -1
  66. package/components/section.jsx +1 -1
  67. package/components/state.jsx +1 -1
  68. package/components/submit.jsx +1 -1
  69. package/components/trial-banner.jsx +1 -1
  70. package/dist/accept-terms.js +42 -7
  71. package/dist/b2c-partnership-confirmation.js +1 -1
  72. package/dist/confirmation.js +2 -2
  73. package/dist/continue-reading.js +2 -2
  74. package/dist/decision-maker.js +2 -2
  75. package/dist/delivery-address.js +4 -4
  76. package/dist/delivery-instructions.js +2 -2
  77. package/dist/delivery-security-instructions.js +2 -2
  78. package/dist/delivery-start-date.js +2 -2
  79. package/dist/fieldset.js +2 -2
  80. package/dist/licence-confirmation.js +2 -2
  81. package/dist/loader.js +2 -2
  82. package/dist/message.spec.js +2 -2
  83. package/dist/payment-term.js +2 -2
  84. package/dist/payment-type.js +3 -3
  85. package/package.json +10 -6
  86. package/test-jest/helpers/expect-to-render-correctly.js +1 -1
  87. package/utils/app-banner.js +1 -1
  88. package/utils/apple-pay.js +15 -15
  89. package/utils/billing-city.js +1 -1
  90. package/utils/billing-country.js +3 -3
  91. package/utils/billing-postcode.js +1 -1
  92. package/utils/company-name.js +1 -1
  93. package/utils/countries.js +2 -2
  94. package/utils/country.js +3 -3
  95. package/utils/delivery-address-type.js +3 -3
  96. package/utils/delivery-address.js +1 -1
  97. package/utils/delivery-instructions.js +1 -1
  98. package/utils/delivery-option-messages.js +11 -11
  99. package/utils/delivery-option-messages.spec.js +2 -2
  100. package/utils/delivery-option.js +5 -5
  101. package/utils/delivery-po-box.js +1 -1
  102. package/utils/delivery-postcode.js +1 -1
  103. package/utils/delivery-start-date.js +4 -4
  104. package/utils/email.js +4 -4
  105. package/utils/event-notifier.js +1 -1
  106. package/utils/form-element.js +8 -8
  107. package/utils/loader.js +10 -10
  108. package/utils/password.js +2 -2
  109. package/utils/payment-term.js +5 -5
  110. package/utils/payment-type.js +12 -12
  111. package/utils/postcode.js +3 -3
  112. package/utils/province.js +1 -1
  113. package/utils/salesforce.js +2 -2
  114. package/utils/state.js +1 -1
  115. package/utils/submit.js +5 -5
  116. package/utils/tracking.js +7 -7
  117. package/utils/validation.js +10 -10
  118. package/utils/zuora-error-map.js +5 -5
  119. package/utils/zuora.js +22 -12
package/utils/zuora.js CHANGED
@@ -19,7 +19,7 @@ const PaymentType = require('./payment-type');
19
19
  */
20
20
 
21
21
  class Zuora {
22
- constructor(window) {
22
+ constructor (window) {
23
23
  this.Z = window.Z;
24
24
 
25
25
  this.iframe = new FormElement(window.document, '.ncf__zuora-payment');
@@ -43,7 +43,7 @@ class Zuora {
43
43
  * @param {Object} prePopulatedFields Parameters with field ids and values to be pre-populated on the form
44
44
  * @param {Function} renderCallback A function that gets called after the form is rendered.
45
45
  */
46
- render({ params, prePopulatedFields = {}, renderCallback = () => {} }) {
46
+ render ({ params, prePopulatedFields = {}, renderCallback = () => {}, captchaCallback = () => {} }) {
47
47
  // Using an undocumented Zuora method to attach a render callback for the iframe.
48
48
  // This method is called once when the iframe is rendered but gets removed for subsequent renderings.
49
49
  // In the Zuora code https://static.zuora.com/Resources/libs/hosted/1.3.1/zuora.js
@@ -71,6 +71,16 @@ class Zuora {
71
71
  this.Z.sendErrorMessageToHpm(key, errorMessage);
72
72
  }
73
73
  );
74
+
75
+ // if we have RECAPTCHA enabled for a given app id this allows the application
76
+ // to hide/show the loader so it is not in the way of completing the challenge
77
+ // docs: https://knowledgecenter.zuora.com/Billing/Billing_and_Payments/LA_Hosted_Payment_Pages/B_Payment_Pages_2.0/Configure_Advanced_Security_Checks_for_Payment_Pages_2.0
78
+ /**
79
+ * Z.setEventHandler - Zuora 3rd party method
80
+ * @param {string} event name
81
+ * @param {Function} anonymous - expects a single argument - event
82
+ */
83
+ this.Z.setEventHandler('onCaptchaStateChange', captchaCallback);
74
84
  }
75
85
 
76
86
  /**
@@ -79,7 +89,7 @@ class Zuora {
79
89
  * @param {String} paymentType Type of payment being used
80
90
  * @returns {Promise} Resolves when the submission has occurred, rejects if there was an error.
81
91
  */
82
- submit(paymentType) {
92
+ submit (paymentType) {
83
93
  return new Promise((resolve, reject) => {
84
94
  // Only handle credit card and direct debit payments
85
95
  if (
@@ -119,7 +129,7 @@ class Zuora {
119
129
  * agreement checkbox changing (inside the 3rd party Zuora iframe).
120
130
  * @param {Function} callback - the callback to fire upon change
121
131
  */
122
- onAgreementCheckboxChange(callback) {
132
+ onAgreementCheckboxChange (callback) {
123
133
  // Zuora 3rd party method, returns response to callback
124
134
  this.Z.setEventHandler('agreement_checked', () => {
125
135
  callback(true);
@@ -134,7 +144,7 @@ class Zuora {
134
144
  * of the direct debit mandate (inside the 3rd party Zuora iframe).
135
145
  * @param {Function} callback - the callback to fire upon confirmation.
136
146
  */
137
- onDirectDebitConfirmation(callback) {
147
+ onDirectDebitConfirmation (callback) {
138
148
  // Zuora 3rd party method, returns response to callback
139
149
  this.Z.setEventHandler('mandate_confirmed', () => {
140
150
  callback(true);
@@ -149,7 +159,7 @@ class Zuora {
149
159
  * Zuora doc: https://knowledgecenter.zuora.com/Billing/Billing_and_Payments/LA_Hosted_Payment_Pages/B_Payment_Pages_2.0/H_Integrate_Payment_Pages_2.0#Add_a_Checkbox_for_Stored_Credential_Consent
150
160
  * @returns {boolean}
151
161
  */
152
- setAgreement() {
162
+ setAgreement () {
153
163
  const mitConsentAgreementSrc = 'External';
154
164
  const mitProfileType = 'Recurring';
155
165
  const agreementSupportedBrands = 'Visa,Mastercard';
@@ -166,21 +176,21 @@ class Zuora {
166
176
  /**
167
177
  * Expose ZuoraErrorValidation
168
178
  */
169
- static get ZuoraErrorValidation() {
179
+ static get ZuoraErrorValidation () {
170
180
  return ZuoraErrorValidation;
171
181
  }
172
182
 
173
183
  /**
174
184
  * Expose ZuoraErrorMandateCancel
175
185
  */
176
- static get ZuoraErrorMandateCancel() {
186
+ static get ZuoraErrorMandateCancel () {
177
187
  return ZuoraErrorMandateCancel;
178
188
  }
179
189
 
180
190
  /**
181
191
  * Expose ZuoraErrorInvalidPaymentType
182
192
  */
183
- static get ZuoraErrorInvalidPaymentType() {
193
+ static get ZuoraErrorInvalidPaymentType () {
184
194
  return ZuoraErrorInvalidPaymentType;
185
195
  }
186
196
  }
@@ -189,19 +199,19 @@ class Zuora {
189
199
  * Error classes
190
200
  */
191
201
  class ZuoraErrorValidation extends Error {
192
- constructor(message) {
202
+ constructor (message) {
193
203
  super(message);
194
204
  Object.setPrototypeOf(this, ZuoraErrorValidation.prototype);
195
205
  }
196
206
  }
197
207
  class ZuoraErrorMandateCancel extends Error {
198
- constructor(message) {
208
+ constructor (message) {
199
209
  super(message);
200
210
  Object.setPrototypeOf(this, ZuoraErrorMandateCancel.prototype);
201
211
  }
202
212
  }
203
213
  class ZuoraErrorInvalidPaymentType extends Error {
204
- constructor(message) {
214
+ constructor (message) {
205
215
  super(message);
206
216
  Object.setPrototypeOf(this, ZuoraErrorInvalidPaymentType.prototype);
207
217
  }