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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
//!
//! [![Version](https://img.shields.io/crates/v/paypal-rs)](https://crates.io/crates/paypal-rs)
//! [![Downloads](https://img.shields.io/crates/d/paypal-rs)](https://crates.io/crates/paypal-rs)
//! [![License](https://img.shields.io/crates/l/paypal-rs)](https://crates.io/crates/paypal-rs)
//! ![Rust](https://github.com/edg-l/paypal-rs/workflows/Rust/badge.svg)
//! [![Docs](https://docs.rs/paypal-rs/badge.svg)](https://docs.rs/paypal-rs)
//!
//! A rust library that wraps the [paypal api](https://developer.paypal.com/docs/api) asynchronously in a strongly typed manner.
//!
//! If there is a missing endpoint that you need, you may try to implement the [Endpoint](endpoint::Endpoint) and pass it to [Client::execute](client::Client::execute)
//!
//! Currently in early development.
//!
//! ## Example
//!
//! ```no_run
//! 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();
//! }
//! ```
//!
//! ## Testing
//! You need the enviroment variables PAYPAL_CLIENTID and PAYPAL_SECRET to be set.
//!
//! `cargo test`
//!
//! ## Roadmap
//!
//! - [x] Orders API - 0.1.0
//! - - [x] Create order
//! - - [x] Update order
//! - - [x] Show order details
//! - - [x] Authorize payment for order
//! - - [x] Capture payment for order
//! - [x] Invoicing API - 0.2.0
//! - - [x] Generate Invoice number
//! - - [x] Create Draft Invoice
//! - - [x] Show Invoice Details (Get Invoice)
//! - - [x] List Invoices
//! - - [x] Delete Invoice
//! - - [x] Update Invoice
//! - - [x] Cancel Invoice
//! - - [x] Send Invoice
//! - - [ ] Send Invoice Reminder
//! - - [ ] List Templates
//! - - [ ] Create Template
//! - - [ ] Delete Template
//! - - [ ] Fully Update Template
//! - - [ ] Show Template Template
//! - [ ] Payments API - 0.3.0
//! - [ ] Tracking API - 0.4.0
//! - [ ] Subscriptions API - 0.5.0
//! - [ ] Identity API - 0.6.0
//! - [ ] Disputes API - 0.7.0
//! - [ ] Catalog Products API - 0.8.0
//! - [ ] Partner Referrals API - 0.9.0
//! - [ ] Payouts API - 0.10.0
//! - [ ] Transaction Search API - 0.11.0
//! - [ ] Referenced Payouts API - 0.12.0
//! - [ ] Vault API - 0.13.0
//! - [ ] Webhooks Management API - 0.14.0
//! - [ ] Payment Experience Web Profiles API - 1.0.0
pub use *;
use Builder;
use Serialize;
use skip_serializing_none;
/// The paypal api endpoint used on a live application.
pub const LIVE_ENDPOINT: &str = "https://api-m.paypal.com";
/// The paypal api endpoint used on when testing.
pub const SANDBOX_ENDPOINT: &str = "https://api-m.sandbox.paypal.com";
/// Represents the query used in most GET api requests.
///
/// Reference: <https://developer.paypal.com/docs/api/reference/api-requests/#query-parameters>
///
/// Note: You can avoid most fields by the Default impl like so:
/// ```
/// use paypal_rs::Query;
/// let query = Query { count: Some(40), ..Default::default() };
/// ```
/// Represents the optional header values used on paypal requests.
///
/// <https://developer.paypal.com/docs/api/reference/api-requests/#paypal-auth-assertion>