| Crates.io | payjp |
| lib.rs | payjp |
| version | 0.0.1 |
| created_at | 2024-12-31 12:04:46.090427+00 |
| updated_at | 2024-12-31 12:04:46.090427+00 |
| description | Payjp SDK based on arlyon/async-stripe |
| homepage | https://github.com/darai0512/payjp-rust-with-openapi |
| repository | https://github.com/darai0512/payjp-rust-with-openapi |
| max_upload_size | |
| id | 1499953 |
| size | 45,418 |
based on arlyon/async-stripe by Alexander Lyon
This asynchronous example uses Tokio to create
a Payjp Customer. Your Cargo.toml could
look like this:
tokio = { version = "1", features = ["full"] }
payjp = { version = "0.28", features = ["runtime-tokio-hyper"] }
payjp_core = { version = "0.28", features = ["customer"] }
And then the code:
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let secret_key = "sk_xxx";
let client = payjp::Client::new(secret_key);
let customer = payjp_core::customer::CreateCustomer {
email: Some("test@async-payjp.com"),
..Default::default()
}
.send(&client)
.await?;
println!("created a customer at https://pay.jp/d/customers/{}", customer.id);
Ok(())
}
A full list of examples can be found in the examples.
The main entry point is the payjp-rust crate which provides a client for making Payjp
API requests.
payjp-rust is compatible with the async-std
and tokio runtimes and the native-tls
and rustls backends. When adding the dependency, you must select a runtime feature.
[dependencies]
payjp = { version = "0.31", features = ["runtime-tokio-hyper"] }
supports the following features combining runtime and TLS choices:
runtime-tokio-hyperruntime-tokio-hyper-rustlsruntime-tokio-hyper-rustls-webpkiruntime-blockingruntime-blocking-rustlsruntime-blocking-rustls-webpkiruntime-async-std-surf