🏠DocumentationGateway
Essentials

Gateway

Learn how to create Stripe-like checkout experiences for Pi payments using our Gateway

ZyrapayGateway provides a Stripe-like checkout service where developers can easily integrate Pi payments into their applications. Create checkout sessions, manage payments, and receive Pi payments with just your API key.

How It Works

  • Call our API to create a checkout session with your order metadata
  • We return a payment URL to redirect your user to
  • User pays on our secure checkout page
  • We process the payment and send you a webhook notification with your metadata
  • You extract the metadata to identify the order and confirm it on your side

You don't handle any payment processing. We handle everything and just notify you when it's done.

Metadata: Include your order ID or any metadata when creating the checkout - we'll send it back in the webhook so you can match it to your system.

API Endpoints

Below are the core API endpoints for creating and managing Pi payment checkouts:

POST api.checkout.zyrapay.net – Create a new checkout session
GET api.checkout.zyrapay.net/checkoutId – Get checkout session details

Request Parameters

Here are all the parameters you can send when creating a checkout session:

Required Parameters

items (array) - Array of items to purchase

Each item should include: name, description, quantity, image, amount

successUrl (string) - URL to redirect after successful payment
cancelUrl (string) - URL to redirect if payment is cancelled
currency (string) - Currency code (i.e. "USD")
webhookUrl (string) - URL to receive payment notifications

Optional Parameters

expiresInMinutes (number) - Checkout expiration time (default: 30 minutes)
metadata (object) - Custom data to store with the checkout

Items Structure

The items array can contain as many products as you want. Each item represents a product in your checkout:

Item Object Structure

name (string) - Product name
description (string) - Product description
quantity (number) - How many of this item
image (string) - Product image URL
amount (number) - Price per item

Multiple Items: You can send as many items as needed. Perfect for shopping carts, subscriptions, or any multi-product purchase.

Complete Implementation Example

Here's a complete example showing how to implement checkout in your application:

JavaScript Implementation

POST
// API endpoint: POST api.checkout.zyrapay.net // Headers: { "apikey": "your_api_key_here" } const response = await axios.post("https://api.checkout.zyrapay.net", { // Items array - can contain as many products as needed items: [ { name: "Premium Plan", description: "Monthly subscription with all features", quantity: 1, image: "https://yourapp.com/images/premium.jpg", amount: 29.99 }, { name: "Extra Storage", description: "Additional 100GB storage", quantity: 2, image: "https://yourapp.com/images/storage.jpg", amount: 9.99 } ], // Required URLs successUrl: "https://yourapp.com/success", cancelUrl: "https://yourapp.com/cancel", currency: "USD", // Optional parameters webhookUrl: "https://yourapp.com/webhook", expiresInMinutes: 45, // Custom metadata metadata: { orderId: "order_12345", customerEmail: "customer@example.com", customerName: "John Doe", totalAmount: 49.97 } }, { headers: { "apikey": "your_project_api_key_here", "Content-Type": "application/json" } }); // Handle response if (response.data.success && response.data.checkoutUrl) { // Redirect user to checkout page window.location.href = response.data.checkoutUrl; } else { console.error("Checkout creation failed:", response.data.message); }
200
{
"success": true,
"checkoutUrl": "https://checkout.zyrapay.net/ch_xyz123",
"checkoutId": "ch_xyz123",
"expiresAt": "2024-01-15T11:15:00Z",
"totalAmount": 49.97,
"currency": "USD"
}
400
{
"success": false,
"message": "Invalid API key",
"error": "UNAUTHORIZED"
}

Webhooks

We send webhooks when checkout payments are processed. Include your webhookUrl when creating checkout.

Webhook Types

  • checkout.paid - Exact payment amount received
  • checkout.overpaid - More than required amount paid
  • checkout.underpaid - Less than required amount paid

Each webhook includes type and data fields.

Chat with AI