Skip to main content

Crate bitmomo

Crate bitmomo 

Source
Expand description

BitMomo merchant SDK: accept crypto payments and verify BitMomo webhooks.

Test money only. BitMomo currently runs on test networks. Live API keys are disabled, so nothing you do with this SDK moves real money.

use bitmomo::{Client, CreatePaymentParams, Decimal};

let client = Client::new(std::env::var("BITMOMO_API_KEY").unwrap(), "https://api.dev.bitmomo.app")?;
let params = CreatePaymentParams::new(Decimal::new("150.00")?, "USDT_TRC20")
    .order_id("order-1001")
    .idempotency_key("order-1001"); // reuse the same key if you retry
let payment = client.create_payment(&params).await?;
println!("{} {} {}", payment.deposit_address, payment.crypto_amount, payment.qr_code_data);

Verify webhooks with webhooks::verify_event. Every failure is an Error with the HTTP status, the API’s code, a message and a retriable hint. Money is Decimal, an exact decimal string.

The client feature (on by default) provides the async Client; turn default features off to use only the webhook helpers. TLS uses rustls by default (rustls-tls); enable native-tls instead if you prefer.

Guides and the API reference: https://docs.bitmomo.app

Re-exports§

pub use models::*;

Modules§

models
Request parameters and response models. Field names match the API.
webhooks
Verify BitMomo webhook deliveries.

Structs§

Client
Async client for the BitMomo merchant API. Cheap to clone; clones share one connection pool.
ClientBuilder
Configures a Client.
Decimal
An exact decimal amount such as "150.00". Money never passes through f64. Convert it with your decimal crate, for example rust_decimal::Decimal::from_str(d.as_str()).
Error
Every failure the SDK returns.

Constants§

VERSION
The SDK version, sent in the User-Agent header.

Functions§

new_idempotency_key
A random UUID (version 4) to use as an idempotency key. Keep it with the business intent and reuse it when you retry.