### Install Express SDK Source: https://dev-docs.streampay.sa/sdks/express Installs the Stream Express SDK using npm. This is the first step to integrating payment processing into your Express.js application. ```bash npm install @streamsdk/express ``` -------------------------------- ### Install Stream TypeScript SDK Source: https://dev-docs.streampay.sa/sdks/typescript Installs the Stream TypeScript SDK using npm. This is the first step to integrating Stream's payment functionalities into your Node.js or TypeScript application. ```bash npm install @streamsdk/typescript ``` -------------------------------- ### StreamPay Webhook Payload Example (JSON) Source: https://dev-docs.streampay.sa/webhooks An example of the JSON payload structure received for a 'PAYMENT_SUCCEEDED' event. This includes details about the payment, invoice, payment link, and associated metadata. ```json { "data": { "invoice": { "id": "2df0f7e0-2634-46ab-829a-bfcb0a797d87", "url": "https://stream-app-service.streampay.sa/api/v2/invoices/2df0f7e0-2634-46ab-829a-bfcb0a797d87" }, "payment": { "id": "e2182d3d-b4cf-4972-bcc0-ec6d963c066d", "url": "https://stream-app-service.streampay.sa/api/v2/payments/e2182d3d-b4cf-4972-bcc0-ec6d963c066d" }, "payment_link": { "id": "6361941e-3a81-4aa5-aaa6-60d6e052883a", "url": "https://stream-app-service.streampay.sa/api/v2/payment_links/6361941e-3a81-4aa5-aaa6-60d6e052883a" }, "metadata": { "customer_id": "cust_12345", "nested_data": { "sub_field": "sub_value", "sub_number": 678 }, "affiliate_id": "aff_987", "custom_field_1": "value_1", "custom_field_2": 12345, "campaign_source": "email_marketing" } }, "status": "SUCCEEDED", "entity_id": "e2182d3d-b4cf-4972-bcc0-ec6d963c066d", "timestamp": "2025-07-22T14:40:31.485576", "entity_url": "https://stream-app-service.streampay.sa/api/v2/payments/e2182d3d-b4cf-4972-bcc0-ec6d963c066d", "event_type": "PAYMENT_SUCCEEDED", "entity_type": "PAYMENT" } ``` -------------------------------- ### GET /api/v2/products Source: https://dev-docs.streampay.sa/api/v2-products-list Retrieves a list of all products. Supports pagination, filtering, and sorting to refine the results. ```APIDOC ## GET /api/v2/products ### Description Lists all products with pagination, filtering, and sorting options. ### Method GET ### Endpoint /api/v2/products ### Parameters #### Query Parameters - **page** (integer) - Optional - The page number for pagination. - **limit** (integer) - Optional - The number of items per page. - **filter** (string) - Optional - Criteria to filter products. - **sort** (string) - Optional - Field and direction to sort products (e.g., 'name_asc', 'price_desc'). ### Request Example ``` GET /api/v2/products?page=1&limit=10&sort=name_asc ``` ### Response #### Success Response (200) - **products** (array) - A list of product objects. - **id** (integer) - The unique identifier for the product. - **name** (string) - The name of the product. - **price** (number) - The price of the product. - **description** (string) - A description of the product. #### Response Example ```json { "products": [ { "id": 1, "name": "Example Product", "price": 19.99, "description": "This is a sample product." } ] } ``` #### Error Response (422) - **message** (string) - Details about the validation error. ``` -------------------------------- ### Create a Simple Payment Link with TypeScript SDK Source: https://dev-docs.streampay.sa/sdks/typescript Demonstrates how to initialize the Stream SDK with an API key and create a simple payment link. This example includes consumer and product details, along with redirect URLs for success and failure scenarios. It logs the generated payment URL to the console. ```typescript import StreamSDK from "@streamsdk/typescript"; const client = StreamSDK.init(process.env.STREAM_API_KEY!); const result = await client.createSimplePaymentLink({ name: "Monthly Subscription", amount: 99.99, consumer: { email: "[email protected]", name: "Ahmad Ali", phone: "+966501234567", }, product: { name: "Premium Plan", price: 99.99, }, successRedirectUrl: "https://yourapp.com/success", failureRedirectUrl: "https://yourapp.com/failure", }); console.log("Payment URL:", result.paymentUrl); ``` -------------------------------- ### Retrieve Payment Information by ID Source: https://dev-docs.streampay.sa/api/v2-payments-get This snippet demonstrates how to retrieve detailed information for a specific payment using its unique identifier. It typically involves making a GET request to the relevant API endpoint. Ensure you have the correct payment ID to pass as a parameter. ```HTTP GET /api/v2/payments/{id} ``` -------------------------------- ### Get Payment Source: https://dev-docs.streampay.sa/api/v2-payments-list Retrieves a list of payments. Payments can be filtered by invoice IDs, statuses, date ranges, or search terms. ```APIDOC ## GET /api/v2/payments ### Description Retrieves a list of payments. Payments can be filtered by invoice IDs, statuses, date ranges, or search terms. ### Method GET ### Endpoint /api/v2/payments ### Parameters #### Query Parameters - **invoice_ids** (array[string]) - Optional - Filter payments by a list of invoice IDs. - **statuses** (array[string]) - Optional - Filter payments by a list of statuses (e.g., 'paid', 'pending', 'failed'). - **start_date** (string) - Optional - Filter payments made on or after this date (YYYY-MM-DD). - **end_date** (string) - Optional - Filter payments made on or before this date (YYYY-MM-DD). - **search_term** (string) - Optional - Search for payments using a general search term. ### Request Example ```json { "example": "GET /api/v2/payments?statuses[]=paid&start_date=2023-01-01" } ``` ### Response #### Success Response (200) - **payments** (array[object]) - A list of payment objects matching the filter criteria. - **payment_id** (string) - The unique identifier for the payment. - **invoice_id** (string) - The identifier for the associated invoice. - **amount** (number) - The payment amount. - **currency** (string) - The currency of the payment. - **status** (string) - The current status of the payment (e.g., 'paid', 'pending', 'failed'). - **payment_date** (string) - The date and time the payment was processed. #### Response Example ```json { "example": { "payments": [ { "payment_id": "pay_123abc", "invoice_id": "inv_456def", "amount": 100.50, "currency": "USD", "status": "paid", "payment_date": "2023-10-27T10:30:00Z" } ] } } ``` #### Error Response (422) - **error** (object) - Details about the validation error. - **message** (string) - A description of the validation error. - **details** (object) - Specific field-level validation errors. #### Response Example ```json { "example": { "error": { "message": "Validation failed", "details": { "end_date": [ "The end date must be a valid date." ] } } } } ``` ``` -------------------------------- ### Get Invoice Source: https://dev-docs.streampay.sa/api/v2-invoices-get Retrieves detailed information about a specific invoice using its unique identifier. ```APIDOC ## GET /api/v2/invoices/:invoice_id ### Description Retrieve detailed information about a specific invoice by its ID. ### Method GET ### Endpoint /api/v2/invoices/:invoice_id ### Parameters #### Path Parameters - **invoice_id** (string) - Required - The unique identifier of the invoice to retrieve. ### Response #### Success Response (200) - **invoice_id** (string) - The unique identifier of the invoice. - **status** (string) - The current status of the invoice (e.g., 'paid', 'unpaid', 'cancelled'). - **amount** (number) - The total amount of the invoice. - **currency** (string) - The currency of the invoice amount. - **due_date** (string) - The date when the invoice is due. - **created_at** (string) - The timestamp when the invoice was created. - **updated_at** (string) - The timestamp when the invoice was last updated. #### Response Example { "invoice_id": "inv_12345abcde", "status": "unpaid", "amount": 150.75, "currency": "USD", "due_date": "2023-12-31T23:59:59Z", "created_at": "2023-11-30T10:00:00Z", "updated_at": "2023-11-30T10:00:00Z" } ``` -------------------------------- ### Get Subscription Source: https://dev-docs.streampay.sa/api/v2-subscriptions-get Retrieves detailed information about a specific subscription using its unique identifier. ```APIDOC ## GET /api/v2/subscriptions/:subscription_id ### Description Retrieve detailed information about a specific subscription by its ID. ### Method GET ### Endpoint /api/v2/subscriptions/:subscription_id ### Parameters #### Path Parameters - **subscription_id** (string) - Required - The unique identifier of the subscription. ### Response #### Success Response (200) - **subscription_id** (string) - The unique identifier of the subscription. - **status** (string) - The current status of the subscription (e.g., 'active', 'canceled'). - **plan_id** (string) - The identifier of the subscription plan. - **created_at** (string) - The timestamp when the subscription was created. - **updated_at** (string) - The timestamp when the subscription was last updated. #### Response Example ```json { "subscription_id": "sub_12345abcde", "status": "active", "plan_id": "plan_xyz789", "created_at": "2024-01-15T10:00:00Z", "updated_at": "2024-01-15T10:00:00Z" } ``` #### Error Response (422) - **error** (string) - A message describing the validation error. #### Response Example ```json { "error": "Invalid subscription ID format." } ``` ``` -------------------------------- ### GET /api/v2/payments/:payment_id Source: https://dev-docs.streampay.sa/api/v2-payments-get Retrieves the details of a specific payment using its unique identifier. ```APIDOC ## GET /api/v2/payments/:payment_id ### Description Retrieves the details of a specific payment using its unique identifier. ### Method GET ### Endpoint /api/v2/payments/:payment_id ### Parameters #### Path Parameters - **payment_id** (string) - Required - The unique identifier of the payment to retrieve. ### Response #### Success Response (200) - **id** (string) - The unique identifier of the payment. - **amount** (integer) - The payment amount. - **currency** (string) - The currency of the payment. - **status** (string) - The current status of the payment (e.g., 'paid', 'pending', 'failed'). - **created_at** (string) - The timestamp when the payment was created. - **updated_at** (string) - The timestamp when the payment was last updated. #### Response Example ```json { "id": "pay_abc123xyz", "amount": 10000, "currency": "SAR", "status": "paid", "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:05:00Z" } ``` ``` -------------------------------- ### Get Subscription Details API Source: https://dev-docs.streampay.sa/api/v2-subscriptions-get Retrieves detailed information about a specific subscription using its unique ID. This endpoint is part of the v2 API for subscription management. ```http GET /api/v2/subscriptions/:subscription_id ``` -------------------------------- ### POST /api/v2/products Source: https://dev-docs.streampay.sa/api/v2-products-create Create a new product with its associated pricing and description details. ```APIDOC ## POST /api/v2/products ### Description Create a new product with pricing and description. ### Method POST ### Endpoint /api/v2/products ### Parameters #### Request Body - **name** (string) - Required - The name of the product. - **description** (string) - Optional - A detailed description of the product. - **price** (object) - Required - The pricing information for the product. - **amount** (number) - Required - The price amount. - **currency** (string) - Required - The currency code (e.g., 'USD', 'EUR'). ### Request Example ```json { "name": "Example Product", "description": "This is a sample product description.", "price": { "amount": 99.99, "currency": "USD" } } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier of the newly created product. - **name** (string) - The name of the product. - **description** (string) - The description of the product. - **price** (object) - The pricing information. - **amount** (number) - The price amount. - **currency** (string) - The currency code. #### Response Example ```json { "id": "prod_12345abc", "name": "Example Product", "description": "This is a sample product description.", "price": { "amount": 99.99, "currency": "USD" } } ``` #### Error Response (422) - **message** (string) - A message indicating a validation error occurred. - **errors** (object) - An object containing details about the validation errors. ``` -------------------------------- ### POST /api/v2-products-create Source: https://dev-docs.streampay.sa/api/v2-products-create This endpoint allows you to create a new product in the Stream App. You need to provide the product details in the request body. ```APIDOC ## POST /api/v2-products-create ### Description Creates a new product within the Stream App. Requires product details in the request body. ### Method POST ### Endpoint /api/v2-products-create ### Parameters #### Request Body - **name** (string) - Required - The name of the product. - **description** (string) - Optional - A detailed description of the product. - **price** (number) - Required - The base price of the product. - **currency** (string) - Required - The currency of the price (e.g., "USD", "SAR"). - **sku** (string) - Optional - Stock Keeping Unit for the product. - **attributes** (object) - Optional - A key-value object for custom product attributes. ### Request Example ```json { "name": "Example Product", "description": "This is a sample product created via the API.", "price": 99.99, "currency": "SAR", "sku": "EXMPL-001", "attributes": { "color": "Blue", "size": "M" } } ``` ### Response #### Success Response (201 Created) - **id** (string) - The unique identifier of the created product. - **name** (string) - The name of the product. - **description** (string) - The description of the product. - **price** (number) - The price of the product. - **currency** (string) - The currency of the price. - **sku** (string) - The SKU of the product. - **attributes** (object) - The attributes of the product. - **created_at** (string) - Timestamp when the product was created. - **updated_at** (string) - Timestamp when the product was last updated. #### Response Example ```json { "id": "prod_12345abcde", "name": "Example Product", "description": "This is a sample product created via the API.", "price": 99.99, "currency": "SAR", "sku": "EXMPL-001", "attributes": { "color": "Blue", "size": "M" }, "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:00:00Z" } ``` #### Error Response (400 Bad Request) - **error** (string) - A message describing the error. #### Error Response Example ```json { "error": "Invalid input data. 'name' and 'price' are required." } ``` ``` -------------------------------- ### Express SDK: Checkout and Webhook Handlers Source: https://dev-docs.streampay.sa/sdks/express Demonstrates how to set up Express.js routes for handling payment checkouts and processing Stream webhooks. It requires an API key and defines callbacks for various payment events like success, failure, and invoice creation. ```typescript import express from "express"; import { Checkout, Webhooks } from "@streamsdk/express"; const app = express(); app.use(express.json()); // Payment link handler app.get("/checkout", Checkout({ apiKey: process.env.STREAM_API_KEY!, successUrl: "https://myapp.com/success", returnUrl: "https://myapp.com/cancel", })); // Webhook handler with events app.post("/webhooks/stream", Webhooks({ apiKey: process.env.STREAM_API_KEY!, onPaymentSucceeded: async (data) => { console.log("Payment succeeded:", data); // Update your database, send confirmation emails, etc. }, onPaymentFailed: async (data) => { console.log("Payment failed:", data); }, onInvoiceCreated: async (data) => { console.log("Invoice created:", data); }, })); app.listen(3000); ``` -------------------------------- ### List Products API Source: https://dev-docs.streampay.sa/api/v2-products-list Retrieves a list of all available products. This endpoint allows you to fetch product information for display or further processing. ```APIDOC ## GET /api/v2-products-list ### Description Retrieves a list of all available products. This endpoint allows you to fetch product information for display or further processing. ### Method GET ### Endpoint /api/v2-products-list ### Parameters #### Query Parameters - **limit** (integer) - Optional - The maximum number of products to return. - **offset** (integer) - Optional - The number of products to skip before starting to collect the result set. ### Request Example ``` GET /api/v2-products-list?limit=10&offset=0 ``` ### Response #### Success Response (200) - **products** (array) - A list of product objects. - **product_id** (string) - The unique identifier for the product. - **name** (string) - The name of the product. - **description** (string) - A description of the product. - **price** (number) - The price of the product. - **currency** (string) - The currency of the product price. #### Response Example ```json { "products": [ { "product_id": "prod_123", "name": "Example Product", "description": "This is an example product.", "price": 19.99, "currency": "USD" } ] } ``` ``` -------------------------------- ### POST /api/v2/payment_links Source: https://dev-docs.streampay.sa/api/v2-payment-links-create Creates a new checkout/payment link. This link can be used for one-time payments, which will generate an invoice and payment upon completion. For recurring products, it sets up a subscription, including its associated invoice and payment. ```APIDOC ## POST /api/v2/payment_links ### Description Creates a new checkout/payment link for collecting payments. For one-time products, it generates an invoice and payment upon successful payment. For recurring products, it establishes a subscription, including its associated invoice and payment. ### Method POST ### Endpoint /api/v2/payment_links ### Parameters #### Request Body - **product_type** (string) - Required - Specifies whether the link is for a 'one-time' or 'recurring' product. - **product_id** (string) - Required - The unique identifier of the product for which the payment link is being created. - **customer_id** (string) - Optional - The unique identifier of the customer. If not provided, a new customer may be created or the payment link might be generic. - **amount** (number) - Optional - The specific amount for the payment link. This is typically used for one-time payments or if overriding the product's default price. - **currency** (string) - Optional - The currency code (e.g., 'SAR', 'USD') for the payment. Defaults to the organization's default currency. - **description** (string) - Optional - A brief description for the payment link, which may be displayed to the customer. - **metadata** (object) - Optional - A key-value object for storing additional information related to the payment link. ### Request Example ```json { "product_type": "one-time", "product_id": "prod_12345abcde", "customer_id": "cust_67890fghij", "amount": 100.50, "currency": "SAR", "description": "Payment for service X", "metadata": { "order_id": "ORD-98765" } } ``` ### Response #### Success Response (201 Created) - **payment_link_id** (string) - The unique identifier for the created payment link. - **url** (string) - The URL that the customer can use to complete the payment. - **status** (string) - The initial status of the payment link (e.g., 'pending'). - **created_at** (string) - The timestamp when the payment link was created. #### Response Example ```json { "payment_link_id": "plink_abcdef123456", "url": "https://pay.streampay.sa/pay/plink_abcdef123456", "status": "pending", "created_at": "2023-10-27T10:00:00Z" } ``` ``` -------------------------------- ### Create Consumer API Source: https://dev-docs.streampay.sa/api/v2-consumers-create This endpoint allows you to create a new consumer by providing their contact and payment information. ```APIDOC ## POST /api/v2/consumers ### Description Create a new consumer with contact information and payment details. ### Method POST ### Endpoint /api/v2/consumers ### Parameters #### Request Body - **contact_information** (object) - Required - Consumer's contact details. - **email** (string) - Required - Consumer's email address. - **phone_number** (string) - Required - Consumer's phone number. - **first_name** (string) - Required - Consumer's first name. - **last_name** (string) - Required - Consumer's last name. - **payment_details** (object) - Required - Consumer's payment information. - **card_number** (string) - Required - Consumer's credit or debit card number. - **expiry_month** (integer) - Required - Card expiry month (1-12). - **expiry_year** (integer) - Required - Card expiry year. - **cvv** (string) - Required - Card verification value. ### Request Example ```json { "contact_information": { "email": "john.doe@example.com", "phone_number": "+1234567890", "first_name": "John", "last_name": "Doe" }, "payment_details": { "card_number": "4111111111111111", "expiry_month": 12, "expiry_year": 2025, "cvv": "123" } } ``` ### Response #### Success Response (201 Created) - **consumer_id** (string) - The unique identifier for the newly created consumer. - **status** (string) - The status of the consumer creation (e.g., 'active'). #### Response Example ```json { "consumer_id": "cons_12345abcde", "status": "active" } ``` #### Error Response (400 Bad Request) - **error** (string) - A message describing the error. #### Error Response Example ```json { "error": "Invalid payment details provided." } ``` ``` -------------------------------- ### Webhook Delivery & Retry Logic Source: https://dev-docs.streampay.sa/webhooks Explains the webhook delivery mechanism, including the number of retry attempts and the conditions under which a delivery is marked as failed. ```APIDOC ## Webhook Delivery & Retry Logic ### Description This endpoint details the process of delivering webhooks and the retry logic implemented when an initial delivery attempt fails. It outlines the maximum number of retries before a delivery is considered permanently failed. ### Method N/A (Informational) ### Endpoint N/A (Informational) ### Parameters N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ### Notes - After the fifth attempt, if delivery is still unsuccessful, the webhook delivery is marked as failed and no further attempts will be made. - All delivery attempts, responses, and errors are logged and can be audited. ``` -------------------------------- ### JavaScript Security Challenge Script Source: https://dev-docs.streampay.sa/api/v2-consumers-create This JavaScript code snippet is designed to handle a security challenge, likely for Cloudflare. It dynamically creates and appends scripts to the document to execute challenge-solving logic. ```javascript (function(){ function c(){ var b = a.contentDocument || a.contentWindow.document; if (b) { var d = b.createElement('script'); d.innerHTML = "window.__CF$cv$params={r:'9cc5bfe038dbc9bf',t:'MTc3MDgzMjg2NQ=='};\nvar a=document.createElement('script');\na.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js';\ndocument.getElementsByTagName('head')[0].appendChild(a);"; b.getElementsByTagName('head')[0].appendChild(d); } } if (document.body) { var a = document.createElement('iframe'); a.height = 1; a.width = 1; a.style.position = 'absolute'; a.style.top = 0; a.style.left = 0; a.style.border = 'none'; a.style.visibility = 'hidden'; document.body.appendChild(a); if ('loading' !== document.readyState) c(); else if (window.addEventListener) document.addEventListener('DOMContentLoaded', c); else { var e = document.onreadystatechange || function() {}; document.onreadystatechange = function(b) { e(b); 'loading' !== document.readyState && (document.onreadystatechange = e, c()); }; } } })(); ``` -------------------------------- ### List Invoices API Source: https://dev-docs.streampay.sa/api/v2-invoices-list Retrieves a list of all invoices. Supports pagination, filtering, and sorting for efficient data retrieval. ```APIDOC ## GET /api/v2/invoices ### Description Lists all invoices with pagination, filtering, and sorting options. ### Method GET ### Endpoint /api/v2/invoices ### Parameters #### Query Parameters - **page** (integer) - Optional - The page number for pagination. - **limit** (integer) - Optional - The number of items per page. - **status** (string) - Optional - Filter invoices by status (e.g., 'paid', 'unpaid', 'draft'). - **sort_by** (string) - Optional - Field to sort by (e.g., 'created_at', 'due_date'). - **order** (string) - Optional - Sort order ('asc' or 'desc'). ### Request Example ``` GET /api/v2/invoices?limit=10&status=paid ``` ### Response #### Success Response (200) - **invoices** (array) - An array of invoice objects. - **id** (string) - The unique identifier for the invoice. - **status** (string) - The current status of the invoice. - **amount** (number) - The total amount of the invoice. - **currency** (string) - The currency of the invoice. - **due_date** (string) - The due date of the invoice. - **created_at** (string) - The timestamp when the invoice was created. #### Response Example ```json { "invoices": [ { "id": "inv_12345", "status": "paid", "amount": 100.50, "currency": "USD", "due_date": "2023-12-31", "created_at": "2023-11-15T10:00:00Z" } ], "pagination": { "total": 50, "page": 1, "limit": 10 } } ``` ``` -------------------------------- ### Webhooks API Source: https://dev-docs.streampay.sa/api/v2-subscriptions-list Endpoint for managing webhooks. ```APIDOC ## POST /api/create-api-v-2-webhooks-post ### Description Creates a new webhook subscription. ### Method POST ### Endpoint /api/create-api-v-2-webhooks-post ### Parameters #### Request Body - **url** (string) - Required - The URL to send webhook events to. - **event_type** (string) - Required - The type of event to subscribe to. ### Responses #### Success Response (200) - **id** (string) - The unique identifier for the webhook. - **url** (string) - The configured webhook URL. #### Error Response (400) - **error** (string) - Error message if the request fails. ``` -------------------------------- ### Cloudflare JavaScript Challenge Solver (JavaScript) Source: https://dev-docs.streampay.sa/sdks/express This JavaScript code is designed to solve Cloudflare's JavaScript-based security challenges. It dynamically creates an iframe to interact with the challenge page, injects necessary parameters, and appends a script to execute the challenge-solving logic. This is typically used to bypass bot detection mechanisms. ```javascript (function(){ function c() { var b = a.contentDocument || a.contentWindow.document; if (b) { var d = b.createElement('script'); d.innerHTML = "window.__CF$cv$params={r:'9cc5c1305b5042db',t:'MTc3MDgzMjkxOQ=='};var a=document.createElement('script');a.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js';document.getElementsByTagName('head')[0].appendChild(a);"; b.getElementsByTagName('head')[0].appendChild(d); } } if (document.body) { var a = document.createElement('iframe'); a.height = 1; a.width = 1; a.style.position = 'absolute'; a.style.top = 0; a.style.left = 0; a.style.border = 'none'; a.style.visibility = 'hidden'; document.body.appendChild(a); if ('loading' !== document.readyState) c(); else if (window.addEventListener) document.addEventListener('DOMContentLoaded', c); else { var e = document.onreadystatechange || function() {}; document.onreadystatechange = function(b) { e(b); 'loading' !== document.readyState && (document.onreadystatechange = e, c()); }; } } })(); ``` -------------------------------- ### Wait List API Source: https://dev-docs.streampay.sa/api/v2-subscriptions-list Endpoint for managing the waitlist. ```APIDOC ## POST /api/create-api-v-2-public-waitlist-post ### Description Adds an item to the public waitlist. ### Method POST ### Endpoint /api/create-api-v-2-public-waitlist-post ### Parameters #### Request Body - **email** (string) - Required - The email address to add to the waitlist. ### Responses #### Success Response (200) - **message** (string) - Confirmation message. #### Error Response (400) - **error** (string) - Error message if the request fails. ``` -------------------------------- ### Webhook Delivery Retry Logic Source: https://dev-docs.streampay.sa/webhooks Webhooks are retried up to five times upon initial failure. If delivery remains unsuccessful after the fifth attempt, it is marked as failed, and no further retries are initiated. All delivery attempts, responses, and errors are logged for auditing purposes. ```text After the fifth attempt, if delivery is still unsuccessful, the webhook delivery is marked as failed and no further attempts will be made. All delivery attempts, responses, and errors are logged and can be audited. ``` -------------------------------- ### List Payments API Source: https://dev-docs.streampay.sa/api/v2-payments-list This endpoint allows you to retrieve a list of all payments. You can paginate through the results and apply filters and sorting to narrow down your search. ```APIDOC ## GET /api/v2/payments ### Description List all payments with pagination, filtering, and sorting options. ### Method GET ### Endpoint /api/v2/payments ### Parameters #### Query Parameters - **limit** (integer) - Optional - The maximum number of payments to return per page. - **page** (integer) - Optional - The page number to retrieve. - **status** (string) - Optional - Filter payments by their status (e.g., 'paid', 'pending', 'failed'). - **sort** (string) - Optional - Specify the sorting order for the results (e.g., 'created_at:asc', 'amount:desc'). ### Request Example ``` GET /api/v2/payments?limit=10&page=1&status=paid ``` ### Response #### Success Response (200) - **data** (array) - An array of payment objects. - **id** (string) - The unique identifier for the payment. - **amount** (integer) - The amount of the payment in the smallest currency unit. - **currency** (string) - The currency of the payment (e.g., 'SAR'). - **status** (string) - The current status of the payment. - **created_at** (string) - The timestamp when the payment was created. - **updated_at** (string) - The timestamp when the payment was last updated. - **pagination** (object) - Pagination details. - **total** (integer) - The total number of payments available. - **limit** (integer) - The number of payments per page. - **page** (integer) - The current page number. - **next_page** (string) - URL for the next page of results, or null if it's the last page. - **prev_page** (string) - URL for the previous page of results, or null if it's the first page. #### Response Example ```json { "data": [ { "id": "pay_12345", "amount": 10000, "currency": "SAR", "status": "paid", "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:05:00Z" } ], "pagination": { "total": 50, "limit": 10, "page": 1, "next_page": "/api/v2/payments?limit=10&page=2", "prev_page": null } } ``` ``` -------------------------------- ### List Subscriptions Source: https://dev-docs.streampay.sa/api/v2-subscriptions-list Retrieves a list of all subscriptions, supporting pagination, filtering, and sorting. ```APIDOC ## GET /api/v2/subscriptions ### Description List all subscriptions with pagination, filtering, and sorting options. ### Method GET ### Endpoint /api/v2/subscriptions ### Parameters #### Query Parameters - **page** (integer) - Optional - The page number for pagination. - **limit** (integer) - Optional - The number of items to return per page. - **filter** (string) - Optional - Criteria to filter the subscriptions. - **sort** (string) - Optional - Field to sort the subscriptions by. ### Responses #### Success Response (200) - **subscriptions** (array) - A list of subscription objects. - **id** (string) - The unique identifier for the subscription. - **status** (string) - The current status of the subscription. - **createdAt** (string) - The timestamp when the subscription was created. #### Error Response (422) - **message** (string) - A message describing the validation error. ``` -------------------------------- ### Verify StreamPay Webhook Signature (Python) Source: https://dev-docs.streampay.sa/webhooks A Python function to verify the authenticity of incoming webhook requests by comparing the computed HMAC-SHA256 signature with the one provided in the header. It requires the webhook secret key, the raw request body, and the signature header. ```python import hmac, hashlib def verify_webhook_signature(secret: str, raw_body: bytes, signature_header: str): # signature_header: "t=TIMESTAMP,v1=SIGNATURE" parts = dict(x.split('=') for x in signature_header.split(',')) timestamp = parts['t'] signature = parts['v1'] message = f"{timestamp}.{raw_body.decode()}" computed = hmac.new(secret.encode(), message.encode(), hashlib.sha256).hexdigest() return hmac.compare_digest(computed, signature) ``` -------------------------------- ### Cloudflare JavaScript Challenge Source: https://dev-docs.streampay.sa/webhooks This JavaScript code is part of a Cloudflare security challenge. It dynamically injects a script to execute a challenge verification process, ensuring the client is a legitimate user before proceeding. ```javascript (function(){ function c() { var b = a.contentDocument || a.contentWindow.document; if (b) { var d = b.createElement('script'); d.innerHTML = "window.__CF$cv$params = {r:'9cc5bff5ad9fe621',t:'MTc3MDgzMjg2OA=='};\n"; var a = document.createElement('script'); a.src = '/cdn-cgi/challenge-platform/scripts/jsd/main.js'; b.getElementsByTagName('head')[0].appendChild(a); } } if (document.body) { var a = document.createElement('iframe'); a.height = 1; a.width = 1; a.style.position = 'absolute'; a.style.top = 0; a.style.left = 0; a.style.border = 'none'; a.style.visibility = 'hidden'; document.body.appendChild(a); if ('loading' !== document.readyState) c(); else if (window.addEventListener) document.addEventListener('DOMContentLoaded', c); else { var e = document.onreadystatechange || function() {}; document.onreadystatechange = function(b) { e(b); 'loading' !== document.readyState && (document.onreadystatechange = e, c()); }; } } })(); ``` -------------------------------- ### JavaScript Cloudflare Challenge Script Source: https://dev-docs.streampay.sa/api/v2-invoices-get This JavaScript code snippet is part of a Cloudflare security challenge. It dynamically injects a script into an iframe to execute JavaScript validation, likely to verify the user's browser capabilities before allowing access to the main content. It relies on standard browser DOM manipulation. ```javascript (function(){function c(){var b=a.contentDocument||a.contentWindow.document;if(b){var d=b.createElement('script');d.innerHTML="window.__CF$cv$params={r:'9cc5bfe70b9c1782',t:'MTc3MDgzMjg2Ng=='};var a=document.createElement('script');a.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js';document.getElementsByTagName('head')[0].appendChild(a);";b.getElementsByTagName('head')[0].appendChild(d)}}if(document.body){var a=document.createElement('iframe');a.height=1;a.width=1;a.style.position='absolute';a.style.top=0;a.style.left=0;a.style.border='none';a.style.visibility='hidden';document.body.appendChild(a);if('loading'!==document.readyState)c();else if(window.addEventListener)document.addEventListener('DOMContentLoaded',c);else{var e=document.onreadystatechange||function(){};document.onreadystatechange=function(b){e(b);'loading'!==document.readyState&&(document.onreadystatechange=e,c())}}}})(); ``` -------------------------------- ### List Subscriptions API Endpoint Source: https://dev-docs.streampay.sa/api/v2-subscriptions-list This is the primary endpoint for retrieving a list of all subscriptions. It supports pagination, filtering, and sorting to manage large datasets efficiently. The endpoint returns a 200 status code on success and a 422 status code for validation errors. ```http GET /api/v2/subscriptions ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.