This project demonstrates how to use the Tapsilat Rust SDK to create orders and handle payments. It includes a simple web interface to simulate a shopping cart and checkout process, mirroring the functionality of the Go example.
- Rust 1.70 or higher
- A Tapsilat API Key (you can get one from the Tapsilat dashboard)
-
Clone the repository (if you haven't already):
git clone https://github.com/tapsilat/examples.git cd examples/rust -
Build the project:
cargo build
-
Create a
.envfile in the root directory (you can copy.env.example):cp .env.example .env
-
Edit the
.envfile and set your Tapsilat credentials:TAPSILAT_API_KEY=your_api_key_here TAPSILAT_WEBHOOK_SECRET=your_webhook_secret_here PORT=5005
-
Start the server:
cargo run
-
Open your browser and navigate to: http://localhost:5005
- New Order: Add items to your cart and create orders with hosted checkout links.
- Elements Sessions: Create, view, and cancel native mobile card sheet sessions (
/api/elements/sessions). - Subscriptions & Terms: Manage recurring plans and term schedules.
- Webhook Signature Verifier: Test signature validation with
WebhookModule::verify_webhook.
src/main.rs: The main application entry point containing the Actix-Web server logic and Tapsilat SDK integration.templates/: Tera HTML templates for the web interface.static/: Static assets (CSS, JS, images).Cargo.toml: Rust package configuration and dependencies.
- Order Creation: Create orders with basket items, billing/shipping addresses.
- Payment Processing: Handle payment success/failure callbacks.
- Subscriptions: Create and manage subscriptions.
- Webhooks: Receive and log webhook events from Tapsilat.
- Order Management: List orders, view details, transactions, cancel, and refund.