0.2.5-alpha.0 • Published 6 months ago

@oystrfinance/direct-debit-client v0.2.5-alpha.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Oystr Direct Debit SDK Documentation

Installation

To use the direct debit SDK, you need to include the SDK script in your HTML file. You can either host the script locally or use a CDN. Here's an example of including the SDK and using a CDN:

Using NPM

npm i @oystrfinance/direct-debit-client

OR

Inline Script

<script src="https://cdn.jsdelivr.net/npm/@oystrfinance/direct-debit-client@latest/dist/bundle.js"></script>

Usage

The SDK expects that you have a backend and have called the create collection API endpoint like this

curl -X POST "https://oystr-direct-debit-api-staging.azurewebsites.net/v1/debits/create" -H "Content-Type: application/json" -H "api-key: xxxxxx" -d '{
  "amount": 5000,
  "frequency": "daily",
  "description": "Collection On John Doe",
  "start_date": "2023-09-30",
  "duration_in_days": 19,
  "reference": "'"$(($RANDOM % 1000000000))"'",
  "payer_data": {
    "bvn": "00000000000",
    "name": "John Doe",
    "phone_number": "+2348012345678",
    "email": "john@doe.com"
  }
}'

Warning

:warning: Never call the create collection endpoint from the frontend.

The above endpoint should only be called from the backend. Calling it from the frontend exposes your API key and allows anyone to create a collection on your behalf.

Initializing the SDK

The token gotten from the above endpoint can now be used to initialize the SDK like this

DirectDebit.setup(token).initialize({
            toggleLive: true,
});

Test Mode

The SDK has a test mode that can be used to test the SDK without making real payments. To enable test mode, pass toggleLive as false when initializing the SDK. The default value is true.

DirectDebit.setup(token).initialize({
            toggleLive: false,
});

Retries

For incomplete collections, passing the same token to the SDK will retry the collection. The SDK can retry the collection until it is successful or the collection expires.

0.2.5-alpha.0

6 months ago

0.2.4-alpha.0

7 months ago

0.2.4

7 months ago

0.2.3

7 months ago

0.2.2

7 months ago

0.2.1

8 months ago

0.2.0

8 months ago

0.1.8

8 months ago

0.1.7

8 months ago

0.1.6

8 months ago

0.1.5

8 months ago

0.1.4

8 months ago

0.1.3

8 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago

0.0.9

8 months ago

0.0.8

8 months ago

0.0.7

8 months ago

0.0.6

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago