Skip to content

Commit

Permalink
correctly handle array parameters (fixes #7)
Browse files Browse the repository at this point in the history
  • Loading branch information
pstadler committed Jun 19, 2018
1 parent 5d3ee0c commit 17863d9
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 69 deletions.
33 changes: 6 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@
Official Datatrans light box library for showing our payment page in React applications.
React is defined as a peer dependency and expected to be made available by your project. Other than that this library is completely dependency-free.



## How to install

```bash
# using npm
npm i react-datatrans-light-box --save
```

or

```bash
# using yarn
yarn add react-datatrans-light-box
```

Expand All @@ -27,7 +23,6 @@ The LightBox HOC wraps your target component in a `div` tag and adds a LightBox
### Example Usage of LightBoxHoc

```javascript

const config = {
merchantId: '1100004624',
refno: '11000asdfasdf4624',
Expand All @@ -38,7 +33,6 @@ const config = {
}

class LightBoxHocApproachBase extends Component {

constructor(props) {
super(props)

Expand All @@ -50,13 +44,10 @@ class LightBoxHocApproachBase extends Component {
}

render() {

const {lightBox} = this.props

return <div>

<h1> Test LightBoxHoc Apprach </h1>

<div> props.lightBox: </div>
<pre> {JSON.stringify(lightBox, null, 2)} </pre>

Expand All @@ -67,18 +58,15 @@ class LightBoxHocApproachBase extends Component {
<button onClick={() => lightBox.load(config)}>
load lightbox with HOC
</button>

</div>
}

}

LightBoxHocApproachBase.propTypes = {
lightBox: LightBox.Hoc.propType,
}

const LightBoxHocApproach = LightBox.Hoc(LightBoxHocApproachBase)

```

### props.lightBox
Expand All @@ -99,16 +87,13 @@ LightBoxHoc.propType = PropTypes.shape({
})
```


## Example Usage of LightBox component
You can also use a more direct approach and display the LightBox component whenever or whereever you like.

```javascript

import React, {PropTypes, Component} from 'react'
import Lightbox from 'react-datatrans-light-box'


const config = {
merchantId: '1100004624',
refno: '11000asdfasdf4624',
Expand All @@ -119,7 +104,6 @@ const config = {
}

class LightBoxApproach extends Component {

constructor(props) {
super(props)
this.state = {
Expand All @@ -133,23 +117,21 @@ class LightBoxApproach extends Component {
}

render() {

return <div>
<h1> Test LightBox Approach </h1>
<div>
{ this.state.showsLightBox
{this.state.showsLightBox
? 'LightBox is rendered and cannot be reused.'
: <button onClick={this.start}> start lightbox </button>
: <button onClick={this.start}>start lightbox</button>
}

{ this.state.showsLightBox && <LightBox {...config} /> }
{this.state.showsLightBox && <LightBox {...config} />}

{ this.state.error && <div>{JSON.stringify(this.state.error)}</div> }
{this.state.error && <div>{JSON.stringify(this.state.error)}</div>}
</div>
</div>
}
}

```

## Props
Expand All @@ -167,8 +149,6 @@ Name | Type | Description
`currency` | String | The type of currency that will be used for the payment.|
`sign` | String | Transaction security parameter. Find it in Datatrans' [Webadmin Tool](https://payment.datatrans.biz/). |



### Optional
|Name | Type |Description |
|----- |:------ |------------|
Expand All @@ -178,6 +158,5 @@ Name | Type | Description
|`onError` | Function | Called when there was an error loading the payment page.|
|and many more... | | Refer to this [PDF](https://pilot.datatrans.biz/showcase/doc/Technical_Implementation_Guide.pdf) to get the full list of supported parameters.|


[npm-url]: https://npmjs.com/package/react-datatrans-light-box
[npm-version-image]: https://img.shields.io/npm/v/react-datatrans-light-box.svg?style=flat-square
55 changes: 31 additions & 24 deletions example/lib/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 1 addition & 13 deletions example/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,19 @@ const config = {
currency: 'CHF',
sign: 'adsadf',
production: false,
paymentmethod: ['ECA', 'VIS', 'AMX'],
}

export default class App extends Component {

render() {

return <div>
<LightBoxApproach />
<LightBoxHocApproach />

</div>
}

}



class LightBoxApproach extends Component {

constructor(props) {
super(props)
this.state = {
Expand All @@ -40,7 +34,6 @@ class LightBoxApproach extends Component {
}

render() {

return <div>
<h1> Test LightBox Approach </h1>
<div>
Expand Down Expand Up @@ -70,15 +63,11 @@ class LightBoxHocApproachBase extends Component {
})
}


render() {

const {lightBox} = this.props

return <div>

<h1> Test LightBoxHoc Apprach </h1>

<div> props.lightBox: </div>
<pre> {JSON.stringify(lightBox, null, 2)} </pre>

Expand All @@ -89,7 +78,6 @@ class LightBoxHocApproachBase extends Component {
<button onClick={() => lightBox.load(config)}>
load lightbox with HOC
</button>

</div>
}

Expand Down
2 changes: 1 addition & 1 deletion example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2400,7 +2400,7 @@ rc@^1.1.7:
strip-json-comments "~2.0.1"

react-datatrans-light-box@../:
version "1.0.4"
version "1.0.8"

react-dom@^16.2.0:
version "16.2.0"
Expand Down
Loading

0 comments on commit 17863d9

Please sign in to comment.