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

trustpayments

v3.2.1

Published

TypeScript/JavaScript client for Trust Payments

Downloads

12

Readme

Trust Payments TypeScript Library

The Trust Payments TypeScript library wraps around the Trust Payments API. This library facilitates your interaction with various services such as transactions, accounts, and subscriptions.

Documentation

Trust Payments Web Service API

Requirements

  • npm 6+

Installation

NPM install (recommended)

npm install trustpayments

Usage

The library needs to be configured with your account's space id, user id, and secret key which are available in your Trust Payments account dashboard. Set space_id, user_id, and api_secret to their values. You can also add custom default headers to the configuration.

Configuring a Service

'use strict';
import { TrustPayments } from 'trustpayments';

let spaceId: number = 405;
let userId: number = 512;
let apiSecret: string = 'FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=';

let config = {
    space_id: spaceId,
    user_id: userId,
    api_secret: apiSecret
    default_headers: {
        'x-meta-header-name-1': 'header-value-1',
        'x-meta-header-name-2': 'header-value-2'
    }
}

// Transaction Service
let transactionService: TrustPayments.api.TransactionService = new TrustPayments.api.TransactionService(config);

To get started with sending transactions, please review the example below:

'use strict';
import { TrustPayments } from 'trustpayments';

let spaceId: number = 405;
let userId: number = 512;
let apiSecret: string = 'FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=';

let config = {
    space_id: spaceId,
    user_id: userId,
    api_secret: apiSecret
}

// Transaction Service
let transactionService: TrustPayments.api.TransactionService = new TrustPayments.api.TransactionService(config);

// TransactionPaymentPage Service
let transactionPaymentPageService: TrustPayments.api.TransactionPaymentPageService = new TrustPayments.api.TransactionPaymentPageService(config);

// LineItem of type PRODUCT
let lineItem: TrustPayments.model.LineItemCreate = new TrustPayments.model.LineItemCreate();
lineItem.name='Red T-Shirt';
lineItem.uniqueId='5412';
lineItem.sku='red-t-shirt-123';
lineItem.quantity=1;
lineItem.amountIncludingTax=3.50;
lineItem.type=TrustPayments.model.LineItemType.PRODUCT;

// Transaction
let transaction: TrustPayments.model.TransactionCreate = new TrustPayments.model.TransactionCreate();
transaction.lineItems=[lineItem];
transaction.autoConfirmationEnabled=true;
transaction.currency='EUR';

transactionService.create(spaceId, transaction).then((response) => {
    let transactionCreate: TrustPayments.model.Transaction = response.body;
    transactionPaymentPageService.paymentPageUrl(spaceId, <number> transactionCreate.id).then(function (response) {
        let pageUrl: string = response.body;
        // window.location.href = pageUrl;
    });
});

Configure connection timeout

Connection timeout determines how long the request can take, before cutting off the connection. Same value applies both to inner 'Read timeout' and 'Connection timeout' of a NPM request module.

Default connection timeout is 25s.

Connection timeout can be set 2 ways:

  1. Via configuration property 'timeout' providing value in seconds.
let config = {
    ... other properties ...
    timeout: 15
}
let transactionService: TrustPayments.api.TransactionService = new TrustPayments.api.TransactionService(config);
  1. Via service property 'timeout' providing value in seconds
let config = {
    ... properties ...
}
let transactionService: TrustPayments.api.TransactionService = new TrustPayments.api.TransactionService(config);
transactionService.timeout = 15;

License

Please see the license file for more information.