Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 0 additions & 108 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ rust-version = "1.84"

[features]
default = []
snippets = ["tokio", "dotenv", "tempfile", "uuid"]

[dependencies]
serde = { version = "1.0", features = ["derive"] }
Expand All @@ -37,117 +36,10 @@ pem = "3.0"
log = "0.4"
rand = "0.8"

# Optional dependencies for snippets
tokio = { version = "1.45.0", features = ["full"], optional = true }
dotenv = { version = "0.15", optional = true }
tempfile = { version = "3.20.0", optional = true }
uuid = { version = "1.16", features = ["v4", "serde"], optional = true }

[lib]
name = "open_payments"
path = "src/lib.rs"

# Binary targets for snippets
[[bin]]
name = "grant-cancel"
path = "src/snippets/grant/cancel.rs"
required-features = ["snippets"]

[[bin]]
name = "grant-continuation"
path = "src/snippets/grant/continuation.rs"
required-features = ["snippets"]

[[bin]]
name = "grant-incoming-payment"
path = "src/snippets/grant/incoming_payment.rs"
required-features = ["snippets"]

[[bin]]
name = "grant-outgoing-payment"
path = "src/snippets/grant/outgoing_payment.rs"
required-features = ["snippets"]

[[bin]]
name = "grant-quote"
path = "src/snippets/grant/quote.rs"
required-features = ["snippets"]

[[bin]]
name = "incoming-payment-complete"
path = "src/snippets/incoming_payment/complete.rs"
required-features = ["snippets"]

[[bin]]
name = "incoming-payment-create"
path = "src/snippets/incoming_payment/create.rs"
required-features = ["snippets"]

[[bin]]
name = "incoming-payment-get"
path = "src/snippets/incoming_payment/get.rs"
required-features = ["snippets"]

[[bin]]
name = "incoming-payment-list"
path = "src/snippets/incoming_payment/list.rs"
required-features = ["snippets"]

[[bin]]
name = "outgoing-payment-create"
path = "src/snippets/outgoing_payment/create.rs"
required-features = ["snippets"]

[[bin]]
name = "outgoing-payment-get"
path = "src/snippets/outgoing_payment/get.rs"
required-features = ["snippets"]

[[bin]]
name = "outgoing-payment-list"
path = "src/snippets/outgoing_payment/list.rs"
required-features = ["snippets"]

[[bin]]
name = "quote-create"
path = "src/snippets/quote/create.rs"
required-features = ["snippets"]

[[bin]]
name = "quote-create-with-debit-amount"
path = "src/snippets/quote/create_with_debit_amount.rs"
required-features = ["snippets"]

[[bin]]
name = "quote-create-with-receive-amount"
path = "src/snippets/quote/create_with_receive_amount.rs"
required-features = ["snippets"]

[[bin]]
name = "quote-get"
path = "src/snippets/quote/get.rs"
required-features = ["snippets"]

[[bin]]
name = "token-revoke"
path = "src/snippets/token/revoke.rs"
required-features = ["snippets"]

[[bin]]
name = "token-rotate"
path = "src/snippets/token/rotate.rs"
required-features = ["snippets"]

[[bin]]
name = "wallet-address-get"
path = "src/snippets/wallet_address/get.rs"
required-features = ["snippets"]

[[bin]]
name = "wallet-address-get-keys"
path = "src/snippets/wallet_address/get_keys.rs"
required-features = ["snippets"]

[[bin]]
name = "http-signature-example"
path = "src/http_signature/examples/generate_signature.rs"
Expand Down
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Additionally, this crate contains several modules:

- [`client`](./src/client) contains a Rust client to make requests via the Open Payments API.
- [`types`](./src/types) contains Rust types for the API.
- [`snippets`](./src/snippets) contains examples of Rust client usage for getting accustomed to the Open Payments flow.
- [`http_signature`](./src/http_signature) provides tools for working with [HTTP Message Signatures](https://datatracker.ietf.org/doc/draft-ietf-httpbis-message-signatures).

## Dependencies
Expand Down Expand Up @@ -77,14 +76,14 @@ cd open-payments-rust
cargo build
```

### Running Examples
### Running Snippets

See [src/snippets/README.md](./src/snippets/README.md) for details on running code snippets and payment flows. For example, to run a snippet:
Rust snippets are no longer shipped in this repository. Please use the Open Payments docs to view and run the latest examples:

```sh
cd src/snippets
cargo run --features snippets --bin grant-incoming-payment
```
- Docs: https://openpayments.dev
- Rust snippet sources: https://github.com/interledger/open-payments/tree/main/snippets/rust

See [src/snippets/README.md](./src/snippets/README.md) for a short pointer.

### Useful commands

Expand All @@ -106,9 +105,6 @@ cargo doc --no-deps

# Generate documentation and open in browser:
cargo doc --no-deps --open

# Generate documentation with snippets feature:
cargo doc --features snippets --no-deps
```

## Adding crate as dependency
Expand Down
8 changes: 0 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//! - **Types**: Complete type definitions for all Open Payments resources and operations
//! - **HTTP Client**: Async HTTP client with authentication and signature support
//! - **HTTP Signatures**: Utilities for creating and validating HTTP message signatures
//! - **Snippets**: Ready-to-use code examples for common operations (optional feature)
//!
//! ## Quick Start
//!
Expand Down Expand Up @@ -42,11 +41,6 @@
//! - [`client`] - HTTP client for making unauthenticated and authenticated requests to Open Payments servers
//! - [`types`] - Type definitions for all Open Payments resources and operations
//! - [`http_signature`] - Utilities for HTTP message signature creation and validation
//! - \[`snippets`\] - Code examples for common operations (requires `snippets` feature)
//!
//! ## Cargo Features
//!
//! - `snippets` - Enables snippet binaries with example code for common operations
//!
//! ## Examples
//!
Expand Down Expand Up @@ -122,8 +116,6 @@

pub mod client;
pub mod http_signature;
#[cfg(feature = "snippets")]
pub mod snippets;
pub mod types;

// Re-export everything public from client at the crate root
Expand Down
35 changes: 0 additions & 35 deletions src/snippets/.env.example

This file was deleted.

52 changes: 25 additions & 27 deletions src/snippets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ These code snippets are intended for use with <a href="https://rafiki.money" tar
everyone is welcome to use these code snippets as a reference, please note that they may need to be adapted to suit your
particular application.

---
To view and run the latest examples, please use the Open Payments documentation and snippets:

### Prerequisites
- Open Payments Docs: <a href="https://openpayments.dev" target="_blank">openpayments.dev</a>
- Rust snippet sources: <a href="https://github.com/interledger/open-payments/tree/main/snippets/rust" target="_blank">interledger/open-payments/snippets/rust</a>

- Rust (>=1.43.1)
- Rust (>=1.85)
- Cargo (comes with Rust)
- [Rust Open Payments SDK](https://github.com/interledger/open-payments-rust)

Expand Down Expand Up @@ -51,33 +53,29 @@ From the repository's root you can execute the following commands:

| Command | Description |
| ------------------ | ---------------------------------------------- |
| `cargo run --features snippets --bin grant-cancel` | Cancel a grant |
| `cargo run --features snippets --bin grant-continuation` | Continuation request for a grant (interactive) |
| `cargo run --features snippets --bin grant-incoming-payment` | Request a grant for an incoming payment |
| `cargo run --features snippets --bin grant-outgoing-payment` | Request a grant for an outgoing payment |
| `cargo run --features snippets --bin grant-quote` | Request a grant for a quote |
| `cargo run --features snippets --bin incoming-payment-create` | Create an incoming payment |
| `cargo run --features snippets --bin incoming-payment-complete` | Complete an incoming payment |
| `cargo run --features snippets --bin incoming-payment-get` | Retrieve an incoming payment |
| `cargo run --features snippets --bin incoming-payment-list` | List incoming payments |
| `cargo run --features snippets --bin outgoing-payment-create` | Create an outgoing payment |
| `cargo run --features snippets --bin outgoing-payment-get` | Retrieve an outgoing payment |
| `cargo run --features snippets --bin outgoing-payment-list` | List outgoing payments |
| `cargo run --features snippets --bin quote-create` | Create a quote |
| `cargo run --features snippets --bin quote-create-debit-amount` | Create a quote with debit amount |
| `cargo run --features snippets --bin quote-create-receive-amount` | Create a quote with receive amount |
| `cargo run --features snippets --bin quote-get` | Retrieve a quote |
| `cargo run --features snippets --bin wallet-address-get` | Retrieve wallet address' information |
| `cargo run --features snippets --bin wallet-address-get-keys` | Retrieve wallet address' JWKs |
| `cargo run --features snippets --bin token-revoke` | Revoke a token |
| `cargo run --features snippets --bin token-rotate` | Rotate a token |
| `cargo run --bin grant-cancel` | Cancel a grant |
| `cargo run --bin grant-continuation` | Continuation request for a grant (interactive) |
| `cargo run --bin grant-incoming-payment` | Request a grant for an incoming payment |
| `cargo run --bin grant-outgoing-payment` | Request a grant for an outgoing payment |
| `cargo run --bin grant-quote` | Request a grant for a quote |
| `cargo run --bin incoming-payment-create` | Create an incoming payment |
| `cargo run --bin incoming-payment-complete` | Complete an incoming payment |
| `cargo run --bin incoming-payment-get` | Retrieve an incoming payment |
| `cargo run --bin incoming-payment-list` | List incoming payments |
| `cargo run --bin outgoing-payment-create` | Create an outgoing payment |
| `cargo run --bin outgoing-payment-get` | Retrieve an outgoing payment |
| `cargo run --bin outgoing-payment-list` | List outgoing payments |
| `cargo run --bin quote-create` | Create a quote |
| `cargo run --bin quote-create-debit-amount` | Create a quote with debit amount |
| `cargo run --bin quote-create-receive-amount` | Create a quote with receive amount |
| `cargo run --bin quote-get` | Retrieve a quote |
| `cargo run --bin wallet-address-get` | Retrieve wallet address' information |
| `cargo run --bin wallet-address-get-keys` | Retrieve wallet address' JWKs |
| `cargo run --bin token-revoke` | Revoke a token |
| `cargo run --bin token-rotate` | Rotate a token |

Example:

```sh
cargo run --features snippets --bin grant-incoming-payment
cargo run --bin grant-incoming-payment
```

### Examples

- [Payment flow example](./examples/payment-flow.md)
83 changes: 0 additions & 83 deletions src/snippets/examples/payment-flow.md

This file was deleted.

Loading
Loading