BMKeros / mercadopago_sdk_dart

MercadoPago Dart SDK
MIT License
31 stars 9 forks source link

factory and method for access token #23

Closed hostelix closed 4 years ago

hostelix commented 4 years ago

Add new changes

1) Using factory

```
var mp = MP.fromAccessToken('MYACCESSTOKEN');
var preference = {
        "items": [
            {
                "title": "Test",
                "quantity": 1,
                "currency_id": "USD",
                "unit_price": 10.4
            }
        ]
    };
var result = await mp.createPreference(preference);```

2) Using method

```
var mp = MP("CLIENT_ID", "CLIENT_SECRET");
var preference = {
        "items": [
            {
                "title": "Test",
                "quantity": 1,
                "currency_id": "USD",
                "unit_price": 10.4
            }
        ]
    };
// Change access token

mp.setAccessToken('MYACCESSTOKEN'); var result = await mp.createPreference(preference);```