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

cashramp

v0.0.4

Published

Cashramp API NodeJS SDK

Downloads

23

Readme

Cashramp SDK

This is the official NodeJS SDK for Cashramp's API.

➕ Installation

# NPM
npm install cashramp --save

or

# Yarn
yarn add cashramp

👨🏾‍💻 Quick Start

// CommonJS
const Cashramp = require("cashramp");

// ES6 import
import Cashramp from "cashramp";

const cashrampAPI = new Cashramp({
  env: "test", // Can be either `test` or `live`
  secretKey: "CSHRMP-SECK_apE0rjq1tiWl6VLB",
});

// Example: Fetch available countries
const response = await cashrampAPI.getAvailableCountries();
if (response.success) {
  console.log(response.result);
} else {
  console.log(response.error);
}

API Reference

Queries

  • getAvailableCountries(): Fetch the countries that Cashramp is available in
  • getMarketRate({ countryCode }): Fetch the Cashramp market rate for a country
  • getPaymentMethodTypes({ country }): Fetch the payment method types available in a country
  • getRampableAssets(): Fetch the assets you can on/offramp with the Onchain Ramp
  • getRampLimits(): Fetch the Onchain Ramp limits
  • getPaymentRequest({ reference }): Fetch the details of a payment request
  • getAccount(): Fetch the account information for the authenticated user.

Mutations

  • confirmTransaction({ paymentRequest, transactionHash }): Confirm a crypto transfer sent into Cashramp's Secure Escrow address
  • initiateHostedPayment({ amount, paymentType, countryCode, currency, email, reference, redirectUrl, firstName, lastName }): Initiate a payment request
  • cancelHostedPayment({ paymentRequest }): Cancel an ongoing payment request
  • createCustomer({ firstName, lastName, email, country }): Create a new customer profile
  • addPaymentMethod({ customer, paymentMethodType, fields }): Add a payment method for an existing customer
  • withdrawOnchain({ address, amountUsd }): Withdraw from your balance to an onchain wallet address

Custom Queries

For advanced use cases where the provided methods don't cover your specific needs, you can use the sendRequest method to send custom GraphQL queries:

const query = `
  query {
    availableCountries {
      id
      name
      code
      currency {
        isoCode
        name
      }
    }
  }
`;

const response = await cashrampAPI.sendRequest({
  name: "availableCountries",
  query,
});

if (response.success) {
  console.log(response.result); // `result` contains the list of countries
}

Error Handling

All methods in the SDK return a response object with a success boolean. When success is false, an error property will be available with details about the error. Always check the success property before accessing the result.

TypeScript Support

This SDK includes TypeScript definitions out of the box. No additional types package is needed.

Documentation

For detailed API documentation, visit Cashramp's API docs.