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

xsolla

v0.5.3

Published

A Node.js client for working with the Xsolla Merchant API

Downloads

124

Readme

Xsolla Node Client

A Node.js client for the Xsolla API. Written in TypeScript to provide you with all the type checking and auto-completion convenience supported by most modern JS IDEs. 👌

Installation

Pull in the package with npm:

npm install xsolla

Usage

Initialize Xsolla:

const Xsolla = require('xsolla').default;

const client = new Xsolla({
    merchantId: 123456,
    apiKey: 'abc123',
})

Projects

The Xsolla client exposes a projects property that can be used to create, update and read projects attached to your merchant account.

Create a project

client.projects.create({
    name: ["My brand new Xsolla project"],
    url: 'https://example.com',
}).then((project) => console.log('Created new project', project));

Returns a promise for a Project model.

Get a project:

const project = await client.projects.get({ project_id: 123456 })

Returns a promise for a Project model.

Fetch all projects

const projects = client.projects.all();

Returns a promise for an array of Project models.

The Project Model

The Project model is an instance of a project that you've either created or fetched

Create a payment token

You can create payment tokens directly from a Project model. (Obtained by either Xsolla.projects.get() or Xsolla.projects.create())

const { token } = await project.createPaymentToken({
    user: {
        id: {
            value: '47',
        }
    },
    
    settings: {
        mode: 'sandbox',
    },
   
    purchase: {
        checkout: {
            amount: 13.37,
            currency: 'USD',
        }
    }
});

Create a payment link

const url = await project.createPaymentUrl({
    user: {
         id: {
             value: '47',
         }
     },
     
     settings: {
         mode: 'sandbox',
     },
    
     purchase: {
         checkout: {
             amount: 13.37,
             currency: 'USD',
         }
     }
});

Update a project

const updatedProject = await project.update({
    name: ["Some other Xsolla project name"],
});

Returns a promise for an updated Project model.

Validate an incoming webhook

app.post('/webhooks/xsolla', (req, res) => {
    try {
        project.validateWebhookRequest(req.getHeader('authorization'), req.rawBody);   
    } catch (xsollaException) {
        res.send(xsollaException.jsonResponse());
        res.status(xsollaException.httpResponseCode).end();
    }
});

Project's validateWebhookRequest() method throws an XsollaException for unauthorized requests.

License

This repository is licensed under the ISC license.

Copyright (c) 2019, Jørgen Vatle.