1.6.1 • Published 10 months ago

bogpay v1.6.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Bank Of Georgia online payment API

An NPM package to simplify the usage and integration of the Bank of Georgia online payment API.

Documentation

Check Bank of Georgia API docs for further information.

Installation

Install the package with:

npm install bogpay

Usage

To use the library, HTTP Basic Auth is required. You will need to know the unique credentials of your business to enter the system. These credentials consist of two parameters, client_id, and client_secret, used as the username and password for business authentication.

How to obtain the credentials for entering the business system?

Upon registering a company as a business in the banking system and providing all the necessary data, the system provides the credentials client_id and client_secret necessary to enter the system. These credentials are unique identifiers of the business. It is impermissible to disclose or transfer the client_secret parameter to another person. Doing so significantly increases the probability of a security breach. The business cannot change the client_secret parameter.

Authentication

This method allows businesses to undergo the authentication process. Upon calling the API, the online payment server returns the Bearer Token, which is the necessary authentication parameter for calling all further methods.

try
{
    const data = await getAuthToken(clientId, secretKey) // returns Authentication token, it's lifetime and type(Bearer)
}
catch (error)
{
    //...
}

Order request

To place an order request, businesses must send payment details, technical specifications, and the amount to be paid to the online payment server. If the process is successful, the customer should be redirected to the online payment page at the redirect address returned to the _link parameter to complete the payment.

try
{
    // returns order_id and links for payment details and redirects
    const response = await orderRequest(requestCredentials) // requestCredentials is an object and it's strucutre shown below
}
catch (error)
{
    //...
}

A structure of requestCredentials:

{
    "headers": {
        "Authorization": "Bearer some_token", // change "some_token" with your actual token
        "Content-Type": "application/json"
    },
    "body": {
        "callback_url": "https://example.com/callback",
        "external_order_id": "order_12345",
        "purchase_units": {
            "basket": [
                {
                    "product_id": "prod_001",
                    "quantity": 2, 
                    "unit_price": 100 
                },
                {
                    "product_id": "prod_002", 
                    "quantity": 1, 
                    "unit_price": 200 
                }
            ],
            "total_amount": 420 
        },
        "redirect_urls": {
            "success": "https://example.com/success", 
            "fail": "https://example.com/fail"
        }
    }
}

For more options for the request check out Bank of Georgia's official docs

Payment details

This method allows businesses to receive detailed information about an online payment using its identifier.

Note: The in order to run this function, getAuthToken() must be run first

try
{
    const details = await paymentDetails(order_id) // fetches payment details for the given order ID
}
catch (error)
{
    //...
}

Wrap up

If you encounter any trouble using the library, use this template:

async function payment()
{
    try
    {
        
        const {access_token} = await getAuthToken(clientId,secretKey); // authenticate a buisness
    
        const requestCredentials = 
        {
            headers: 
            {
                "Content-Type": "application/json",
                "Authorization": `Bearer ${access_token}`
            },
            body: data
        }
        
        const requestData = await orderRequest(requestCredentials); // make a request with required data
    
    
        const details = await getPaymentDetails(requestData.id); // get details about the payment
        
        console.log(details);
        
        return details;

    }
    catch (error)
    {
        console.error(error);
    }
    
}
1.6.1

10 months ago

1.6.0

11 months ago

1.5.8

11 months ago

1.5.7

11 months ago

1.4.7

11 months ago

1.4.6

11 months ago

1.4.5

11 months ago

1.3.5

11 months ago

1.2.5

11 months ago

1.2.4

11 months ago

1.2.3

11 months ago

1.2.2

11 months ago

1.1.2

11 months ago

1.1.1

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago