paydemic-sdk

0.0.1 • Public • Published

paydemic-node

Paydemic.com API for node.js

Installation

npm install paydemic

API Overview

Every resource is accessed via your paydemic instance:

var accessKey = require("<path>/accessKey.json")
var paydemic = require('paydemic')(accessKey);
// paydemic.{ RESOURCE_NAME }.{ METHOD_NAME }

Every resource method returns a promise, so you don't have to use the regular callback. E.g.

// Create a new purchase link:
const purchaseLinkDefinition = {
  finalUrl: 'https://paydemic.com/how-it-works.html',
  price: {
    currencyCode: 'USD',
    amount: 9.9
  },
  title: 'Paydemic - How It Works'
};
paydemic.PurchaseLinks.create(purchaseLinkDefinition)
  .then(function(purchaseLink) {
    // New purchase link created
    console.log('Created purchase link with id: ', purchaseLink.id);
  }).catch(function(err) {
    // Deal with an error
  });

// retrieve an existing purchase link:

paydemic.PurchaseLinks.retrieve(id)
  .then(function(purchaseLink) {
    // New purchase link created
    console.log('Retrieved the purchase link created at UTC: ', purchaseLink.creationDate);
  }).catch(function(err) {
    // Deal with an error
  });

// List all the existing purchase links under this project:

paydemic.PurchaseLinks.list()
  .then(function(purchaseLinkArray) {
    // New purchase link created
    console.log('The number of Purchase Links in this project is: ', purchaseLinkArray.length);
  }).catch(function(err) {
    // Deal with an error
  });

// Update an existing purchase link:
const purchaseLinkDefinition = {
  finalUrl: 'https://paydemic.com/faq.html',
  price: {
    currencyCode: 'USD',
    amount: 3.76
  },
  title: 'Paydemic - FAQ'
};
paydemic.PurchaseLinks.update(id, purchaseLinkDefinition)
  .then(function(purchaseLink) {
    // The purchase link updated
    console.log('Updated purchase link at UTC: ', purchaseLink.creationDate);
  }).catch(function(err) {
    // Deal with an error
  });

// remove an existing purchase link:

paydemic.PurchaseLinks.remove(id)
  .then(function(purchaseLinkRemovalStatus) {
    // Purchase link was removed
    console.log('Purchase link removal status: ', purchaseLinkRemovalStatus.status);
  }).catch(function(err) {
    // Deal with an error
  });

Available resources & methods

Where you see params it is a plain JavaScript object.

Development

Run the tests using npm:

$ npm install
$ npm test

Contribution

  • If you would like to contribute, please fork the repo and send in a pull request.

Package Sidebar

Install

npm i paydemic-sdk

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • paydemic