Crates.io | mercadopago-sdk-rust |
lib.rs | mercadopago-sdk-rust |
version | 0.1.1 |
source | src |
created_at | 2022-05-15 19:16:31.315051 |
updated_at | 2022-05-15 22:07:06.978035 |
description | A strongly-typed wrapper for MercadoPago payment gateway API. |
homepage | |
repository | https://github.com/saskenuba/mercadopago-sdk-rust |
max_upload_size | |
id | 587287 |
size | 67,838 |
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.
The library is still under development and its public API is subject to change.
Added the following into your Cargo.toml:
mercadopago_sdk_rust = "0.1"
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
]
use mercadopago_sdk_rust::common_types::{CheckoutProPayer, Item};
use mercadopago_sdk_rust::payments::requests::DocumentType;
use mercadopago_sdk_rust::preferences::requests::CheckoutProPreferences;
use mercadopago_sdk_rust::MercadoPagoSDKBuilder;
#[tokio::main]
async fn async_main() {
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(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();
}
Check out the tests
folder inside our repository to check for more examples.
Project is licensed under the permissive MIT license.