Crates.io | paypal-rs |
lib.rs | paypal-rs |
version | 0.2.6 |
source | src |
created_at | 2020-06-08 20:36:35.963874 |
updated_at | 2024-06-03 06:02:14.604667 |
description | A library that wraps the paypal api asynchronously. |
homepage | |
repository | https://github.com/edg-l/paypal-rs/ |
max_upload_size | |
id | 251620 |
size | 213,327 |
A rust library that wraps the paypal api asynchronously in a strongly typed manner.
If there is a missing endpoint that you need, you may try to implement the Endpoint and pass it to Client::execute
Currently in early development.
use paypal_rs::{
Client,
api::orders::*,
data::orders::*,
data::common::Currency,
PaypalEnv,
};
#[tokio::main]
async fn main() {
dotenvy::dotenv().ok();
let clientid = std::env::var("PAYPAL_CLIENTID").unwrap();
let secret = std::env::var("PAYPAL_SECRET").unwrap();
let mut client = Client::new(clientid, secret, PaypalEnv::Sandbox);
client.get_access_token().await.unwrap();
let order = OrderPayloadBuilder::default()
.intent(Intent::Authorize)
.purchase_units(vec![PurchaseUnit::new(Amount::new(Currency::EUR, "10.0"))])
.build().unwrap();
let create_order = CreateOrder::new(order);
let _order_created = client
.execute(&create_order).await.unwrap();
}
You need the enviroment variables PAYPAL_CLIENTID and PAYPAL_SECRET to be set.
cargo test
License: MIT OR Apache-2.0