A rust library that wraps the paypal api asynchronously in a strongly typed manner.
Crate: https://crates.io/crates/paypal-rs
Documentation: https://docs.rs/paypal-rs
Currently in early development.
```rust use paypal_rs::{ Client, HeaderParams, Prefer, orders::{OrderPayload, Intent, PurchaseUnit, Amount} };
async fn main() { let clientid = std::env::var("PAYPALCLIENTID").unwrap(); let secret = std::env::var("PAYPALSECRET").unwrap();
let mut client = Client::new(clientid.as_str(), secret.as_str(), true);
client.get_access_token().await.unwrap();
let order_payload = OrderPayload::new(
Intent::Authorize,
vec![PurchaseUnit::new(Amount::new(
"EUR", "10.0",
))],
);
let order = client
.create_order(
order_payload,
HeaderParams {
prefer: Some(Prefer::Representation),
..Default::default()
},
)
.await
.unwrap();
} ```
You need the enviroment variables PAYPALCLIENTID and PAYPALSECRET to be set.
cargo test --lib