ezstripe

Crates.ioezstripe
lib.rsezstripe
version0.6.1
sourcesrc
created_at2023-01-09 13:33:42.725627
updated_at2023-01-18 09:19:34.289491
descriptionUse ezstripe to easily communicate with Stripe's API.
homepage
repositoryhttps://github.com/EntenKoeniq/ezstripe
max_upload_size
id754524
size216,480
Nick-I. A. (EntenKoeniq)

documentation

README

ezstripe 💳

A Stripe-SDK for Rustlang

Use ezstripe to easily communicate with Stripe's API.

CRATESIO DOCS EXAMPLES CHANGELOG BENCHMARKS

Your our discord

Usage

Installation

# Cargo.toml
[dependencies]
ezstripe = "0.6.1"

or cargo add ezstripe

Features

All features are enabled by default, but you can only select the features you really need for your project.

# Cargo.toml
[dependencies]
ezstripe = { version = "0.6.1", default-features = false, features = ["payment_intent", "refund"] }

Check all available features

Example

# Cargo.toml
[dependencies]
ezstripe = "0.6.1"
env_logger = "0.10.0" # Optional
// Required to use the `ezbody!` macro
#[macro_use] extern crate ezstripe;

#[tokio::main]
async fn main() {
  // To show possible errors (recommended for development)
  env_logger::init_from_env(env_logger::Env::default().filter_or("MY_LOG_LEVEL", "debug"));

  // We need a client to make requests
  let client = ezstripe::Client::new("SECRET_KEY");
  
  // Create a body for the request
  let stripe_body = ezbody!(
      "amount" => 1500,
      "currency" => "eur",
      "payment_method_types[]" => "card",
      "payment_method_types[]" => "sofort",
      "capture_method" => "automatic",
      "shipping[name]" => "Your Name",
      "shipping[address][city]" => "Test"
    );
  
  // Now send a request to Stripe's API
  let stripe_response = client.create_payment_intent(stripe_body).send().await;
  if let Err((e_msg, e_info)) = stripe_response {
    if let Some(r) = e_info {
      println!("{}: {} | {} | {}", e_msg, r.r#type, r.code, r.message);
    } else { // Such an error only occurs when a request to Stripe failed
      println!("{}", e_msg);
    }
    std::process::exit(1);
  }
  
  // No error, so let's unpack the answer
  let stripe_result = stripe_response.unwrap();
  
  // Print the unique ID from the created PaymentIntent
  println!("Created: {}", stripe_result.id);
}

Status

A list of currently supported and planned features.

CORE RESOURCES

  • Balance
  • Balance Transactions
  • Charges
  • Customers
  • Disputes
  • Events
  • Files
  • File Links
  • Mandates
  • PaymentIntents
  • SetupIntents
  • SetupAttempts
  • Payouts
  • Refunds
  • Tokens

Contributing

Note
We don't bring in code from other projects! I ask you to respect the projects of others and the time invested and not to copy anything! No Struct! No Line!

Interested in contributing to this SDK? Github offers you the possibility to create pull requests where you can contribute your work to improve the experience with ezstripe!

License

I spent hours writing the code and creating each member of a struct. So please respect my time and work.

This project is licensed under MIT license.

Commit count: 0

cargo fmt