### Go GET account transfer detail Source: https://docs.singapay.id/api-reference/account-transfer/show-account-transfer-detail Go example using net/http to GET account transfer details. Prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://sandbox-payment-b2b.singapay.id/api/v1.0/account-transfer/{account_id}/{transaction_id}" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") req.Header.Add("X-PARTNER-ID", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Go example for listing cardless withdrawals Source: https://docs.singapay.id/api-reference/cardless-withdrawal/list Uses the net/http package to send a GET request to the cardless withdrawals list endpoint. Prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://sandbox-payment-b2b.singapay.id/api/v1.0/cardless-withdrawals/transaction/{account_id}" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") req.Header.Add("X-PARTNER-ID", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Go net/http POST to get access token Source: https://docs.singapay.id/api-reference/authentication/get-access-token Go example using the standard net/http library to POST the authentication payload. Prints the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://sandbox-apigw.singapay.id/api/v1/kyc/auth/get-auth-token" payload := strings.NewReader("{\n \"client_id\": \"kc_live_a3f2c4\",\n \"timestamp\": \"2026-05-26T07:30:00Z\",\n \"signature\": \"9d4e7a8b1f3c2e5d6a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Go GET Recurring Plan Source: https://docs.singapay.id/api-reference/subscription-recurring/get-plan Go example using net/http to GET /api/v2.0/recurring/plans/{id}. Sets Authorization and X-PARTNER-ID headers, reads response body, and prints it. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://sandbox-payment-b2b.singapay.id/api/v2.0/recurring/plans/{id}" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") req.Header.Add("X-PARTNER-ID", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Go: Get Plan Source: https://docs.singapay.id/api-reference/subscription-recurring/get-plan Uses net/http to send a GET request and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://sandbox-payment-b2b.singapay.id/api/v2.0/recurring/plans/{id}" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") req.Header.Add("X-PARTNER-ID", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Go net/http GET cardless-withdrawals transaction detail Source: https://docs.singapay.id/api-reference/cardless-withdrawal/show-detail Go example using net/http to GET cardless withdrawal transaction details. Prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://sandbox-payment-b2b.singapay.id/api/v1.0/cardless-withdrawals/transaction/{account_id}/{reference_number}" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") req.Header.Add("X-PARTNER-ID", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Python GET account transfer detail Source: https://docs.singapay.id/api-reference/account-transfer/show-account-transfer-detail Python example using the requests library to GET account transfer details. Requires the requests package and valid credentials. ```python import requests url = "https://sandbox-payment-b2b.singapay.id/api/v1.0/account-transfer/{account_id}/{transaction_id}" headers = { "Authorization": "Bearer ", "X-PARTNER-ID": "" } response = requests.get(url, headers=headers) print(response.text) ``` -------------------------------- ### Python requests example for listing cardless withdrawals Source: https://docs.singapay.id/api-reference/cardless-withdrawal/list Uses the requests library to perform a GET request to the cardless withdrawals list endpoint. Prints the response text. ```python import requests url = "https://sandbox-payment-b2b.singapay.id/api/v1.0/cardless-withdrawals/transaction/{account_id}" headers = { "Authorization": "Bearer ", "X-PARTNER-ID": "" } response = requests.get(url, headers=headers) print(response.text) ``` -------------------------------- ### Ruby Net::HTTP GET account transfer detail Source: https://docs.singapay.id/api-reference/account-transfer/show-account-transfer-detail Ruby example using Net::HTTP to GET account transfer details. Prints the response body. ```ruby require 'uri' require 'net/http' url = URI("https://sandbox-payment-b2b.singapay.id/api/v1.0/account-transfer/{account_id}/{transaction_id}") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' request["X-PARTNER-ID"] = '' response = http.request(request) puts response.read_body ``` -------------------------------- ### Java Unirest example for listing cardless withdrawals Source: https://docs.singapay.id/api-reference/cardless-withdrawal/list Uses the Unirest library to send a GET request to the cardless withdrawals list endpoint. Returns the response as a string. ```java HttpResponse response = Unirest.get("https://sandbox-payment-b2b.singapay.id/api/v1.0/cardless-withdrawals/transaction/{account_id}") .header("Authorization", "Bearer ") .header("X-PARTNER-ID", "") .asString(); ``` -------------------------------- ### Ruby Net::HTTP POST to get access token Source: https://docs.singapay.id/api-reference/authentication/get-access-token Ruby example using Net::HTTP to POST the authentication payload. Prints the response body. ```ruby require 'uri' require 'net/http' url = URI("https://sandbox-apigw.singapay.id/api/v1/kyc/auth/get-auth-token") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = 'application/json' request.body = "{\n \"client_id\": \"kc_live_a3f2c4\",\n \"timestamp\": \"2026-05-26T07:30:00Z\",\n \"signature\": \"9d4e7a8b1f3c2e5d6a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f\"\n}" response = http.request(request) puts response.read_body ``` -------------------------------- ### Ruby Net::HTTP example for listing cardless withdrawals Source: https://docs.singapay.id/api-reference/cardless-withdrawal/list Uses the Net::HTTP library to send a GET request to the cardless withdrawals list endpoint. Prints the response body. ```ruby require 'uri' require 'net/http' url = URI("https://sandbox-payment-b2b.singapay.id/api/v1.0/cardless-withdrawals/transaction/{account_id}") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' request["X-PARTNER-ID"] = '' response = http.request(request) puts response.read_body ``` -------------------------------- ### Java (Unirest): Get Plan Source: https://docs.singapay.id/api-reference/subscription-recurring/get-plan Uses Unirest to send a GET request and returns the response as a string. ```java HttpResponse response = Unirest.get("https://sandbox-payment-b2b.singapay.id/api/v2.0/recurring/plans/{id}") .header("Authorization", "Bearer ") .header("X-PARTNER-ID", "") .asString(); ``` -------------------------------- ### Go example for account transfer Source: https://docs.singapay.id/api-reference/account-transfer/transfer-between-accounts-pg-or-cross-channel Uses net/http to POST the transfer payload. The response body is read and printed. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://sandbox-payment-b2b.singapay.id/api/v1.0/account-transfer/{account_id}/transfer" payload := strings.NewReader("{\n \"amount\": 500000,\n \"beneficiary_channel\": \"KYC\",\n \"beneficiary_account_number\": \"123456789012\",\n \"beneficiary_account_id\": null,\n \"merchant_ref_no\": \"MOVE-20260702-001\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("X-PARTNER-ID", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### JavaScript fetch GET account transfer detail Source: https://docs.singapay.id/api-reference/account-transfer/show-account-transfer-detail JavaScript fetch example to GET account transfer details. Uses async promise handling and logs the JSON response. ```javascript const options = { method: 'GET', headers: {Authorization: 'Bearer ', 'X-PARTNER-ID': ''} }; fetch('https://sandbox-payment-b2b.singapay.id/api/v1.0/account-transfer/{account_id}/{transaction_id}', options) .then(res => res.json()) .then(res => console.log(res)) .catch(err => console.error(err)); ``` -------------------------------- ### Python: Get Plan Source: https://docs.singapay.id/api-reference/subscription-recurring/get-plan Uses the requests library to fetch a plan. Prints the response text. ```python import requests url = "https://sandbox-payment-b2b.singapay.id/api/v2.0/recurring/plans/{id}" headers = { "Authorization": "Bearer ", "X-PARTNER-ID": "" } response = requests.get(url, headers=headers) print(response.text) ``` -------------------------------- ### Ruby Net::HTTP GET Recurring Plan Source: https://docs.singapay.id/api-reference/subscription-recurring/get-plan Ruby Net::HTTP example for GET /api/v2.0/recurring/plans/{id}. Sets Authorization and X-PARTNER-ID headers, uses SSL, and prints response body. ```ruby require 'uri' require 'net/http' url = URI("https://sandbox-payment-b2b.singapay.id/api/v2.0/recurring/plans/{id}") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' request["X-PARTNER-ID"] = '' response = http.request(request) puts response.read_body ``` -------------------------------- ### Ruby: Get Plan Source: https://docs.singapay.id/api-reference/subscription-recurring/get-plan Uses Net::HTTP to fetch a plan and prints the response body. ```ruby require 'uri' require 'net/http' url = URI("https://sandbox-payment-b2b.singapay.id/api/v2.0/recurring/plans/{id}") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' request["X-PARTNER-ID"] = '' response = http.request(request) puts response.read_body ``` -------------------------------- ### JavaScript fetch POST to get access token Source: https://docs.singapay.id/api-reference/authentication/get-access-token JavaScript example using the Fetch API to POST the authentication payload. Logs the parsed JSON response or any error to the console. ```javascript const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ client_id: 'kc_live_a3f2c4', timestamp: '2026-05-26T07:30:00Z', signature: '9d4e7a8b1f3c2e5d6a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f' }) }; fetch('https://sandbox-apigw.singapay.id/api/v1/kyc/auth/get-auth-token', options) .then(res => res.json()) .then(res => console.log(res)) .catch(err => console.error(err)); ``` -------------------------------- ### Python requests example for payment credit Source: https://docs.singapay.id/api-reference/qris-money-out/trigger-payment-credit Uses the requests library to POST the payment payload to the endpoint. Requires the requests package and the same headers as the cURL example. ```python import requests url = "https://sandbox-payment-b2b.singapay.id/api/v2.0/qris/issuer/mpm/payment-credit" payload = { "reference_number": "INV-20231130-001", "account_id": "01K946KF851RK7FX075GJHBVKF", "amount": 100000, "qr_data": "00020101021226620015ID.SINGAPAY.WWW0118936012070412260002...", "customer_name": "John Doe", "customer_email": "john.doe@example.com", "customer_phone": "081234567890", "customer_location": "Jakarta" } headers = { "X-Signature": "", "X-Timestamp": "", "Authorization": "Bearer ", "X-PARTNER-ID": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.text) ``` -------------------------------- ### Python requests GET cardless-withdrawals transaction detail Source: https://docs.singapay.id/api-reference/cardless-withdrawal/show-detail Python example using the requests library to call the cardless withdrawal detail endpoint. Prints the raw response text. ```python import requests url = "https://sandbox-payment-b2b.singapay.id/api/v1.0/cardless-withdrawals/transaction/{account_id}/{reference_number}" headers = { "Authorization": "Bearer ", "X-PARTNER-ID": "" } response = requests.get(url, headers=headers) print(response.text) ``` -------------------------------- ### JavaScript fetch example for listing cardless withdrawals Source: https://docs.singapay.id/api-reference/cardless-withdrawal/list Uses the fetch API to send a GET request to the cardless withdrawals list endpoint. Logs the JSON response or error. ```javascript const options = { method: 'GET', headers: {Authorization: 'Bearer ', 'X-PARTNER-ID': ''} }; fetch('https://sandbox-payment-b2b.singapay.id/api/v1.0/cardless-withdrawals/transaction/{account_id}', options) .then(res => res.json()) .then(res => console.log(res)) .catch(err => console.error(err)); ``` -------------------------------- ### 404 Not Found response Source: https://docs.singapay.id/api-reference/account-transfer/show-account-transfer-detail Example error response when the account is not found. ```json { "status": 404, "success": false, "error": { "code": 404, "message": "Account not found." } } ``` -------------------------------- ### Access Token Signature Example in Python Source: https://docs.singapay.id/api-reference/building-x-signature Python example for generating the Access Token Signature. Uses hmac.new with hashlib.sha512 and the client_secret as the key. The current date is formatted as YYYYMMDD from datetime.now(). ```python import hmac import hashlib from datetime import datetime client_id = 'your_client_id' client_secret = 'your_client_secret' current_date = datetime.now().strftime('%Y%m%d') # Asia/Jakarta date payload = f'{client_id}_{client_secret}_{current_date}' signature = hmac.new(client_secret.encode(), payload.encode(), hashlib.sha512).hexdigest() ``` -------------------------------- ### Access Token Signature Example in Node.js Source: https://docs.singapay.id/api-reference/building-x-signature Node.js example for generating the Access Token Signature. Uses crypto.createHmac with sha512 and the client_secret as the key. The current date is formatted as YYYYMMDD from the ISO string. ```javascript const crypto = require('crypto'); const clientId = 'your_client_id'; const clientSecret = 'your_client_secret'; const currentDate = new Date().toISOString().slice(0, 10).replace(/-/g, ''); // YYYYMMDD (Asia/Jakarta date) const payload = `${clientId}_${clientSecret}_${currentDate}`; const signature = crypto.createHmac('sha512', clientSecret).update(payload).digest('hex'); ``` -------------------------------- ### Go GET Binding Status Source: https://docs.singapay.id/api-reference/direct-debit/binding-status Use this Go program to fetch the binding status. It creates an HTTP GET request with the required headers and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://sandbox-payment-b2b.singapay.id/api/v2.0/direct-debit/binding/{binding_id}" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") req.Header.Add("X-PARTNER-ID", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Go example for inquiry-status Source: https://docs.singapay.id/api-reference/e-wallet-money-out/inquiry-status Uses net/http to POST the reference number to the inquiry-status endpoint. Prints the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://sandbox-payment-b2b.singapay.id/api/v2.0/ewallet/{account_id}/inquiry-status" payload := strings.NewReader("{\n \"reference_number\": \"REF-001\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("X-PARTNER-ID", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Response 200: Success Source: https://docs.singapay.id/api-reference/subscription-recurring/get-plan Example success response with plan details including schedule, retry policy, and payment link. ```json { "response_code": "SP000", "response_message": "Successfully", "data": { "id": "9f8b6c2e-1a2b-4c3d-8e4f-5a6b7c8d9e0f", "name": "Monthly Pro Subscription", "amount": "150000", "currency": "IDR", "created_at": "2026-06-09T10:00:00+07:00", "schedule": { "interval": 1, "interval_unit": "month", "current_interval": 1, "total_interval": 12, "start_time": "2026-07-01T00:00:00+07:00", "previous_payment_at": null, "next_payment_at": "2026-07-01T00:00:00+07:00" }, "status": "active", "payment_type": "credit_card", "retry_policy": { "max_attempts": 3, "interval_days": 1, "failed_payment_action": "continue_plan" }, "metadata": { "description": "Pro plan monthly billing", "extra": [] }, "subscription_id": "SUB-2026-0001", "merchant_reff_no": "REF-0001", "payment_link_url": "https://pay.singapay.id/sub/9f8b6c2e", "parent_plan_id": null, "created_from": null } } ``` -------------------------------- ### Access Token Signature Example in PHP Source: https://docs.singapay.id/api-reference/building-x-signature PHP example for generating the Access Token Signature. Uses date('Ymd') for the current date and hash_hmac with sha512. The resulting signature is used in the X-Signature header. ```php $clientId = 'your_client_id'; $clientSecret = 'your_client_secret'; $currentDate = date('Ymd'); // e.g. 20260727 $payload = "{$clientId}_{$clientSecret}_{$currentDate}"; $signature = hash_hmac('sha512', $payload, $clientSecret); // Headers: // X-PARTNER-ID: your_api_key // X-CLIENT-ID: your_client_id // X-Signature: <$signature> ``` -------------------------------- ### JavaScript: Get Plan Source: https://docs.singapay.id/api-reference/subscription-recurring/get-plan Uses fetch to retrieve a plan. Logs the JSON response or an error. ```javascript const options = { method: 'GET', headers: {Authorization: 'Bearer ', 'X-PARTNER-ID': ''} }; fetch('https://sandbox-payment-b2b.singapay.id/api/v2.0/recurring/plans/{id}', options) .then(res => res.json()) .then(res => console.log(res)) .catch(err => console.error(err)); ``` -------------------------------- ### Update Payment Link with Net::HTTP (Ruby) Source: https://docs.singapay.id/api-reference/payment-link/update-v2 Ruby example using Net::HTTP to send a PUT request to the update payment link endpoint. Requires the uri and net/http libraries. The request includes the same JSON body as the Java example and prints the response body. ```ruby require 'uri' require 'net/http' url = URI("https://sandbox-payment-b2b.singapay.id/api/v2.0/payment-link/update/{link_id}") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Put.new(url) request["Authorization"] = 'Bearer ' request["X-PARTNER-ID"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"description\": \"Updated description\",\n \"max_usage\": 5,\n \"expired_at\": \"2026-08-10T00:00:00+07:00\",\n \"status\": \"closed\",\n \"whitelisted_payment_method\": [\n \"\"\n ],\n \"success_redirect_url\": \"https://merchant.example.com/payment/success\",\n \"expired_redirect_url\": \"https://merchant.example.com/payment/expired\",\n \"optional_metadata\": {},\n \"required_customer_number\": false,\n \"required_customer_email\": true\n}" response = http.request(request) puts response.read_body ``` -------------------------------- ### Create Account with Go Source: https://docs.singapay.id/api-reference/accounts/create-account Go example using the standard library to create an account. It constructs a POST request with the JSON payload and required headers, then prints the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://sandbox-payment-b2b.singapay.id/api/v1.0/accounts" payload := strings.NewReader("{\n \"name\": \"John Doe\",\n \"account_type\": \"owned\",\n \"invite_members\": [\n \"john@example.com\"\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("X-PARTNER-ID", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Java Unirest GET account transfer detail Source: https://docs.singapay.id/api-reference/account-transfer/show-account-transfer-detail Java example using Unirest to GET account transfer details. Returns the response as a string. ```java HttpResponse response = Unirest.get("https://sandbox-payment-b2b.singapay.id/api/v1.0/account-transfer/{account_id}/{transaction_id}") .header("Authorization", "Bearer ") .header("X-PARTNER-ID", "") .asString(); ``` -------------------------------- ### PHP cURL GET account transfer detail Source: https://docs.singapay.id/api-reference/account-transfer/show-account-transfer-detail PHP cURL example to GET account transfer details. Handles errors and prints the response. ```php "https://sandbox-payment-b2b.singapay.id/api/v1.0/account-transfer/{account_id}/{transaction_id}", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => [ "Authorization: Bearer ", "X-PARTNER-ID: " ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ``` -------------------------------- ### Java Unirest GET Recurring Plan Source: https://docs.singapay.id/api-reference/subscription-recurring/get-plan Java Unirest example for GET /api/v2.0/recurring/plans/{id}. Sets Authorization and X-PARTNER-ID headers and returns response as string. ```java HttpResponse response = Unirest.get("https://sandbox-payment-b2b.singapay.id/api/v2.0/recurring/plans/{id}") .header("Authorization", "Bearer ") .header("X-PARTNER-ID", "") .asString(); ``` -------------------------------- ### Create Account with Python requests Source: https://docs.singapay.id/api-reference/accounts/create-account Python example using the requests library to create an account. It sends a POST request with the JSON payload and required headers, then prints the response text. ```python import requests url = "https://sandbox-payment-b2b.singapay.id/api/v1.0/accounts" payload = { "name": "John Doe", "account_type": "owned", "invite_members": ["john@example.com"] } headers = { "Authorization": "Bearer ", "X-PARTNER-ID": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.text) ``` -------------------------------- ### Java Unirest GET cardless-withdrawals transaction detail Source: https://docs.singapay.id/api-reference/cardless-withdrawal/show-detail Java example using Unirest to GET cardless withdrawal transaction details. Returns the response as a string. ```java HttpResponse response = Unirest.get("https://sandbox-payment-b2b.singapay.id/api/v1.0/cardless-withdrawals/transaction/{account_id}/{reference_number}") .header("Authorization", "Bearer ") .header("X-PARTNER-ID", "") .asString(); ``` -------------------------------- ### Go example for payment credit Source: https://docs.singapay.id/api-reference/qris-money-out/trigger-payment-credit Uses the net/http package to send a POST request with the payment payload. Reads and prints the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://sandbox-payment-b2b.singapay.id/api/v2.0/qris/issuer/mpm/payment-credit" payload := strings.NewReader("{\n \"reference_number\": \"INV-20231130-001\",\n \"account_id\": \"01K946KF851RK7FX075GJHBVKF\",\n \"amount\": 100000,\n \"qr_data\": \"00020101021226620015ID.SINGAPAY.WWW0118936012070412260002...\",\n \"customer_name\": \"John Doe\",\n \"customer_email\": \"john.doe@example.com\",\n \"customer_phone\": \"081234567890\",\n \"customer_location\": \"Jakarta\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-Signature", "") req.Header.Add("X-Timestamp", "") req.Header.Add("Authorization", "Bearer ") req.Header.Add("X-PARTNER-ID", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### PHP cURL GET cardless-withdrawals transaction detail Source: https://docs.singapay.id/api-reference/cardless-withdrawal/show-detail PHP cURL example to GET cardless withdrawal transaction details. Handles cURL errors and prints the response. ```php "https://sandbox-payment-b2b.singapay.id/api/v1.0/cardless-withdrawals/transaction/{account_id}/{reference_number}", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => [ "Authorization: Bearer ", "X-PARTNER-ID: " ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ``` -------------------------------- ### Trigger Top-Up Request (Go) Source: https://docs.singapay.id/api-reference/e-wallet-money-out/trigger-top-up Go example using net/http to POST to the trigger-topup endpoint. Requires a bearer token, API key, signature, and timestamp in headers. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://sandbox-payment-b2b.singapay.id/api/v2.0/ewallet/trigger-topup" payload := strings.NewReader("{\n \"account_id\": \"01K5G4FZZ18DMK0M5QTR8Y9QY9\",\n \"reference_number\": \"REF-001\",\n \"ewallet_code\": \"DANA\",\n \"customer_number\": \"085733347341\",\n \"amount\": {\n \"value\": \"10000.00\",\n \"currency\": \"IDR\"\n },\n \"notes\": \"Top up DANA\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-Signature", "") req.Header.Add("X-Timestamp", "") req.Header.Add("Authorization", "Bearer ") req.Header.Add("X-PARTNER-ID", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Create Account with Ruby Net::HTTP Source: https://docs.singapay.id/api-reference/accounts/create-account Ruby example using Net::HTTP to create an account. It sends a POST request with the JSON payload and required headers, then prints the response body. ```ruby require 'uri' require 'net/http' url = URI("https://sandbox-payment-b2b.singapay.id/api/v1.0/accounts") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["X-PARTNER-ID"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"name\": \"John Doe\",\n \"account_type\": \"owned\",\n \"invite_members\": [\n \"john@example.com\"\n ]\n}" response = http.request(request) puts response.read_body ``` -------------------------------- ### Generate OAuth access token with Go Source: https://docs.singapay.id/api-reference/authentication/generate-oauth-access-token Go example using the standard library to request an OAuth access token. It constructs a POST request with the client_credentials grant type and prints the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://sandbox-biller-b2b.singapay.id/api/v1.0/access-token/b2b" payload := strings.NewReader("{\n \"grant_type\": \"client_credentials\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Content-Type", "Application/json") req.Header.Add("X-PARTNER-ID", "") req.Header.Add("Authorization", "Basic ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Ruby Net::HTTP GET cardless-withdrawals transaction detail Source: https://docs.singapay.id/api-reference/cardless-withdrawal/show-detail Ruby example using Net::HTTP to GET cardless withdrawal transaction details. Prints the response body. ```ruby require 'uri' require 'net/http' url = URI("https://sandbox-payment-b2b.singapay.id/api/v1.0/cardless-withdrawals/transaction/{account_id}/{reference_number}") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' request["X-PARTNER-ID"] = '' response = http.request(request) puts response.read_body ``` -------------------------------- ### Create Account with Java Unirest Source: https://docs.singapay.id/api-reference/accounts/create-account Java example using the Unirest HTTP library to create an account. It sends a POST request with the JSON payload and required headers, returning the response as a string. ```java HttpResponse response = Unirest.post("https://sandbox-payment-b2b.singapay.id/api/v1.0/accounts") .header("Authorization", "Bearer ") .header("X-PARTNER-ID", "") .header("Content-Type", "application/json") .body("{\n \"name\": \"John Doe\",\n \"account_type\": \"owned\",\n \"invite_members\": [\n \"john@example.com\"\n ]\n}") .asString(); ``` -------------------------------- ### PHP cURL GET Recurring Plan Source: https://docs.singapay.id/api-reference/subscription-recurring/get-plan PHP cURL example for GET /api/v2.0/recurring/plans/{id}. Requires Authorization Bearer token and X-PARTNER-ID header. Prints response or cURL error. ```php "https://sandbox-payment-b2b.singapay.id/api/v2.0/recurring/plans/{id}", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => [ "Authorization: Bearer ", "X-PARTNER-ID: " ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ``` -------------------------------- ### Python: Generate X-Signature for SingaPay Source: https://docs.singapay.id/api-reference/building-x-signature Python example using hashlib, hmac, json, and time to normalize the body, hash it, build the string to sign, and compute the HMAC-SHA512 signature. ```python import hashlib import hmac import json import time def sort_keys_recursive(obj): if isinstance(obj, list): return [sort_keys_recursive(v) for v in obj] if isinstance(obj, dict): return {k: sort_keys_recursive(obj[k]) for k in sorted(obj.keys())} return obj method = 'POST' endpoint = '/api/v2.0/disbursement/transfer' access_token = 'your_bearer_token' secret_key = 'your_client_secret' timestamp = str(int(time.time())) body = {'account_number': '1234567890', 'amount': 100000, 'bank_code': 'BCA'} normalized_json = json.dumps(sort_keys_recursive(body), separators=(',', ':'), ensure_ascii=False) hashed_body = hashlib.sha256(normalized_json.encode()).hexdigest() string_to_sign = f'{method}:{endpoint}:{access_token}:{hashed_body}:{timestamp}' signature = hmac.new(secret_key.encode(), string_to_sign.encode(), hashlib.sha512).hexdigest() ``` -------------------------------- ### Create Account with JavaScript Fetch Source: https://docs.singapay.id/api-reference/accounts/create-account JavaScript example using the Fetch API to create an account. It sends a POST request with the JSON payload and required headers, then logs the response or error. ```javascript const options = { method: 'POST', headers: { Authorization: 'Bearer ', 'X-PARTNER-ID': '', 'Content-Type': 'application/json' }, body: JSON.stringify({name: 'John Doe', account_type: 'owned', invite_members: ['john@example.com']}) }; fetch('https://sandbox-payment-b2b.singapay.id/api/v1.0/accounts', options) .then(res => res.json()) .then(res => console.log(res)) .catch(err => console.error(err)); ``` -------------------------------- ### JavaScript fetch GET cardless-withdrawals transaction detail Source: https://docs.singapay.id/api-reference/cardless-withdrawal/show-detail JavaScript fetch example to retrieve cardless withdrawal transaction details. Logs the JSON response or error. ```javascript const options = { method: 'GET', headers: {Authorization: 'Bearer ', 'X-PARTNER-ID': ''} }; fetch('https://sandbox-payment-b2b.singapay.id/api/v1.0/cardless-withdrawals/transaction/{account_id}/{reference_number}', options) .then(res => res.json()) .then(res => console.log(res)) .catch(err => console.error(err)); ``` -------------------------------- ### Create Account with PHP cURL Source: https://docs.singapay.id/api-reference/accounts/create-account PHP example using cURL to create an account. It sets the URL, headers, and JSON payload, then executes the request and outputs the response or an error message. ```php "https://sandbox-payment-b2b.singapay.id/api/v1.0/accounts", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => json_encode([ 'name' => 'John Doe', 'account_type' => 'owned', 'invite_members' => [ 'john@example.com' ] ]), CURLOPT_HTTPHEADER => [ "Authorization: Bearer ", "Content-Type: application/json", "X-PARTNER-ID: " ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ``` -------------------------------- ### Java Unirest POST to get access token Source: https://docs.singapay.id/api-reference/authentication/get-access-token Java example using the Unirest HTTP client to POST the authentication payload. The response is captured as a string. ```java HttpResponse response = Unirest.post("https://sandbox-apigw.singapay.id/api/v1/kyc/auth/get-auth-token") .header("Content-Type", "application/json") .body("{\n \"client_id\": \"kc_live_a3f2c4\",\n \"timestamp\": \"2026-05-26T07:30:00Z\",\n \"signature\": \"9d4e7a8b1f3c2e5d6a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f\"\n}") .asString(); ``` -------------------------------- ### Trigger Top-Up Request (Ruby) Source: https://docs.singapay.id/api-reference/e-wallet-money-out/trigger-top-up Ruby example using Net::HTTP to POST to the trigger-topup endpoint. Requires a bearer token, API key, signature, and timestamp in headers. ```ruby require 'uri' require 'net/http' url = URI("https://sandbox-payment-b2b.singapay.id/api/v2.0/ewallet/trigger-topup") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["X-Signature"] = '' request["X-Timestamp"] = '' request["Authorization"] = 'Bearer ' request["X-PARTNER-ID"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"account_id\": \"01K5G4FZZ18DMK0M5QTR8Y9QY9\",\n \"reference_number\": \"REF-001\",\n \"ewallet_code\": \"DANA\",\n \"customer_number\": \"085733347341\",\n \"amount\": {\n \"value\": \"10000.00\",\n \"currency\": \"IDR\"\n },\n \"notes\": \"Top up DANA\"\n}" response = http.request(request) puts response.read_body ``` -------------------------------- ### Ruby: Trigger Top-Up Request Source: https://docs.singapay.id/api-reference/e-wallet-money-out/trigger-top-up Ruby example using Net::HTTP to POST to the trigger-topup endpoint. Requires X-Signature, X-Timestamp, Bearer token, and X-PARTNER-ID headers. ```ruby require 'uri' require 'net/http' url = URI("https://sandbox-payment-b2b.singapay.id/api/v2.0/ewallet/trigger-topup") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["X-Signature"] = '' request["X-Timestamp"] = '' request["Authorization"] = 'Bearer ' request["X-PARTNER-ID"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"account_id\": \"01K5G4FZZ18DMK0M5QTR8Y9QY9\",\n \"reference_number\": \"REF-001\",\n \"ewallet_code\": \"DANA\",\n \"customer_number\": \"085733347341\",\n \"amount\": {\n \"value\": \"10000.00\",\n \"currency\": \"IDR\"\n },\n \"notes\": \"Top up DANA\"\n}" response = http.request(request) puts response.read_body ``` -------------------------------- ### Trigger Top-Up Request (Java) Source: https://docs.singapay.id/api-reference/e-wallet-money-out/trigger-top-up Java example using Unirest to POST to the trigger-topup endpoint. Requires a bearer token, API key, signature, and timestamp in headers. ```java HttpResponse response = Unirest.post("https://sandbox-payment-b2b.singapay.id/api/v2.0/ewallet/trigger-topup") .header("X-Signature", "") .header("X-Timestamp", "") .header("Authorization", "Bearer ") .header("X-PARTNER-ID", "") .header("Content-Type", "application/json") .body("{\n \"account_id\": \"01K5G4FZZ18DMK0M5QTR8Y9QY9\",\n \"reference_number\": \"REF-001\",\n \"ewallet_code\": \"DANA\",\n \"customer_number\": \"085733347341\",\n \"amount\": {\n \"value\": \"10000.00\",\n \"currency\": \"IDR\"\n },\n \"notes\": \"Top up DANA\"\n}") .asString(); ``` -------------------------------- ### PHP cURL example for listing cardless withdrawals Source: https://docs.singapay.id/api-reference/cardless-withdrawal/list Uses PHP cURL to send a GET request to the cardless withdrawals list endpoint. Handles errors and prints the response. ```php "https://sandbox-payment-b2b.singapay.id/api/v1.0/cardless-withdrawals/transaction/{account_id}", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => [ "Authorization: Bearer ", "X-PARTNER-ID: " ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ```