Skip to content

Commit

Permalink
feat(config): create the config object
Browse files Browse the repository at this point in the history
  • Loading branch information
lariane-guerra committed Feb 3, 2025
1 parent ea88f26 commit 7fa7836
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
28 changes: 28 additions & 0 deletions examples/sync-tokenization/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,34 @@ const malgaTokenization = new MalgaTokenization({
apiKey: '<YOUR_API_KEY>',
clientId: '<YOUR_CLIENT_ID>',
options: { sandbox: true },
config: {
fields: {
cardNumber: {
selector: '#card-number',
container: 'card-number',
placeholder: 'Card Number',
type: 'number',
},
cardHolderName: {
selector: '#card-holder-name',
container: 'card-holder-name',
placeholder: 'Card Holder Name',
type: 'text',
},
cardCvv: {
selector: '#card-cvv',
container: 'card-cvv',
placeholder: 'Card CVV',
type: 'number',
},
cardExpirationDate: {
selector: '#card-expiration-date',
container: 'card-expiration-date',
placeholder: 'Card Expiration Date',
type: 'text',
},
},
},
})

export function App() {
Expand Down
23 changes: 23 additions & 0 deletions src/common/interfaces/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,32 @@ export interface MalgaConfigurationsElements {
number?: string
}

interface FieldStyles {
input: string
[key: string]: string
}

interface FieldOptions {
container: string | HTMLElement
selector: string
placeholder?: string
stylesField?: FieldStyles
type?: string
}

export interface MalgaConfigurations {
apiKey: string
clientId: string
config: {
fields: {
cardNumber: FieldOptions
cardHolderName: FieldOptions
cardCvv: FieldOptions
cardExpirationDate: FieldOptions
}
styles?: {}
preventAutofill?: boolean
}
options?: {
sandbox?: boolean
elements?: MalgaConfigurationsElements
Expand Down
2 changes: 1 addition & 1 deletion src/tokenization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import type {
MalgaFormElements,
} from 'src/common/interfaces'

import { AsyncTokenize } from './async-tokenize'
import { Tokenize } from './tokenize'
import { AsyncTokenize } from './async-tokenize'

export class MalgaTokenization {
private readonly malga: Malga
Expand Down

0 comments on commit 7fa7836

Please sign in to comment.