Skip to main content

Headers

  • Swich-API-Key: Your secret key
  • Content-Type: application/json

Body (PaymentRequest)

{
  "amount": 50000,
  "currency": "PKR",
  "description": "Order 12345",
  "customerRef": {
    "name": "Ayesha Khan",
    "email": "ayesha@example.com",
    "phone": "+923001234567"
  },
  "orderRef": { "orderRef": "ORD12345" },
  "successUrl": "https://merchant.example.com/checkout/success",
  "cancelUrl": "https://merchant.example.com/checkout/cancel",
  "metadataJson": "{\"cartId\":\"c_abc123\"}"
}

Successful Response (200)

{
  "paymentIntentId": "2c4b7c5a-f7a6-4f2d-a8b9-9b1b2c3d4e5f",
  "checkoutUrl": "https://pay.swich.com/checkout?token=2c4b7c5a-f7a6-4f2d-a8b9-9b1b2c3d4e5f",
  "expiresAt": "2025-11-15T12:00:00Z"
}

Error Response (400)

{
  "code": "validation_error",
  "message": "description must match ^[A-Za-z0-9 ]{1,200}$",
  "details": {
    "field": "description",
    "issue": "invalid_format"
  }
}