nps_sdk 1.0.0

Dart SDK #

Availability #

Supports Dart from 2.0 to above

How to install #

Add the following line in dependencies in your pubspec.yaml file and save it:

dependencies:
  nps_sdk: "^1.0.0"

If pub get wasn't automatically ejecuted, you can do it manually by opening a terminal in your project and executing the command:

pub get

Now you are ready to import our SDK:

import 'package:nps_sdk/nps_sdk.dart';

Configuration #

It's a basic configuration of the SDK

import 'dart:async';

import 'package:nps_sdk/nps_sdk.dart';

main(List<String> arguments) async {
  Nps nps = new Nps(sandbox);
}

Here is an simple example request:

import 'dart:async';

import 'package:nps_sdk/nps_sdk.dart';

main(List<String> arguments) async {
  Nps nps = new Nps(sandbox);

  Map createPaymentMethodTokenParams = {
    "psp_Version": "2.2",
    "psp_MerchantId": "sdk_test",
    "psp_CardInputDetails": {
      "Number": "4507990000000010",
      "ExpirationDate": "2501",
      "SecurityCode": "123",
      "HolderName": "JOHN DOE"
    },
    "psp_ClientSession": "YOUR_CLIENT_SESSION_HERE"
  };

  Future response = nps.createPaymentMethodToken(nps, createPaymentMethodTokenParams);
  response.then((resp) {
            print(resp["psp_ResponseCod"]); //Only one key
            jsonPrettyPrint(resp); //All the XML
          })
          .catchError((error) => print);
}

Environments #

import 'package:nps_sdk/nps_sdk.dart';

Nps nps = new Nps(sandbox);
Nps nps = new Nps(staging);
Nps nps = new Nps(production);

Error handling #

With this SDK you will be able to handle errors as you prefer. In order to do this, you just need to specify what you want to do with the error in the catchError callback:

import 'dart:async';

import 'package:nps_sdk/nps_sdk.dart';

main(List<String> arguments) async {
    //Code
    
    Future response = nps.createPaymentMethodToken(nps, createPaymentMethodTokenParams);
      response.then((resp) => print(resp["psp_ResponseCod"]))
              .catchError((error) {
                //Your code to handle the error
              });
}

Flutter #

This SDK can be imported in Flutter's projects. For a Flutter example, click here.

1.0.0 #

  • Upgrade to Dart 2

0.0.9 #

  • Fixed pub warnings

0.0.8 #

  • Added Flutter example

0.0.7 #

  • Changed xml's library version

0.0.6 #

  • Refactored code

0.0.5 #

  • Added methods for validation
  • Changed hosts' paths
  • Fixed getInstallmentsOptions method

0.0.4 #

  • Made changes in README.md

0.0.3 #

  • Made changes in README.md

0.0.2 #

  • Made changes in the example

0.0.1 #

  • First SDK's commit

example/nps_sdk_example.dart

import 'dart:async';

import 'package:nps_sdk/nps_sdk.dart';

main(List<String> arguments) async {
  Nps nps = new Nps(sandbox);

  Map createPaymentMethodTokenParams = {
    "psp_Version": "2.2",
    "psp_MerchantId": "sdk_test",
    "psp_CardInputDetails": {
      "Number": "4507990000000010",
      "ExpirationDate": "2501",
      "SecurityCode": "123",
      "HolderName": "JOHN DOE"
    },
    "psp_ClientSession": "YOUR_CLIENT_SESSION"
  };

  Future response = nps.createPaymentMethodToken(nps, createPaymentMethodTokenParams);
  response.then((resp) => jsonPrettyPrint(resp))
          .catchError((error) => print);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  nps_sdk: ^1.0.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:nps_sdk/nps_sdk.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
82
Overall:
Weighted score of the above. [more]
46
Learn more about scoring.

We analyzed this package on Jul 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:nps_sdk/nps_sdk.dart.

Health issues and suggestions

Document public APIs. (-1 points)

40 out of 40 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/nps_sdk.dart.

Run dartfmt to format lib/nps_sdk.dart.

Format lib/src/constants.dart.

Run dartfmt to format lib/src/constants.dart.

Format lib/src/deserializer.dart.

Run dartfmt to format lib/src/deserializer.dart.

Fix additional 4 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/serializer.dart (Run dartfmt to format lib/src/serializer.dart.)
  • lib/src/services.dart (Run dartfmt to format lib/src/services.dart.)
  • lib/src/soap_client.dart (Run dartfmt to format lib/src/soap_client.dart.)
  • lib/src/utilities.dart (Run dartfmt to format lib/src/utilities.dart.)

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (http).

The package description is too short. (-8 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
http ^0.11.3+17 0.11.3+17 0.12.0+2
xml ^3.2.0 3.5.0
xml2json ^3.0.1 3.0.3
Transitive dependencies
async 2.3.0
charcode 1.1.2
collection 1.14.11
convert 2.1.1
http_parser 3.1.3
meta 1.1.7
path 1.6.2
petitparser 2.4.0
source_span 1.5.5
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6

Admin