Skip to main content

Cryptocurrency withdraw

To connect to the cryptocurrency balance shop and cryptocurrency payway, you need to contact the supervising manager or support@qostiq.com.

Make sure that your shop is activated and configured to work via the API: shop ID is received, interaction URL is specified, secret key is generated and IP addresses of your services are specified. Limits of payway and the name are specified in the personal account — shop settings — payment methods / withdrawal directions.

Scheme of work with cryptocurrency withdraws

  1. The shop makes a request to preliminary withdraw calculation and the possibility of creating a withdraw on these data. If you get result == true go to step 2. If you get result == error, you must analyze the error message in message.
  2. The shop sends a request to create a withdraw. If result == true is received, the withdraw is created and the shop waits for a notification with the final status (step 3) or requests the withdraw status (step 4). If result == error is received, you must analyze the error message in message.
  3. Qostiq system sends notifications to the URL for cryptocurrency interactions with the withdraw status.
  4. The shop can request the current withdraw status as needed.

Withdraw: pre-calculation [/crypto/withdraw/try]

URL: https://core.qostiq.com/crypto/withdraw/try

Method: POST

Mandatory parameters: amount, amount_type, now, payway, shop_currency, shop_id

This request is not binding to create a withdraw. The request specifies the possibility of creating a withdraw with the specified parameters, returns the amounts debited from the shop and received by the client after fee calculation.

Example request:

{
"amount": "1.00000001",
"amount_type": "ps_amount",
"now": 1655738319,
"payway": "usdt_bep20",
"shop_currency": "USDT",
"shop_id": 6,
"sign": "806b007c4cd5d855013237f250d0f91fe1569f9ee6e6125332714ee11d2eb2d8"
}

Where,

ParameterDescriptionFormatExample
amounttransaction amount in cryptocurrencyString or number, see "Specifying the operation amount" for details"1.00000001" or 1.00000001
amount_typeindicates the type of amount, possible values: ps_amount — amount to be received in the payment system, shop_amount — amount to be written off from the shop balanceString"shop_amount" or "ps_amount"
nowrequest time, in the format unixtimestampInteger1655738319
paywayPayment direction (blockchain and currency)String"usdt_bep20"
shop_currencycurrency of the shop balance from which funds will be withdrawnString"USDT"
shop_idshop identifier in the Qostiq systemInteger6
signsignature, see Signature formation rules for crypto operations (sign)String"806b007c4cd5d855013237f250d0f91fe1569f9ee6e6125332714ee11d2eb2d8"

Example response:

{
"data": {
"payee_currency": "USDT",
"payee_receive": "1.000000001",
"shop_currency": "USDT",
"shop_write_off": "1.03000000103"
},
"error_code": 0,
"message": "Ok",
"result": true
}

Where,

data.payee_currency — currency of receipt by the client;

data.payee_receive — amount receivable by the client, in the currency of payway;

data.shop_currency — shop write-off currency;

data.shop_write_off — the amount written off the balance of the store in shop_currency.

Withdraw: create [/crypto/withdraw/create]

URL: https://core.qostiq.com/crypto/withdraw/create

Method: POST

Mandatory parameters: account, amount, amount_type, now, payway, shop_currency, shop_id, shop_payment_id

The request may also include the account_details parameter — an additional parameter for detailing information about the recipient's account (depends on the chosen payment direction). For example, comment refers to a TON Comment/Tag/Memo for withdrawals in the TON blockchain. A list of fields can be viewed in the personal account for each direction.

Example of sending additional parameters:

"account_details": {
"comment": "12345678"
}

Example request:

{
"account": "EQC67_9GtyJveay9fYwjuOUg2VvokASM3xI7MQ7R84UzC2Qx",
"account_details": {
"comment": "12345678"
},
"amount": "1",
"amount_type": "ps_amount",
"now": 1655802380,
"payway": "ton_ton",
"shop_currency": "TON",
"shop_id": 6,
"shop_payment_id": "test_withdraw_id_4",
"sign": "bc21703c682f0b9f53d4b554cfd55d8a25fc75c0e386fe589033aa0f49f35d07"
}

Where,

ParameterDescriptionFormatRequired?Example
accountpayee addressStringyes"EQC67_9GtyJveay9fYwjuOUg2VvokASM3xI7MQ7R84UzC2Qx"
amounttransaction amount in cryptocurrencyString or number, see "Specifying the operation amount" for detailsyes"1" or 1.00
amount_typeindicates the type of amount, possible values: ps_amount — amount to be received in the payment system, shop_amount — amount to be written off from the shop balanceStringyes"shop_amount" or "ps_amount"
nowrequest time, in the format unixtimestampIntegeryes1655802380
paywayPayment direction (blockchain and currency)Stringyes"ton_ton"
shop_currencycurrency of the shop balance from which funds will be withdrawnStringyes"TON"
shop_idshop identifier in the Qostiq systemIntegeryes6
shop_payment_idunique transaction number on the shop sideStringyes"test_withdraw_id_4"
signsignature, see Signature formation rules for crypto operations (sign)Stringyes"bc21703c682f0b9f53d4b554cfd55d8a25fc75c0e386fe589033aa0f49f35d07"
account_details.commentdetailed info about the recipient's account, for example Comment/Tag/Memo for TON networkString up to 255 charactersno"12345678"
descriptionoperation descriptionString up to 255 charactersno"test description"
crypto_callback_urlURL for accepting a payout callbackStringno"https://shop.com/callback/crypto"

Example response:

{
"data": {
"balance": "2.96",
"id": 15,
"payee_address": "EQC67_9GtyJveay9fYwjuOUg2VvokASM3xI7MQ7R84UzC2Qx",
"payee_currency": "TON",
"payee_receive": "1",
"shop_currency": "TON",
"shop_payment_id": "test_withdraw_id_4",
"shop_write_off": "1.005",
"status": 2
},
"error_code": 0,
"message": "Ok",
"result": true
}

Where,

data.balance — the available balance of the shop in the currency shop_currency after creating the withdraw;

data.id — transaction number in the Qostiq system;

data.payee_address — address to which the withdraw was created;

data.payee_currency — currency of receipt;

data.payee_receive — amount receivable by the client, in the currency of payway;

data.shop_currency — shop write-off currency;

data.shop_payment_id — withdraw number on the side of the shop;

data.shop_write_off — amount written off the balance of the store in shop_currency;

data.status — current operation status.

When you receive a network error on the request to create a withdraw, you must make a request for the withdraw status by shop_payment_id.

Withdraw: callback with final withdraw status [/crypto_withdraw/callback]

After receiving the final status of the crypto withdraw, the Qostiq system sends a callback to the shop at the crypto interaction URL specified in the settings.

Notifications are sent from IP addresses:

  • 34.90.243.164
  • 34.147.48.238
  • 34.90.176.128
  • 34.90.34.134
  • 35.242.192.50

When you receive a notification, be sure to check the signature — sign, type of operation — callback_type, the status of the operation — status in the notification.

Method: POST, Content-Type=application/json

Example notification:

{
"address": "0xf8227AA7aF9B5166AF69581C703A4398387B2B07",
"callback_type": "crypto_withdraw",
"created": "2022-06-29 10:29:47",
"description": null,
"payee_receive": "0.000100000000000000",
"payment_id": 58,
"payway": "bnb_bep20",
"processed": "2022-06-29 10:30:33",
"ps_currency": "BNB",
"ps_data": {
"transaction_hash": "0x8d3d3f6851a16c4f5d957124fa8444f4be9add351aa9c4e301e2eeff13a910df"
},
"shop_currency": "BNB",
"shop_id": 6,
"shop_order_id": "test_withdraw_id_5",
"shop_write_off": "0.000103000000000000",
"sign": "f8ec782aa4d1332532cc7ac5364ef979f593079505529d895e1f2c4a7cd0e024",
"status": "success"
}

Where,

address — address on which the withdraw was created;

callback_type — type of transaction for which the notification came, "crypto_withdraw" for a withdraw;

created — date and time of withdraw creation;

description — withdraw description;

payee_receive — the amount sent to the customer to the address;

payment_id — unique identifier of the issued withdraw in the Qostiq system;

payway — payment direction in the Qostiq system through which the withdraw was created;

processed — date and time when the withdraw status changed (success or reject);

ps_currency — currency of the payment direction;

ps_data.transaction_hash — withdraw hash in the blockchain;

shop_currency — shop write-off currency;

shop_id — shop ID that created the withdraw;

shop_order_id — shop's transaction number;

shop_write_off — amount written off from the shop in shop_currency;

status — withdraw status;

sign — signature.

The signature is formed using the same algorithm as all operations, but all parameters whose value is not null and not an empty string are involved in forming the signature.

If the notification is received and processed correctly, it is necessary to return http status 200 and the message body OK. Otherwise notifications will be sent repeatedly, at increasing intervals, a total of 25 attempts, the last at the end of the day.

Example of a string to generate a signature:

0xf8227AA7aF9B5166AF69581C703A4398387B2B07:crypto_withdraw:2022-06-29 10:29:47:0.000100000000000000:58:bnb_bep20:2022-06-29 10:30:33:BNB:{"transaction_hash": "0x8d3d3f6851a16c4f5d957124fa8444f4be9add351aa9c4e301e2eeff13a910df"}:BNB:6:test_withdraw_id_5:0.000103000000000000:successTestkey1

Withdraw: status request by withdraw_id [/crypto/withdraw/status]

URL: https://core.qostiq.com/crypto/withdraw/status

Method: POST

Mandatory parameters: now, shop_id, withdraw_id

Example request:

{
"now": 1655802380,
"shop_id": 6,
"withdraw_id": 15,
"sign": "bc21703c682f0b9f53d4b554cfd55d8a25fc75c0e386fe589033aa0f49f35d07"
}

Where,

ParameterDescriptionFormatExample
nowrequest time, in the format unixtimestampInteger1655815845
shop_idshop identifier in the Qostiq systemInteger6
withdraw_idtransaction number on the Qostiq system (returned in response to /crypto/withdraw/create in parameter data.id)Integer15
signsignature, see Signature formation rules for crypto operations (sign)String"175365f50e85fa717be6cb5dc3e456b09c5d3e2e6ee7046286ef31019f87ff59"

Example response:

{
"data": {
"id": 15,
"payee_address": "0xf8227AA7aF9B5166AF69581C703A4398387B2B07",
"payee_currency": "USDT",
"payee_receive": "0.0001",
"shop_currency": "USDT",
"shop_payment_id": "test_withdraw_id_4",
"shop_write_off": "0.000103",
"status": 2
},
"error_code": 0,
"message": "Ok",
"result": true
}

Where,

data.id — transaction number in the Qostiq system;

data.payee_address — client's address to which the withdraw was created;

data.payee_currency — currency of receipt;

data.payee_receive — amount receivable by the client, in the currency of payway;

data.shop_currency — shop write-off currency;

data.shop_payment_id — transaction number on the shop;

data.shop_write_off — amount written off the balance of the shop in shop_currency;

data.status — current operation status.

Attention! The request for withdraw status should be made no more than once a minute.

If the payment is created, a unique payment identifier and its status will be returned in the response. Status can be final and non-final; with non-final status it is necessary to make a status request before receiving the final status, or wait to receive a callback after receiving the final withdraw status.

Withdraw: status request by shop_payment_id [/crypto/withdraw/shop_payment_status]

URL: https://core.qostiq.com/crypto/withdraw/shop_payment_status

Method: POST

Mandatory parameters: now, shop_id, shop_payment_id

Request returns the current withdraw status by the transaction ID on the store side — shop_payment_id. For example, if you receive a network error on the request to create a withdraw, you can get information about whether the withdraw was created in the Qostiq system and its current status.

Example request:

{
"now": 1655802380,
"shop_id": 6,
"shop_payment_id": "test_withdraw_id_4",
"sign": "bc21703c682f0b9f53d4b554cfd55d8a25fc75c0e386fe589033aa0f49f35d07"
}

Where,

ParameterDescriptionFormatExample
nowrequest time, in the format unixtimestampInteger1655815845
shop_idshop identifier in the Qostiq systemInteger6
shop_payment_idtransaction number on the shop sideString"test_withdraw_id_4"
signsignature, see Signature formation rules for crypto operations (sign)String"175365f50e85fa717be6cb5dc3e456b09c5d3e2e6ee7046286ef31019f87ff59"

Example response when a withdraw was created:

{
"data": {
"id": 15,
"payee_address": "0xf8227AA7aF9B5166AF69581C703A4398387B2B07",
"payee_currency": "USDT",
"payee_receive": "0.0001",
"shop_currency": "USDT",
"shop_payment_id": "test_withdraw_id_4",
"shop_write_off": "0.000103",
"status": 2
},
"error_code": 0,
"message": "Ok",
"result": true
}

data.id — transaction number on the Qostiq system;

data.payee_address — address to which the withdraw was created;

data.payee_currency — currency of receipt;

data.payee_receive — amount receivable by the client, in the currency of payway;

data.shop_currency — store write-off currency;

data.shop_payment_id — withdraw number on the side of the shop;

data.shop_write_off — the amount written off the balance of the store in shop_currency;

data.status — current withdraw status.

Example response if the withdraw was not created on the Qostiq system:

{
"data": null,
"error_code": 7,
"message": "Withdraw (shop_payment_id='test_withdraw_id_5') is not found",
"result": false
}

Attention! The request for withdraw status should be made no more than once a minute.

Withdraw: operation statuses [/status/crypto_withdraw]

StatusValueDescriptionFinal?
1NewWithdraw created, waiting for processingNo, request the status
2WaitingWithdraw created, waiting for processingNo, request the status
3SuccessWithdraw successfully completedYes, funds written off from the store
4RejectedWithdraw rejectedYes, funds are not debited from the store
5ProcessingErrorProcessing errorNo, request the status

Cryptocurrency shop balance

Requesting the cryptocurrency balance of the shop [/crypto/shop_balance]

URL: https://core.qostiq.com/crypto/shop_balance

Method: POST

Mandatory parameters: now, shop_id

Example request:

{
"now": 1655821138,
"shop_id": 6,
"sign": "f2c67bc4f3cf7afdf9b08573de36d42b1fc1984d48187ef560d6163beeb907e7"
}

Where,

ParameterDescriptionFormatExample
nowrequest time, in the format unixtimestampInteger1655821138
shop_idshop identifier in the Qostiq systemInteger6
signsignature, see Signature formation rules for crypto operations (sign)String"f2c67bc4f3cf7afdf9b08573de36d42b1fc1984d48187ef560d6163beeb907e7"

Example response:

{
"data": {
"balances": [
{
"available": "9.8",
"currency": "USDT",
"frozen": "0.0",
"hold": "0.0"
},
{
"available": "0.0000134",
"currency": "BNB",
"frozen": "0.000103",
"hold": "0.0010475903"
}
],
"shop_id": 6
},
"error_code": 0,
"message": "Ok",
"result": true
}

Where,

data.balances — an array of data on currencies on the shop in which:

data.balances.available — balance available for withdraw;

data.balances.currency — balance cryptocurrency;

data.balances.frozen — frozen funds on the balance (for example, under the created withdraw, which is being processed);

data.balances.hold — temporarily withheld funds (for example: risky invoice).