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

spreedly-api

v0.0.7

Published

Spreedly API wrapper

Downloads

81

Readme

spreedly-api

Build Status

This API supported Spreedly's v1 standard REST-style API that accepts/returns JSON requests and Here is the [API reference] (https://docs.spreedly.com/reference/api/v1)

You can find examples here. This will help you for faster implmentation of 'spreedly-api'

It does supports EcmaScript 5, EcmaScript 6, EcmaScript 8, TypeScript, async-await, Promises, Callback !
It supports pure JSON response.
All methods support Promise and Callback both.
Please Feel free to create Issue for any help !

Installation

npm install spreedly-api --save

Development

Run the installation:

npm install

Configuration

Set your Environment Key and Access Secret. This is available in Spreedly Document.

var spreedly = require('spreedly-api')('environmentKey','accessSecret');

Gateways

Create test gateway

    spreedly.gateways.create({
        'gateway': {
            'gateway_type': 'test'
        }
    }, function (error, response) {
        if (error) {
            console.log('error ', error);
            return;
        }
        console.log('response', response);
        // asynchronously called
    });

Create production gateway

    spreedly.gateways.create({
        'gateway': {
            'gateway_type': 'stripe',
            'login': 'your Stripe API secret'
        }
    }, function (error, response) {
        if (error) {
            console.log('error ', error);
            return;
        }
        console.log('response', response);
        // asynchronously called
    });

Show gateway

    spreedly.gateways.show('7UcPnN6rDdk7nmmCl2LESVkfj2w', function (error, response) {
        if (error) {
            console.log('error ', error);
            return;
        }
        console.log('response', response);
    });

Payment Methods

Create credit card

    spreedly.payment.create({
        'payment_method': {
            'credit_card': {
                'first_name': 'Joe',
                'last_name': 'Jones',
                'number': '5555555555554444',
                'verification_value': 423,
                'month': '3',
                'year': '2032'
            },
            'email': '[email protected]'
        }
    }, function (error, response) {
        if (error) {
            console.log('error ', error);
            return;
        }
        console.log('response', response);

        // asynchronously called
    });

Create bank account

    spreedly.payment.create({
        'payment_method': {
            'bank_account': {
                'first_name': 'Jon',
                'last_name': 'Doe',
                'bank_routing_number': '021000021',
                'bank_account_number': '9876543210',
                'bank_account_type': 'checking',
                'bank_account_holder_type': 'personal'
            },
            'email': '[email protected]',
            'data': {
                'my_payment_method_identifier': 448,
                'extra_stuff': {
                    'some_other_things': 'Can be anything really'
                }
            }
        }
    }, function (error, response) {
        if (error) {
            console.log('error ', error);
            return;
        }
        console.log('response', response);
        // asynchronously called
    });

Purchase

Tokenized payment method

    spreedly.purchase.create('7UcPnN6rDdk7nmmCl2LESVkfj2w', {
        'transaction': {
            'payment_method_token': '56wyNnSmuA6CWYP7w0MiYCVIbW6',
            'amount': 100,
            'currency_code': 'USD'
        }
    }, function (error, response) {
        if (error) {
            console.log('error ', error);
            return;
        }
        console.log('response', response);
    });

Pass-in credit card

    spreedly.purchase.usingCreditCard('7UcPnN6rDdk7nmmCl2LESVkfj2w', {
        'transaction': {
            'credit_card': {
                'first_name': 'Joe',
                'last_name': 'Smith',
                'number': '4111111111111111',
                'verification_value': '123',
                'month': '12',
                'year': '2018'
            },
            'amount': 100,
            'currency_code': 'USD'
        }
    }, function (error, response) {
        if (error) {
            console.log('error ', error);
            return;
        }
        console.log('response', response);
    });

Pass-in bank account/eCheck

    spreedly.purchase.usingBank('7UcPnN6rDdk7nmmCl2LESVkfj2w', {
        'transaction': {
            'bank_account': {
                'first_name': 'Joe',
                'last_name': 'Smith',
                'bank_routing_number': '021000021',
                'bank_account_number': '9876543210'
            },
            'amount': 100,
            'currency_code': 'USD'
        }
    }, function (error, response) {
        if (error) {
            console.log('error ', error);
            return;
        }
        console.log('response', response);
    });

Reference purchase

    spreedly.purchase.usingPaymentMethod('FPKawD8tNdpdavp0wCAUhK7xaNG', {
        'transaction': {
            'amount': 80
        }
    }, function (error, response) {
        if (error) {
            console.log('error ', error);
            return;
        }
        console.log('response', response);
    });

Authorize

Tokenized payment method

    spreedly.authorize.create('7UcPnN6rDdk7nmmCl2LESVkfj2w', {
        'transaction': {
            'payment_method_token': '56wyNnSmuA6CWYP7w0MiYCVIbW6',
            'amount': 100,
            'currency_code': 'USD'
        }
    }, function (error, response) {
        if (error) {
            console.log('error ', error);
            return;
        }
        console.log('response', response);
    });

Pass-in credit card

    spreedly.authorize.usingCreditCard('7UcPnN6rDdk7nmmCl2LESVkfj2w', {
        'transaction': {
            'credit_card': {
                'first_name': 'Joe',
                'last_name': 'Smith',
                'number': '4111111111111111',
                'verification_value': '123',
                'month': '12',
                'year': '2018'
            },
            'amount': 100,
            'currency_code': 'USD'
        }
    }, function (error, response) {
        if (error) {
            console.log('error ', error);
            return;
        }
        console.log('response', response);
    });

Capture

Full amount

    spreedly.capture.fullAmount('M1D0HR7iYJUmcP8aHr6motPGCPU', function (error, response) {
        if (error) {
            console.log('error ', error);
            return;
        }
        console.log('response', response);
    });

Partial amount

    spreedly.capture.partialAmount('M1D0HR7iYJUmcP8aHr6motPGCPU', {
        'transaction': {
            'amount': 50,
            'currency_code': 'USD'
        }
    }, function (error, response) {
        if (error) {
            console.log('error ', error);
            return;
        }
        console.log('response', response);
    });

Certificates

List

    spreedly.certificates.list(function (error, response) {
        if (error) {
            console.log('error ', error);
            return;
        }
        console.log('response', response);
        // asynchronously called
    });

Create

    spreedly.certificates.create({
        'certificate': {
            'algorithm': 'ec-prime256v1',
            'cn': 'MyApp ApplePay Production Certificate',
            'email_address': '[email protected]'
        }
    }, function (error, response) {
        if (error) {
            console.log('error ', error);
            return;
        }
        console.log('response', response);
        // asynchronously called
    });

Update

    spreedly.certificates.update('OLK1a6xQxWes8qKRb2EpuEXNkIS', {
        'certificate': {
            'pem': '-----BEGIN CERTIFICATE-----\nMIIEiTCCBC6gAwIBAgIIFRZ9ouKAzqwwCgYIKoZIzj0EAwIwgYAxNDAyBgNVBAMM\nK0FwcGxlIFdvcmxkd2lkZSBEZXZlbG9wZXIgUmVsYXRpb25zIENBIC0gRzIxJjAk\nBgNVBAsMHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRMwEQYDVQQKDApB\ncHBsZSBJbmMuMQswCQYDVQQGEwJVUzAeFw0xNTAyMTkyMDMzMzBaFw0xNzAzMjAy\nMDMzMzBaMIG5MTowOAYKCZImiZPyLGQBAQwqbWVyY2hhbnQuY29tLnNlYXRnZWVr\nLlNwcmVlZGx5QXBwbGVQYXlUZXN0MUAwPgYDVQQDDDdNZXJjaGFudCBJRDogbWVy\nY2hhbnQuY29tLnNlYXRnZWVrLlNwcmVlZGx5QXBwbGVQYXlUZXN0MRMwEQYDVQQL\nDAo5QjNRWTlXQlo1MRcwFQYDVQQKDA5TZWF0R2VlaywgSW5jLjELMAkGA1UEBhMC\nVVMwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQhoBD6FaOXUJq3e4EoI7rWemTz\nhLaPlAdF87WzmbhWKVNJ9LAEhrBjAtj6is765Ow2dnYta0QPF9EJoubwKOjKo4IC\nVTCCAlEwRwYIKwYBBQUHAQEEOzA5MDcGCCsGAQUFBzABhitodHRwOi8vb2NzcC5h\ncHBsZS5jb20vb2NzcDA0LWFwcGxld3dkcmNhMjAxMB0GA1UdDgQWBBQMV4lSAdev\nm6sv1MVm5yR0gWij+jAMBgNVHRMBAf8EAjAAMB8GA1UdIwQYMBaAFIS2hMw6hmJy\nFlmU6BqjvUjfOt8LMIIBHQYDVR0gBIIBFDCCARAwggEMBgkqhkiG92NkBQEwgf4w\ngcMGCCsGAQUFBwICMIG2DIGzUmVsaWFuY2Ugb24gdGhpcyBjZXJ0aWZpY2F0ZSBi\neSBhbnkgcGFydHkgYXNzdW1lcyBhY2NlcHRhbmNlIG9mIHRoZSB0aGVuIGFwcGxp\nY2FibGUgc3RhbmRhcmQgdGVybXMgYW5kIGNvbmRpdGlvbnMgb2YgdXNlLCBjZXJ0\naWZpY2F0ZSBwb2xpY3kgYW5kIGNlcnRpZmljYXRpb24gcHJhY3RpY2Ugc3RhdGVt\nZW50cy4wNgYIKwYBBQUHAgEWKmh0dHA6Ly93d3cuYXBwbGUuY29tL2NlcnRpZmlj\nYXRlYXV0aG9yaXR5LzA2BgNVHR8ELzAtMCugKaAnhiVodHRwOi8vY3JsLmFwcGxl\nLmNvbS9hcHBsZXd3ZHJjYTIuY3JsMA4GA1UdDwEB/wQEAwIDKDBPBgkqhkiG92Nk\nBiAEQgxAODlDQjI1MDkxOTI0RDY3RjlFMEM2QUVDMzA0MENBMkFGNzA4MEYzRTBG\nQ0NFMTZBOTY5RDkyMUE0QkM5RTA1RjAKBggqhkjOPQQDAgNJADBGAiEAvKYdzDtD\nQ87guVNkybbcEY1Y/nXO9Ry+4fVDwXYMET0CIQDEiK1+xSSziPZ/PPQHF8MCWsD0\nLDW0aLigLHbDgQcrXA==\n-----END CERTIFICATE-----\n'
        }
    }, function (error, response) {
        if (error) {
            console.log('error ', error);
            return;
        }
        console.log('response', response);
    });

Transactions

List

    spreedly.transactions.list(function (error, response) {
        if (error) {
            console.log('error ', error);
            return;
        }
        console.log('response', response);
        // asynchronously called
    });

Show

    spreedly.transactions.show('9xYaLekcLzT6gRet1CmbXUU8JsL', function (error, response) {
        if (error) {
            console.log('error ', error);
            return;
        }
        console.log('response', response);
        // asynchronously called
    });

Transcript

    spreedly.transactions.transcript('9xYaLekcLzT6gRet1CmbXUU8JsL', function (error, response) {
        if (error) {
            console.log('error ', error);
            return;
        }
        console.log('response', response);
        // asynchronously called
    });

Author

Originally by Bhushankumar Lilapara ([email protected]).