Skip to content

Create Transaction ​

Creates a transaction and returns the challenge key used to generate an advance OTP. The server also pushes the challenge key to the user's device via Firebase.

Endpoint ​

http
POST /api/v1/saas-sotp/create-transaction
Content-Type: application/json
json
{
  "partner_id": "{{partner_id}}",
  "partner_key": "{{partner_key}}",
  "token": "{{token}}",
  "app_id": "{{app_id}}",
  "transaction_id": "{{transaction_id}}",
  "transaction_desc": "{{transaction_desc}}",
  "transaction_amount": "{{transaction_amount}}",
  "transaction_date": "{{transaction_date}}",
  "receiver_account": "{{receiver_account}}",
  "sender_account": "{{sender_account}}",
  "currency": "VND",
  "type": "{{type}}",
  "transaction_metadata": "{\"test\":\"abc\"}"
}

Parameters:

ParamTypeRequiredDefaultDescription
partner_idstringYes—The partner id.
partner_keystringYes—The partner key.
tokenstringYes—The registration token generated by Register.
app_idstringYes—The app name the transaction was created under.
transaction_idstringYes—The unique transaction id on the partner side.
transaction_descstringYes—The transaction description.
transaction_amountstringYes—The transaction amount.
transaction_datestringYes—The date the transaction was created.
receiver_accountstringYes—The receiver account id.
sender_accountstringYes—The sender account id.
currencystringYes—The currency used to perform the transaction.
typestringYes—The type of transaction, defined on the partner side.
transaction_metadatastringNo—Additional transaction information, as a JSON string.

user_id and transaction_id form the composite key identifying the transaction.

Returns: CreateTransactionResponse

Sample Request ​

bash
curl --location --request POST '<BASE_URL>/saas-sotp/create-transaction' \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --data-raw '{
    "partner_id": "{{partner_id}}",
    "partner_key": "{{partner_key}}",
    "token": "{{token}}",
    "app_id": "{{app_id}}",
    "transaction_id": "{{transaction_id}}",
    "transaction_desc": "{{transaction_desc}}",
    "transaction_amount": "{{transaction_amount}}",
    "transaction_date": "{{transaction_date}}",
    "receiver_account": "{{receiver_account}}",
    "sender_account": "{{sender_account}}",
    "currency": "VND",
    "type": "{{type}}",
    "transaction_metadata": "{\"test\":\"abc\"}"
  }'

Response ​

json
{
  "success": true,
  "code": 1,
  "message": "Success",
  "challenge_key": "fake_challenge_key"
}
FieldTypeDescription
successboolRequest status.
codeintThe status code — 1 on success.
messagestringThe status or error message.
challenge_keystringThe challenge key used to generate the advance OTP.

challenge_key is returned at the top level, not nested under data.

INFO

The challenge key is pushed to the device via Firebase as well as returned here. Return it to the app in your own response only when push notifications are switched off for that user — otherwise let the push deliver it.

Errors ​

CodeDescription
3Parameter invalid
103Thông tin Partner không chính xác — Partner details are incorrect.
126Có lỗi xảy ra vui lòng thử lại — An error occurred, please retry.
129Token không hợp lệ — Invalid token.
190108Tài khoản chưa hoạt động — Account not activated.
190201Không thể tạo transaction hoặc transaction_id đã tồn tại — Cannot create the transaction, or the id already exists.

190201 most often means a duplicate transaction_id. Generate a fresh one rather than retrying with the same value.

Next Steps ​

  • Validate OTP — verify the advance OTP generated from this challenge key
  • Get Transaction — re-read the challenge key if the push was missed

Developers