mercadopago_sdk 1.0.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 79

MercadoPago SDK module for Payments integration #

Usage #

To use this plugin, add mercadopago_sdk as a dependency in your pubspec.yaml file.

  • Basic checkout
  • Customized checkout
  • Generic methods

Basic checkout #

Configure your credentials


import 'package:mercadopago_sdk/mercadopago_sdk.dart';

var mp = MP("CLIENT_ID", "CLIENT_SECRET");

Preferences #

Get an existent Checkout preference


Future<Map<String, dynamic>> index() async {
    result = await mp.getPreference("PREFERENCE_ID");

    return result;
}

Create a Checkout preference


Future<Map<String, dynamic>> index() async {
    var preference = {
        "items": [
            {
                "title": "Test",
                "quantity": 1,
                "currency_id": "USD",
                "unit_price": 10.4
            }
        ]
    };

    var result = await mp.createPreference(preference);

    return result;
}

Update an existent Checkout preference


Future<Map<String, dynamic>> index() async {
    var preference = {
        "items": [
            {
                "title": "Test Modified",
                "quantity": 1,
                "currency_id": "USD",
                "unit_price": 20.4
            }
        ]
    };

    var result = await mp.updatePreference(id, preference);

    return result;
}

Payments/Collections #

Search for payments #

Future<Map<String, dynamic>> index() async {
    var filters = {
        "id": None,
        "external_reference": None
    };

    var searchResult = await mp.searchPayment(filters)

    return searchResult;
}

Get payment data #

Future<Map<String, dynamic>> index() async {
    paymentInfo = await mp.getPayment("PID");

    return paymentInfo;
}

Cancel (only for pending payments) #

Future<Map<String, dynamic>> index() async {
    var result = await mp.cancelPayment("PID");

    // Show result
    return result;
}

Refund (only for accredited payments) #

Future<Map<String, dynamic>> index() async {
    var result = await mp.refundPayment("PID");

    // Show result
    return result;
}

Customized checkout #

Configure your credentials #


import 'package:mercadopago_sdk/mercadopago_sdk.dart';

var mp = MP("ACCESS_TOKEN");

Create payment #

mp.post("/v1/payments", data);

Create customer #

mp.post("/v1/customers", {"email": "email@test.com"});

Get customer #

mp.get("/v1/customers/CUSTOMER_ID");

Generic methods #


You can access any other resource from the MercadoPago API using the generic methods:

// Get a resource, with optional URL params. Also you can disable authentication for public APIs
mp.get("/resource/uri", { params, authenticate });

// Create a resource with "data" and optional URL params.
mp.post("/resource/uri", { data, params });

// Update a resource with "data" and optional URL params.
mp.put("/resource/uri", { data, params });

// Delete a resource with optional URL params.
mp.delete("/resource/uri", { params });

For example, if you want to get the Sites list (no params and no authentication):

var result = mp.get("/sites");

print(result);

1.0.5 #

  • Health suggestions sdk.dart

1.0.4 #

  • Health suggestions Future

1.0.3 #

  • Health suggestions
  • Fix markdown readme.md

1.0.2 #

  • Add Generic methods GET, POST, PUT, DELETE

1.0.1 #

  • Apply dartfmt to files
  • Add dartdoc to sdk.dart file
  • Add example folder

1.0.0 #

  • Initial Release

example/main.dart

import 'package:mercadopago_sdk/mercadopago_sdk.dart';

void main() async {
  var mp = MP('CLIENT_ID', 'CLIENT_SECRET');

  String token = await mp.getAccessToken();

  print('Mercadopago token ${token}');
}

Use this package as a library

1. Depend on it

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


dependencies:
  mercadopago_sdk: ^1.0.5

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:mercadopago_sdk/mercadopago_sdk.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
59
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
79
Learn more about scoring.

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

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
http ^0.12.0 0.12.0+2
test ^1.5.1+1 1.9.3
Transitive dependencies
analyzer 0.39.0
args 1.5.2
async 2.4.0
boolean_selector 1.0.5
charcode 1.1.2
collection 1.14.12
convert 2.1.1
coverage 0.13.3
crypto 2.1.3
csslib 0.16.1
front_end 0.1.28
glob 1.2.0
html 0.14.0+3
http_multi_server 2.1.0
http_parser 3.1.3
io 0.3.3
js 0.6.1+1
kernel 0.3.28
logging 0.11.3+2
matcher 0.12.6
meta 1.1.7
mime 0.9.6+3
multi_server_socket 1.0.2
node_interop 1.0.3
node_io 1.0.1+2
node_preamble 1.4.8
package_config 1.1.0
package_resolver 1.0.10
path 1.6.4
pedantic 1.8.0+1
pool 1.4.0
pub_semver 1.4.2
shelf 0.7.5
shelf_packages_handler 1.0.4
shelf_static 0.2.8
shelf_web_socket 0.2.3
source_map_stack_trace 1.1.5
source_maps 0.10.8
source_span 1.5.5
stack_trace 1.9.3
stream_channel 2.0.0
string_scanner 1.0.5
term_glyph 1.1.0
test_api 0.2.10
test_core 0.2.14
typed_data 1.1.6
vm_service 1.2.0 2.1.1
watcher 0.9.7+12
web_socket_channel 1.1.0
yaml 2.2.0