0.0.2 • Published 5 years ago

@lyracom/react-embedded-form-dev v0.0.2

Weekly downloads
-
License
-
Repository
-
Last release
5 years ago

React Embedded Form

Build Status GitHub license

Installation

Add the next package to your library:

With Yarn

yarn add package-name

With NPM

npm install --save package-name

Usage

You can add a form to any React application as follows:

// Import the library
import { LyraForm, setGlobalOptions } from 'package-name'

// define component setup options
const setup = {
    'kr-client-domain': 'https://api.payzen.eu',
    'kr-theme': 'classic',
    'kr-public-key': '69876357:testpublickey_DEMOPUBLICKEY95me92597fd28tGD4r5'
};

setGlobalOptions(setup);

Now, you can add the component to your application:

<LyraForm
    kr-form-token='YOUR_TOKEN'
    kr-post-url-success='/success'
    kr-post-url-refused='/refused'
    kr-language='en-EN'
    kr-placeholder-pan='Pan'
    kr-placeholder-expiry='Expiry'
    kr-placeholder-security-code='Security Code'
    kr-hide-debug-toolbar='true'
    kr-clear-on-error='false'
/>

Examples

ExampleDescription
minimala minimal example
pre-loadedpre-load the payment form to get it as fast as possible

You can run these examples from 'minimal' folder or 'pre-loaded'

Go to the certain folder (e.g. minimal) and execute npm or yarn command

npm install
npm run start
yarn install
yarn start

Parameters

The allowed configuration parameters are:

ParameterDescriptionSetupTemplateRuntime
kr-client-domainSets the endpoint of the library
kr-public-keyPublic key used for the payment
kr-themeSets one of two themes
kr-form-tokenSets form token
kr-languageLanguage used on the payment form
kr-post-url-successThe URL to POST on successfull payment
kr-post-url-refusedThe URL to POST on failed payment
kr-clear-on-errorDisable the security code cleaning after a failed payment
kr-hide-debug-toolbarDisables the toolbar (only visible for test public keys)
kr-placeholder-expiryChanges the default placeholder of the expiry field
kr-placeholder-panChanges the default placeholder of the pan field
kr-placeholder-security-codeChanges the default placeholder of the security code field

Setup parameters

All the Parameters are configurable on the setup step adding the value on the corresponding key as the next example:

// Import the library
import { LyraForm, setGlobalOptions } from 'package-name'

// Configure your endpoint of payment
const setup = {
    'kr-client-domain': 'https://api.payzen.eu',
    'kr-post-url-success': '/post-result',
    'kr-public-key': '69876357:testpublickey_DEMOPUBLICKEY95me92597fd28tGD4r5',
    'kr-theme': 'classic',
    (...)
};
setGlobalOptions(setup);

Template parameters

All the Parameters (except kr-client-domain, kr-public-key and kr-theme) enabled for templates are configurable on the template step adding the value on the corresponding property on the LyraForm component as the next example:

<LyraForm
    kr-placeholder-pan="My pan!"
    kr-hide-debug-toolbar="true"
    kr-post-url-success="/my-post"
    ...
/>

Runtime parameters

All the Parameters (except kr-client-domain, kr-public-key and kr-theme) enabled for runtime are configurable on the runtime calling the next KR setFormConfig library method:

window.KR.setFormConfig({
    'kr-post-url-success': '/my-post',
    'kr-placeholder-expiry': 'My expiration date',
});

Themes

The theme property can be configured only on the setup object argument of the LyraForm plugin. Available themes are:

  • classic
  • material

If no theme is configured, no CSS will be applied to the final form.

0.0.2

5 years ago

0.0.1

5 years ago