@@ -98,21 +98,22 @@ export default App;
98
98
99
99
<br />
100
100
101
- ### 3. Define secure input fields:
102
-
103
- | Collect.js input type | Collect.js React Component | Default Prop Values |
104
- | ---------------------- | ------------------------------------------- | ---------------------------------------------------------- |
105
- | ` text ` | ` <VGSCollectForm.TextField/> ` | ` {type: 'text', placeholder: 'Cardholder Name'} ` |
106
- | ` card-number ` | ` <VGSCollectForm.CardNumberField/> ` | ` {type: 'card-number', placeholder: 'Credit Card Number'} ` |
107
- | ` card-expiration-date ` | ` <VGSCollectForm.CardExpirationDateField/> ` | ` {type: 'card-expiration-date', placeholder: 'MM/YY'} ` |
108
- | ` card-security-code ` | ` <VGSCollectForm.CardSecurityCodeField/> ` | ` {type: 'card-security-code', placeholder: 'CVC/CVV'} ` |
109
- | ` password ` | ` <VGSCollectForm.PasswordField/> ` | ` {type: 'password', placeholder: 'Enter Password'} ` |
110
- | ` ssn ` | ` <VGSCollectForm.SSNField/> ` | ` {type: 'ssn', placeholder: 'SSN'} ` |
111
- | ` zip-code ` | ` <VGSCollectForm.ZipCodeField/> ` | ` {type: 'zip-code', placeholder: 'Zip Code'} ` |
112
- | ` number ` | ` <VGSCollectForm.NumberField/> ` | ` {type: 'number', placeholder: 'Number'} ` |
113
- | ` textarea ` | ` <VGSCollectForm/TextareaField/> ` | ` {type: 'textarea', placeholder: 'Comment'} ` |
114
- | ` file ` | ` <VGSCollectForm/FileField/> ` | ` {type: 'file', placeholder: ''} ` |
115
- | ` date ` | ` <VGSCollectForm/DateField/> ` | ` {type: 'date', placeholder: ''} ` |
101
+ ### 3. Define secure input fields
102
+
103
+ | ** Collect.js input type** | ** Collect.js React Component** | ** Default Prop Values** |
104
+ | ---------------------------| ---------------------------------------------| ------------------------------------------------------------------------------------------|
105
+ | ` text ` | ` <VGSCollectForm.TextField /> ` | ` { type: 'text', placeholder: 'Cardholder Name' } ` |
106
+ | ` text ` | ` <VGSCollectForm.CardholderField /> ` | ` { type: 'text', name: 'cardholder', placeholder: 'Cardholder' } ` |
107
+ | ` card-number ` | ` <VGSCollectForm.CardNumberField /> ` | ` { type: 'card-number', name: 'pan', validations: ['required', 'validCardNumber'], placeholder: 'Credit Card Number' } ` |
108
+ | ` card-expiration-date ` | ` <VGSCollectForm.CardExpirationDateField /> ` | ` { type: 'card-expiration-date', name: 'exp-date', validations: ['required', 'validCardExpirationDate'], yearLength: 2, placeholder: 'MM/YY' } ` |
109
+ | ` card-security-code ` | ` <VGSCollectForm.CardSecurityCodeField /> ` | ` { type: 'card-security-code', name: 'cvc', validations: ['required', 'validCardSecurityCode'], placeholder: 'CVC/CVV' } ` |
110
+ | ` password ` | ` <VGSCollectForm.PasswordField /> ` | ` { type: 'password', placeholder: 'Enter Password' } ` |
111
+ | ` ssn ` | ` <VGSCollectForm.SSNField /> ` | ` { type: 'ssn', placeholder: 'SSN' } ` |
112
+ | ` zip-code ` | ` <VGSCollectForm.ZipCodeField /> ` | ` { type: 'zip-code', placeholder: 'Zip Code' } ` |
113
+ | ` number ` | ` <VGSCollectForm.NumberField /> ` | ` { type: 'number', placeholder: 'Number' } ` |
114
+ | ` textarea ` | ` <VGSCollectForm.TextareaField /> ` | ` { type: 'textarea', placeholder: 'Comment' } ` |
115
+ | ` file ` | ` <VGSCollectForm.FileField /> ` | ` { type: 'file', placeholder: '' } ` |
116
+ | ` date ` | ` <VGSCollectForm.DateField /> ` | ` { type: 'date', placeholder: '' } ` |
116
117
117
118
The complete list of supported properties you can find here: https://www.verygoodsecurity.com/docs/api/collect/#api-formfield .
118
119
All configuration properties available in the Reference Documentation can be passed in the component props using the same name.
@@ -122,8 +123,7 @@ _Example:_
122
123
``` javascript
123
124
import { VGSCollectForm } from ' @vgs/collect-js-react' ;
124
125
125
- const { CardNumberField , CardExpirationDateField , CardSecurityCodeField } =
126
- VGSCollectForm;
126
+ const { CardNumberField , CardExpirationDateField , CardSecurityCodeField } = VGSCollectForm;
127
127
128
128
const myApp = () => {
129
129
const onSubmitCallback = (status , data ) => {};
@@ -134,7 +134,7 @@ const myApp = () => {
134
134
vaultId= ' <vault_id>'
135
135
environment= ' <environment>'
136
136
action= ' /post'
137
- submitParamethers = {{
137
+ submitParameters = {{
138
138
headers: {
139
139
myHeader: ' MyHeader'
140
140
}
@@ -192,12 +192,7 @@ The library exposes the following handlers: `onFocus`, `onBlur`, `onUpdate`, `on
192
192
In order to access the form state and response from the hook, wrap consumer component with the form in ` VGSCollectProvider ` context provider.
193
193
194
194
``` javascript
195
- import {
196
- VGSCollectProvider ,
197
- useVGSCollectState ,
198
- useVGSCollectResponse ,
199
- VGSCollectForm
200
- } from ' @vgs/collect-js-react' ;
195
+ import { VGSCollectProvider , useVGSCollectState , useVGSCollectResponse , VGSCollectForm } from ' @vgs/collect-js-react' ;
201
196
202
197
const { TextField } = VGSCollectForm;
203
198
@@ -219,17 +214,43 @@ const VGSCollectSecureForm = () => {
219
214
}
220
215
}, [state]);
221
216
217
+ return (
218
+ < VGSCollectForm vaultId= ' <vault_id>' environment= ' <environment>' action= ' /post' >
219
+ < TextField name= ' cardholder-name' validations= {[' required' ]} placeholder= ' Cardholder name' / >
220
+ < / VGSCollectForm>
221
+ );
222
+ };
223
+ ```
224
+
225
+ ## Integration with Card Management Platform
226
+
227
+ You can create a predefined Collect.js form to integrate with the [ VGS Card Management Platform] ( https://docs.verygoodsecurity.com/card-management/api )
228
+
229
+ ``` javascript
230
+ import { VGSCollectForm } from ' @vgs/collect-js-react' ;
231
+
232
+ const {CardholderField , CardNumberField , CardExpirationDateField , CardSecurityCodeField } = VGSCollectForm;
233
+
234
+ const myApp = () => {
235
+ const onSubmitCallback = (status , data ) => {};
236
+ const onUpdateCallback = (state ) => {};
237
+
222
238
return (
223
239
< VGSCollectForm
224
240
vaultId= ' <vault_id>'
225
241
environment= ' <environment>'
226
- action= ' /post'
242
+ submitParamethers= {{
243
+ createCard: {
244
+ auth: < vgs_auth_token>
245
+ }
246
+ }}
247
+ onUpdateCallback= {onUpdateCallback}
248
+ onSubmitCallback= {onSubmitCallback}
227
249
>
228
- < TextField
229
- name= ' cardholder-name'
230
- validations= {[' required' ]}
231
- placeholder= ' Cardholder name'
232
- / >
250
+ < CardholderField css= {{}} / >
251
+ < CardNumberField css= {{}} / >
252
+ < CardExpirationDateField css= {{}} / >
253
+ < CardSecurityCodeField css= {{}} / >
233
254
< / VGSCollectForm>
234
255
);
235
256
};
0 commit comments