search

No results found

API Reference chevron_right Items chevron_right Stock Lock
lock STOCK LOCK New

Stock Lock

Reservasi stok sementara selama periode pembayaran untuk mencegah overselling. Lock stok sebelum buyer bayar agar tidak diambil oleh pembeli lain.

Alur Penggunaan

shopping_cart

Buyer pilih
produk

lock

Lock stok
(10 menit)

payments

Buyer
bayar

check_circle

Buat trx
+ lock_token

warning

Penting

  • Lock berlaku maksimal 10 menit. Setelah expired, stok otomatis kembali tersedia.
  • Maksimal 50 lock aktif secara bersamaan per akun reseller.
  • Lock tidak diperlukan untuk produk dengan stok unlimited (manual/h2h).
  • Saat membuat transaksi dengan lock_token, stok dijamin tersedia.
POST
/v1/item/lock

Lock Stock

Reservasi stok untuk item tertentu selama periode pembayaran.

Request Body

Parameter Type Description
item_id Required
integer ID item/variant yang akan di-lock.
quantity Required
integer Jumlah stok yang akan di-lock. Minimal sesuai min_order item.
lock_duration
integer Optional. Durasi lock dalam detik. Min: 60, Max: 600 (10 menit). Default: 600.

Error Responses

404 ITEM_NOT_FOUND

Item tidak ditemukan atau tidak aktif.

422 INSUFFICIENT_STOCK

Stok tidak mencukupi untuk di-lock.

422 MINIMUM_ORDER_NOT_MET

Quantity kurang dari minimum order item.

422 LOCK_NOT_REQUIRED

Item memiliki stok unlimited, tidak perlu di-lock.

429 MAX_ACTIVE_LOCKS_REACHED

Sudah mencapai batas maksimal 10 lock aktif.


GET
/v1/item/lock

List Active Locks

Lihat semua lock aktif milik Anda beserta sisa waktu.


DELETE
/v1/item/lock/{lock_token}

Release Lock

Batalkan lock secara manual. Stok akan langsung tersedia kembali.

Error Responses

404 LOCK_NOT_FOUND

Lock token tidak ditemukan atau bukan milik Anda.

422 LOCK_ALREADY_USED / EXPIRED / RELEASED

Lock sudah tidak aktif.


POST
/v1/trx + lock_token

Create Transaction with Lock

Saat membuat transaksi via POST /v1/trx, tambahkan parameter lock_token untuk menjamin stok yang sudah di-lock.

Parameter Type Description
lock_token
string Optional. Token dari POST /v1/item/lock. Item dan quantity di carts harus match dengan lock.

Lock-specific Errors

404 LOCK_NOT_FOUND

Lock token tidak ditemukan.

422 LOCK_EXPIRED

Lock sudah expired, stok tidak lagi di-reservasi.

422 LOCK_MISMATCH

item_id / quantity di carts tidak sesuai dengan lock.

1. Lock Stock

curl --request POST \
          --url https://sekalipay.com/api/v1/item/lock \
          --header 'X-APIKEY: YOUR_API_KEY' \
          --header 'Content-Type: application/json' \
          --data '{
            "item_id": 123,
            "quantity": 1,
            "lock_duration": 600
          }'

Lock Response

201 Created
{
          "success": true,
          "data": {
            "lock_token": "LCK-a1b2c3d4-...",
            "item_id": 123,
            "quantity": 1,
            "locked_at": "2026-02-27T20:00:00Z",
            "expires_at": "2026-02-27T20:10:00Z"
          }
        }

2. Create Transaction + Lock

curl --request POST \
          --url https://sekalipay.com/api/v1/trx \
          --header 'X-APIKEY: YOUR_API_KEY' \
          --header 'Content-Type: application/json' \
          --data '{
            "ref_id": "INV-20260227-ABC",
            "lock_token": "LCK-a1b2c3d4-...",
            "carts": [
              {
                "item_id": 123,
                "quantity": 1
              }
            ]
          }'

3. Release Lock (Cancel)

curl --request DELETE \
          --url https://sekalipay.com/api/v1/item/lock/LCK-a1b2c3d4-... \
          --header 'X-APIKEY: YOUR_API_KEY'

4. List Active Locks

curl --request GET \
          --url https://sekalipay.com/api/v1/item/lock \
          --header 'X-APIKEY: YOUR_API_KEY'
chat_bubble Feedback