npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jokul-nodejs-library

v2.0.1

Published

Official NodeJs Library for Jokul API. Visit https://jokul.doku.com for more information about the product and https://jokul.doku.com/docs for the technical documentation

Downloads

751

Readme

Jokul Node.js Library

Official Node.js Library for Jokul API. Visit https://jokul.doku.com for more information about the product and https://jokul.doku.com/docs for the technical documentation.

Table of Contents

Requirements

Node v10 or above Npm v6 or above

Installation

Npm

Run command npm install jokul-nodejs-library --save && npm install sync-request --save && npm install crypto-js --save

Usage

Setup Configuration

Get your Client ID and Shared Key from Jokul Back Office.

Setup your configuration:

const dokuLib = require('jokul-nodejs-library');

let setupConfiguration = dokuLib.SetupConfiguration;
    setupConfiguration.environment = 'sandbox'
    setupConfiguration.client_id = 'CLIENTID';
    setupConfiguration.merchant_name = 'MERCHANT_NAME';
    setupConfiguration.shared_key = 'SHARED_KEY';
    setupConfiguration.serverLocation = dokuLib.getServerLocation(setupConfiguration.environment);

Server Location

Sandbox: "sandbox" Production: "production"

Virtual Account

Prepare your request data:

    const dokuLib = require('jokul-nodejs-library');

    let paymentCodeRequest = dokuLib.PaymentCodeRequestDto;
        paymentCodeRequest.customer.name = 'CUSTOMER_NAME';
        paymentCodeRequest.customer.email ='EMAIL';
        paymentCodeRequest.order.invoice_number = 'INVOICE NUMBER';
        paymentCodeRequest.order.amount = 10000;
        paymentCodeRequest.virtual_account_info.info1 = 'INFO1';
        paymentCodeRequest.virtual_account_info.info2 = 'INFO2';
        paymentCodeRequest.virtual_account_info.info3 = 'INFO3';
        paymentCodeRequest.virtual_account_info.reusable_status = false;
        paymentCodeRequest.virtual_account_info.expired_time = 60;

Mandiri VA

After preparing your request data, you can now generate the payment code / virtual account number:

const dokuLib = require('jokul-nodejs-library');
 
dokuLib.generateMandiriVa(setupConfiguration, paymentCodeRequest);

DOKU VA

After preparing your request data, you can now generate the payment code / virtual account number:

const dokuLib = require('jokul-nodejs-library');
 
dokuLib.generateDOKUVa(setupConfiguration, paymentCodeRequest);

Example Code - Virtual Account

Putting them all together. Here is the example code from setup your configuration to generate payment code / virtual account number:

const dokuLib = require('jokul-nodejs-library');

var channel = req.body.channel;

    let setupConfiguration = dokuLib.SetupConfiguration;
    setupConfiguration.environment = req.body.environment;
    setupConfiguration.client_id = req.body.clientId;
    setupConfiguration.merchant_name = req.body.merchantName;
    setupConfiguration.shared_key = req.body.sharedKey;
    setupConfiguration.serverLocation = dokuLib.getServerLocation(setupConfiguration.environment);
    setupConfiguration.channel = channel;

    let paymentCodeRequest = dokuLib.PaymentCodeRequestDto;
    paymentCodeRequest.customer.name = req.body.customerName;
    paymentCodeRequest.customer.email = req.body.email;
    paymentCodeRequest.order.invoice_number = randomInvoice(30);
    paymentCodeRequest.order.amount = req.body.amount;
    paymentCodeRequest.virtual_account_info.info1 = req.body.info1;
    paymentCodeRequest.virtual_account_info.info2 = req.body.info2;
    paymentCodeRequest.virtual_account_info.info3 = req.body.info3;
    paymentCodeRequest.virtual_account_info.reusable_status = req.body.reusableStatus;
    paymentCodeRequest.virtual_account_info.expired_time = req.body.expiredTime != null ? req.body.expiredTime : '';

    (async function () {
        let response = await post(setupConfiguration, paymentCodeRequest, channel);
        res.send(response);
    })();

});

async function post(setupConfiguration, paymentCodeRequest, channel) {
    try {
        let response;

        if (channel == 'mandiri') {
            response = await dokuLib.generateMandiriVa(setupConfiguration, paymentCodeRequest);
        } else if (channel == 'doku') {
            response = await dokuLib.generateDOKUVa(setupConfiguration, paymentCodeRequest);
        } else if (channel == 'mandiri-syariah') {
            //do something
        }

        return response;
    } catch (error) {
        console.log(error);
        return null;
    }

}

Notification

Notification is a class for receive payment information from DOKU, so merchant can use the Dto for Serialize object and Deserialize Object Inbound Request Data :

let notifyRequestDto = dokuLib.NotifyRequestDto;
notifyRequestDto.client.id = 'CLIENT-ID';
notifyRequestDto.order.invoice_number = 'INVOICE-NUMBER';
notifyRequestDto.order.amount = 10;
notifyRequestDto.virtual_account_info.virtual_account_number = 'VANUMBER';
notifyRequestDto.virtual_account_payment.date = 'DATE';
notifyRequestDto.virtual_account_payment.systrace_number = 'SYSTRACE-NUMBER';
notifyRequestDto.virtual_account_payment.reference_number = 'REFERENCE-NUMBER';
notifyRequestDto.virtual_account_payment.channel_code = 'CHANNEL-CODE';
notifyRequestDto.security.check_sum = 'CHECKSUM';

Outbound Response Data :

let notifyResponseDto = dokuLib.NotifyResponseDto;

notifyResponseDto.client.id = 'CLIENT-ID';
notifyResponseDto.order.invoice_number = 'INVOICE-NUMBER';
notifyResponseDto.order.amount = 10;
notifyResponseDto.virtual_account_info.virtual_account_number = 'VANUMBER';
notifyResponseDto.security.check_sum = 'CHECKSUM';

Example

Please refer to this repo for the example project: Jokul Node JS Example.

Help and Support

Got any issues? Found a bug? Have a feature requests? You can open new issue.

For further information, you can contact us on [email protected].