API Reset
Verifikasi Kehadiran pada Pelatihan Online
Digunakan untuk me-reset tahapan Verifikasi Kehadiran Online.
Hanya bisa dilakukan untuk test case positive.
- TC1-001-200 : Test case positive untuk pembelajaran mandiri di sequence 1 / redeem
- TC1-999-200 : Test case positive untuk pembelajaran mandiri di sequence 999 / posttest
- TC2-001-200 : Test case positive untuk webinar di sequence 1 / redeem
- TC2-999-200 : Test case positive untuk webinar di sequence 999 / posttest
Kode redeem harus mempunyai prefix PRAT-
Request
1curl --location 'https://api.prakerja.go.id/api/v1/integration/payment/redeem-code/reset' \
2--header 'Content-Type: application/json' \
3--header 'client_code: CLIENT_CODE' \
4--header 'signature: SIGNATURE' \
5--header 'timestamp: TIMESTAMP_UNIX_IN_SECONDS' \
6--data '{
7 "redeem_code":"PRAT-XXXXXX"
8}'
Endpoint Path
/api/v1/integration/payment/redeem-code/reset
Method
POSTHeader
Key | Value |
---|---|
Content-Type | application/json |
client_code | Unique Client ID yang disediakan Prakerja ke DP / LP. Prakerja akan menyediakan credential yaitu kombinasi client_code dan sign_key ke DP / LP. |
signature | Signature dibuat dari raw_signature yang di-hashing menggunakan algoritma HMAC-SHA1 dengan sign_key yang disediakan Prakerja ke DP / LP |
timestamp | Format nilai waktu dalam satuan detik yang digunakan saat melakukan hit API Contoh 1698289216 = 26-10-2023 10:00:16 WIB = 2023-10-26T10:00:16+07:00 Timestamp digunakan di --header 'timestamp:' yang nilainya harus sama persis dengan timestamp yang digunakan untuk membuat signature. |
Body (Payload)
Field | Type | Description |
---|---|---|
redeem_code | string, required | kode yang didapatkan oleh user prakerja ketika sukses membeli pelatihan. |
Response
Success Response
Response 200 OK
1{
2 "success": true,
3 "message": "OK",
4 "data": {
5 "redeem_code": "GHOPNYXUVMT0",
6 "course_code": "prakerjaoauth1",
7 "invoice_code": "testing-1234567",
8 "schedule_code": "prakerjaoauth",
9 "status": 1,
10 "attendance_status": 0,
11 "redeem_at": "2023-10-24T10:54:45Z",
12 "dp_platform": "Tokopedia",
13 "schedule_start_end": ", 15 November 2023 - 30 November 2023",
14 "course_type": 1,
15 "course_type_label": "online",
16 "course_learning_method": "lms",
17 "is_online_attendance": true,
18 "sequence": 999
19 }
20}
Response Detail
Field | Type | Description |
---|---|---|
success | boolean | Status hit API,
|
message | string | Deskripsi status hit API |
code | string | Kode error di response API. Format ERRXXX |
data.redeem_code | string | redeem_code pada request payload |
data.course_code | string | Kode unik pelatihan yang dibeli |
data.invoice_code | string | Kode unik pembelian pelatihan |
data.schedule_code | string | Kode unik jadwal pelatihan |
data.status | integer | Status redeem/kehadiran pertama. Nilai
|
data.attendance_status | integer | Status kehadiran sesuai sesi data.sequence. Nilai
|
data.redeem_at | timestamp | Waktu berhasil melakukan redeem/kehadiran pertama, contoh output: 2020-03-18T20:23:45Z, nilai dalam format rfc3339 |
data.dp_platform | string | Nama Digital Platform di mana pelatihan dibeli |
data.schedule_start_end | string | Contoh : "NAMA_PELATIHAN, 01 Januari 2023 - 05 Januari 2023" |
data.course_type | integer |
|
data.course_type_label | string |
|
data.course_learning_method | string |
|
data.is_online_attendance | boolean | Tipe validasi kehadiran
|
data.sequence | integer | Menunjukan tahapan kehadiran
|
Error Response
- Termasuk juga list error general response
- Response 400 Bad Request kode redeem harus diisi
1{ 2 "code": "ERRPPA41006", 3 "message": "oauth redeem_code harus diisi", 4 "success": false 5}
- Response 400 Bad Request kode redeem harus dengan prefix PRAT-
1{ 2 "code": "ERRPPA30006", 3 "message": "Redeem reset gagal, kode tidak valid.", 4 "success": false 5}
- Response 404 Not Found kode redeem tidak termasuk dalam testcase
1{ 2 "code": "ERRDGEN40402", 3 "message": "Test case not found.", 4 "success": false 5}
- Response 400 Bad Request kode redeem hanya untuk test case positive
1{ 2 "code": "ERRPPA41021", 3 "message": "Redeem reset gagal. Test case TCX-XXX-200 harus positive.", 4 "success": false 5}
Try this API
Example Code
1// Generated by Prakerja Generator
2// for complete documentation please visit https://developer.prakerja.go.id
3
4const crypto = require('crypto-js');
5const axios = require('axios');
6
7const redeem_code = ''; // redeem code generated by system when user buy training
8
9const client_code = ''; // provided by Prakerja
10const timestamp = Math.round((new Date()).getTime() / 1000); // generate current timestamp
11const method = 'POST'; // API Method
12const endpoint = '/api/v1/integration/payment/redeem-code/reset'; // API Redeem Status Endpoint
13
14const data = {};
15
16const input = client_code + timestamp + method + endpoint + JSON.stringify(data); // create signature input
17const sign_key = ''; // provided by Prakerja
18
19const signature = crypto.HmacSHA1(input, sign_key).toString(crypto.enc.Hex); // generate signature
20
21axios({
22method: 'post',
23url: 'https://api.prakerja.go.id' + endpoint,
24headers: {
25 'Content-Type': 'application/json',
26 'client_code': client_code,
27 'signature': signature,
28 'timestamp': timestamp
29},
30data
31})
32.then((response) => {
33console.log(response.data)
34})
35.catch((error) => {
36console.log(error.response.data)
37});
1<?php
2// Generated by Prakerja Generator
3// for complete documentation please visit https://developer.prakerja.go.id
4
5$redeem_code = ''; // redeem code generated by system when user buy training
6
7$client_code = ''; // provided by Prakerja
8$timestamp = time(); // generate current timestamp
9$method = 'POST'; // API Method
10$endpoint = '/api/v1/integration/payment/redeem-code/reset'; // API Redeem Status Endpoint
11
12$data = [];
13
14$input = $client_code . $timestamp . $method . $endpoint . json_encode($data); // create signature input
15$sign_key = ''; // provided by Prakerja
16
17$signature = hash_hmac('sha1', $input, $sign_key); // generate signature
18
19$headers = [
20'Content-Type: application/json',
21'client_code: ' . $client_code,
22'signature: ' . $signature,
23'timestamp: ' . $timestamp,
24];
25
26$ch = curl_init();
27curl_setopt($ch, CURLOPT_URL, 'https://api.prakerja.go.id' . $endpoint );
28curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
29curl_setopt($ch, CURLOPT_POST, 1);
30curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
31curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
32$result = curl_exec($ch);
33curl_close ($ch);
34
35print_r("result: ");
36print_r($result);
1# Generated by Prakerja Generator
2# for complete documentation please visit https://developer.prakerja.go.id
3
4from hashlib import sha1
5import hmac
6import time
7import json
8import requests
9
10redeem_code = '' # redeem code generated by system when user buy training
11
12client_code = '' # provided by Prakerja
13timestamp = str(int(time.time())) # generate current timestamp
14method = 'POST' # API Method
15endpoint = '/api/v1/integration/payment/redeem-code/reset' # API Redeem Status Endpoint
16
17data = {}
18
19# create signature input
20input = client_code + timestamp + method + endpoint + json.dumps(data, separators=(',', ':'))
21
22sign_key = '' # provided by Prakerja
23
24# generate signature
25signature = hmac.new(sign_key.encode("utf-8"), input.encode("utf-8"), sha1).hexdigest()
26
27headers = {
28'Content-Type': 'application/json',
29'client_code': client_code,
30'signature': signature,
31'timestamp': timestamp
32}
33
34result = requests.post(
35'https://api.prakerja.go.id' + endpoint,
36headers=headers,
37data=json.dumps(data)
38)
39
40print('result: ')
41print(result.text)
1# Generated by Prakerja Generator
2# for complete documentation please visit https://developer.prakerja.go.id
3
4require 'base64'
5require 'cgi'
6require 'openssl'
7require 'net/http'
8require 'uri'
9require 'json'
10
11redeem_code = '' # redeem code generated by system when user buy training
12
13client_code = '' # provided by Prakerja
14timestamp = String(Time.now.to_i) # generate current timestamp
15method = 'POST' # API Method
16endpoint = '/api/v1/integration/payment/redeem-code/reset' # API Redeem Status Endpoint
17
18data = {}
19
20# create signature input
21input = client_code + timestamp + method + endpoint + JSON.generate(data, quirks_mode: true)
22
23key = '' # provided by Prakerja
24
25signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new('sha1'), key.encode("ASCII"), input.encode("ASCII"))
26
27uri = URI.parse('https://api.prakerja.go.id' + endpoint)
28request = Net::HTTP::Post.new(uri)
29request.content_type = "application/json"
30request.body = JSON.generate(data, quirks_mode: true)
31request['Client_code'] = client_code
32request['Signature'] = signature
33request['Timestamp'] = timestamp
34
35req_options = {
36use_ssl: uri.scheme == "https",
37}
38
39result = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
40http.request(request)
41end
42
43# result.code
44# result.body
45puts 'result: ' + result.body