Paylike Meteor
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.
; // Passing your API key here is optional if you've got your API key defined in your Meteor Settings.const paylike = 'paylike-api-key';
Meteor settings format:
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;
Example output:
Create app
This adds an app to the merchant your current API key (app) belongs to.
const newApp = paylikeapps;
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 = paylikemerchant; console // "My Online Shop"
Create a merchant
const myMerchant = paylikemerchants; console // "Acme Commerce"
Fetch a merchant
const myMerchant = paylikemerchants;
Update a merchant
myMerchant; console // "Acme Commerce 2"
Fetch all merchants
const merchants = paylikemerchants;
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 = myMerchantusers; console; // "5bbe8430882cf804f6112d9f"console; // "true"/"false" - Whether or not the user was a member before creation.
Fetch a user
const acmeUser = myMerchantusers;
Remove a user
// You can use:acmeUser; // Or:acmeUser; // Or:acmeUser;
Fetch all users
myMerchantusers;
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 = myMerchanttransactions; // ... Or use a saved card:const cardTransaction = myMerchanttransactions;
Fetch a transaction
const transaction = myMerchanttransactions;
Capture a transaction
transaction;
Void a transaction
transaction;
Refund a transaction
transaction;
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 = myMerchantcards;
Fetch a card
const card = myMerchantcards;
Create a transaction from card
const transaction = card;
Fraud alerts
Fetch all fraud alerts
const alerts = myMerchantfraudAlerts;
Fetch an alert
const alert = myMerchantfraudAlerts;
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
- Add your Paylike credentials to
settings.json
(Seesettings.example.json
for an example) - Use
npm install
to install dependencies. - 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.