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

apollopayment-sdk

v1.0.1

Published

Apollopayment API SDK

Downloads

2

Readme

ApolloPayment SDK

ApolloPayment SDK is a comprehensive JavaScript library designed to streamline the integration of blockchain-based payment solutions into various applications. This SDK provides developers with the tools necessary to facilitate secure, transparent, and efficient transactions on supported blockchain networks.

Key Features:

  • Ease of Integration: Simplifies the process of adding blockchain payment capabilities to your applications.
  • Security: Ensures high-level security for all transactions using blockchain technology.
  • Transparency: Leverages the transparency of blockchain networks to provide clear and verifiable transaction records.
  • Multi-Network Support: Supports multiple blockchain networks, providing flexibility and scalability.

For detailed documentation, installation guides, and API references, please visit ApolloPayment Documentation.

This package makes it easy ApolloPayment Api.

Installation

npm i apollopayment-sdk

Use

Go to your personal account https://app.apollopayment.io/api-keys and get api-keys.

Substitute keys in class call:

const { ApolloPayment } = require('apollopayment-sdk');

const client = new ApolloPayment('__PUBLIC_KEY__', '__PRIVATE_KEY__');

Check signature

You can test your signature within this method.

const checkSignature = await client.base.checkSignature();

if(!checkSignature.success) {
    console.error('Request error', checkSignature.error);
    
    process.exit(1);
}

if(!checkSignature.response.checkSignatureResult) {
    console.error('Signature incorrect', checkSignature.response.errors);

    process.exit(1);
}

console.log('Signature correct');

Fetch available currencies

Get list of available currencies for depositing/withdrawing

const availableCurrencies = await client.base.availableCurrencies();

if(!availableCurrencies.success) {
    console.error('Request error', availableCurrencies.error);

    process.exit(1);
}

for(const currency of availableCurrencies.response) {
    console.log(`${currency.currency} (${currency.alias}) = ${currency.priceUSD}`);

    if (currency.networks) {
        console.log('\tnetworks:');

        for (const network of currency.networks) {
            console.log(`\t\t ${network.name} (${network.alias})`);
        }
    }
}

Get currencies price-rate

Get price rate from one currency to another

const price = await client.base.priceRate('ETH', 'USDT');

if(!price.success) {
    console.error('Request error', price.error);

    process.exit(1);
}

console.log('Price', price.response);

Get advanced balances info

Get info about advanced balance by its id

const balance = await client.account.getBalance();

if(!balance.success) {
    console.error('Request error', balance.error);

    process.exit(1);
}

console.log(`[${balance.response.advancedBalanceId}] (${balance.response.currency}) \n\tAvalable for deposit: ${balance.response.availableCurrenciesForDeposit.join(', ')}`);

Or get list of advanced balances of user

const balances = await client.account.getBalances();

if(!balances.success) {
    console.error('Request error', balances.error);

    process.exit(1);
}

for(const balance of balances.response) {
    console.log(`[${balance.advancedBalanceId}] (${balance.currency}) \n\tAvalable for deposit: ${balance.availableCurrenciesForDeposit.join(', ')}`);
}

Create order

const { ApolloPayment } = require('apollopayment-sdk');

const client = new ApolloPayment("__PUBLIC_KEY__", "__PRIVATE_KEY__");

const createOrder = async (currency, network, amount) => {
    const order = await client.order.makeOrder({
        currency: currency,
        network: network,
        amount: amount,
        order: 'Order #1234567',
        errorWebhook: 'https://merchant.domain/webhook-url',
        successWebhook: 'https://merchant.domain/webhook-url',
        returnUrl: 'https://merchant.domain',
        description: 'Buy some item',
    });
    
    if(!order.success) {
        throw new Error(order.error.message);
    }

    return order.response.link;
};

(async () => {
    // your code
    
    const orderLink = await createOrder("USDT", "tron", "1000")

    // your code
})();

Auto-swap to external address

const { ApolloPayment } = require('apollopayment-sdk');

const client = new ApolloPayment("__PUBLIC_KEY__", "__PRIVATE_KEY__");

const makeWithdrawal = async (currency, network, address, amount) => {
    const swap = await client.autoSwap.createAutoSwaps({
        address: address,
        currency: currency,
        network: network,
        amountTo: amount,
        webhookUrl: 'https://merchant.domain/webhook-url',
    });

    if(!swap.success) {
        throw new Error(swap.error.message);
    }

    return swap.id;
};

(async () => {
    // your code 
    
    const autoSwapId = await makeWithdrawal("USDT", "tron", "TUfVHn...DDC", "100")

    // your code 
})();