API Reference
API Reference

Quick Start

Prerequisites

  1. Have a registered Subotiz merchant account(signup url
  2. Have completed the Subotiz payment gateway setup and payment method configuration

Quick Integration Steps

Step 1: Obtain Access Credentials

  1. Log in to the Subotiz merchant platform

  2. Configure Payment Callback URLs

    • return_url:Redirect URL after payment success. Default value when Using the API to create a checkout session.
    • cancel_url:Redirect URL after payment cancellation. Default value when Using the API to create a checkout session.
    📘

    URL supplied at session creation override the defaults set here. We recommend setting a global default address for convenience, while using the API to provide specific URL for unique scenarios

  3. Obtain the access information provided by the platform:

    • access_no: Unique identifier for the integrating party
    • merchant_id: Unique merchant identifier
    • API Key: API authentication key. See Authentication for how to obtain it(​​Keep strictly confidential, never expose on the client-side

Step 2: Obtain Product Information

Create products and product pricing within the Subotiz merchant platform. Store the product and price information on your server. Creating a Checkout Session relies on the pricing_id of the product pricing to dynamically retrieve product information.
Create a Product:​

​​Create Product Pricing:​​


Step 3: Create a Checkout Session

Use the API to create a checkout session, retrieve the payment page URL, and guide the customer through completing the payment.

​​Request Example​​

curl --location 'https://api.stg.subotiz.com/api/v1/session' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {your_api_key}' \
--header 'Request-Id: 07949371-7868-2282-78af-2a8d5c043760' \
--data-raw '{
  "access_no": "{Your access_no}",
  "sub_merchant_id": "{Your merchant_id}",
  "order_id": "test_order_001",
  "email": "[email protected]",
  "line_items": [
    {
      "price_id": "{Product pricing ID}",
      "quantity": "1"
    }
  ],
  "return_url": "https://your-app.com/success",
  "cancel_url": "https://your-app.com/cancel"
}'

Step 4: Test Payment Completion

  1. Upon successful API response, obtain the data.session_url(payment page URL)
  2. Access this link in a browser to view the Subotiz-hosted checkout page
  3. Use the following test card numbers to complete payment testing(for Subotiz Payments)
  • ​​Payment Success:​​ Card number 4242424242424242, any 3-digit CVC, any future expiration date
  • Payment Failure:​​ Card number 4000000000000002, any 3-digit CVC, any future expiration date

Example Checkout Page


Step 5: Handle Payment Result Notifications

  1. Upon payment completion, the user will be redirected to the return_url(success scenario).

  2. Simultaneously, Subotiz will send a Webhook notification to your webhook entpoint(event type trades.succeeded).

  3. Verify the Webhook's legitimacy:

    1. Extract Parameters:​​ Obtain the X-Timestamp from the request headers (denoted as timestamp), and get the raw request body content (denoted as body).

    2. ​​Construct Signature Original String:​​ Format is ${timestamp}.${body}.

    3. ​​Compute Signature:​​ Using the access_secret assigned by Subotiz as the key, compute the signature value via the HMAC-SHA256 algorithm.

        // Compute Signature
        func CalcSignature(timestamp int64, body []byte, secret string) string {
            mac := hmac.New(sha256.New, []byte(secret))
            mac.Write([]byte(fmt.Sprintf("%d", timestamp)))
            mac.Write([]byte("."))
            mac.Write(body)
            return hex.EncodeToString(mac.Sum(nil))
        }
    4. Compare and Verify:​​ Compare the calculated signature with the X-Signature value from the request headers. If they match, the request is legitimate.

Verifying the Result

  1. Log in to the Subotiz merchant platform to review transaction records and subscription records.
  2. Verify that the order amount and product information are correct.