1
1
<!-- BACK TO TOP LINK -->
2
- <a id =" readme-top " ></a >
3
2
3
+ <a id =" readme-top " ></a >
4
4
5
5
<!-- PROJECT SHIELDS -->
6
6
<div align =" center " >
37
37
</p >
38
38
</div >
39
39
40
-
41
40
![ SmartForm] ( ./assets/smartform.png )
42
41
43
42
## About the project
44
43
45
44
Any payment form must comply with PCI-DSS requirements. A classical integration will be displayed
46
45
on the banks page using a redirection. In that case, PCI-DSS requirements are done by your bank.
47
46
48
- By using this package Lyra allows to integrate a payment form using standard HTML elements on your
49
- website. This library will load the [ Javacript library] [ doc-home ] from Lyra servers transforming
50
- automatically each sensitive field (pan, security code, ...) into an IFrame, allowing to comply with
47
+ By using this package Lyra allows to integrate a payment form using standard HTML elements on your
48
+ website. This library will load the [ Javacript library] [ doc-home ] from Lyra servers transforming
49
+ automatically each sensitive field (pan, security code, ...) into an IFrame, allowing to comply with
51
50
all regulations.
52
51
53
- The ** embedded-form-glue** library provides a set of utilities to easily integrate the Payment
54
- form into any we application made with Javascript frameworks like React, Vue, Angular, Svelte,
52
+ The ** embedded-form-glue** library provides a set of utilities to easily integrate the Payment
53
+ form into any we application made with Javascript frameworks like React, Vue, Angular, Svelte,
55
54
Ionic, etc.
56
55
57
56
## Getting Started
@@ -77,15 +76,17 @@ First, define the theme files to load in the head section of your HTML page:
77
76
``` html
78
77
<head >
79
78
(...)
80
- <link rel =" stylesheet"
81
- href =" ~~CHANGE_ME_ENDPOINT~~/static/js/krypton-client/V4.0/ext/neon-reset.css" >
79
+ <link
80
+ rel =" stylesheet"
81
+ href =" ~~CHANGE_ME_ENDPOINT~~/static/js/krypton-client/V4.0/ext/neon-reset.css"
82
+ />
82
83
<script src =" ~~CHANGE_ME_ENDPOINT~~/static/js/krypton-client/V4.0/ext/neon.js" ></script >
83
84
(...)
84
85
</head >
85
86
```
86
87
87
88
> ** Note**
88
- >
89
+ >
89
90
> Replace ** ` ~~CHANGE_ME_ENDPOINT~~ ` ** with your configuration endpoint.
90
91
91
92
For more information about theming, please see [ Lyra theming documentation] [ doc-themes ]
@@ -101,45 +102,44 @@ After that, define the location where the payment form will be generated in your
101
102
```
102
103
103
104
> ** Note**
104
- >
105
- > Specifify the element ** kr-smart-form** inside the target location to load the Smart Form (any
105
+ >
106
+ > Specifify the element ** kr-smart-form** inside the target location to load the Smart Form (any
106
107
> kind of payment method).
107
108
108
109
### Javascript
109
110
110
111
Import the library in your javascript file or component with:
111
112
112
113
``` javascript
113
- import KRGlue from " @lyracom/embedded-form-glue" ;
114
+ import KRGlue from ' @lyracom/embedded-form-glue'
114
115
```
115
116
116
117
And finally, you can generate the payment form with the following code:
117
118
118
119
``` javascript
119
120
/* Integration public key */
120
- const publicKey = ' ~~CHANGE_ME_PUBLIC_KEY~~' ;
121
- /* Endpoint. Must include the protocol (https://) */
122
- const endPoint = ' ~~CHANGE_ME_ENDPOINT~~' ;
121
+ const publicKey = ' ~~CHANGE_ME_PUBLIC_KEY~~'
122
+ /* Endpoint. Base domain with its protocol (e.g. https://domain.name, do not include any path after the domain ) */
123
+ const endPoint = ' ~~CHANGE_ME_ENDPOINT~~'
123
124
124
125
/* Load the remote library and get the KR object */
125
- const { KR } = await KRGlue .loadLibrary (endPoint, publicKey)
126
+ const { KR } = await KRGlue .loadLibrary (endPoint, publicKey)
126
127
/* Setting configuration */
127
128
await KR .setFormConfig ({ ' kr-language' : ' en-US' })
128
- /* Attach a payment form to a given DOM selector */
129
- const { result } = await KR .attachForm (' #myPaymentForm' )
130
- /* Show the payment form */
131
- await KR .showForm (result .formId );
129
+ /* Render the payment form into a given DOM selector */
130
+ await KR .renderElements (' #myPaymentForm' )
132
131
```
132
+
133
133
> ** Note**
134
- >
134
+ >
135
135
> Replace ** ` ~~CHANGE_ME_PUBLIC_KEY~~ ` ** with your configuration public key.
136
- >
136
+ >
137
137
> Replace ** ` ~~CHANGE_ME_ENDPOINT~~ ` ** with your configuration endpoint.
138
138
139
139
> ** Warning**
140
- >
141
- > KR methods use Promises. You should always use the ** await** keyword or ** then method** when
142
- > calling them. Please see [ Javascript Promises] [ js-promises ] and [ Async Functions] [ js-async-await ]
140
+ >
141
+ > KR methods use Promises. You should always use the ** await** keyword or ** then method** when
142
+ > calling them. Please see [ Javascript Promises] [ js-promises ] and [ Async Functions] [ js-async-await ]
143
143
> for more information.
144
144
145
145
## First transaction
@@ -148,8 +148,8 @@ Once the payment form is set up, you will see the skeleton animation. This is be
148
148
using the default demo token. To make a real transaction, you need to get a real ** formToken** .
149
149
150
150
To get a proper test ** formToken** , make a request to the Charge/CreatePayment web service. To not
151
- expose your credentials, it is mandatory to do that from a server. Please see the
152
- [ NodeJS server example] ( examples/server/README.md ) , or visit the following links for more
151
+ expose your credentials, it is mandatory to do that from a server. Please see the
152
+ [ NodeJS server example] ( examples/server/README.md ) , or visit the following links for more
153
153
information:
154
154
155
155
- [ Embedded form quick start] [ doc-quick-start ]
@@ -160,10 +160,14 @@ Once you have a **formToken**, you can set it in the payment form with the follo
160
160
161
161
``` javascript
162
162
// Use the loadLibrary to set the form token
163
- const { KR } = await KRGlue .loadLibrary (endPoint, publicKey, ' ~~CHANGE_ME_FORM_TOKEN~~' )
163
+ const { KR } = await KRGlue .loadLibrary (
164
+ endPoint,
165
+ publicKey,
166
+ ' ~~CHANGE_ME_FORM_TOKEN~~'
167
+ )
164
168
165
169
// Or set the form token once the library is loaded
166
- const { KR } = await KRGlue .loadLibrary (endPoint, publicKey)
170
+ const { KR } = await KRGlue .loadLibrary (endPoint, publicKey)
167
171
await KR .setFormConfig ({ formToken: ' ~~CHANGE_ME_FORM_TOKEN~~' })
168
172
```
169
173
@@ -178,11 +182,11 @@ methods.
178
182
179
183
### loadLibrary
180
184
181
- Use ` loadLibrary ` method to load the Lyra Javascript library. The method returns a ` Promise ` with
185
+ Use ` loadLibrary ` method to load the Lyra Javascript library. The method returns a ` Promise ` with
182
186
the ` KR ` object.
183
187
184
188
``` javascript
185
- const { KR } = await KRGlue .loadLibrary (endPoint, publicKey)
189
+ const { KR } = await KRGlue .loadLibrary (endPoint, publicKey)
186
190
```
187
191
188
192
## KR object
@@ -195,7 +199,7 @@ The available methods and callbacks are described in the following sections.
195
199
- [ KR callbacks] ( ./docs/kr_callbacks.md )
196
200
197
201
> ** Note**
198
- >
202
+ >
199
203
> See Lyra [ Javascript library reference] [ doc-reference ] for the complete reference guide.
200
204
201
205
## JavaScript frameworks integration
@@ -221,14 +225,15 @@ The payment form can be customized in many ways. Some of them in the following e
221
225
- [ Add additional fields] ( ./docs/customization#add-additional-fields )
222
226
- [ Use a different HTML structure] ( ./docs/customization#use-a-different-html-structure )
223
227
224
- Any of these customizations can be done using the same method ** KR.attachForm ()** .
228
+ Any of these customizations can be done using the same method ** KR.renderElements ()** .
225
229
226
230
> ** Note**
227
- >
228
- > Please see the [ Field Customization] [ doc-customization ] section of the documentation for more
231
+ >
232
+ > Please see the [ Field Customization] [ doc-customization ] section of the documentation for more
229
233
> information.
230
234
231
235
<!-- CONTRIBUTING -->
236
+
232
237
## Contributing
233
238
234
239
Contributions are welcome and pull requests will be reviewed and taken into account.
@@ -260,17 +265,19 @@ npm run examples:serve
260
265
Execute the tests with the command:
261
266
262
267
``` bash
263
- npm run test
268
+ npm run test:e2e
264
269
```
265
270
266
271
<!-- LICENSE -->
272
+
267
273
## License
268
274
269
275
Distributed under the MIT License. See the [ LICENSE file] ( ./LICENCE.txt ) for more information.
270
276
271
277
<p align =" right " >(<a href =" #readme-top " >back to top</a >)</p >
272
278
273
279
<!-- MARKDOWN LINKS & IMAGES -->
280
+
274
281
[ build-shield ] : https://img.shields.io/circleci/build/github/lyra/embedded-form-glue?style=for-the-badge&logo=github
275
282
[ build-url ] : https://circleci.com/gh/lyra/embedded-form-glue
276
283
[ npm-shield ] : https://img.shields.io/npm/v/@lyracom/embedded-form-glue?style=for-the-badge&logo=npm
@@ -285,6 +292,7 @@ Distributed under the MIT License. See the [LICENSE file](./LICENCE.txt) for mor
285
292
[ license-url ] : https://github.com/lyra/embedded-form-glue/blob/master/LICENSE.txt
286
293
287
294
<!-- DOC LINKS -->
295
+
288
296
[ doc-home ] : https://docs.lyra.com/en/rest/V4.0/javascript/
289
297
[ doc-quick-start ] : https://docs.lyra.com/en/rest/V4.0/javascript/quick_start_js.html
290
298
[ doc-reference ] : https://docs.lyra.com/en/rest/V4.0/javascript/features/reference.html
0 commit comments