Create Deposit

Create a new deposit transaction for your customer.

POST/v1/deposit

Creates a new deposit transaction and returns a checkout URL for the customer.

Description

Use this endpoint to create a new deposit transaction. After creating the transaction, redirect your customer to the checkout URL where they can complete the payment.

Important

Transactions expire after 30 minutes. Make sure your customer completes the payment before the expiration time.

Request Body

NameTypeRequiredDescription
processIdstringRequiredYour unique transaction identifier (max 50 characters)
amountnumberRequiredTransaction amount in the smallest currency unit
currencystringOptionalCurrency code (default: TRY)
bankCodestringOptionalBank code from available-banks endpoint
customer.idstringRequiredYour customer's unique identifier
customer.namestringRequiredCustomer's full name
customer.usernamestringRequiredCustomer's username
callbackUrlstringOptionalURL to receive transaction status updates (overrides site default)
metadataobjectOptionalAdditional data to attach to the transaction

Request Example

cURL
curl -X POST "https://<service_name>.api.wiapay.co/v1/deposit" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: pk_live_abc123..." \
  -H "X-Signature: a1b2c3d4e5f6..." \
  -H "X-Timestamp: 1705320000" \
  -d '{
    "processId": "ORDER-12345",
    "amount": 1000,
    "currency": "TRY",
    "bankCode": "5fe0f093bb4f0b001b5ea63d",
    "customer": {
      "id": "user-123",
      "name": "Ahmet Yilmaz",
      "username": "ahmetyilmaz"
    }
  }'
JavaScript
const createDeposit = async () => {
  const timestamp = Math.floor(Date.now() / 1000).toString();
  const body = {
    processId: 'ORDER-12345',
    amount: 1000,
    currency: 'TRY',
    bankCode: '5fe0f093bb4f0b001b5ea63d',
    customer: {
      id: 'user-123',
      name: 'Ahmet Yilmaz',
      username: 'ahmetyilmaz'
    }
  };

  const signature = generateSignature(
    API_SECRET,
    timestamp,
    'POST',
    '/v1/deposit',
    JSON.stringify(body)
  );

  const response = await fetch(
    'https://<service_name>.api.wiapay.co/v1/deposit',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'X-API-Key': API_KEY,
        'X-Signature': signature,
        'X-Timestamp': timestamp
      },
      body: JSON.stringify(body)
    }
  );

  const data = await response.json();

  if (data.success) {
    // Redirect customer to checkout
    window.location.href = data.data.checkoutUrl;
  }
};

Response

Success Response (201 Created)

{
  "success": true,
  "data": {
    "transactionId": "674abc123def456789012345",
    "processId": "ORDER-12345",
    "amount": 1000,
    "currency": "TRY",
    "status": "pending",
    "assignedAccount": {
      "bankName": "Ziraat Bankasi",
      "accountName": "WIAPAY ODEME HIZMETLERI",
      "iban": "TR12 0001 0012 3456 7890 1234 56"
    },
    "checkoutUrl": "https://pay.wiapay.co/pay/674abc123def456789012345?token=...",
    "expiresAt": "2024-01-15T12:30:00.000Z",
    "createdAt": "2024-01-15T12:00:00.000Z"
  },
  "timestamp": 1705320000
}

Response Fields

FieldTypeDescription
transactionIdstringWiaPay's unique transaction identifier
processIdstringYour transaction identifier (echoed back)
amountnumberConfirmed transaction amount
currencystringTransaction currency
statusstringCurrent transaction status
assignedAccountobjectBank account details for the deposit (if assigned)
checkoutUrlstringURL to redirect customer for payment
expiresAtstringTransaction expiration timestamp
createdAtstringTransaction creation timestamp

Transaction Flow

1

Create Transaction

Create a deposit transaction using this API endpoint

2

Redirect Customer

Redirect your customer to the checkout URL from the response

3

Customer Makes Payment

Customer completes the payment on the checkout page

4

Payment Confirmed

You receive a callback with the final transaction status

Error Responses

400 Bad Request - Validation Error
{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "processId and amount are required"
  },
  "timestamp": 1705320000
}
400 Bad Request - Duplicate Transaction
{
  "success": false,
  "error": {
    "code": "DUPLICATE_TRANSACTION",
    "message": "Transaction with this processId already exists"
  },
  "timestamp": 1705320000
}
400 Bad Request - Amount Out of Range
{
  "success": false,
  "error": {
    "code": "AMOUNT_OUT_OF_RANGE",
    "message": "Amount must be between 100 and 50000 TRY for this bank"
  },
  "timestamp": 1705320000
}