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

@utrustdev/utrust-ts-library

v1.1.0

Published

Utrust library for store integration

Downloads

702

Readme

Utrust typescript library

The official Typescript library for the Utrust API.

Minimum Requirements

  • nodejs (minimum: 12)
  • npm

Install

npm install @utrustdev/utrust-ts-library

or

yarn add @utrustdev/utrust-ts-library

Usage

API Client

Creating a new Order:

import {ApiClient} from '@utrustdev/utrust-ts-library';

const {createOrder} = ApiClient(<API_KEY>, <ENVIRONMENT>)

As environment you can either use production or sandbox. It defaults to production if nothing is passed.

Then you can just create a new order passing an order and customer object as specified in the docs, which will return you a promise with the following structure:

const {status, data, errors} = await createOrder(order, customer);

Where you can get:

  • status: response status;
  • data: which should contain {redirectUrl, uuid} in case of success;
  • errors: in case something goes wrong

Getting Order's Data

import {ApiClient} from '@utrustdev/utrust-ts-library';

const {getOrder} = ApiClient(<API_KEY>, <ENVIRONMENT>)

Again, as environment you can either use production or sandbox. It defaults to production if nothing is passed.

const {status, data, errors} = await getOrder(uuid)

Using the order uuid that you could grab on order creation, you can later use it for fetching that specific order. This can be useful for checking order status if you don't build a webhook integration. Other useful returned data includes:

  • created_at
  • items
  • pricing_details
  • reference
  • settlement_amount - in merchant settlement currency
  • total_amount - in original store currency
  • id - order uuid
  • status

A complete example of this payload can be found in the tests/API documentation

Webhook Validator

The Webhook validator module can be used to verify an incoming event via Webhook. For easy reausability you can just initiate your WebhookValidator with your WEBHOOK_SECRET (which you can retrieve on your Merchants Dashboard/Integrations), and then just call validateSignature with your webhook's payload It simply returns:

  • true - in case provided payload can be verified by provided webhookSecret;
  • false - otherwise;

Example:

import {WebhookValidator} from '@utrustdev/utrust-ts-library';

const {validateSignature} = WebhookValidator(<WEBHOOK_SECRET>);


const isValid = await validateSignature(payload)

Contribute

This library was written and is maintained by the Utrust development team. We have now opened it to the world so that the community using this library may have the chance of shaping its development.

You can contribute by simply letting us know your suggestions or any problems that you find by opening an issue on GitHub.

You can also fork the repository on GitHub and open a pull request for the master branch with your missing features and/or bug fixes. Please make sure the new code follows the same style and conventions as already written code. Our team is eager to welcome new contributors into the mix :blush:.

Tests

When contributing with new changes, please make an effort to provide the respective tests. This is especially important when fixing any problems, as it will prevent other contributors from accidentally reintroducing the issue in the future.

Before submitting a pull request with your changes, please make sure every test passes:

npm run test

Lint

Before contributing your changes, make sure it passes on the linter:

npm run lint

License

Utrust utrust-ts-library is maintained with :purple_heart: by the Utrust development team, and is available to the public under the GNU GPLv3 license. Please see LICENSE for further details.

© Utrust 2021