Overview
Card Collect is a JavaScript plugin that lets you process credit card payments without handling card data directly, so your integration does not require PCI compliance. The widget provides secure, customizable fields where the cardholder enters their card details. The widget converts those details into a temporary token you can use with any Paybyrd API that requires card data.Installation
Install the package:dist/cardCollect-web.js and include it in your HTML file.
Quick Start
Designate the HTML elements where your fields will render, then initialize the library.| Property | Description |
|---|---|
| onStageChanged | This handler will be called whenever the form state changes. The only argument passed is a state object with the current status of the form fields. You can use this handler to enable/disable the submit button to prevent the user from misusing your form. |
card_number and one with card_exp. These are mandatory.
The response is a JSON object that will contain the TokenId. These tokens are different from tokenization API tokens. Card Collect tokens are short-lived and are discarded after use.
TokenId, you can call any Paybyrd API that requires card data. Inside the Card node, instead of sending the raw card data, you will send the TokenId as shown in the sample below:
Adding fields
Mandatory fields
You must include at minimum:card_number(type: 'card-number')card_exp(type: 'card-expiration-date')
Field properties
| Property | Required | Description |
|---|---|---|
name | Yes | Field identifier |
type | Yes | text, card-number, card-expiration-date, card-security-code |
validations | No | Array of validation rules |
css | No | Style object with CSS properties |
classes | No | CSS class mapping for states: dirty, empty, focused, valid, invalid, touched |
serializers | No | Data transformation rules applied before submission |
showCardIcon | No | Display the detected card brand icon |
yearLength | No | For expiry fields: '2' or '4' |
Supported validations
| Rule | Description |
|---|---|
required | Field must not be empty |
validCardNumber | Luhn algorithm check |
validCardExpirationDate | Validates date format and future date |
validCardSecurityCode | CVV/CVC validation |
| Custom RegExp | Pass a regular expression for custom pattern matching |
Styling
Submitting
Response
Using the token in a payment
PasstokenId in place of raw card fields:
Supported card brands
Visa, Mastercard, Amex, Maestro, Discover, Diners Club, JCB, UnionPay, Elo, and others.Advanced: Smart CVC
Link the CVC field to the card number field for brand-specific CVC length validation:Advanced: Data serializers
Use serializers to transform field data before submission:| Serializer | Description |
|---|---|
replace | Find-and-replace on the field value |
separate | Split value at a delimiter |
toBase64 | Base64-encode the field value |

