MercadoPago SDK

Crate version on crates.io Crate documentation on docs.rs Crate license

An open source, strongly-typed SDK for the MercadoPago API.

It will try to hold your hand and reduce the possibility of errors, providing the correct API surface.

Note

The library is still under development and its public API is subject to change.

Installation

Added the following into your Cargo.toml:

toml mercadopago_sdk_rust = "0.1"

Usage

The client is built using the MercadoPagoSDKBuilder::with_token with_token method.

```rust use mercadopagosdkrust::{MercadoPagoSDK, MercadoPagoSDKBuilder};

let mpsdk: MercadoPagoSDK = MercadoPagoSDKBuilder::withtoken("MPACCESSTOKEN");

```

Once the token is inserted, you can call methods on [crate::MercadoPagoSDK]

Creating a CheckoutPro Preference

```rust use mercadopagosdkrust::commontypes::{CheckoutProPayer, Item}; use mercadopagosdkrust::payments::requests::DocumentType; use mercadopagosdkrust::preferences::requests::CheckoutProPreferences; use mercadopagosdk_rust::MercadoPagoSDKBuilder;

[tokio::main]

async fn asyncmain() { let mpsdk = MercadoPagoSDKBuilder::withtoken("MPACCESS_TOKEN");

let sample_item =
    Item::minimal_item("Sample item".to_string(), "".to_string(), 15.00, 1).unwrap();

let preferences = CheckoutProPreferences::new()
    .set_items(vec![sample_item])
    .set_payer(CheckoutProPayer::minimal_payer(
        "fulano@beltrano.com.br".to_string(),
        DocumentType::CPF,
        41810524485,
    ));

mp_sdk
    .create_preferences_checkout_pro(preferences)
    .expect("Failed to validate checkout preference. Something is wrong.")
    .execute()
    .await
    .unwrap();

} ```

Other Examples

Check out the tests folder inside our repository to check for more examples.

License

Project is licensed under the permissive MIT license.