Expand description

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

The library is still under development and its public API is subject to change. Project is licensed under the permissive MIT license.

Usage

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

use mercadopago_sdk_rust::{MercadoPagoSDK, MercadoPagoSDKBuilder};

let mp_sdk: MercadoPagoSDK = MercadoPagoSDKBuilder::with_token("MP_ACCESS_TOKEN");

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

Creating a CheckoutPro Preference

use mercadopago_sdk_rust::common_types::{Item, PreferencePayerInformation};
use mercadopago_sdk_rust::payments::requests::DocumentType;
use mercadopago_sdk_rust::preferences::requests::CheckoutProPreferences;
use mercadopago_sdk_rust::MercadoPagoSDKBuilder;

let mp_sdk = MercadoPagoSDKBuilder::with_token("MP_ACCESS_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(PreferencePayerInformation::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.

Modules

This class will allow you to send your customers card data for Mercado Pago server and receive a token to complete the payments transactions.

When creating payment for CreditCard, use card_tokens to generate a credit card token.

Preferences for Checkout Pro Official API page: https://www.mercadopago.com.br/developers/en/docs/checkout-pro/checkout-customization/preferences

You can setup your webhooks only

Structs