@motopays/pay-form 1.0.21-rc.0 → 1.0.22-rc.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.
package/README.md CHANGED
@@ -1,409 +1,605 @@
1
- # @motopays/pay-form
2
-
3
- ## Installation
4
-
5
- ```
6
- npm i @motopays/pay-form
7
- #or
8
- yarn add @motopays/pay-form
9
- ```
10
-
11
- ## Usage
12
-
13
- ```html
14
- <body>
15
- <moto-web-pay id="payment"></moto-web-pay>
16
- </body>
17
- ```
18
-
19
- ```javascript
20
- import "@motopays/pay-form/lib/index.js";
21
- import "@motopays/pay-form/lib/styles/styles.css";
22
-
23
- const payment$ = document.querySelector("#payment");
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
- if(event.detail.type == 'user-preference-checkbox-1-check') {
29
- console.log(event.detail.payload);
30
- }
31
- });
32
-
33
- payment$.payment = {
34
- userAuthToken?: string;
35
- userId: string;
36
-
37
- paymentId: string;
38
- amount: number;
39
- amountType?: AmountType; //one of strings: GrossWithoutGst, Net, Gross
40
- tax?: number;
41
- orderType?: OrderType; //one of numbers: Regular, FreeTrial
42
- currency: string;
43
- merchantId: string;
44
- initiator?: PaymentInitiatorType; //one of strings: Customer, Merchant
45
-
46
- webhookUrl?: string;
47
- returnUrl?: string;
48
-
49
- description: string;
50
- email?: string;
51
- details?: ISimple<any>; //any object
52
- phoneNumber?: string;
53
- ipAddress?: string;
54
- signature?: string;
55
-
56
- billingAddress?: {
57
- addressLine: string;
58
- city: string;
59
- state: string;
60
- country: string;
61
- zip: string;
62
- }
63
- }
64
-
65
- payment$.settings = {
66
- isPhoneNumberFieldVisible: boolean;
67
- isCloseButtonVisible: boolean;
68
- isSignatureRequired: boolean;
69
- isProblemTipsListVisible: boolean;
70
-
71
- urls: {
72
- //For example, "https://billingprofiles.dating.com
73
- billingProfiles: string;
74
- processing: string;
75
- };
76
-
77
- //Now it supports these strings: "american-express" | "discover" | "jcb" | "maestro" | "mastercard" | "unionpay" | "visa"
78
- availableCardBrands: string[] or CreditCardTypeCardBrandId[];
79
-
80
- chargeTerms: {
81
- visible: boolean;
82
- text?: string;
83
- checkboxes?: {
84
- text: string;
85
- link: {
86
- text: string;
87
- href: string;
88
- }
89
- } [];
90
- };
91
-
92
- merchantInfo: {
93
- visible: boolean;
94
- text?: string;
95
- links?: {
96
- text: string;
97
- href: string;
98
- } [];
99
- };
100
- }
101
-
102
- payment$.addEventListener("close", (event) => {
103
- console.log("clicked to close icon: ", e); // Custom event
104
- });
105
-
106
- payment$.addEventListener("paid", (event) => {
107
- console.log("event after pay: ", event.detail); // Payment result event
108
- });
109
- ```
110
-
111
- ### Usage with TypeScript
112
-
113
- ```typescript
114
- declare module "@motopays/pay-form/pay";
115
- ```
116
-
117
- ### Payment interface
118
-
119
- | Field | Type | Description |
120
- | ------------------------ | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
121
- | userAuthToken | string | End-user authorization token to access Motopays services. This field is necessary for ApplePay availability |
122
- | userId **\*required** | string | External end-user Id generated on the merchant side (not Motopays) |
123
- | paymentId **\*required** | string | Id of a payment |
124
- | amount **\*required** | number | Payment amount |
125
- | amountType | AmountType or string | Type of amount can be only one of the following values: {GrossWithoutGst, Net, Gross} |
126
- | tax | number | Payment tax |
127
- | orderType | OrderType or string | Type of order can be only one of the following values: {Regular, FreeTrial} |
128
- | currency **\*required** | string | Payment currency in ISO_4217 format. For example: gbp, eur, usd |
129
- | merchantId **\*required** | string | Merchant's identificator, issued by Motopays. |
130
- | initiator | PaymentInitiatorType or string | Identifies who of 2 types initiated the payment. Currently accepted: {Merchant, Customer} |
131
- | webhookUrl | string | URL where the Motopays will send hooks about the payment status changes |
132
- | returnUrl | string | The URL to which the user will be redirected after completing some types of payment, such as PayPal |
133
- | description | string | Short order description for the customer |
134
- | email | string | End-customer e-mail. That parameter can be used to find a best button appearance for the particular customer. |
135
- | details | ISimple<any> | Additional information about payment |
136
- | phoneNumber | string | End-customer phone number (can be changed if a customer fill the number by themself) |
137
- | ipAddress | string | End-customer ip address |
138
- | billingAddress | BillingAddress | The address linked to a customer bank account |
139
- | billingAddress.addressLine | string | Street, building appartment and etc in one line |
140
- | billingAddress.city | string | City of a customer bank account |
141
- | billingAddress.state | string | State of a customer bank account |
142
- | billingAddress.country | string | Country of a customer bank account (ISO 3166-1 alpha-2 country code). Example: US |
143
- | billingAddress.zip | string | Zip of a customer bank account |
144
- | signature | string | The signature of the payment. For details contact technical support |
145
-
146
- ### Settings interface
147
-
148
- | Field | Type | Description |
149
- |-----------------------------|---------|-----------------------------------------------------------------------------|
150
- | urls **\*required** | IServicesUrls | The necessary services urls |
151
- | urls.processing **\*required** | string | The processing service URL |
152
- | urls.billingprofiles **\*required** | string | The billing profiles service URL |
153
- | isPhoneNumberFieldVisible | boolean | Whether to show the phone input field when creating a map |
154
- | isSignatureRequired | boolean | Whether to show an error and deny access to the payment form if the signature field in the payment model is not set |
155
- | isCloseButtonVisible | boolean | Whether to show a window close button in the top right corner of the screen |
156
- | isProblemTipsListVisible | boolean | Whether to show tips on the payment result page when the payment is rejected, if tips exist for the error status code that occurred |
157
- | merchantInfo | IMerchantInfoSettings | The information displays in merchant info section |
158
- | merchantInfo.visible | boolean | Whether to show the merchant information |
159
- | merchantInfo.text | string | The information about a merchant |
160
- | merchantInfo.links | ILink[] | The array of merchant links. For example, Policy and Terms |
161
- | chargeTerms | IChargeTermsSettings | The charge terms section |
162
- | chargeTerms.visible | boolean | Whether to show the charge terms |
163
- | chargeTerms.checkboxes | ITermCheckbox[] | The checkboxes that, without being selected, the user will not be able to make a payment. All these checkboxes have to be selected by user to be able to make a payment |
164
- | chargeTerms.text | string | The text of charge terms. For example, description of terms and policy |
165
- | chargeTerms.location | string or ChargeTermsLocation | The location of ChargeTerms element. Currently accepted: { BeforePay, AfterPay } |
166
- | availableCardBrands | string[] or CreditCardTypeCardBrandId[] | The сard brands for which icons will be displayed on the form as card payment methods. Currently accepted: {american-express, discover, jcb, maestro, mastercard, unionpay, visa} |
167
- | requiredFieldsBehavior | IRequiredFieldsBehavior | Configuration of the display of required fields for the user to manage the user's focus on them |
168
- | requiredFieldsBehavior<br>.showStars | boolean | Show the stars on labels of required fields |
169
- | requiredFieldsBehavior<br>.buttonStateUntilCorrect | string | If 'disabled', the payment buttons remain disabled until the user fills in all the required fields. If 'enabled', then when one of the buttons is pressed (the buttons are enabled), the required fields will be marked as invalid (red color) for the user. If 'hidden-enabled', then when one of the buttons is pressed (the buttons are enabled but have styles as disabled), the required fields will be marked as invalid (red color) for the user. Current accepted: { enabled, disabled, hidden-enabled } |
170
- | requiredFieldsBehavior<br>.markAsInvalidUntilCorrect | boolean | If true, then all unfilled or incorrectly filled required fields will initially appear as invalid (red color) to the user until they are filled and correct. If the value is false, the required fields will only be shown as invalid in the event that the user presses the payment button when the buttons are enabled |
171
- | userPreferences | IUserPreferencesSettings | The user preferences section |
172
- | userPreferences.visible | boolean | Whether to show the user preferences |
173
- | userPreferences.text | string | The text of user preferences. For example, description of autorefill plan |
174
- | userPreferences.checkboxes | IUserPreferenceCheckbox[] | The text of user preferences. For example, description of autorefill plan |
175
-
176
-
177
- ILink interface:
178
- ```javascript
179
- interface ILink {
180
- text: string;
181
- href: string;
182
- }
183
- ```
184
-
185
- ITermCheckbox interface:
186
- ```javascript
187
- interface ITermCheckbox {
188
- text: string;
189
- link?: ILink;
190
- }
191
- ```
192
-
193
- IUserPreferenceCheckbox interface:
194
- ```javascript
195
- interface IUserPreferenceCheckbox {
196
- name: string;
197
- text: string;
198
- link?: ILink;
199
- defaultValue?: boolean;
200
- }
201
- ```
202
-
203
- Example of merchantInfo:
204
- ```javascript
205
- merchantInfo: {
206
- "visible": true,
207
- "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",
208
- "links": [
209
- {
210
- "text": "Terms",
211
- "href": "https://www.google.com/"
212
- },
213
- {
214
- "text": "Policy",
215
- "href": "https://www.google.com/"
216
- }
217
- ]
218
- }
219
- ```
220
-
221
- Example of chargeTerms:
222
- ```javascript
223
- chargeTerms: {
224
- "visible": true,
225
- "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.",
226
- "checkboxes": [
227
- {
228
- "text": "I hereby agree to the conditions previously outlined.",
229
- "link": {
230
- "text": "Link to the application",
231
- "href": "https://www.google.com/"
232
- }
233
- },
234
- {
235
- "text": "I validate the foregoing stipulations.",
236
- "link": {
237
- "text": "Google",
238
- "href": "https://www.google.com/"
239
- }
240
- }
241
- ]
242
- },
243
- ```
244
-
245
- Example of userPreferences:
246
- ```javascript
247
- "userPreferences": {
248
- "visible": true,
249
- "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.",
250
- "checkboxes": [
251
- {
252
- "name": "autoFill",
253
- "text": "Do you want to auto refill? Check this.",
254
- "link": {
255
- "text": "Refill policy",
256
- "href": "https://www.google.com/"
257
- }
258
- },
259
- {
260
- "name": "isGood",
261
- "defaultValue": true,
262
- "text": "Do you want to mark this as good? Check this.",
263
- "link": {
264
- "text": "Link to the application",
265
- "href": "https://www.google.com/"
266
- }
267
- }
268
- ]
269
- }
270
- ```
271
-
272
- ### Output events
273
-
274
- | Event | Type | Description |
275
- | ----- | -------------- | -------------------------------------------- |
276
- | close | void | triggered by clicking on the closing icon |
277
- | paid | Payment Result | triggered after receiving a payment response |
278
- | analyticsTracked | IAnalyticsData | triggered by analytics events |
279
-
280
- ### Payment Result Structure
281
-
282
- ```javascript
283
- IPaymentResponse {
284
- action?: {
285
- name: string;
286
- data: IThreeDsData | IRedirectData | any;
287
- }
288
- ip: string;
289
- merchant: string;
290
- order: {
291
- invoiceId: string;
292
- details: string;
293
- }
294
- payment: {
295
- paymentId: string;
296
- state: PaymentState; //on of strings: completed, rejected, needAction
297
- rebillAnchor: string;
298
- info: {
299
- completeProcessingTime?: Date;
300
- currency: string;
301
- paymentType: string;
302
- paymentSystem: string;
303
- paymentRequisites?: string;
304
- price: number
305
- }
306
- rejectionDetails?: {
307
- hardDecline: boolean;
308
- message?: string;
309
- problemSolvingTips: string[];
310
- rejectionCode: number;
311
- }
312
- }
313
- taxInfo: {
314
- abbreviation: string;
315
- price: number;
316
- priceNet: number;
317
- tax: number;
318
- }
319
- user: {
320
- id: string;
321
- }
322
- signature: string;
323
- }
324
-
325
- IThreeDsData {
326
- paReq: string;
327
- acsurl: string;
328
- termUrl: string;
329
- md: string;
330
- }
331
-
332
- IRedirectData {
333
- location: string;
334
- }
335
- ```
336
-
337
- ### Analytics
338
- For receiving analytics listen analyticsTracked events.
339
-
340
- 'init-start' - the form has started initializtion. Payload: void.<br>
341
- 'loading-finish' - the form has finished initialization and loading. Payload: void.<br>
342
- 'card-number-field-click' - the card number field has been clicked. Payload: void.<br>
343
- 'expiration-date-field-click' - the expiration date field has been clicked. Payload: void.<br>
344
- 'cvv-field-click' - the cvv field has been clicked. Payload: void.<br>
345
- 'card-holder-field-click' - the card holder field has been clicked. Payload: void.<br>
346
- 'charge-term-checkbox-<number>-check' - the charge term checkbox has been checked. Payload: IChargeTermsAnalytics.<br>
347
- 'charge-term-checkbox-<number>-uncheck' - the charge term checkbox has been unchecked. Payload: IChargeTermsAnalytics.<br>
348
- 'user-preference-checkbox-<number>-check' - the user preference checbox has been checked. Payload: IUserPreferencesAnalytics.<br>
349
- 'user-preference-checkbox-<number>-uncheck' - the user preference checbox has been unchecked. Payload: IUserPreferencesAnalytics.<br>
350
- 'pay-button-click' - the 'Pay' button has been clicked (payment by card). Payload: void.<br>
351
- '<apm>-button-click' - the apm payment button has been clicked. Payload: void.<br>
352
- 'add-card-button-click' - the "Add New Card" button has been clicked. Payload: void.<br>
353
- 'card-options-button-click' - the card options button has been clicked (existing card menu visualised as 3 vertical dots). Payload: ICardAnalytics.<br>
354
- 'remove-card-button-click' - the card removing button has been clicked. Payload: ICardAnalytics.<br>
355
- 'select-card-button-click' - the card selecting button has been clicked. Payload: ICardAnalytics.<br>
356
-
357
- Examples of dynamic event types (number inserting):
358
- &emsp;1. Example of the first checkbox: 'charge-term-checkbox-0-check'
359
- &emsp;2. Example of the second checkbox: 'charge-term-checkbox-1-check'
360
-
361
- Examples of dynamic event types (apm inserting):
362
- &emsp;1. 'coinbase-button-click'
363
- &emsp;2. 'moto-button-click'
364
-
365
- ```javascript
366
- //structure
367
- interface IAnalyticsData {
368
- type: TAnalyticsData,
369
- payload?: any
370
- }
371
-
372
- //event types
373
- type TAnalyticsData =
374
- | 'init-start'
375
- | 'loading-finish'
376
- | 'card-number-field-click'
377
- | 'expiration-date-field-click'
378
- | 'cvv-field-click'
379
- | 'card-holder-field-click'
380
- | `charge-term-checkbox${`-${number}`}-check`
381
- | `charge-term-checkbox${`-${number}`}-uncheck`
382
- | `user-preference-checkbox${`-${number}`}-check`
383
- | `user-preference-checkbox${`-${number}`}-uncheck`
384
- | 'pay-button-click'
385
- | `${string}-button-click`
386
- | 'add-card-button-click'
387
- | 'card-options-button-click'
388
- | 'remove-card-button-click'
389
- | 'select-card-button-click'
390
-
391
-
392
- //payload types
393
- interface ICardAnalytics {
394
- last4Digits: string;
395
- }
396
-
397
- interface IChargeTermsAnalytics {
398
- text: string;
399
- }
400
-
401
- interface IUserPreferencesAnalytics {
402
- name: string;
403
- text: string;
404
- }
405
- ```
406
-
407
- ### Webpack 5 Issues
408
-
1
+ # @motopays/pay-form
2
+
3
+ ## Installation
4
+
5
+ ```
6
+ npm i @motopays/pay-form
7
+ #or
8
+ yarn add @motopays/pay-form
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Html + JS
14
+ ```html
15
+ <head>
16
+ ...
17
+ <link rel="stylesheet" href="motopays/pay-form/styles.css" />
18
+ ...
19
+ </head>
20
+ <body>
21
+ ...
22
+ <div id="moto-payment-form"></div>
23
+ ...
24
+ </body>
25
+ <script src="motopays/pay-form/index.js" type="text/javascript"></script>
26
+ <script type="text/javascript">
27
+ const targetElement = document.getElementById("moto-payment-form");
28
+ const paymentFormElement = document.createElement("moto-payment-form");
29
+ paymentFormElement.id = "moto-payment-form";
30
+
31
+ paymentFormElement.payment = {...};
32
+ paymentFormElement.settings = {...};
33
+
34
+ paymentFormElement.addEventListener("close", (event) => {
35
+ console.log(event);
36
+ });
37
+ paymentFormElement.addEventListener("analyticsTracked", (event) => {
38
+ console.log(event);
39
+ });
40
+ paymentFormElement.addEventListener("paid", (event) => {
41
+ console.log(event);
42
+ });
43
+ paymentFormElement.addEventListener("error", (event) => {
44
+ console.log(event);
45
+ });
46
+
47
+ targetElement.parentNode.replaceChild(formElement, targetElement);
48
+ </script>
49
+ ```
50
+
51
+ ### React
52
+ ```typescript
53
+ import './App.css';
54
+ import '@motopays/pay-form/index.js';
55
+ import { IPaymentSettings, ISettings } from '@motopays/pay-form/index.js';
56
+ import '@motopays/pay-form/styles.css';
57
+ import { useEffect, useRef } from 'react';
58
+
59
+ interface MotoPaymentFormProps extends React.HTMLAttributes<HTMLElement> {
60
+ payment: string;
61
+ settings: string;
62
+ }
63
+
64
+ declare global {
65
+ namespace JSX {
66
+ interface IntrinsicElements {
67
+ 'moto-payment-form': React.DetailedHTMLProps<
68
+ MotoPaymentFormProps,
69
+ HTMLElement
70
+ >;
71
+ }
72
+ }
73
+ }
74
+
75
+ const handleClose = () => console.log('close');
76
+ const handleAnalyticsTracked = (e: any) => console.log(e);
77
+ const handleError = (e: any) => console.log(e);
78
+ const handlePaid = (e: any) => console.log(e);
79
+
80
+ function App() {
81
+ const motoPaymentFormRef = useRef<HTMLElement>(null);
82
+
83
+ useEffect(() => {
84
+ const motoPaymentFormElement = motoPaymentFormRef.current;
85
+
86
+ if (motoPaymentFormElement) {
87
+ motoPaymentFormElement.addEventListener('close', handleClose);
88
+ motoPaymentFormElement.addEventListener('analyticsTracked', handleAnalyticsTracked);
89
+ motoPaymentFormElement.addEventListener('paid', handlePaid);
90
+ motoPaymentFormElement.addEventListener('error', handleError);
91
+
92
+ return () => {
93
+ motoPaymentFormElement.removeEventListener('close', handleClose);
94
+ motoPaymentFormElement.removeEventListener('analyticsTracked', handleAnalyticsTracked);
95
+ motoPaymentFormElement.removeEventListener('paid', handlePaid);
96
+ motoPaymentFormElement.removeEventListener('error', handleError);
97
+ };
98
+ }
99
+ }, []);
100
+
101
+ const payment: IPaymentSettings = {...};
102
+ const settings: ISettings = {...};
103
+ const paymentJSON: string = JSON.stringify(payment);
104
+ const settingsJSON: string = JSON.stringify(settings);
105
+
106
+ return (
107
+ <div className="App">
108
+ <moto-payment-form ref={motoPaymentFormRef} payment={paymentJSON} settings={settingsJSON}></moto-payment-form>
109
+ </div>
110
+ );
111
+ }
112
+
113
+ export default App;
114
+
115
+ ```
116
+
117
+ ### Angular
118
+ ```typescript
119
+ import { CUSTOM_ELEMENTS_SCHEMA, Component } from '@angular/core';
120
+ import '@motopays/pay-form/index.js';
121
+ import '@motopays/pay-form/styles.css';
122
+ import { IPaymentSettings, ISettings } from '@motopays/pay-form/index.js';
123
+
124
+ @Component({
125
+ selector: 'app-root',
126
+ standalone: true,
127
+ template: `
128
+ <moto-payment-form
129
+ [payment]="payment"
130
+ [settings]="settings"
131
+ (close)="onClose()"
132
+ (analyticsTracked)="onAnalyticsTracked($event)"
133
+ (error)="onError($event)"
134
+ (paid)="onPaid($event)">
135
+ </moto-payment-form>
136
+ `,
137
+ styleUrl: './app.component.scss',
138
+ schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
139
+ })
140
+ export class AppComponent {
141
+ protected payment: IPaymentSettings = {...};
142
+ protected settings: ISettings = {...};
143
+
144
+
145
+ protected onClose(): void {
146
+ console.log('close');
147
+ }
148
+
149
+ protected onAnalyticsTracked(e: any): void {
150
+ console.log(e);
151
+ }
152
+
153
+ protected onPaid(e: any): void {
154
+ console.log(e);
155
+ }
156
+
157
+ protected onError(e: any): void {
158
+ console.log(e);
159
+ }
160
+ }
161
+ ```
162
+
163
+ ### Payment interface
164
+
165
+ | Field | Type | Description |
166
+ | ------------------------ | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
167
+ | userId **\*required** | string | External end-user Id generated on the merchant side (not Motopays) |
168
+ | paymentId **\*required** | string | External unique payment Id generated on the merchant side (not Motopays) |
169
+ | amount **\*required** | number | Payment amount |
170
+ | currency **\*required** | string | Payment currency in ISO_4217 format. For example: gbp, eur, usd |
171
+ | merchantId **\*required** | string | Merchant's identifier, issued by Motopays. |
172
+ | email **\*required** | string | End-customer e-mail. |
173
+ | userAuthToken | string | End-user authorization token for accessing cards that have previously been used, as well as for accessing Apple Pay |
174
+ | amountType | TAmountType | Type of amount can be only one of the following values: { 'gross-without-gst', 'net', 'gross' } |
175
+ | tax | number | Payment tax |
176
+ | orderType | TOrderType | Type of order can be only one of the following values: { 'regular', 'free-trial', 'gems' } |
177
+ | initiator | TPaymentInitiator | Identifies who of 2 types initiated the payment. Currently accepted: {'customer', 'merchant'} |
178
+ | webhookUrl | string | URL where the Motopays will send hooks about the payment status changes |
179
+ | returnUrl | string | The URL to which the user will be redirected after completing some types of payment, such as PayPal |
180
+ | description | string | Short order description for the customer |
181
+ | details | ISimple<any> | Additional information about payment |
182
+ | phoneNumber | string | End-customer phone number (can be changed if a customer fill the number by themselves) |
183
+ | ipAddress | string | End-customer ip address |
184
+ | billingAddress | BillingAddress | The address linked to a customer bank account |
185
+ | billingAddress.addressLine | string | Street, building apartment and etc in one line |
186
+ | billingAddress.city | string | City of a customer bank account |
187
+ | billingAddress.state | string | State of a customer bank account |
188
+ | billingAddress.country | string | Country of a customer bank account (ISO 3166-1 alpha-2 country code). Example: US |
189
+ | billingAddress.zip | string | Zip of a customer bank account |
190
+ | signature | string | The signature of the payment. For details contact technical support |
191
+
192
+ ### Settings interface
193
+
194
+ | Field | Type | Description |
195
+ |-----------------------------|---------|-----------------------------------------------------------------------------|
196
+ | urls **\*required** | IServicesUrls | The necessary services urls |
197
+ | urls.processing **\*required** | string | The processing service URL |
198
+ | urls.billingProfiles **\*required** | string | The billing profiles service URL |
199
+ | isSignatureRequired | boolean | Whether to show an error and deny access to the payment form if the signature field in the payment model is not set |
200
+ | isCloseButtonVisible | boolean | Whether to show a window close button in the top right corner of the screen |
201
+ | isHeaderVisible | boolean | Whether to show a header in the top of the screen |
202
+ | closePaymentRedirect | boolean | Whether to close a window that was open on 3ds or apm pages after a redirect to returnUrl |
203
+ | isProblemTipsListVisible | boolean | Whether to show tips on the payment result page when the payment is rejected, if tips exist for the error status code that occurred |
204
+ | languageSettings | ILanguageSettings | The language settings
205
+ | languageSettings.code | TLanguageCode | The code of language. Currently accepted: { 'en-us', 'es-es', 'fr-fr' }. It's also possible to add another code by adding custom language to languageSettings.languages
206
+ | languageSettings.languages | Partial<Record<TLanguageCode, ILanguage>> | Languages by codes
207
+ | components | TComponentType[] | Components that will be on the form, as well as their order, which depends on the position of the components in the array. Currently accepted: {'available-card-brands', 'card-list', 'requisites', 'phone-number', 'charge-terms', 'pay-button', 'apm-list', 'user-preferences', 'merchant-info', 'protected-by', 'no-methods'}
208
+ | resultComponentsStructure | IResultComponentsStructure | Components that will be on the result page of the form, as well as their order, which depends on the position of the components in the array
209
+ | resultComponentsStructure<br>.aboveResult | TComponentType[] | Components that will be on the result page of the form above the result, as well as their order, which depends on the position of the components in the array
210
+ | resultComponentsStructure<br>.belowResult | TComponentType[] | Components that will be on the result page of the form below the result, as well as their order, which depends on the position of the components in the array
211
+ | merchantInfo | IMerchantInfoSettings | The information displays in merchant info section |
212
+ | merchantInfo.text | Partial<Record<TLanguageCode, string>> | The information about a merchant multilingual support and linkify. Read more about linkify in the Linkify section |
213
+ | merchantInfo.links | ILink[] | The array of merchant links. For example, Policy and Terms |
214
+ | chargeTerms | IChargeTermsSettings | The charge terms section |
215
+ | chargeTerms.checkboxes | Partial<Record<TLanguageCode, string>>[] | The user must select all the checkboxes to proceed with the payment. Without selecting these checkboxes, the payment cannot be made. Multilingual support and linkify. Read more about linkify in the Linkify section |
216
+ | chargeTerms.text | Partial<Record<TLanguageCode, string>> | The text of charge terms. For example, description of terms and policy. Multilingual support and linkify. Read more about linkify in the Linkify section |
217
+ | userPreferences | IUserPreferencesSettings | The user preferences section |
218
+ | userPreferences.text | Partial<Record<TLanguageCode, string>> | The text of user preferences. For example, description of autorefill plan. Multilingual support and linkify. Read more about linkify in the Linkify section |
219
+ | userPreferences.checkboxes | IUserPreferenceCheckbox[] | The text of user preferences. For example, description of autorefill plan. Multilingual support and linkify. Read more about linkify in the Linkify section |
220
+ | availableCardBrands | string[] or CreditCardTypeCardBrandId[] | The сard brands for which icons will be displayed on the form as card payment methods. Currently accepted: {american-express, discover, jcb, maestro, mastercard, unionpay, visa} |
221
+ | requiredFieldsBehavior | IRequiredFieldsBehavior | Configuration of the display of required fields for the user to manage the user's focus on them |
222
+ | requiredFieldsBehavior<br>.showStars | boolean | Show the stars on labels of required fields |
223
+ | requiredFieldsBehavior<br>.buttonStateUntilFilled | TButtonStateUntilFilled | If 'disabled', the payment buttons remain disabled until the user fills in all the required fields. If 'enabled', then when one of the buttons is pressed (the buttons are enabled), the required fields will be marked as invalid (red color) for the user. If 'hidden-enabled', then when one of the buttons is pressed (the buttons are enabled but have styles as disabled), the required fields will be marked as invalid (red color) for the user. Current accepted: { enabled, disabled, hidden-enabled } |
224
+ | requiredFieldsBehavior<br>.markAsInvalidUntilCorrect | boolean | If true, then all unfilled or incorrectly filled required fields will initially appear as invalid (red color) to the user until they are filled and correct. If the value is false, the required fields will only be shown as invalid in the event that the user presses the payment button when the buttons are enabled |
225
+ | events | IEvents | The events configuration |
226
+ | events.analytics | { optional: boolean; required: boolean; } | The analytics events configuration. Optional is responsible for 'focus' events. Required is responsible for 'click' events. Read more about analytics events in the Analytics section |
227
+ | events.error | boolean | The error events configuration. If true, the error events will be emitted; otherwise, they will not |
228
+ | apmsCollapse | boolean | The apms collapse configuration. If true, the 'or use alternative methods' text will be clickable and will control whether the apms are shown or not. By default, if true, the apms will be collapsed. |
229
+
230
+ ### Example
231
+
232
+ #### Payment
233
+
234
+ ```typescript
235
+ const payment: IPaymentSettings = {
236
+ amount: 10,
237
+ currency: 'usd',
238
+ email: 'random@gmail.com',
239
+ merchantId: '22504',
240
+ paymentId: 'IS949832NF29',
241
+ userId: 'OIDSF0202JFS',
242
+ amountType: 'net',
243
+ tax: 3,
244
+ orderType: 'gems',
245
+ userAuthToken: 'testestest.testestest.testestest',
246
+ billingAddress: {
247
+ addressLine: "main street 1",
248
+ city: "Paris",
249
+ country: "US",
250
+ state: "NY",
251
+ zip: "220125"
252
+ },
253
+ description: 'my description',
254
+ initiator: 'customer',
255
+ details: {
256
+ myField: 21
257
+ },
258
+ ipAddress: '12.12.12.12',
259
+ phoneNumber: '+995234234234',
260
+ returnUrl: 'https://my.return.com',
261
+ signature: '0saidmc0smac',
262
+ webhookUrl: 'https://my.webhook.com'
263
+ }
264
+ ```
265
+
266
+ #### Settings
267
+
268
+ ```typescript
269
+ const settings: ISettings = {
270
+ urls: {
271
+ processing: 'https://my.processing.com',
272
+ billingProfiles: 'https://my.billingprofiles.com',
273
+ },
274
+ apmsCollapse: false,
275
+ availableCardBrands: ['visa', 'american-express', 'mastercard', 'diners-club', 'jcb'],
276
+ chargeTerms: {
277
+ text: {
278
+ 'en-us': 'My charge terms { href: "https://google.com", text: "Google" } the ending of text',
279
+ 'es-es': 'My charge terms { href: "https://google.com", text: "Google es-es" } the ending of text es-es',
280
+ 'custom': 'custom charge terms text'
281
+ },
282
+ checkboxes: [
283
+ {
284
+ 'en-us': 'Charge terms { href: "https://google.com", text: "Google" } checkbox',
285
+ 'es-es': 'Charge terms { href: "https://google.com", text: "Google es-es" } checkbox es-es',
286
+ 'custom': 'custom'
287
+ }
288
+ ]
289
+ },
290
+ closePaymentRedirect: true,
291
+ components: [
292
+ 'available-card-brands',
293
+ 'no-methods',
294
+ 'card-list',
295
+ 'requisites',
296
+ //'phone-number',
297
+ 'charge-terms',
298
+ 'pay-button',
299
+ 'apm-list',
300
+ 'user-preferences',
301
+ 'merchant-info',
302
+ 'protected-by'
303
+ ],
304
+ events: {
305
+ analytics: {
306
+ optional: true,
307
+ required: true,
308
+ },
309
+ error: true
310
+ },
311
+ isCloseButtonVisible: true,
312
+ isHeaderVisible: true,
313
+ isProblemTipsListVisible: true,
314
+ isSignatureRequired: false,
315
+ languageSettings: {
316
+ code: 'custom',
317
+ languages: {
318
+ 'custom': {
319
+ apms: {
320
+ or: 'custom',
321
+ orUseAlternative: 'custom'
322
+ },
323
+ availableCardBrandsHeader: 'custom',
324
+ close: 'custom',
325
+ errors: {
326
+ invalidCardExpiration: 'custom',
327
+ invalidCardHolder: 'custom',
328
+ invalidCardNumber: 'custom',
329
+ invalidCvv: 'custom',
330
+ invalidPhoneNumber: 'custom',
331
+ notCheckedCheckboxes: 'custom'
332
+ },
333
+ existingCards: {
334
+ addNewCard: 'custom',
335
+ manageCardsHeader: 'custom',
336
+ removeCard: 'custom'
337
+ },
338
+ header: 'custom',
339
+ noAvailablePaymentMethods: 'custom',
340
+ notifications: {
341
+ cardDeleted: {
342
+ text: 'custom',
343
+ title: 'custom'
344
+ },
345
+ error: {
346
+ default: {
347
+ text: 'custom',
348
+ title: 'custom'
349
+ }
350
+ }
351
+ },
352
+ pay: 'custom',
353
+ paymentProcessing: 'custom',
354
+ paymentResult: {
355
+ success: 'custom',
356
+ failure: {
357
+ main: 'custom',
358
+ paymentFailed: 'custom'
359
+ }
360
+ },
361
+ phone: {
362
+ header: 'custom',
363
+ placeholder: 'custom'
364
+ },
365
+ requisites: {
366
+ cardExpirationPlaceholder: 'custom',
367
+ cardHolderHeader: 'custom',
368
+ cardHolderPlaceholder: 'custom',
369
+ cardNumberPlaceholder: 'custom',
370
+ cvvHint: 'custom',
371
+ paymentDetailsHeader: 'custom',
372
+ cvvPlaceholder: {
373
+ CID: 'custom',
374
+ CVC: 'custom',
375
+ CVE: 'custom',
376
+ CVN: 'custom',
377
+ CVP2: 'custom',
378
+ CVV: 'custom'
379
+ }
380
+ },
381
+ totalHeader: 'custom',
382
+ transactionProtectedBy: 'custom'
383
+ }
384
+ }
385
+ },
386
+ merchantInfo: {
387
+ text: {
388
+ 'en-us': 'Merchant info { href: "https://google.com", text: "Google" } merchant info { href: "https://google.com", text: "Google" } Merchant info',
389
+ 'es-es': 'Merchant info { href: "https://google.com", text: "Google es-es" } merchant info { href: "https://google.com", text: "Google es-es" } Merchant info es-es',
390
+ 'custom': 'custom merchant info'
391
+ },
392
+ links: [
393
+ {
394
+ href: 'https://google.com',
395
+ text: {
396
+ 'en-us': 'google',
397
+ 'es-es': 'google (es-es)',
398
+ 'custom': 'custom link'
399
+ }
400
+ }
401
+ ]
402
+ },
403
+ requiredFieldsBehavior: {
404
+ buttonStateUntilFilled: 'enabled',
405
+ markAsInvalidUntilCorrect: false,
406
+ showStars: true
407
+ },
408
+ resultComponentsStructure: {
409
+ aboveResult: [],
410
+ belowResult: ['merchant-info', 'protected-by']
411
+ },
412
+ userPreferences: {
413
+ text: {
414
+ 'en-us': 'User preferences text { href: "https://google.com", text: "Google" } User preferences text',
415
+ 'es-es': 'User preferences text { href: "https://google.com", text: "Google es-es" } User preferences text es-es',
416
+ 'custom': 'custom user preferences text'
417
+ },
418
+ checkboxes: [
419
+ {
420
+ name: 'user_preference_name',
421
+ text: {
422
+ 'en-us': 'User preference { href: "https://google.com", text: "Google" } checkbox',
423
+ 'es-es': 'User preference { href: "https://google.com", text: "Google es-es" } checkbox es-es',
424
+ 'custom': 'custom user preferences checkbox'
425
+ },
426
+ defaultValue: false
427
+ }
428
+ ]
429
+ }
430
+ };
431
+ ```
432
+
433
+ ### Output events
434
+
435
+ | Event | Type | Description |
436
+ | ----- | ---------------- | -------------------------------------------- |
437
+ | close | void | triggered by clicking on the closing icon |
438
+ | paid | IPaymentResponse | triggered after receiving a payment response |
439
+ | error | any | triggered by error events |
440
+ | analyticsTracked | TAnalyticsServiceAction | triggered by analytics events |
441
+
442
+ ### Payment Result Structure
443
+
444
+ ```javascript
445
+ IPaymentResponse {
446
+ action?: {
447
+ name: string;
448
+ data: IThreeDsData | IRedirectData | any;
449
+ }
450
+ ip: string;
451
+ merchant: string;
452
+ order: {
453
+ invoiceId: string;
454
+ details: string;
455
+ }
456
+ payment: {
457
+ paymentId: string;
458
+ state: TPaymentState; //on of strings: completed, rejected, needAction
459
+ rebillAnchor: string;
460
+ info: {
461
+ completeProcessingTime?: Date;
462
+ currency: string;
463
+ paymentType: string;
464
+ paymentSystem: string;
465
+ paymentRequisites?: string;
466
+ price: number
467
+ }
468
+ rejectionDetails?: {
469
+ hardDecline: boolean;
470
+ message?: string;
471
+ problemSolvingTips: string[];
472
+ rejectionCode: number;
473
+ }
474
+ }
475
+ taxInfo: {
476
+ abbreviation: string;
477
+ price: number;
478
+ priceNet: number;
479
+ tax: number;
480
+ }
481
+ user: {
482
+ id: string;
483
+ }
484
+ signature: string;
485
+ }
486
+
487
+ IThreeDsData {
488
+ paReq: string;
489
+ acsurl: string;
490
+ termUrl: string;
491
+ md: string;
492
+ }
493
+
494
+ IRedirectData {
495
+ location: string;
496
+ }
497
+ ```
498
+
499
+ ### Analytics
500
+ For receiving analytics listen analyticsTracked events.
501
+
502
+ 'init-start' - the form has started initialization. Payload: void.<br>
503
+ 'loading-finish' - the form has finished initialization and loading. Payload: void.<br>
504
+ 'card-number-field-focus' - the card number field has been focused. Payload: void.<br>
505
+ 'expiration-date-field-focused' - the expiration date field has been focused. Payload: void.<br>
506
+ 'cvv-field-focused' - the cvv field has been focused. Payload: void.<br>
507
+ 'card-holder-field-focused' - the card holder field has been focused. Payload: void.<br>
508
+ 'charge-term-checkbox-<number>-focus' - the charge term checkbox has been focused. Payload: IChargeTermsAnalytics.<br>
509
+ 'charge-term-checkbox-<number>-check' - the charge term checkbox has been checked. Payload: IChargeTermsAnalytics.<br>
510
+ 'charge-term-checkbox-<number>-uncheck' - the charge term checkbox has been unchecked. Payload: IChargeTermsAnalytics.<br>
511
+ 'user-preference-checkbox-<number>-focus' - the user preference checkbox has been focused. Payload: IUserPreferencesAnalytics.<br>
512
+ 'user-preference-checkbox-<number>-check' - the user preference checkbox has been checked. Payload: IUserPreferencesAnalytics.<br>
513
+ 'user-preference-checkbox-<number>-uncheck' - the user preference checkbox has been unchecked. Payload: IUserPreferencesAnalytics.<br>
514
+ 'pay-button-focus' - the 'Pay' button has been focused (payment by card). Payload: void.<br>
515
+ 'pay-button-click' - the 'Pay' button has been clicked (payment by card). Payload: void.<br>
516
+ '<apm>-button-focus' - the apm payment button has been focused. Payload: void.<br>
517
+ '<apm>-button-click' - the apm payment button has been clicked. Payload: void.<br>
518
+ 'add-card-button-focus' - the "Add New Card" button has been focused. Payload: void.<br>
519
+ 'add-card-button-click' - the "Add New Card" button has been clicked. Payload: void.<br>
520
+ 'card-options-button-click' - the card options button has been clicked (existing card menu visualized as 3 vertical dots). Payload: ICardAnalytics.<br>
521
+ 'cards-toggle-button-click' - the cards toggle button has been clicked (show or collapse card list). Payload: ICardListAnalytics.<br>
522
+ 'remove-card-button-click' - the card removing button has been clicked. Payload: ICardAnalytics.<br>
523
+ 'select-card-button-click' - the card selecting button has been clicked. Payload: ICardAnalytics.<br>
524
+ 'apms-show-button-click' - the apm collapse text has been clicked. Payload: ICardAnalytics.<br>
525
+
526
+ Examples of dynamic event types (number inserting):
527
+ &emsp;1. Example of the first checkbox: 'charge-term-checkbox-0-check'
528
+ &emsp;2. Example of the second checkbox: 'charge-term-checkbox-1-check'
529
+
530
+ Examples of dynamic event types (apm inserting):
531
+ &emsp;1. 'coinbase-button-click'
532
+ &emsp;2. 'moto-button-click'
533
+
534
+ ```javascript
535
+ type TAnalyticsServiceAction =
536
+ | ServiceAction<'init-start'>
537
+ | ServiceAction<'loading-finish'>
538
+ | ServiceAction<'card-number-field-focus'>
539
+ | ServiceAction<'expiration-date-field-focus'>
540
+ | ServiceAction<'cvv-field-focus'>
541
+ | ServiceAction<'card-holder-field-focus'>
542
+ | ServiceAction<'number-field-focus'> //
543
+ | ServiceAction<
544
+ `charge-term-checkbox${`-${number}`}-focus`,
545
+ IChargeTermsAnalytics
546
+ >
547
+ | ServiceAction<
548
+ `charge-term-checkbox${`-${number}`}-check`,
549
+ IChargeTermsAnalytics
550
+ >
551
+ | ServiceAction<
552
+ `charge-term-checkbox${`-${number}`}-uncheck`,
553
+ IChargeTermsAnalytics
554
+ >
555
+ | ServiceAction<
556
+ `user-preference-checkbox${`-${number}`}-focus`,
557
+ IUserPreferencesAnalytics
558
+ >
559
+ | ServiceAction<
560
+ `user-preference-checkbox${`-${number}`}-check`,
561
+ IUserPreferencesAnalytics
562
+ >
563
+ | ServiceAction<
564
+ `user-preference-checkbox${`-${number}`}-uncheck`,
565
+ IUserPreferencesAnalytics
566
+ >
567
+ | ServiceAction<'pay-button-focus'>
568
+ | ServiceAction<'pay-button-click'>
569
+ | ServiceAction<`${string}-button-focus`>
570
+ | ServiceAction<`${string}-button-click`>
571
+ | ServiceAction<'add-card-button-focus'>
572
+ | ServiceAction<'add-card-button-click'>
573
+ | ServiceAction<'card-options-button-click', ICardAnalytics>
574
+ | ServiceAction<'cards-toggle-button-click', ICardListAnalytics>
575
+ | ServiceAction<'remove-card-button-click', ICardAnalytics>
576
+ | ServiceAction<'select-card-button-click', ICardAnalytics>
577
+ | ServiceAction<'apms-show-button-click', ICardAnalytics>;
578
+
579
+
580
+ //payload types
581
+ interface ICardListAnalytics {
582
+ toggle: boolean;
583
+ }
584
+
585
+ interface ICardAnalytics {
586
+ last4Digits: string;
587
+ }
588
+
589
+ interface IChargeTermsAnalytics {
590
+ text: string;
591
+ }
592
+
593
+ interface IUserPreferencesAnalytics {
594
+ name: string;
595
+ text: string;
596
+ }
597
+ ```
598
+
599
+ ### Linkify
600
+ Text elements, which are described in the documentation as linkify, can be transformed into text with links. The link object starts with the '{' character and ends with the '}' character. The href field specifies the URL to navigate to when clicked, and the text field specifies the text that will be displayed to the user as the link.
601
+ Example: 'My text { href: "https://google.com", text: "Link1" } the ending of text. The continuation of the text { href: "https://google.com", text: "Link1" }.'
602
+
603
+ ### Webpack 5 Issues
604
+
409
605
  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.