Skip to content

Finish payment form #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/node_modules
/.pnp
.pnp.js
.idea/

# testing
/coverage
Expand Down
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: node_js
node_js:
- "lts/*"
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## 0.1.0 (December 21, 2018)


* Add LyraForm component
* Configure global, template and runtime parameters
* Add unit tests
* Add minimal amd pre-loaded examples
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright 2018 Lyra Network

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
162 changes: 136 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,154 @@
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
# React Embedded Form

## Available Scripts
[![Build Status](https://travis-ci.org/PureBilling/react-embedded-form.svg?branch=develop)](https://travis-ci.org/PureBilling/react-embedded-form)
[![GitHub license](https://img.shields.io/github/license/Naereen/StrapDown.js.svg)](https://github.com/PureBilling/react-embedded-form/blob/master/LICENSE)

In the project directory, you can run:
- [Installation](#installation)
- [Installation with Yarn](#with-yarn)
- [Installation with NPM](#with-npm)
- [Usage](#usage)
- [Parameters](#parameters)

### `npm start`

Runs the app in the development mode.<br>
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
## Installation

The page will reload if you make edits.<br>
You will also see any lint errors in the console.
Add the next package to your library:

### With Yarn

```bash
yarn add package-name
```

### `npm test`
### With NPM

Launches the test runner in the interactive watch mode.<br>
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
```bash
npm install --save package-name
```

## Usage

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

```javascript
// 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:

```javascript
<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'
/>
```

### `npm run build`
## Examples

Builds the app for production to the `build` folder.<br>
It correctly bundles React in production mode and optimizes the build for the best performance.
Example | Description
------------------------------------ | ---------------------------------------------------
[minimal](examples/minimal) | a minimal example
[pre-loaded](examples/pre-loaded) | pre-load the payment form to get it as fast as possible

The build is minified and the filenames include the hashes.<br>
Your app is ready to be deployed!
You can run these examples from 'minimal' folder or 'pre-loaded'

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
Go to the certain folder (e.g. minimal) and execute npm or yarn command

### `npm run eject`
```bash
npm install
npm run start
```
```bash
yarn install
yarn start
```

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
## Parameters

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
The allowed configuration parameters are:

Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
Parameter | Description | Setup | Template | Runtime |
-------------------------------------|--------------------------------------------------------------|:--------:|:---------:|:--------:|
kr-client-domain | Sets the endpoint of the library | &#10003; | &#10060; | &#10060; |
kr-public-key | Public key used for the payment | &#10003; | &#10060; | &#10060; |
kr-theme | Sets one of two themes | &#10003; | &#10060; | &#10060; |
kr-form-token | Sets form token | &#10003; | &#10003; | &#10003; |
kr-language | Language used on the payment form | &#10003; | &#10003; | &#10003; |
kr-post-url-success | The URL to POST on successfull payment | &#10003; | &#10003; | &#10003; |
kr-post-url-refused | The URL to POST on failed payment | &#10003; | &#10003; | &#10003; |
kr-clear-on-error | Disable the security code cleaning after a failed payment | &#10003; | &#10003; | &#10003; |
kr-hide-debug-toolbar | Disables the toolbar (only visible for test public keys) | &#10003; | &#10003; | &#10003; |
kr-placeholder-expiry | Changes the default placeholder of the expiry field | &#10003; | &#10003; | &#10003; |
kr-placeholder-pan | Changes the default placeholder of the pan field | &#10003; | &#10003; | &#10003; |
kr-placeholder-security-code | Changes the default placeholder of the security code field | &#10003; | &#10003; | &#10003; |

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
### Setup parameters

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

## Learn More
```javascript
// Import the library
import { LyraForm, setGlobalOptions } from 'package-name'

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).
// 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:

```html
<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:

```javascript
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.
23 changes: 23 additions & 0 deletions examples/minimal/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
8 changes: 8 additions & 0 deletions examples/minimal/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### `npm start`
In the project directory, you can run `npm start`

Runs the app in the development mode.<br>
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.<br>

26 changes: 26 additions & 0 deletions examples/minimal/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "minimal",
"version": "0.1.0",
"private": true,
"dependencies": {
"prop-types": "^15.6.2",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-scripts": "2.1.1"
},
"scripts": {
"start": "PORT=3001 react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
11 changes: 11 additions & 0 deletions examples/minimal/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Minimal example</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
27 changes: 27 additions & 0 deletions examples/minimal/src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';

import LyraForm from './lyra-form/LyraForm';
import setGlobalOptions from './lyra-form/tools/setGlobalOptions';

const setup = {
'kr-client-domain': 'https://api.payzen.eu',
'kr-theme': 'classic',
'kr-public-key': '69876357:testpublickey_DEMOPUBLICKEY95me92597fd28tGD4r5',
'kr-form-token': '013023XhmLSs67YzwRY7ZV2w18CeyJhIjo5OTAsIm0iOiJFVVIiLCJvIjpudWxsLCJjIjp7ImIiOnsidmkiOnsiZiI6eyJ2YWRDYXJkVHlwZSI6eyJ2YWx1ZSI6IlZJU0EifX19LCJtYyI6eyJmIjp7InZhZENhcmRUeXBlIjp7InZhbHVlIjoiTUFTVEVSQ0FSRCJ9fX0sImFtIjp7ImYiOnsidmFkQ2FyZFR5cGUiOnsidmFsdWUiOiJBTUVYIn19fSwiY2IiOnsiZiI6eyJkZWJpdENyZWRpdCI6eyJ2YWx1ZSI6ImNyZWRpdCJ9fX19fX0b602',
'kr-post-url-success': '/success',
'kr-post-url-refused': '/refused',
'kr-language': 'en-EN',
};
setGlobalOptions(setup);

const App = () => (
<LyraForm
kr-placeholder-pan="Minimal Example Pan"
kr-placeholder-expiry="Minimal Example Expiry"
kr-placeholder-security-code="Minimal Example Security Code"
kr-hide-debug-toolbar="false"
kr-clear-on-error="false"
/>
);

export default App;
9 changes: 9 additions & 0 deletions examples/minimal/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import ReactDOM from 'react-dom';

import App from './App';

ReactDOM.render(
<App />,
document.getElementById('root'),
);
Loading