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

@quable/quable-partner-js

v1.1.3

Published

Quable Partner API Client

Downloads

11

Readme

Quable Partner JS

The Quable Partner JS is designed to simplify partnership experience, making it easier for partners to build their apps successfully within the Quable PIM platform. It's a user-friendly and efficient tool that assists partners in their Quable journey.

The Quable Partner JS is organized into two key modules:

  1. Partner Module: This module is specifically designed to assist partners in managing their partnership-related entities within the Quable platform. It simplifies interactions with Quable instances, apps and teams.
  2. Payment Module: The payment module is dedicated to handling financial transactions within Quable apps. It provides the necessary tools to manage monetary operations. This includes linking Stripe accounts, generating payment links, and retrieving payment information, giving partners control over their financial transactions.

Getting started

Requirements

  1. You must download and install Node.js if you don't already have it.
  2. You must create a partner account if you don’t have one.

Installing

The library can be installed through NPM or Yarn:

yarn  add  @quable/quable-partner-js
or
npm  install  @quable/quable-partner-js

Usage

You must get your <partner-id> and <access-token>.

To obtain your <partner-id> and <access-token>, you need to go to your partner's dashboard and follow these steps:

  1. Navigate to your dashboard.
  2. Click on "Settings."
  3. Look for the "API Token" section.

You'll find your <partner-id> and <access-token> there.

Initialize the client : Once your client is initialized, you can access either the Partner or Payment modules.

import { QuablePartnerAPI } from '@quable/quable-partner-js';

const partnerClient = new QuablePartnerAPI({
  accessToken: '<access-token>',
  partnerId: '<partner-id>',
});

a) Partner Methods

Get Quable applications

The provided code snippet fetches a list of Quable applications. The code specifies a limit of 5, meaning it will retrieve at most 5 Quable applications.

const quableApps = await partnerClient.Partner.QuableApplication.getAll({
  limit: 5,
});

Create a Quable application

The provided code snippet demonstrates the creation of a new application within the Quable ecosystem through the partner portal:

const createdApp = await partnerClient.Partner.QuableApplication.create({
  appType: 'in_app',
  name: 'Quable App',
  url: 'https://your-app-url.com',
  description: '',
  appIcon: 'bezier-curve',
});

Add a Quable instance

The provided code snippet adds a Quable instance within the partner portal:

const instance = await partnerClient.Partner.QuableInstance.add({
  authToken: '<instance-api-key>',
  quableInstanceName: '<instance-name>',
});

Install a Quable application

The provided code snippet installs a Quable application on the specified Quable instance:

const installedApp = await partnerClient.Partner.QuableApplication.install(
  quable - app - id,
  { instance: '<instance-name>' },
);

a) Payment Methods

Get payments

The provided code snippet is used to retrieve payments from the Quable payment, including both subscription and one-time payments based on the provided criteria:

//To retrieve subscription payments
const subscriptionPayments =
  await partnerClient.Payment.SubscriptionPayment.getPayments({
    appCheckoutId: '<app-checkout-id>',
    appId: '<app-id>',
    customer: '<customer>',
    limit: 5,
    status: 'paid',
  });

//To retrieve onetime payments
const onetimePayments = await partnerClient.Payment.OneTimePayment.getPayments({
  appCheckoutId: '<app-checkout-id>',
  appId: '<app-id>',
  customer: '<customer>',
  limit: 5,
  status: 'paid',
});

Generate payment link for an existing product

The provided code snippet is used to generate payment links for both subscription and one-time payments.

Note: It's important to note that you need to create a product on Stripe and obtain the corresponding price ID. The product represents the item you want to sell, and the price ID defines the specific pricing details. You can set up your product and price on Stripe's platform and then use the provided code to generate payment links:

//To generate subscription payment link
const subscriptionPaymentLink =
  await partnerClient.Payment.SubscriptionPayment.generatePaymentLink({
    appCheckoutId: '99811bd2-99e8-412f-a3a9-6ac50bdd654a',
    appId: '<app-id>',
    customer: '<customer>',
    quantity: 1,
    price: { priceId: '<stripe-price-id>' },
    interval: 'DAILY',
  });

//To generate onetime payment link
const onetimePaymentLink =
  await partnerClient.Payment.OneTimePayment.generatePaymentLink({
    appCheckoutId: '13671fdd-f563-43ef-a391-d5ba8c8e0e13',
    appId: '<app-id>',
    customer: '<customer>',
    quantity: 1,
    price: { priceId: '<stripe-price-id>' },
  });

Generate payment link without an existing product

The provided code snippet is used to generate payment links for both subscription and one-time payments without creating the product on stripe beforehand:

//To generate subscription payment link
const subscriptionPaymentLink =
  await partnerClient.Payment.SubscriptionPayment.generatePaymentLink({
    appCheckoutId: '99811bd2-99e8-412f-a3a9-6ac50bdd654a',
    appId: '<app-id>',
    customer: '<customer>',
    quantity: 1,
    price: {
      priceData: {
        amount: 10,
        currency: 'EUR',
        product: { name: 'Product name' },
      },
    },
    interval: 'DAILY',
  });

//To generate onetime payment link
const onetimePaymentLink =
  await partnerClient.Payment.OneTimePayment.generatePaymentLink({
    appCheckoutId: '13671fdd-f563-43ef-a391-d5ba8c8e0e13',
    appId: '<app-id>',
    customer: '<customer>',
    quantity: 1,
    price: {
      priceData: {
        amount: 100,
        currency: 'EUR',
        product: { name: 'Product name' },
      },
    },
  });

Testing the library:

To run tests within the Quable Partner JS, run the following command:

yarn  test

Author

[email protected]

License

MIT License