@koibanx/crypto-checkout-sdk
v0.1.12
Published
Crypto Checkout SDK
Downloads
1,190
Readme
Koibanx Crypto Checkout SDK
Crypto Checkout SDK based in module Crypto Checkout
Description
The Module Crypto Checkout handles:
SDK Documentation
Installation
npm install @koibanx/crypto-checkout-sdk
NOTE: you must have the npm token in your .npmrc file
Initialization
Node
Using ES6 import
import CryptoCheckoutSdk from '@koibanx/crypto-checkout-sdk';
const cryptoCheckout = CryptoCheckoutSdk({
baseURL: 'http://your-url',
});
With require
exports.__esModule = true;
const CryptoCheckoutSdk = require('@koibanx/crypto-checkout-sdk')["default"];
const cryptoCheckout = CryptoCheckoutSdk({
baseURL: 'http://your-url',
});
Types
- Typescript (
@koibanx/crypto-checkout-sdk/dist/index.d.ts
)
Examples
Using ES6 import
import CryptoCheckoutSdk from "@koibanx/crypto-checkout-sdk";
const cryptoCheckout = CryptoCheckoutSdk({
baseURL: 'http://your-url',
})
const catchError = (err, modulo) => {
console.log('Modulo: ', modulo);
console.log('details: ', err.details);
console.log('shortMessage: ', err.message);
console.log('errorCode: ', err.code);
}
/**
* Create Order
*/
cryptoCheckoutSDK.order.createOrder({
amount: 10,
currency: 'eth',
network: 'ethereum',
chargeCurrency: 'algo',
chargesCount: 1,
callback: 'https://webhook.site/f4754ad0-fd03-43a2-b91a-cb30c5b22034',
}).then((res) => {
console.log('createOrder: ', res.status);
}).catch((err) => catchError(err, 'createOrder'));
/**
* Get Order
*/
cryptoCheckoutSDK.order.getOrder({
id: '639b99e94edc6c3ef26ce0c5',
}).then((res) => {
console.log('getOrder: ', res._id);
}).catch((err) => catchError(err, 'getOrder'));
/**
* Add Charge To Order
*/
cryptoCheckoutSDK.order.addChargeToOrder({
id: '639b988a4edc6c3ef26ce0af',
amount: 1,
currency: 'algo',
network: 'algorand',
callback: 'https://webhook.site/c495fc10-fea0-4ace-b462-dc576c49ed1a',
accountId: '6362c806c1c3cce181307bee',
}).then((res) => {
console.log('addChargeToOrder: ', res.id);
}).catch((err) => catchError(err, 'addChargeToOrder'));
/**
* Update Order
*/
cryptoCheckoutSDK.order.updateOrder({
callback: 'http://test',
id: '639b988a4edc6c3ef26ce0af',
}).then((res) => {
console.log('updateOrder: ', res.modifiedCount);
}).catch((err) => catchError(err, 'updateOrder'));
/**
* Delete Order
*/
cryptoCheckoutSDK.order.deleteOrder({
id: '639b988a4edc6c3ef26ce0af',
}).then((res) => {
console.log('deleteOrder: ', res.modifiedCount);
}).catch((err) => catchError(err, 'deleteOrder'));
/**
* ADDRESS
*/
/**
* List Addresses
*/
cryptoCheckoutSDK.address.listAddresses().then((res) => {
console.log('listAddresses: ', JSON.stringify(res.results));
}).catch((err) => catchError(err, 'listAddresses'));
/**
* Create Address
*/
cryptoCheckoutSDK.address.createAddress({
internalCurrencyCode: 'algo',
callback: 'https://webhook.site/f4754ad0-fd03-43a2-b91a-cb30c5b22034',
}).then((res) => {
console.log('createAddress: ', res._id);
}).catch((err) => catchError(err, 'createAddress'));
/**
* Get Address
*/
cryptoCheckoutSDK.address.getAddress({
id: '639cf008ff26b3665f51c14d',
}).then((res) => {
console.log('getAddress: ', res.address);
}).catch((err) => catchError(err, 'getAddress'));
/**
* Update Address
*/
cryptoCheckoutSDK.address.updateAddress({
address_label: 'test',
id: '639cf008ff26b3665f51c14d',
}).then((res) => {
console.log('updateAddress: ', res.address_label);
}).catch((err) => catchError(err, 'updateAddress'));
/**
* Delete Address
*/
cryptoCheckoutSDK.address.deleteAddress({
id: '639cf008ff26b3665f51c14d',
}).then((res) => {
console.log('deleteAddress: ', res.matchedCount);
}).catch((err) => catchError(err, 'deleteAddress'));