1.2.34 • Published 2 years ago

@coindirect/payments v1.2.34

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Coindirect Payments

Coindirect Merchant React Payments SDK

NPM JavaScript Style Guide

Install

yarn add @coindirect/payments

or

npm install --save @coindirect/payments

Local instalation

npm install
cd /example
npm install

Note: If NPM install fails, you can change 'link' to 'file' in package.json from the example folder.

Overview

This library is used to create payment forms in React for Coindirect.

Go the Coindirect's Merchant Portal for the admin functionality.

Properties

Each in addition to the properties below, each Component has an optional uuid property.

If none is supplied, it will attempt to fetch it from (in order of precedence):

  • the url (like ?uuid={uuid})
  • the session storage.

Payout

Used to initiate pay-out.

PropType
confirmPayoutSuccess() => null
confirmPayoutFailure() => null

PayoutComplete

On pay-out sucessfully completed.

PropType
successPayin(paymentStatus) => null
failurePayin() => null

Payin

Used to initiate pay-in.

PropType
successPayin(paymentStatus) => null
failurePayin() => null

Address

Used to display wallet details in the pay-in flow.

PropType
confirmimageUrl: string
copyimageUrl: string
paymentStatus(paymentStatus) => null

Channel

Used to display wallet details in the channel payment flow.

PropType
infoIconimageUrl: string
walletIconimageUrl: string
logoimageUrl: string

PaymentInProgess

Used to display "in-progress" in the pay-in flow.

PropType
paymentStatus(paymentStatus) => null

PayinComplete

On pay-in sucessfully completed.

PropType
paymentStatus(paymentStatus) => null

Note on styling

Every class name is prefixed with .cdp--

You can simply overwrite the styling by importing the same classnames in a css file after this line:

import '@coindirect/payments/src/index.css'

Or you could create your own theme.

Sample usage

import React, { Component } from 'react'
import {
  Payout,
  Payin,
  Address,
  PaymentInProgess,
  PayinComplete,
  PayoutComplete,
  ChannelAddress
} from '@coindirect/payments'
import '@coindirect/payments/src/index.css'
import { Switch, Route } from 'react-router-dom'
import { Redirect, withRouter } from 'react-router'
import copy from './copy.svg'
import confirm from './confirm.svg'
import info from './info.svg'
import wallet from './wallet.svg'
import coindirect from './coindirect.svg'

class App extends Component {
  handleConfirmPayout = () => {
    this.props.history.push('confirm')
  }

  paymentStatus = (status) => {
    if (status === 'PROCESSING' && !window.location.pathname.includes('seen')) {
      this.props.history.push('seen')
    } else if (
      status === 'COMPLETE' &&
      !window.location.pathname.includes('done')
    ) {
      this.props.history.push('done')
    }
  }

  handleFailedPayout = () => {
    console.log('Payment Failed')
  }

  handleConfirmPayin = (status) => {
    if (status === 'PENDING') {
      this.props.history.push('address')
    }
  }

  handleFailurePayin = () => {
    console.log('handle failure payin')
  }

  render() {
    return (
      <div className='App'>
        <Switch>
          {/* Payout Routes */}
          <Route exact path='/payout'>
            <Payout
              confirmPayoutSuccess={this.handleConfirmPayout}
              confirmPayoutFailure={this.handleFailedPayout}
            />
          </Route>
          <Route exact path='/confirm' component={() => <PayoutComplete />} />

          {/* Payin Routes */}
          <Route exact path='/payin'>
            <Payin
              successPayin={this.handleConfirmPayin}
              failurePayin={this.handleFailurePayin}
            />
          </Route>
          <Route
            exact
            path='/address'
            component={() => (
              <Address
                paymentStatus={this.paymentStatus}
                copy={copy}
                confirm={confirm}
              />
            )}
          />
          <Route
            exact
            path='/channel'
            component={() => (
              <ChannelAddress
                infoIcon={copy}
                walletIcon={wallet}
                logo={coindirect}
              />
            )}
          />
          <Route
            exact
            path='/seen'
            component={() => (
              <PaymentInProgess paymentStatus={this.paymentStatus} />
            )}
          />
          <Route
            exact
            path='/done'
            component={() => (
              <PayinComplete paymentStatus={this.paymentStatus} />
            )}
          />

          <Redirect from='/' to='/payout' />
        </Switch>
      </div>
    )
  }
}

export default withRouter(App)
1.2.28

2 years ago

1.2.29

2 years ago

1.2.30

2 years ago

1.2.31

2 years ago

1.2.34

2 years ago

1.2.32

2 years ago

1.2.33

2 years ago

1.2.27

2 years ago

1.2.25

2 years ago

1.2.26

2 years ago

1.2.24

2 years ago

1.2.18

3 years ago

1.2.19

3 years ago

1.2.20

3 years ago

1.2.21

3 years ago

1.2.22

2 years ago

1.1.19

2 years ago

1.2.17

3 years ago

1.2.16

3 years ago

1.2.15

3 years ago

1.2.14

3 years ago

1.2.12

3 years ago

1.2.13

3 years ago

1.2.11

3 years ago

1.2.10

3 years ago

1.2.9

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.0

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago