A comprehensive dashboard application demonstrating the Tapsilat Ruby SDK capabilities, built with Sinatra.
This example is created for the official Tapsilat Ruby SDK: https://github.com/tapsilat/tapsilat-ruby
-
Order Management
- Create orders with full customization
- List orders with filtering and pagination
- View order details
- Cancel and refund orders
- Payment terms management
-
Subscriptions
- Create recurring subscriptions
- List active subscriptions
- Cancel subscriptions
- Manage subscription billing
-
Webhook Monitoring
- Real-time webhook capture
- Webhook history viewer
- Support for success, failure, refund, and cancel callbacks
-
Interactive Dashboard
- Modern, responsive UI
- Multi-step order creation wizard
- Real-time order status updates
- Payment success/failure pages
# Install dependencies
bundle install
# Create .env file and add your credentials
cp .env.example .env
# Edit .env and set:
# TAPSILAT_API_KEY=your_key_here
# TAPSILAT_WEBHOOK_SECRET=your_webhook_secret_here
# Start the application
bundle exec ruby app.rbThe application will run at http://localhost:8080 (or the port specified in your .env).
- Ruby 3.0 or higher
- Bundler
- Tapsilat API credentials
-
Clone the repository and navigate to the example directory:
cd examples/ruby -
Install dependencies:
bundle install
-
Create a
.envfile from the example:cp .env.example .env
-
Configure your environment variables in
.env:TAPSILAT_API_KEY=your_api_key_here TAPSILAT_BASE_URL=https://panel.tapsilat.dev/api/v1 PORT=8080
Start the server using bundle exec:
bundle exec ruby app.rbbundle exec rackupAlways use bundle exec when running the application to ensure the local SDK and dependencies are correctly loaded:
# Correct
bundle exec ruby app.rb
# Wrong - will fail with LoadError
ruby app.rbexamples/ruby/
├── app.rb # Main application file
├── Gemfile # Ruby dependencies
├── .env.example # Environment variables template
├── views/ # ERB templates
│ ├── index.erb # Main dashboard
│ ├── payment_success.erb
│ └── payment_failure.erb
├── webhooks/ # Webhook storage (auto-created)
└── README.md
POST /api- Create a new orderGET /api/order/list- List orders with paginationGET /api/order/details/:reference_id- Get order detailsGET /api/payment/status/:reference_id- Get payment statusPOST /api/cancel- Cancel an orderPOST /api/refund- Refund an order
POST /api/subscription- Create a subscriptionGET /api/subscription/list- List subscriptionsPOST /api/subscription/cancel- Cancel a subscription
POST /api/callback- Success webhookPOST /api/fail_callback- Failure webhookPOST /api/refund_callback- Refund webhookPOST /api/cancel_callback- Cancel webhookGET /api/webhooks- List received webhooks
GET /payment/success- Payment success pageGET /payment/failure- Payment failure page
The dashboard provides an interactive wizard for creating orders:
- Step 1: Configure order settings and add basket items
- Step 2: Enter billing and shipping information
- Step 3: Select payment options and complete the order
Alternatively, use the API directly:
require 'net/http'
require 'json'
uri = URI('http://localhost:8080/api')
req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
req.body = {
cart: [
{ id: 1, name: 'Product 1', price: 100.0, quantity: 1 }
],
billing: {
contact_name: 'John Doe',
email: 'john@example.com',
contact_phone: '5551234567',
address: 'Test Address',
city: 'Istanbul',
zip_code: '34000',
vat_number: '11111111111'
},
locale: 'tr',
currency: 'TRY',
three_d_force: true
}.to_json
response = Net::HTTP.start(uri.hostname, uri.port) do |http|
http.request(req)
end
puts response.bodyuri = URI('http://localhost:8080/api/subscription')
req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
req.body = {
name: 'Monthly Plan',
amount: 49.90,
period: 1,
payment_date: 1,
subscriber_email: 'subscriber@example.com',
subscriber_phone: '5551234567'
}.to_json
response = Net::HTTP.start(uri.hostname, uri.port) do |http|
http.request(req)
end
puts response.bodyTo receive webhooks from Tapsilat:
-
Configure your webhook URLs in the Tapsilat dashboard:
- Success:
http://your-domain.com/api/callback - Failure:
http://your-domain.com/api/fail_callback - Refund:
http://your-domain.com/api/refund_callback - Cancel:
http://your-domain.com/api/cancel_callback
- Success:
-
Webhooks are automatically saved to the
webhooks/directory -
View received webhooks in the dashboard's "Webhook Monitor" section
The application uses sinatra/reloader in development mode for automatic code reloading.
- Add new routes in
app.rb - Create corresponding views in
views/ - Update the sidebar navigation in
index.erb
If port 5006 is already in use, change the PORT in your .env file:
PORT=8080Verify your API credentials:
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://panel.tapsilat.dev/api/v1/health- Ensure your application is publicly accessible
- Check firewall settings
- Verify webhook URLs in Tapsilat dashboard
- Check
webhooks/directory permissions
For production deployment:
- Use a production-grade web server (Puma, Unicorn)
- Set up SSL/TLS certificates
- Configure environment variables securely
- Enable logging and monitoring
- Set up a reverse proxy (Nginx, Apache)
Example with Puma:
bundle exec puma -p 8080 -e productionThis example application is provided as-is for demonstration purposes.