Wondering what’s next for npm?Check out our public roadmap! »

    spreedly-api

    0.0.7 • Public • Published

    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

    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': 'joey@example.com'
            }
        }, 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': 'jon.doe@example.com',
                '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': 'security@yourorg.com'
            }
        }, 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\nMDMzMzBaMIG5MTowOAY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HJjYTIuY3JsMA4GA1UdDwEB/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 (bhushankumar.lilapara@gmail.com).

    Install

    npm i spreedly-api

    DownloadsWeekly Downloads

    60

    Version

    0.0.7

    License

    MIT

    Last publish

    Collaborators

    • avatar