paypal_rust/
lib.rs

1//! # paypal-rust
2//! ---
3//! [![Downloads](https://img.shields.io/crates/d/paypal-rust?style=for-the-badge)](https://crates.io/crates/paypal-rust)
4//! [![Version](https://img.shields.io/crates/v/paypal-rust?style=for-the-badge)](https://crates.io/crates/paypal-rust)
5//!
6//! Rust bindings for the PayPal [REST](https://developer.paypal.com/api/rest) API.
7//!
8//! This library is a work in progress. While functional, it is not yet advised
9//! to be used in production (The API will change, tests are not yet complete, etc).
10//!
11//! For more information on the PayPal REST API, see the [PayPal Developer Portal](https://developer.paypal.com/api/rest).
12//! We aren't affiliated with PayPal in any way and this library is not endorsed by them.
13//!
14//! ## Usage
15//!
16//! ```no_run
17//! use dotenv::dotenv;
18//! use paypal_rust::client::AppInfo;
19//! use paypal_rust::{
20//!     AmountWithBreakdown, Client, CreateOrderDto, CurrencyCode, Environment, Order,
21//!     OrderApplicationContext, OrderIntent, PurchaseUnitRequest
22//! };
23//!
24//! #[tokio::main]
25//! async fn main() {
26//!     dotenv().ok();
27//!     let username = std::env::var("CLIENT_ID").expect("CLIENT_ID must be set");
28//!     let password = std::env::var("CLIENT_SECRET").expect("CLIENT_SECRET must be set");
29//!
30//!     let mut client = Client::new(username, password, Environment::Sandbox)
31//!         .unwrap()
32//!         .with_app_info(&AppInfo {
33//!             name: "PayPal Rust Test App".to_string(),
34//!             version: "1.0".to_string(),
35//!             website: None,
36//!         });
37//!
38//!     client.authenticate().await.unwrap();
39//!
40//!     let order = Order::create(
41//!         &client,
42//!         CreateOrderDto {
43//!             intent: OrderIntent::Capture,
44//!             payer: None,
45//!             purchase_units: vec![PurchaseUnitRequest::new(AmountWithBreakdown::new(
46//!                 CurrencyCode::Euro,
47//!                 "10.00".to_string(),
48//!             ))],
49//!             application_context: Some(
50//!                 OrderApplicationContext::new()
51//!                     .return_url("https://example.com/#/return".to_string())
52//!                     .cancel_url("https://example.com/#/cancel".to_string()),
53//!             ),
54//!         },
55//!     ).await.unwrap();
56//!
57//!     println!("Created order: {:?}", order);
58//! }
59//! ```
60//!
61//! # Features
62//!
63//! This library offers a "utils" feature that enables the `utils` module. This module contains
64//! some useful functions for working with the PayPal API. As of now:
65//!
66//! - `Order::get_maximum_reauthorization_amount()`
67//! - `Order::get_authorization_id()`
68
69#![forbid(unsafe_code)]
70
71pub mod client;
72pub mod resources;
73
74pub use client::paypal::*;
75pub use resources::*;
76
77#[cfg(feature = "utils")]
78pub mod utils;