Skip to main content
POST
/
payments
/
refunds
import cobo_waas2
from cobo_waas2.models.create_refund_request import CreateRefundRequest
from cobo_waas2.models.refund import Refund
from cobo_waas2.rest import ApiException
from pprint import pprint

# See configuration.py for a list of all supported configurations.
configuration = cobo_waas2.Configuration(
    # Replace `<YOUR_PRIVATE_KEY>` with your private key
    api_private_key="<YOUR_PRIVATE_KEY>",
    # Select the development environment. To use the production environment, change the URL to https://api.cobo.com/v2.
    host="https://api.dev.cobo.com/v2",
)
# Enter a context with an instance of the API client
with cobo_waas2.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = cobo_waas2.PaymentApi(api_client)
    create_refund_request = cobo_waas2.CreateRefundRequest(
        request_id="123e4567-e89b-12d3-a456-426614174004",
        payable_amount="0.25",
        token_id="ETH_USDT",
        refund_type="Merchant",
    )

    try:
        # Create refund order
        api_response = api_instance.create_refund(
            create_refund_request=create_refund_request
        )
        print("The response of PaymentApi->create_refund:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling PaymentApi->create_refund: %s\n" % e)

{
  "request_id": "123e4567-e89b-12d3-a456-426614174004",
  "refund_id": "R20250304-M1001-1001",
  "order_id": "O20250304-M1001-1001",
  "merchant_id": "M1001",
  "token_id": "ETH_USDT",
  "chain_id": "ETH",
  "amount": "0.0025",
  "to_address": "0x9876543210abcdef1234567890abcdef12345678",
  "status": "Pending",
  "refund_type": "Merchant",
  "created_timestamp": 1744689600,
  "updated_timestamp": 1744689600,
  "initiator": "b2ae1b5aaade686c968ef2bbd31cc75ba94e5a85fd9cb0b85b81dcc15f920e9d",
  "transactions": [
    {
      "tx_id": "tx_123e4567-e89b-12d3-a456-426614174003",
      "tx_hash": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
      "token_id": "ETH_USDT",
      "from_address": "0xF8e4bfc10A2821DF52D3322cB5170E5E9276b537",
      "to_address": "0x15B95A2D8af95D9F48148667B6b8B3CdF89e4F15",
      "amount": "0.15",
      "status": "Submitted",
      "created_timestamp": 1610445878970,
      "updated_timestamp": 1610445878970
    }
  ],
  "charge_merchant_fee": false,
  "merchant_fee_amount": "0.0001",
  "merchant_fee_token_id": "ETH_USDT",
  "commission_fee": {
    "fee_amount": "<string>"
  }
}
import cobo_waas2
from cobo_waas2.models.create_refund_request import CreateRefundRequest
from cobo_waas2.models.refund import Refund
from cobo_waas2.rest import ApiException
from pprint import pprint

# See configuration.py for a list of all supported configurations.
configuration = cobo_waas2.Configuration(
    # Replace `<YOUR_PRIVATE_KEY>` with your private key
    api_private_key="<YOUR_PRIVATE_KEY>",
    # Select the development environment. To use the production environment, change the URL to https://api.cobo.com/v2.
    host="https://api.dev.cobo.com/v2",
)
# Enter a context with an instance of the API client
with cobo_waas2.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = cobo_waas2.PaymentApi(api_client)
    create_refund_request = cobo_waas2.CreateRefundRequest(
        request_id="123e4567-e89b-12d3-a456-426614174004",
        payable_amount="0.25",
        token_id="ETH_USDT",
        refund_type="Merchant",
    )

    try:
        # Create refund order
        api_response = api_instance.create_refund(
            create_refund_request=create_refund_request
        )
        print("The response of PaymentApi->create_refund:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling PaymentApi->create_refund: %s\n" % e)

Authorizations

BIZ-API-KEY
string
header
required

The API key. For more details, refer to API key.

In the API playground, enter your API secret, and your API key will be accordingly calculated.

Body

application/json

The request body to create a refund order.

request_id
string
required

The request ID that is used to track a refund request. The request ID is provided by you and must be unique.

Example:

"123e4567-e89b-12d3-a456-426614174004"

payable_amount
string
required

The amount to refund in cryptocurrency. The amount must be a positive number and can have up to two decimal places

Example:

"0.25"

token_id
string
required

The ID of the cryptocurrency used for refund. Supported values:

  • USDC: ETH_USDC, ARBITRUM_USDCOIN, SOL_USDC, BASE_USDC, MATIC_USDC2, BSC_USDC
  • USDT: TRON_USDT, ETH_USDT, ARBITRUM_USDT, SOL_USDT, BASE_USDT, MATIC_USDT, BSC_USDT
Example:

"ETH_USDT"

refund_type
enum<string>
required

Specifies the source of funds for the refund:

  • Merchant: The refund amount will be deducted from the merchant balance.
  • Psp: The refund amount will be deducted from the developer balance.
Available options:
Merchant,
Psp
Example:

"Merchant"

merchant_id
string

The merchant ID.

Example:

"M1001"

to_address
string

The address where the refunded cryptocurrency will be sent.

Example:

"0x9876543210abcdef1234567890abcdef12345678"

order_id
string

The ID of the original pay-in order associated with this refund. Use this to track refunds against specific payments.

Example:

"R20250304-M1001-1001"

charge_merchant_fee
boolean

Whether to charge developer fee to the merchant. This field is only valid when refund_type is Merchant. For more information, please refer to Funds allocation and balances.

  • true: The fee amount (specified in merchant_fee_amount) will be deducted from the merchant's balance and added to the developer's balance

  • false: The merchant is not charged any developer fee

When enabled, ensure both merchant_fee_amount and merchant_fee_token_id are properly specified.

Example:

false

merchant_fee_amount
string

The developer fee amount to charge the merchant, denominated in the cryptocurrency specified by merchant_fee_token_id. This field is only valid when refund_type is Merchant. For more information, please refer to Funds allocation and balances.

This field is required when charge_merchant_fee is true. Must be:

  • A positive integer with up to two decimal places.
  • Less than the refund amount
Example:

"0.01"

merchant_fee_token_id
string

The ID of the cryptocurrency used for the developer fee. It must be the same as token_id. Supported values:

  • USDC: ETH_USDC, ARBITRUM_USDCOIN, SOL_USDC, BASE_USDC, MATIC_USDC2, BSC_USDC
  • USDT: TRON_USDT, ETH_USDT, ARBITRUM_USDT, SOL_USDT, BASE_USDT, MATIC_USDT, BSC_USDT
Example:

"ETH_USDT"

Response

Refund transaction created successfully.

refund_id
string
required

The refund order ID.

Example:

"R20250304-M1001-1001"

token_id
string
required

The ID of the cryptocurrency used for refund.

Example:

"ETH_USDT"

chain_id
string
required

The ID of the blockchain network on which the refund transaction occurs.

Example:

"ETH"

amount
string
required

The amount in cryptocurrency to be returned for this refund order.

Example:

"0.0025"

to_address
string
required

The recipient's wallet address where the refund will be sent.

Example:

"0x9876543210abcdef1234567890abcdef12345678"

status
enum<string>
required

The current status of the refund order. For information about transaction status, see Transaction statuses and sub-statuses.

  • Pending: The refund order has been created but the transaction has not been initiated.
  • Processing: The refund order is currently being processed, with at least one refund transaction in progress.
  • Completed: All refund transactions have been completed successfully.
  • PartiallyCompleted: Some refund transactions have been completed successfully, while others have failed.
  • Failed: All refund transactions have failed.
  • PendingConfirmation: The refund order has been created but the address to send (to_address) has not been specified. Once you use the Update refund order operation to specify the address, the status will be updated to Pending.
Available options:
Pending,
Processing,
Completed,
PartiallyCompleted,
Failed,
PendingConfirmation
Example:

"Pending"

request_id
string

The request ID provided by you when creating the refund request.

Example:

"123e4567-e89b-12d3-a456-426614174004"

order_id
string

The ID of the pay-in order corresponding to this refund.

Example:

"O20250304-M1001-1001"

merchant_id
string

The merchant ID.

Example:

"M1001"

refund_type
enum<string>

Specifies the source of funds for the refund:

  • Merchant: The refund amount will be deducted from the merchant balance.
  • Psp: The refund amount will be deducted from the developer balance.
Available options:
Merchant,
Psp
Example:

"Merchant"

created_timestamp
integer

The creation time of the refund order, represented as a UNIX timestamp in seconds.

Example:

1744689600

updated_timestamp
integer

The last update time of the refund order, represented as a UNIX timestamp in seconds.

Example:

1744689600

initiator
string

The initiator of this settlement request. Can return either an API key or the Payments App's ID.

  • Format api_key_<API_KEY>: Indicates the settlement request was initiated via the Payments API using the API key.
  • Format app_<APP_ID>: Indicates the settlement request was initiated through the Payments App using the App ID.
Example:

"b2ae1b5aaade686c968ef2bbd31cc75ba94e5a85fd9cb0b85b81dcc15f920e9d"

transactions
object[]

An array of transactions associated with this refund order. Each transaction represents a separate blockchain operation related to the refund process.

charge_merchant_fee
boolean

Whether to charge developer fee to the merchant for the refund.

  • true: The fee amount (specified in merchant_fee_amount) will be deducted from the merchant's balance and added to the developer's balance

  • false: The merchant is not charged any developer fee.

Example:

false

merchant_fee_amount
string

The developer fee amount to charge the merchant, denominated in the cryptocurrency specified by merchant_fee_token_id. This is only applicable if charge_merchant_fee is set to true.

Example:

"0.0001"

merchant_fee_token_id
string

The ID of the cryptocurrency used for the developer fee. This is only applicable if charge_merchant_fee is set to true.

Example:

"ETH_USDT"

commission_fee
object