1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#![deny(missing_docs)]

//! A crate that serves to abstract away the network aspect of interfacing with paypal.
//! Created by nikos
//!
//! Creating a payment is done using the `create_payment` function.
//! ```rust,no_run
//! let token = paypal::get_token("my_id", "my_secret")?;
//! let amount = TransactionAmount {
//!     currency: "USD".to_string(),
//!     total: "100.00".to_string()
//! };
//! let new_payment = payment::new(
//!     &token.access_token,
//!     "mysite.com/whooyoupaid",
//!     "mysite.com/nooyoufailed",
//!     PaymentMethod::Paypal,
//!     PaymentIntent::Sale,
//!     vec![Transaction { amount }],
//! )?;
//! ```

/// Possible ways that a paypal request can fail
pub mod error;
mod payment;
mod request;
mod token;

mod types;

pub use token::get_token;
pub use types::{
    Address, ApplicationContext, CreditCard, CreditCardToken, FailureReason, FundingInstrument,
    LinkDescription, ListPaymentResponse, NormalizationStatus, Payer, PayerStatus, Payment,
    PaymentIntent, PaymentMethod, RedirectUrls, State, Transaction, TransactionAmount,
};
pub use payment::*;

#[cfg(feature = "test-mode")]
const _ADDR: &str = "https://api.sandbox.paypal.com/v1";

#[cfg(not(feature = "test-mode"))]
const _ADDR: &str = "https://api.paypal.com/v1";

fn _make_endpoint(ep: &str) -> String {
    format!("{}{}", _ADDR, ep)
}