Skip to main content

Payment API

Use these endpoints to purchase credits, confirm completed payments, and inspect balances for your MIRI API account.

Authentication

Miri-Api-Key: miri_live_sk_xxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

All payment endpoints require an API key. When initiating purchases, include X-Idempotency-Key to protect against duplicate orders.

Purchase Credits

Start a credit purchase with the configured payment provider.

Endpoint

POST /public/v1/payments/purchase

Headers

Miri-Api-Key: miri_live_sk_xxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: application/json
X-Idempotency-Key: unique-request-id-123 (optional)

Request Body

{
"packageType": "STANDARD",
"paymentMethod": "CARD"
}

Field Reference

FieldTypeRequiredDescription
packageTypestringYesCredit package to purchase: BASIC, STANDARD, PRO, or MAX.
paymentMethodstringNoPayment method (currently only CARD). Defaults to CARD when omitted.

Response (201 Created)

{
"success": true,
"data": {
"orderId": "ord_2025090100001",
"packageType": "STANDARD",
"amount": 20000,
"clientKey": "test_ck_xxxxxxxxxxxxxxxxx",
"successUrl": "https://partner.example.com/payments/success",
"failUrl": "https://partner.example.com/payments/fail"
},
"message": "Payment initiated. Please proceed with payment.",
"code": "SUCCESS",
"metadata": null
}

Response Fields

FieldTypeDescription
orderIdstringUnique payment order identifier.
packageTypestringSelected package tier.
amountnumberPurchase amount in KRW.
clientKeystringPayment gateway client key for front-end checkout.
successUrlstringRedirect URL after a successful payment.
failUrlstringRedirect URL after a failed payment.
Idempotent submissions

Reuse the same X-Idempotency-Key if you need to retry a purchase request. The service will return the original orderId instead of creating a duplicate transaction.

Confirm Payment

Finalize a payment after the user completes checkout with the gateway.

Endpoint

POST /public/v1/payments/confirm

Headers

Miri-Api-Key: miri_live_sk_xxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: application/json

Request Body

{
"orderId": "ord_2025090100001",
"paymentKey": "payment_key_from_gateway",
"amount": 20000
}

Response (200 OK)

{
"success": true,
"data": {
"orderId": "ord_2025090100001",
"creditsAdded": 60,
"totalCredits": 300,
"message": "Payment successful. Credits have been added to your account."
},
"message": "Payment confirmed successfully",
"code": "SUCCESS",
"metadata": null
}

Response Fields

FieldTypeDescription
orderIdstringConfirmed payment order.
creditsAddedintegerCredits granted by this transaction.
totalCreditsintegerCustomer’s total balance after confirmation.
messagestringHuman-readable confirmation message.

Get Payment Status

Retrieve the status of a payment order at any time.

Endpoint

GET /public/v1/payments/{orderId}

Response (200 OK)

{
"success": true,
"data": {
"orderId": "ord_2025090100001",
"status": "CONFIRMED",
"packageType": "STANDARD",
"amount": 20000,
"createdAt": "2025-09-01T10:00:00Z",
"confirmedAt": "2025-09-01T10:15:00Z"
},
"message": "Payment status retrieved",
"code": "SUCCESS",
"metadata": null
}

Status Reference

StatusDescription
PENDINGOrder is awaiting confirmation; no credits have been added yet.
CONFIRMEDPayment succeeded and credits were added to the account.
FAILEDPayment failed or was rejected; credits were not added.
CANCELLEDCancellation succeeded and the order is closed. Any previously added credits are rolled back during cancellation.
REFUNDEDA previously confirmed order was refunded by the platform after settlement.

Get Credit Balance

Check the current credit balance for the authenticated customer.

Endpoint

GET /public/v1/payments/credits

Response (200 OK)

{
"success": true,
"data": {
"credits": 240,
"customerId": "550e8400-e29b-41d4-a716-446655440000"
},
"message": "Credit amount retrieved",
"code": "SUCCESS",
"metadata": null
}

List Credit Packages

Retrieve the packages available for purchase.

Endpoint

GET /public/v1/payments/packages

Response (200 OK)

{
"success": true,
"data": [
{
"packageType": "BASIC",
"credits": 1,
"price": 1000,
"displayName": "Basic Plan - 1 Credit",
"description": "1 credit for ₩1,000",
"bonusPercentage": 0,
"bonusCredits": 0
},
{
"packageType": "STANDARD",
"credits": 21,
"price": 20000,
"displayName": "Standard Plan - 21 Credits",
"description": "21 credits for ₩20,000",
"bonusPercentage": 5,
"bonusCredits": 1
},
{
"packageType": "PRO",
"credits": 110,
"price": 100000,
"displayName": "Pro Plan - 110 Credits",
"description": "110 credits for ₩100,000",
"bonusPercentage": 10,
"bonusCredits": 10
},
{
"packageType": "MAX",
"credits": 1200,
"price": 1000000,
"displayName": "Max Plan - 1,200 Credits",
"description": "1,200 credits for ₩1,000,000",
"bonusPercentage": 20,
"bonusCredits": 200
}
],
"message": "Available credit packages",
"code": "SUCCESS",
"metadata": null
}

Package Summary

PackageCredits (base+bonus)Bonus %Price (KRW)
BASIC10%₩1,000
STANDARD20 + 15%₩20,000
PRO100 + 1010%₩100,000
MAX1,000 + 20020%₩1,000,000

Cancel Payment

Cancel a previously initiated payment.

Endpoint

POST /public/v1/payments/cancel

Headers

Miri-Api-Key: miri_live_sk_xxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: application/json

Request Body

{
"paymentKey": "payment_key_from_gateway",
"reason": "User requested cancellation"
}

Response (200 OK)

{
"success": true,
"data": {
"message": "Payment cancelled"
},
"message": null,
"code": "SUCCESS",
"metadata": null
}

The top-level message remains null; use data.message for user-facing copy. If the cancellation fails, the service returns 400 Bad Request with code = "PAYMENT_CANCEL_FAILED" and includes the paymentKey and reason in metadata.

Error Codes

CodeHTTP StatusDescription
INVALID_API_KEY401Header missing or malformed (edge authentication filter).
AUTH001401API key not recognized.
AUTH003403API key suspended.
VAL001400Request body could not be parsed.
VAL002400Required field missing (for example, packageType).
VAL003400Field validation failed or contained an unsupported enum value.
VAL004400Request size exceeded the platform limit.
BUS002402Credit balance insufficient for the attempted operation.
PAYMENT_CANCEL_FAILED400Cancellation request rejected; metadata echoes the paymentKey and reason.
NOT000404Payment not found or does not belong to the caller.
SVC001503Payment service temporarily unavailable; retry later.
INT001500Unexpected server error.
  • Analysis API – Consume credits for single analyses.
  • Batch API – Consume credits for batch submissions.