2020-06-10 14:46:05 +00:00
|
|
|
# paypal-rs
|
2022-04-27 07:27:59 +00:00
|
|
|
|
|
|
|
|
2021-07-02 09:46:57 +00:00
|
|
|
[![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)
|
2020-06-09 08:08:22 +00:00
|
|
|
![Rust](https://github.com/edg-l/paypal-rs/workflows/Rust/badge.svg)
|
2021-01-08 15:03:19 +00:00
|
|
|
[![Docs](https://docs.rs/paypal-rs/badge.svg)](https://docs.rs/paypal-rs)
|
2020-06-08 20:30:45 +00:00
|
|
|
|
2021-01-08 15:37:04 +00:00
|
|
|
A rust library that wraps the [paypal api](https://developer.paypal.com/docs/api) asynchronously in a strongly typed manner.
|
2020-06-08 20:30:45 +00:00
|
|
|
|
2020-06-09 16:27:51 +00:00
|
|
|
Crate: https://crates.io/crates/paypal-rs
|
|
|
|
|
2020-06-09 13:04:14 +00:00
|
|
|
Documentation: https://docs.rs/paypal-rs
|
|
|
|
|
2020-06-09 16:26:31 +00:00
|
|
|
Currently in early development.
|
|
|
|
|
2022-04-27 07:27:59 +00:00
|
|
|
### Example
|
2020-06-10 11:03:18 +00:00
|
|
|
|
|
|
|
```rust
|
|
|
|
use paypal_rs::{
|
|
|
|
Client,
|
2022-04-27 07:27:59 +00:00
|
|
|
api::orders::*,
|
|
|
|
data::orders::*,
|
|
|
|
data::common::Currency,
|
2020-06-10 11:03:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() {
|
2022-04-27 07:27:59 +00:00
|
|
|
dotenv::dotenv().ok();
|
2020-06-10 11:03:18 +00:00
|
|
|
let clientid = std::env::var("PAYPAL_CLIENTID").unwrap();
|
|
|
|
let secret = std::env::var("PAYPAL_SECRET").unwrap();
|
|
|
|
|
2020-08-12 08:34:59 +00:00
|
|
|
let mut client = Client::new(clientid, secret, true);
|
2020-06-10 11:03:18 +00:00
|
|
|
|
|
|
|
client.get_access_token().await.unwrap();
|
|
|
|
|
2022-04-27 07:27:59 +00:00
|
|
|
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();
|
2020-06-10 11:03:18 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2022-04-27 07:27:59 +00:00
|
|
|
### Testing
|
2020-06-09 16:26:31 +00:00
|
|
|
You need the enviroment variables PAYPAL_CLIENTID and PAYPAL_SECRET to be set.
|
|
|
|
|
2022-04-27 07:27:59 +00:00
|
|
|
`cargo test`
|
2020-06-10 11:03:18 +00:00
|
|
|
|
2022-04-27 07:27:59 +00:00
|
|
|
### Roadmap
|
2020-06-10 11:03:18 +00:00
|
|
|
|
2020-06-10 14:44:00 +00:00
|
|
|
- [x] Orders API - 0.1.0
|
2020-06-10 11:19:27 +00:00
|
|
|
- - [x] Create order
|
|
|
|
- - [x] Update order
|
|
|
|
- - [x] Show order details
|
|
|
|
- - [x] Authorize payment for order
|
|
|
|
- - [x] Capture payment for order
|
2020-06-10 14:44:00 +00:00
|
|
|
- [ ] Invoicing API - 0.2.0
|
|
|
|
- [ ] 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
|
2021-01-05 12:40:36 +00:00
|
|
|
- [ ] Payment Experience Web Profiles API - 1.0.0
|
2022-04-27 07:27:59 +00:00
|
|
|
|
|
|
|
License: MIT OR Apache-2.0
|