@fluidcoins/pay.js

    0.1.10 • Public • Published

    Documentation

    Fluidcoins Pay.js

    Fluidcoins Pay.js is quick and secure way to receive crypto payments in your application. It works with all Javascript frameworks

    Requirement

    Nodejs version > 10

    Getting Started

    1: Register a merchant account on Fluidcoins and get your public API key

    Installation

    You can install the package via NPM or Yarn;

    npm install @fluidcoins/pay.js
    

    OR

    yarn add @fluidcoins/pay.js
    

    Usage

    Parameters

    • key
    • amount
    • email
    • onSuccess
    • onLoad (optional)
    • onClose (optional)
    • onError (optional)
    • name (optional)
    • phone (optional)
    • metadata (optional)
    • callback_url (optional)

    key

    REQUIRED

    This is your Fluidcoins public API key from the Fluidcoins dashboard.

    new Fluidcoins({key: 'fluidcoins_public_api_key'})
    

    amount

    REQUIRED

    This is amount in KOBO you'd want to collect from the customer.

    NOTE: The minimum amount is 500 NGN

    new Fluidcoins({
        key: 'fluidcoins_public_api_key',
        amount: 100000
    })
    

    email

    REQUIRED

    This is the email address of the customer

    new Fluidcoins({
        key: 'fluidcoins_public_api_key',
        amount: 100000,
        email: 'customer@test.com'
    })
    

    onSuccess

    REQUIRED

    This is function that will be called when a successful transaction occurs.

    new Fluidcoins({
        key: 'fluidcoins_public_api_key',
        amount: 100000,
        email: 'customer@test.com',
        onSuccess: (data) => { console.log({data})}
    })
    

    A JSON payload is passed as argument with the structure below;

    { 
        reference: TRANS_REFERENCE,
        coin: 'BTC',
        human_readable_amount: 1000,
        payment_status: 'underpaid | overpaid | paid_in_full'
    }
    

    Payment status could be overpaid, underpaid or paid_in_full

    onLoad

    OPTIONAL

    This closure is called once the Fluidcoins PaySDK loads

    new Fluidcoins({
        key: 'fluidcoins_public_api_key',
        amount: 100000,
        email: 'customer@test.com',
        onSuccess: (data) => { console.log({data})},
        onLoad: () => { console.log('Loaded sdk successfully')}
    })
    

    onClose

    OPTIONAL

    This optional closure is called when a user closes the Fluidcoins Widget. It takes no argument

    new Fluidcoins({
        key: 'fluidcoins_public_api_key',
        amount: 100000,
        email: 'customer@test.com',
        onSuccess: (data) => { console.log({data})},
        onLoad: () => { console.log('Loaded sdk successfully')},
        onClose: () => { console.log('User closed widget')}
    })
    

    onError

    OPTIONAL

    This optional closure is called when an error occurs. Error such as session expired, etc.

    new Fluidcoins({
        key: 'fluidcoins_public_api_key',
        amount: 100000,
        email: 'customer@test.com',
        onSuccess: (data) => { console.log({data})},
        onLoad: () => { console.log('Loaded sdk successfully')},
        onClose: () => { console.log('User closed widget')},
        onError: (error) => { console.log({error})},
    })
    

    A JSON payload is passed as argument with the structure below;

    { 
        type: 'expired',
    }
    

    Error type could be;

    • expired : Payment session for the initiated transaction expired

    name

    OPTIONAL

    This optional parameter; which is the name of customer who want to initiate the transaction. It reflects on the Fluidcoins dashboard.

    new Fluidcoins({
        key: 'fluidcoins_public_api_key',
        amount: 100000,
        email: 'customer@test.com',
        onSuccess: (data) => { console.log({data})},
        onLoad: () => { console.log('Loaded sdk successfully')},
        onClose: () => { console.log('User closed widget')},
        onError: (error) => { console.log({error})},
        name: 'Seun Akanni'
    })
    

    phone

    OPTIONAL

    This optional parameter; which is the phone number of customer who want to initiate the transaction. It reflects on the Fluidcoins dashboard.

    new Fluidcoins({
        key: 'fluidcoins_public_api_key',
        amount: 100000,
        email: 'customer@test.com',
        onSuccess: (data) => { console.log({data})},
        onLoad: () => { console.log('Loaded sdk successfully')},
        onClose: () => { console.log('User closed widget')},
        onError: (error) => { console.log({error})},
        name: 'Seun Akanni',
        phone: '+2348090909090',
    })
    

    reference

    OPTIONAL

    This optional parameter; which is used to identify the initiated transaction.

    NOTE : It must be unique per transaction

    new Fluidcoins({
        key: 'fluidcoins_public_api_key',
        amount: 100000,
        email: 'customer@test.com',
        onSuccess: (data) => { console.log({data})},
        onLoad: () => { console.log('Loaded sdk successfully')},
        onClose: () => { console.log('User closed widget')},
        onError: (error) => { console.log({error})},
        name: 'Seun Akanni',
        phone: '+2348090909090',
        reference: 'random-identifier'
    })
    

    metadata

    OPTIONAL

    This optional parameter, which is should contain data you will like to be passed via webhooks about the transaction. NOTE: The metadata must be an OBJECT

    new Fluidcoins({
        key: 'fluidcoins_public_api_key',
        amount: 100000,
        email: 'customer@test.com',
        onSuccess: (data) => { console.log({data})},
        onLoad: () => { console.log('Loaded sdk successfully')},
        onClose: () => { console.log('User closed widget')},
        onError: (error) => { console.log({error})},
        name: 'Seun Akanni',
        phone: '+2348090909090',
        metadata: {
            key: 1
        }
    })
    

    callback_url

    OPTIONAL

    This optional parameter is used to open a new window tab when a successful [ underpaid, overpaid, paid_in_full ] payment occurs. NOTE: The callback_url must be a valid URL with a HTTPS scheme . Also, it DOES NOT override the onSuccess() event.

    new Fluidcoins({
        key: 'fluidcoins_public_api_key',
        amount: 100000,
        email: 'customer@test.com',
        onLoad: () => { console.log('Loaded sdk successfully')},
        onClose: () => { console.log('User closed widget')},
        onError: (error) => { console.log({error})},
        name: 'Seun Akanni',
        phone: '+2348090909090',
        metadata: {
            key: 1
        },
        callback_url: 'https://www.google.com/'
    })
    

    API References

    setup()

    This method is used to load the widget unto the DOM, the widget remains hidden after invoking this function until the open() method is called.

    const fluidcoins = new Fluidcoins({
        key: 'fluidcoins_public_api_key',
        amount: 100000,
        email: 'customer@test.com',
        onSuccess: (data) => { console.log({data})},
    })
    fluidcoins.setup()
    

    open()

    This method makes the widget visible to the user.

    const fluidcoins = new Fluidcoins({
        key: 'fluidcoins_public_api_key',
        amount: 100000,
        email: 'customer@test.com',
        onSuccess: (data) => { console.log({data})},
    })
    fluidcoins.setup()
    fluidcoins.open()
    

    Keywords

    none

    Install

    npm i @fluidcoins/pay.js

    DownloadsWeekly Downloads

    23

    Version

    0.1.10

    License

    MIT

    Unpacked Size

    15.4 kB

    Total Files

    4

    Last publish

    Collaborators

    • adelowo