mvola-rs

License: MIT

MVola Rust client library.

Install

Add the following line to your Cargo.toml file:

toml [dependencies] mvola = "0.1"

Usage

```rust use chrono::{DateTime, SecondsFormat, Utc}; use mvola::types::KeyValue; use mvola::types::Options; use mvola::types::Service; use mvola::types::TransactionRequest; use mvola::{MVola, SANDBOX_URL}; use std::env; use std::time::SystemTime; use uuid::Uuid;

[tokio::main]

async fn main() { let mut client = MVola::new(SANDBOXURL); let auth = client .auth .generatetoken( &env::var("CONSUMERKEY").unwrap(), &env::var("CONSUMERSECRET").unwrap(), ) .await; client .transaction .setauthorization(&auth.unwrap().accesstoken); client.transaction.setoptions(Options { version: String::from("1.0"), correlationid: Uuid::newv4().tostring(), userlanguage: Some("FR".tostring()), useraccountidentifier: String::from("msisdn;0343500004"), partnername: Some("TestMVola".tostring()), callbackurl: None, }); let transactionref = Uuid::new_v4();

let now = SystemTime::now(); let now: DateTime = now.into(); let now = now.torfc3339opts(SecondsFormat::Millis, true);

let tx: TransactionRequest = TransactionRequest { amount: String::from("1000"), currency: String::from("Ar"), descriptiontext: String::from("test"), requestdate: now.tostring(), debitparty: vec![KeyValue { key: String::from("msisdn"), value: String::from("0343500003"), }], credit_party: vec![KeyValue { key: String::from("msisdn"), value: String::from("0343500004"), }], metadata: vec![ KeyValue { key: String::from("partnerName"), value: String::from("TestMVola"), }, KeyValue { key: String::from("fc"), value: String::from("USD"), }, KeyValue { key: String::from("amountFc"), value: String::from("1"), }, ],

requesting_organisation_transaction_reference: transaction_ref.to_string(),
original_transaction_reference: transaction_ref.to_string(),

}; let response = client.transaction.send_payment(tx).await; println!("{:#?}", response); }

```

Test

sh cargo test

Author

👤 Tsiry Sandratraina tsiry.sndr@aol.com

Show your support

Give a ⭐️ if this project helped you!