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

paylike-meteor

v2.2.2

Published

[![CircleCI branch](https://img.shields.io/circleci/project/github/JorgenVatle/paylike-meteor/master.svg)](https://circleci.com/gh/JorgenVatle/paylike-meteor) [![Atmosphere](https://img.shields.io/badge/atmosphere-jorgenvatle%3Apaylike-blue.svg)](https://

Downloads

20

Readme

Paylike Meteor

CircleCI branch Atmosphere

A full-fledged Meteor wrapper for Paylike's API enabling synchronous consumption of their payments API.

Installation

meteor add jorgenvatle:paylike

Usage

Import package

The following examples will use the paylike constant defined below.

import Paylike from 'meteor/jorgenvatle:paylike';

// Passing your API key here is optional if you've got your API key defined in your Meteor Settings.
const paylike = new Paylike('paylike-api-key');

Meteor settings format:

{
  "paylike": {
    "private": "paylike-api-key"
  }
}

Apps

An app belongs to a merchant and is used to perform actions on the attached merchant. Your API key is regarded as an app.

Current app

console.log(paylike.me);

Example output:

{
  "id": "5bbce49ed0dde36a097c3574",
  "name": "Paylike Meteor Test App",
  "created": "2018-10-09T17:26:10.187Z"
}

Create app

This adds an app to the merchant your current API key (app) belongs to.

const newApp = paylike.apps.create({
    name: 'my-new-app' // Optional
});

Merchants

The Merchant object is responsible for a funding bank account as well as all of it's associated transactions. This is essentially a shop. It is important to note that all users and apps have complete access to their merchant. This includes inviting and removing users.

Current merchant

const merchant = paylike.merchant;

console.log(merchant.name) // "My Online Shop"

Create a merchant

const myMerchant = paylike.merchants.create({
    name: 'Acme Commerce',
    test: true,
    currency: 'EUR',
    email: '[email protected]',
    website: 'https://example.com',
    descriptor: 'ACME',
    company: {
        country: 'RO'
    }
});

console.log(myMerchant.name) // "Acme Commerce"

Fetch a merchant

const myMerchant = paylike.merchants.find('some-merchant-id');

Update a merchant

myMerchant.update({
    name: 'Acme Commerce 2',
    email: '[email protected]',
    descriptor: 'ACME2',
});

console.log(myMerchant.name) // "Acme Commerce 2"

Fetch all merchants

const merchants = paylike.merchants.fetch({
    limit: 50,                          // optional - Defaults to 50.
    before: 'merchant-id-goes-here',    // optional - Fetches all merchants before the given id.
    after: 'merchant-id-goes-here',     // optional - Fetches all merchants after the given id.
});

Merchant's Users

A merchant can have several users attached. These have complete access to their respective merchant and can add and remove additional apps and users.

Invite a user

const acmeUser = myMerchant.users.invite({ email: '[email protected]' });

console.log(acmeUser.id);       // "5bbe8430882cf804f6112d9f"
console.log(acmeUser.isMember); // "true"/"false" - Whether or not the user was a member before creation.

Fetch a user

const acmeUser = myMerchant.users.find('[email protected]');

Remove a user

// You can use:
acmeUser.remove();

// Or:
acmeUser.revoke();

// Or:
acmeUser.delete();

Fetch all users

myMerchant.users.fetch({
    limit: 50,                      // optional - Defaults to 50.
    before: 'user-id-goes-here',    // optional - Fetches all users before the given id.
    after: 'user-id-goes-here',     // optional - Fetches all users after the given id.
});

Transactions

A transaction, or reservation, defines an amount of funds authorized for captures, refunds and voids.

Create a transaction

const details = {
    currency: 'EUR',            // required - Currency
    amount: 1337,               // required - Amount of funds to reserve.
    descriptor: 'test-payment', // optional - Descriptor to show up on bank statement 
};

// Use the card associated with a previous transaction:
const transaction = myMerchant.transactions.create({
    transactionId: 'id-of-a-previous-transaction',  // required - Needs to be a valid transaction ID.
    ...details,
});

// ... Or use a saved card:
const cardTransaction = myMerchant.transactions.create({
    cardId: 'card-id-goes-here',
    ...details,
});

Fetch a transaction

const transaction = myMerchant.transactions.find('transaction-id-goes-here');

Capture a transaction

transaction.capture({
    amount: 1337, // optional - Amount to capture. (defaults to reserved amount) 
});

Void a transaction

transaction.void({
    amount: 1337, // optional - Amount to void. (defaults to reserved amount) 
});

Refund a transaction

transaction.refund({
    amount: 1337, // optional - Amount to refund. (defaults to captured amount)
});

Cards

Cards saved using the Web SDK are already in your vault and doesn't need to be saved on the backend.

Save a card using a transaction

const card = myMerchant.cards.save({
    transactionId: 'id-of-a-previous-transaction',  // required - Needs to be a valid transaction ID.
    notes: 'Some notes about this card',            // optional
});

Fetch a card

const card = myMerchant.cards.find('card-id-goes-here');

Create a transaction from card

const transaction = card.reserve({
    currency: 'EUR',            // required - Currency
    amount: 1337,               // required - Amount of funds to reserve.
    descriptor: 'test-payment', // optional - Descriptor to show up on bank statement 
});

Fraud alerts

Fetch all fraud alerts

const alerts = myMerchant.fraudAlerts.fetch({
    limit: 50,                      // optional - limit the alert count. (defaults to 50)
    before: 'alert-id-goes-here',   // optional - Fetches all users before the given id.
    after: 'alert-id-goes-here',    // optional - Fetches all users after the given id.
    filter: {
        transactionId: 'some-id'    // optional - Fetch alerts only for the given transaction.
    }
});

Fetch an alert

const alert = myMerchant.fraudAlerts.find('alert-id-goes-here');

Contributing

Pull requests are more than welcome! When adding new features, going through the effort to include tests for them is greatly appreciated.

Starting the development environment

  1. Add your Paylike credentials to settings.json (See settings.example.json for an example)
  2. Use npm install to install dependencies.
  3. Use npm start to start both the TypeScript build watcher and the test watcher.

Alternatively, start watchers individually

Use npm test to start just the test watcher.

Use npm run build -- --watch to start just the TypeScript build watcher.

License

This repository is licensed under the ISC license.

Copyright (c) 2018, Jørgen Vatle.