1.6.10 • Published 2 years ago

splitit-sdk v1.6.10

Weekly downloads
114
License
MIT
Repository
-
Last release
2 years ago

Splitit SDK for Typescript (browser)

Environment

  • Webpack / browser

Dependencies

  • "fetch": "~1.1.0"

It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via package.json. (Reference)

Installation

Install via node package manager:

npm install splitit-sdk --save

Breaking changes

1.6.0

Breaking change is introduced in version 1.6. Previous behaviour: catching error from API calls would return only list of errors. Now it returns entire response object, and list of errors can be found in err.responseHeader.errors.

Getting Started

Note: this library is intended for browser use only, therefore call to login and initiate API must be done server-side to keep your credentials safe. Once the PublicToken is obtained, it can be used to invoke further API methods. Please follow the installation instruction and add the following TypeScript code:

import * as splititApi from 'splitit-sdk';

export function testSplititApi() {
    console.log('Initiating...');

    splititApi.Configuration.setSandbox();

    // Obtain PublicToken via server-side call using one of the libraries available [here](https://github.com/Splitit/Splitit.SDKs).

    const publicToken = "TOKEN_OBTAINED_SERVER_SIDE";
    const installmentPlanNumber = "PLAN_NUMBER_OBTAINED_SERVER_SIDE";

    var planApi = new splititApi.InstallmentPlanApi(
        splititApi.Configuration.clientSide(publicToken));

    const createRequest: splititApi.CreateInstallmentPlanRequest = {
        creditCardDetails: <splititApi.CardData>{
            cardNumber: "411111111111111",
            cardCvv: "123",
            cardHolderFullName: "John Smith",
            cardExpMonth: "12",
            cardExpYear: "2022"
        },
        installmentPlanNumber: installmentPlanNumber
    };

    planApi.installmentPlanCreate({ request: createRequest })
        .then(data => console.log(data))
        .catch(err => console.error(err));
}

To use the library in Javascript, use the following slightly modified code:

export function testSplititApi() {
    console.log('Initiating...');

    var splititApi = require('splitit-sdk');
    splititApi.Configuration.setSandbox();

    var publicToken = "TOKEN_OBTAINED_SERVER_SIDE";
    var installmentPlanNumber = "PLAN_NUMBER_OBTAINED_SERVER_SIDE";

    var planApi = new splititApi.InstallmentPlanApi(
            splititApi.Configuration.clientSide(publicToken));

    var createRequest = splititApi.CreateInstallmentPlanRequestFromJSONTyped({
        CreditCardDetails: {
            CardNumber: "411111111111111",
            CardCvv: "123",
            CardHolderFullName: "John Smith",
            CardExpMonth: "12",
            CardExpYear: "2022"
        },
        InstallmentPlanNumber: installmentPlanNumber
    });
    
    planApi.installmentPlanCreate({ request: createRequest }).then(function (data) {
        console.log({ data });
    }).catch(err => {
        console.error(err);
    });
}

For detailed information on request and response procedures, please visit Splitit Web API documentation

1.6.10

2 years ago

1.6.5527

2 years ago

1.6.5528

2 years ago

1.6.5529

2 years ago

1.6.9

3 years ago

1.6.8

3 years ago

1.6.7

3 years ago

1.6.6

3 years ago

1.6.5

3 years ago

1.6.4

3 years ago

1.6.3

3 years ago

1.6.2

3 years ago

1.6.1

3 years ago

1.6.0

3 years ago

1.5.33

3 years ago

1.5.32

3 years ago

1.5.30

4 years ago

1.5.31

4 years ago

1.5.29

4 years ago

1.5.24

4 years ago

1.5.28

4 years ago

1.5.21

4 years ago

1.5.18

4 years ago

1.5.19

4 years ago

1.5.20

4 years ago

1.5.17

4 years ago

1.5.16

4 years ago

1.5.15

4 years ago

1.5.14

4 years ago

1.5.13

4 years ago

1.5.12

4 years ago

1.5.11

4 years ago

1.5.5

4 years ago

1.5.4

4 years ago

1.5.3

4 years ago

1.5.1

4 years ago

1.5.10

4 years ago

1.5.6

4 years ago

1.5.0

4 years ago

1.4.6

4 years ago

1.4.5

4 years ago

1.4.4

4 years ago

1.4.3

4 years ago

1.4.2

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.34

4 years ago

1.3.32

4 years ago

1.3.33

4 years ago

1.3.31

4 years ago

1.3.17

4 years ago

1.3.16

4 years ago

1.3.14

4 years ago

1.3.13

4 years ago

1.0.2

4 years ago

1.0.4

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago