Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-datatrans-light-box

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-datatrans-light-box

Datatrans Lightbox component for React apps

  • 2.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
414
decreased by-79.74%
Maintainers
2
Weekly downloads
 
Created
Source

NPM version Build Status

react-datatrans-light-box

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

npm install react-datatrans-light-box

Example Usage of Lightbox component

You can also use a more direct approach and display the Lightbox component whenever or whereever you like.

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

const config = {
  merchantId: '1100004624',
  refno: 'YOUR_REFERENCE_NUMBER',
  amount: '1000',
  currency: 'CHF',
  sign: '30916165706580013',
  production: false,
  paymentmethod: ['ECA', 'VIS', 'PFC', 'AMX', 'TWI'],
  themeConfiguration: {
    brandColor: '#aa9374'
  }
}

export default class App extends Component {
  constructor(props) {
    super(props)

    this.state = {
      showLightbox: false
    }
  }

  render() {
    return <div>
      <h1>Datatrans Lightbox Demo</h1>
      <div>
        {this.state.showLightbox
          ? <Lightbox
              {...config}
              onLoaded={this.onLoaded}
              onOpened={this.onOpened}
              onCancelled={this.onCancelled}
              onError={this.onError}
            />
          : <button onClick={this.start}>Start Lightbox</button>
        }
      </div>

    </div>
  }

  start = () => {
    this.setState({ showLightbox: true })
  }

  onLoaded = () => {
    console.log('Loaded')
  }

  onOpened = () => {
    console.log('Opened')
  }

  onCancelled = () => {
    console.log('Cancelled')
    this.setState({ showLightbox: false })
  }

  onError = (data) => {
    console.log('Error:', data)
    this.setState({ showLightbox: false })
  }
}

Properties

The Lightbox component takes the following properties as input.

Mandatory

NameTypeDescription
merchantIdStringMerchant identifier provided to you by Datatrans.
refnoStringAny value by which you would like to reference the payment.
amountStringThe amount in cents you would like to charge your customer.
currencyStringThe type of currency that will be used for the payment.
signStringTransaction security parameter. Find it in Datatrans' Webadmin Tool.

Optional

NameTypeDescription
productionBooleanIndicates whether requests hit Datatrans' production or development environment. Defaults to false.
onLoadedFunctionCalled when payment page is loaded.
onOpenedFunctionCalled when payment page is opened.
onCancelledFunctionCalled when user has cancelled payment.
onErrorFunctionCalled when there was an error loading the payment page.
and many more...Refer to this PDF to get the full list of supported parameters.

Keywords

FAQs

Package last updated on 01 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc