@motopays/pay-form 1.0.16 → 1.0.18-rc

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.
package/README.md CHANGED
@@ -22,6 +22,11 @@ import "@motopays/pay-form/lib/styles/styles.css";
22
22
 
23
23
  const payment$ = document.querySelector("#payment");
24
24
 
25
+ //This listener has to be assigned before payment and settings fields set
26
+ payment$.addEventListener("analyticsTracked", (event) => {
27
+ console.log("analytics data was detected: ", e); // Custom event
28
+ });
29
+
25
30
  payment$.payment = {
26
31
  userAuthToken?: string;
27
32
  userId: string;
@@ -161,7 +166,7 @@ declare module "@motopays/pay-form/pay";
161
166
 
162
167
 
163
168
  ILink interface:
164
- ```
169
+ ```javascript
165
170
  interface ILink {
166
171
  text: string;
167
172
  href: string;
@@ -169,7 +174,7 @@ interface ILink {
169
174
  ```
170
175
 
171
176
  ITermCheckbox interface:
172
- ```
177
+ ```javascript
173
178
  interface ITermCheckbox {
174
179
  text: string;
175
180
  link?: ILink;
@@ -177,7 +182,7 @@ interface ITermCheckbox {
177
182
  ```
178
183
 
179
184
  IUserPreferenceCheckbox interface:
180
- ```
185
+ ```javascript
181
186
  interface IUserPreferenceCheckbox {
182
187
  name: string;
183
188
  text: string;
@@ -187,7 +192,7 @@ interface IUserPreferenceCheckbox {
187
192
  ```
188
193
 
189
194
  Example of merchantInfo:
190
- ```
195
+ ```javascript
191
196
  merchantInfo: {
192
197
  "visible": true,
193
198
  "text": "The vendor prides itself on designing and implementing state-of-the-art payment infrastructures that cater to a wide range of commercial activities. Specializing in the creation of robust payment processing platforms, the merchant provides tailored solutions that support the dynamic needs of the global market",
@@ -205,7 +210,7 @@ merchantInfo: {
205
210
  ```
206
211
 
207
212
  Example of chargeTerms:
208
- ```
213
+ ```javascript
209
214
  chargeTerms: {
210
215
  "visible": true,
211
216
  "text": "By checking this box, I am affirming my full and complete understanding of, as well as my agreement to, all the terms and conditions that were previously presented to me, acknowledging that they form a binding contractual agreement.",
@@ -229,7 +234,7 @@ chargeTerms: {
229
234
  ```
230
235
 
231
236
  Example of userPreferences:
232
- ```
237
+ ```javascript
233
238
  "userPreferences": {
234
239
  "visible": true,
235
240
  "text": "By checking this box, I am affirming my full and complete understanding of, as well as my agreement to, all the terms and conditions that were previously presented to me, acknowledging that they form a binding contractual agreement.",
@@ -261,6 +266,7 @@ Example of userPreferences:
261
266
  | ----- | -------------- | -------------------------------------------- |
262
267
  | close | void | triggered by clicking on the closing icon |
263
268
  | paid | Payment Result | triggered after receiving a payment response |
269
+ | analyticsTracked | IAnalyticsData | triggered by analytics events |
264
270
 
265
271
  ### Payment Result Structure
266
272
 
@@ -319,6 +325,76 @@ IRedirectData {
319
325
  }
320
326
  ```
321
327
 
328
+ ### Analytics
329
+ For receiving analytics listen analyticsTracked events.
330
+
331
+ 'init-start' - the form has started initializtion. Payload: void.
332
+ 'loading-finish' - the form has finished initialization and loading. Payload: void.
333
+ 'card-number-field-click' - the card number field has been clicked. Payload: void.
334
+ 'expiration-date-field-click' - the expiration date field has been clicked. Payload: void.
335
+ 'cvv-field-click' - the cvv field has been clicked. Payload: void.
336
+ 'card-holder-field-click' - the card holder field has been clicked. Payload: void.
337
+ 'charge-term-checkbox-<number>-check' - the charge term checkbox has been checked. Payload: IChargeTermsAnalytics.
338
+ 'charge-term-checkbox-<number>-uncheck' - the charge term checkbox has been unchecked. Payload: IChargeTermsAnalytics.
339
+ 'user-preference-checkbox-<number>-check' - the user preference checbox has been checked. Payload: IUserPreferencesAnalytics.
340
+ 'user-preference-checkbox-<number>-uncheck' - the user preference checbox has been unchecked. Payload: IUserPreferencesAnalytics.
341
+ 'pay-button-click' - the 'Pay' button has been clicked (payment by card). Payload: void.
342
+ '<apm>-button-click' - the apm payment button has been clicked. Payload: void.
343
+ 'add-card-button-click' - the "Add New Card" button has been clicked. Payload: void.
344
+ 'card-options-button-click' - the card options button has been clicked (existing card menu visualised as 3 vertical dots). Payload: ICardAnalytics.
345
+ 'remove-card-button-click' - the card removing button has been clicked. Payload: ICardAnalytics.
346
+ 'select-card-button-click' - the card selecting button has been clicked. Payload: ICardAnalytics.
347
+
348
+ Examples of dynamic event types (number inserting):
349
+ &emsp;1. Example of the first checkbox: 'charge-term-checkbox-0-check'
350
+ &emsp;2. Example of the second checkbox: 'charge-term-checkbox-1-check'
351
+
352
+ Examples of dynamic event types (apm inserting):
353
+ &emsp;1. 'coinbase-button-click'
354
+ &emsp;2. 'moto-button-click'
355
+
356
+ ```javascript
357
+ //structure
358
+ interface IAnalyticsData {
359
+ type: TAnalyticsData,
360
+ payload?: any
361
+ }
362
+
363
+ //event types
364
+ type TAnalyticsData =
365
+ | 'init-start'
366
+ | 'loading-finish'
367
+ | 'card-number-field-click'
368
+ | 'expiration-date-field-click'
369
+ | 'cvv-field-click'
370
+ | 'card-holder-field-click'
371
+ | `charge-term-checkbox${`-${number}`}-check`
372
+ | `charge-term-checkbox${`-${number}`}-uncheck`
373
+ | `user-preference-checkbox${`-${number}`}-check`
374
+ | `user-preference-checkbox${`-${number}`}-uncheck`
375
+ | 'pay-button-click'
376
+ | `${string}-button-click`
377
+ | 'add-card-button-click'
378
+ | 'card-options-button-click'
379
+ | 'remove-card-button-click'
380
+ | 'select-card-button-click'
381
+
382
+
383
+ //payload types
384
+ interface ICardAnalytics {
385
+ last4Digits: string;
386
+ }
387
+
388
+ interface IChargeTermsAnalytics {
389
+ text: string;
390
+ }
391
+
392
+ interface IUserPreferencesAnalytics {
393
+ name: string;
394
+ text: string;
395
+ }
396
+ ```
397
+
322
398
  ### Webpack 5 Issues
323
399
 
324
400
  During the integration process, you might face multiple issues with webpack 5. This issue is caused due to the fact that some packages have certain dependencies, which are not present within the browser environment by webpack 5. Hence, you require certain [node polyfills](https://webpack.js.org/configuration/resolve/#resolvefallback) to be added to your project, while overriding the configurations to enable their usage. When that is done, your project should run without any issues.