### Go Native HTTP Example Source: https://developer.sepay.vn/vi/sepay-api/v2/don-hang/danh-sach A Go example demonstrating how to make a GET request to fetch orders. It reads and prints the response body. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://userapi.sepay.vn/v2/bank-accounts/f9e8d7c6-b5a4-3210-fedc-ba0987654321/orders?created_at_sort=SOME_STRING_VALUE&amount_sort=SOME_STRING_VALUE&page=SOME_INTEGER_VALUE&per_page=SOME_INTEGER_VALUE" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer REPLACE_BEARER_TOKEN") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Kotlin OkHttp Example Source: https://developer.sepay.vn/vi/bankhub/api/api-merchant/bo-dem-merchant Example of making a GET request to the merchant-config/counter endpoint using Kotlin's OkHttp client. ```kotlin val client = OkHttpClient() val request = Request.Builder() .url("https://bankhub-api-sandbox.sepay.vn/v1/merchant-config/counter?start_date=2026-04-01&end_date=2026-04-03") .get() .addHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN") .build() val response = client.newCall(request).execute() ``` -------------------------------- ### C# HttpClient Example Source: https://developer.sepay.vn/vi/bankhub/api/api-merchant/bo-dem-merchant Example of making a GET request to the merchant-config/counter endpoint using C#'s HttpClient. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri("https://bankhub-api-sandbox.sepay.vn/v1/merchant-config/counter?start_date=2026-04-01&end_date=2026-04-03"), Headers = { { "Authorization", "Bearer REPLACE_BEARER_TOKEN" }, }, }; using (var response = await client.SendAsync(request)) { response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body); } ``` -------------------------------- ### Get Company Details with .NET HttpClient Source: https://developer.sepay.vn/vi/bankhub/api/cong-ty/chi-tiet-cong-ty This .NET example shows how to use HttpClient to make a GET request for company details. Ensure your bearer token is correctly provided. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class CompanyApiClient { public static async Task GetCompanyDetailsAsync(string companyId, string bearerToken) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("https://bankhub-api-sandbox.sepay.vn"); client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", bearerToken); HttpResponseMessage response = await client.GetAsync($"/v1/company/{companyId}"); if (response.IsSuccessStatusCode) { string responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } else { Console.WriteLine($"Error: {response.StatusCode}"); } } } // Example Usage: // public static async Task Main(string[] args) // { // await GetCompanyDetailsAsync("d3dafd01-e06b-11f0-b29e-52c7e9b4f41b", "REPLACE_BEARER_TOKEN"); // } } ``` -------------------------------- ### Get Company Details with Python Source: https://developer.sepay.vn/vi/bankhub/api/cong-ty/chi-tiet-cong-ty This Python example demonstrates how to retrieve company details using the http.client library. Ensure your bearer token is correctly substituted. ```python import http.client conn = http.client.HTTPSConnection("bankhub-api-sandbox.sepay.vn") headers = { 'Authorization': "Bearer REPLACE_BEARER_TOKEN" } conn.request("GET", "/v1/company/d3dafd01-e06b-11f0-b29e-52c7e9b4f41b", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` -------------------------------- ### Example API Call using cURL Source: https://developer.sepay.vn/vi/sepay-oauth2/luong-xac-thuc Demonstrates how to make a GET request to the bank accounts API using cURL, including the Authorization header. ```curl curl -H 'Authorization: Bearer ACCESS_TOKEN' https://my.sepay.vn/api/v1/bank-accounts ``` -------------------------------- ### Go HTTP GET Request for Prefixes Source: https://developer.sepay.vn/vi/sepay-api/v2/don-hang/tien-to-va A Go example for making a GET request to retrieve bank account prefixes. This snippet uses the standard Go http package. Ensure your bearer token is correctly set and pagination parameters are provided. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://userapi.sepay.vn/v2/bank-accounts/f9e8d7c6-b5a4-3210-fedc-ba0987654321/prefixes?page=SOME_INTEGER_VALUE&per_page=SOME_INTEGER_VALUE" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer REPLACE_BEARER_TOKEN") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Invoices using .NET HttpClient Source: https://developer.sepay.vn/vi/einvoice-api/v1/danh-sach-hoa-don This .NET example shows how to fetch invoice data using HttpClient. Ensure your Bearer token is correctly formatted in the Authorization header. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class InvoiceApiClient { public static async Task GetInvoicesAsync() { using (var client = new HttpClient()) { client.BaseAddress = new Uri("https://einvoice-api.sepay.vn"); client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "REPLACE_BEARER_TOKEN"); var response = await client.GetAsync("/v1/invoices?page=1&per_page=10&source=manual"); response.EnsureSuccessStatusCode(); // Throws if HTTP status code is not 2xx var responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } } } ``` -------------------------------- ### Get Invoices using Kotlin OkHttp Source: https://developer.sepay.vn/vi/einvoice-api/v1/danh-sach-hoa-don This Kotlin example shows how to fetch invoice data using the OkHttp library. Ensure your Bearer token is correctly provided in the Authorization header. ```kotlin import okhttp3.OkHttpClient import okhttp3.Request fun getInvoices() { val client = OkHttpClient() val request = Request.Builder() .url("https://einvoice-api.sepay.vn/v1/invoices?page=1&per_page=10&source=manual") .get() .addHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN") .build() val response = client.newCall(request).execute() // Handle response here println(response.body?.string()) } ``` -------------------------------- ### Get Bank Account Details in C# Source: https://developer.sepay.vn/vi/sepay-api/v2/tai-khoan-ngan-hang/chi-tiet This C# example demonstrates how to fetch bank account details using HttpClient. Remember to substitute 'REPLACE_BEARER_TOKEN' with your valid bearer token. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri("https://userapi.sepay.vn/v2/bank-accounts/f9e8d7c6-b5a4-3210-fedc-ba0987654321"), Headers = { { "Authorization", "Bearer REPLACE_BEARER_TOKEN" }, }, }; using (var response = await client.SendAsync(request)) { response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body); } ``` -------------------------------- ### Swift NSURLSession Example Source: https://developer.sepay.vn/vi/bankhub/api/api-merchant/bo-dem-merchant Example of making a GET request to the merchant-config/counter endpoint using Swift's NSURLSession. ```swift import Foundation let headers = ["Authorization": "Bearer REPLACE_BEARER_TOKEN"] let request = NSMutableURLRequest(url: NSURL(string: "https://bankhub-api-sandbox.sepay.vn/v1/merchant-config/counter?start_date=2026-04-01&end_date=2026-04-03")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### API Response Example (200 OK) Source: https://developer.sepay.vn/vi/speaker-api/yeu-cau-lien-ket-thiet-bi This example shows a successful response when a device linking request is sent. It includes device details and session information. ```json { "code": 200, "message": "Thành công", "data": { "hardwareId": "VNS52508000001", "model": "S5 Plus", "isPaired": false, "session_id": "8b9f6d2a-3c1b-4f7a-a7d4-123456789abc", "online": true } } ``` -------------------------------- ### Initialize SePay Client Source: https://developer.sepay.vn/vi/cong-thanh-toan/sdk/php Initialize the SePay client with your merchant ID, secret key, and environment. Use ENVIRONMENT_SANDBOX for testing and ENVIRONMENT_PRODUCTION for live transactions. ```php use SePay\SePayClient; use SePay\Builders\CheckoutBuilder; // Initialize client $sepay = new SePayClient( 'SP-TEST-XXXXXXX', 'spsk_live_xxxxxxxxxxxo99PoE7RsBpss3EFH5nV', SePayClient::ENVIRONMENT_SANDBOX, // or ENVIRONMENT_PRODUCTION [] ); ``` -------------------------------- ### Java OkHttp Example Source: https://developer.sepay.vn/vi/sepay-api/v2/don-hang/danh-sach Demonstrates how to fetch a list of orders using OkHttp in Java. Ensure you replace 'REPLACE_BEARER_TOKEN' with your actual token. ```java OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder() .url("https://userapi.sepay.vn/v2/bank-accounts/f9e8d7c6-b5a4-3210-fedc-ba0987654321/orders?created_at_sort=SOME_STRING_VALUE&amount_sort=SOME_STRING_VALUE&page=SOME_INTEGER_VALUE&per_page=SOME_INTEGER_VALUE") .get() .addHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN") .build(); Response response = client.newCall(request).execute(); ``` -------------------------------- ### Get Company List (Node.js) Source: https://developer.sepay.vn/vi/bankhub/api/cong-ty/danh-sach-cong-ty This Node.js example shows how to make a GET request to retrieve company data. It uses the built-in 'https' module. ```javascript const http = require("https"); const options = { "method": "GET", "hostname": "bankhub-api-sandbox.sepay.vn", "port": null, "path": "/v1/company?page=SOME_INTEGER_VALUE&per_page=SOME_INTEGER_VALUE&q=SOME_STRING_VALUE&status=SOME_STRING_VALUE&sort%5Bcreated_at%5D=SOME_STRING_VALUE", "headers": { "Authorization": "Bearer REPLACE_BEARER_TOKEN" } }; const req = http.request(options, function (res) { const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); }); req.end(); ``` -------------------------------- ### Install Node.js Dependencies Source: https://developer.sepay.vn/vi/sepay-webhooks/lap-trinh-webhooks/lap-trinh-webhook-nodejs Initialize your Node.js project and install essential packages like express, mysql2, and dotenv. ```bash npm init -y npm install express mysql2 dotenv ``` -------------------------------- ### Run Node.js Server Source: https://developer.sepay.vn/vi/sepay-webhooks/lap-trinh-webhooks/lap-trinh-webhook-nodejs Starts the Node.js server for handling webhooks. ```bash node server.js ``` -------------------------------- ### Swift NSURLSession Example Source: https://developer.sepay.vn/vi/sepay-api/v2/don-hang/danh-sach A Swift example using NSURLSession to make a GET request for orders. It handles potential errors and prints the HTTP response. ```swift import Foundation let headers = ["Authorization": "Bearer REPLACE_BEARER_TOKEN"] let request = NSMutableURLRequest(url: NSURL(string: "https://userapi.sepay.vn/v2/bank-accounts/f9e8d7c6-b5a4-3210-fedc-ba0987654321/orders?created_at_sort=SOME_STRING_VALUE&amount_sort=SOME_STRING_VALUE&page=SOME_INTEGER_VALUE&per_page=SOME_INTEGER_VALUE")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Go Native HTTP Example Source: https://developer.sepay.vn/vi/speaker-api/api-chi-tiet-trang-thai-bien-dong-so-du Provides a Go example for making a POST request to check transaction status. It includes reading the response body and printing it to the console. ```go package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://speaker-api.sepay.vn/devices/v1/speaker/transactions/check_notify" payload := strings.NewReader("{\"requestId\":\"TXN202510130001\"}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer REPLACE_BEARER_TOKEN") req.Header.Add("content-type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Provider Accounts (Node.js) Source: https://developer.sepay.vn/vi/einvoice-api/v1/bat-dau-nhanh This Node.js example shows how to make a GET request to retrieve provider accounts. Ensure your authorization token is correctly inserted. ```javascript const http = require("https"); const options = { "method": "GET", "hostname": "einvoice-api.sepay.vn", "port": null, "path": "/v1/provider-accounts?page=1&per_page=20", "headers": { "Authorization": "Bearer REPLACE_BEARER_TOKEN" } }; const req = http.request(options, function (res) { const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); }); req.end(); ``` -------------------------------- ### Kotlin OkHttp Example Source: https://developer.sepay.vn/vi/sepay-api/v2/don-hang/danh-sach Shows how to fetch orders using OkHttp in Kotlin. Remember to replace the placeholder bearer token. ```kotlin val client = OkHttpClient() val request = Request.Builder() .url("https://userapi.sepay.vn/v2/bank-accounts/f9e8d7c6-b5a4-3210-fedc-ba0987654321/orders?created_at_sort=SOME_STRING_VALUE&amount_sort=SOME_STRING_VALUE&page=SOME_INTEGER_VALUE&per_page=SOME_INTEGER_VALUE") .get() .addHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN") .build() val response = client.newCall(request).execute() ``` -------------------------------- ### Get Transaction Details (Node.js) Source: https://developer.sepay.vn/vi/sepay-api/v2/giao-dich/chi-tiet This Node.js example shows how to make a GET request to retrieve transaction details. Remember to replace the placeholder Bearer token. ```javascript const http = require("https"); const options = { "method": "GET", "hostname": "userapi.sepay.vn", "port": null, "path": "/v2/transactions/a1b2c3d4-e5f6-7890-abcd-ef1234567890", "headers": { "Authorization": "Bearer REPLACE_BEARER_TOKEN" } }; const req = http.request(options, function (res) { const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); }); req.end(); ``` -------------------------------- ### Fetch Virtual Accounts (Go) Source: https://developer.sepay.vn/vi/sepay-api/v2/tai-khoan-ao/danh-sach This Go program demonstrates how to fetch virtual account information using the standard `net/http` package. It includes necessary imports and error handling for the HTTP request. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://userapi.sepay.vn/v2/bank-accounts/f9e8d7c6-b5a4-3210-fedc-ba0987654321/va?q=SOME_STRING_VALUE&active=SOME_STRING_VALUE&official=SOME_INTEGER_VALUE&static=SOME_INTEGER_VALUE&created_at_sort=SOME_STRING_VALUE&page=SOME_INTEGER_VALUE&per_page=SOME_INTEGER_VALUE" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer REPLACE_BEARER_TOKEN") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Swift URLSession GET Request Source: https://developer.sepay.vn/vi/bankhub/api/cong-ty/danh-sach-cong-ty An example of making a GET request to the Company API using Swift's URLSession. Replace the placeholder bearer token. ```swift import Foundation let headers = ["Authorization": "Bearer REPLACE_BEARER_TOKEN"] let request = NSMutableURLRequest(url: NSURL(string: "https://bankhub-api-sandbox.sepay.vn/v1/company?page=SOME_INTEGER_VALUE&per_page=SOME_INTEGER_VALUE&q=SOME_STRING_VALUE&status=SOME_STRING_VALUE&sort%5Bcreated_at%5D=SOME_STRING_VALUE")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Java OkHttp Example Source: https://developer.sepay.vn/vi/speaker-api/api-chi-tiet-trang-thai-bien-dong-so-du Demonstrates how to make a POST request to check transaction status using OkHttp in Java. Ensure OkHttp library is included in your project. ```java OkHttpClient client = new OkHttpClient(); MediaType mediaType = MediaType.parse("application/json"); RequestBody body = RequestBody.create(mediaType, "{\"requestId\":\"TXN202510130001\"}"); Request request = new Request.Builder() .url("https://speaker-api.sepay.vn/devices/v1/speaker/transactions/check_notify") .post(body) .addHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN") .addHeader("content-type", "application/json") .build(); Response response = client.newCall(request).execute(); ``` -------------------------------- ### Get Order Details using Python http.client Source: https://developer.sepay.vn/vi/sepay-api/v2/don-hang/chi-tiet This Python example shows how to get order details using the http.client library. Replace 'REPLACE_BEARER_TOKEN' with your actual token. ```python import http.client conn = http.client.HTTPSConnection("userapi.sepay.vn") headers = { 'Authorization': "Bearer REPLACE_BEARER_TOKEN" } conn.request("GET", "/v2/bank-accounts/f9e8d7c6-b5a4-3210-fedc-ba0987654321/orders/b2c3d4e5-f6a7-8901-bcde-f12345678902", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` -------------------------------- ### Ruby Net::HTTP Example Source: https://developer.sepay.vn/vi/sepay-api/v2/don-hang/danh-sach Shows how to retrieve orders using Ruby's native Net::HTTP library. SSL verification is disabled for simplicity; adjust as needed for production. ```ruby require 'uri' require 'net/http' require 'openssl' url = URI("https://userapi.sepay.vn/v2/bank-accounts/f9e8d7c6-b5a4-3210-fedc-ba0987654321/orders?created_at_sort=SOME_STRING_VALUE&amount_sort=SOME_STRING_VALUE&page=SOME_INTEGER_VALUE&per_page=SOME_INTEGER_VALUE") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer REPLACE_BEARER_TOKEN' response = http.request(request) puts response.read_body ``` -------------------------------- ### C#: Fetch Provider Accounts with HttpClient Source: https://developer.sepay.vn/vi/einvoice-api/v1/danh-sach-tai-khoan This C# example demonstrates fetching provider accounts using HttpClient. Remember to replace the placeholder bearer token. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri("https://einvoice-api.sepay.vn/v1/provider-accounts?page=1&per_page=20"), Headers = { { "Authorization", "Bearer REPLACE_BEARER_TOKEN" }, }, }; using (var response = await client.SendAsync(request)) { response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body); } ``` -------------------------------- ### Get Merchant Configuration using .NET HttpClient Source: https://developer.sepay.vn/vi/bankhub/api/api-merchant/thong-tin-cau-hinh This .NET example shows how to get merchant configuration using HttpClient. Ensure the Authorization header is correctly set with your Bearer token. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class MerchantConfigFetcher { public static async Task GetConfigAsync() { using (var client = new HttpClient()) { client.BaseAddress = new Uri("https://bankhub-api-sandbox.sepay.vn/"); client.DefaultRequestHeaders.Add("Authorization", "Bearer REPLACE_BEARER_TOKEN"); HttpResponseMessage response = await client.GetAsync("v1/merchant-config"); response.EnsureSuccessStatusCode(); // Throw if HTTP status code is not 2xx string responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } } } ``` -------------------------------- ### Get Order Detail using NodeJS Source: https://developer.sepay.vn/vi/cong-thanh-toan/API/don-hang/chi-tiet-don-hang This NodeJS example shows how to make a GET request to fetch order details using the native 'https' module. Replace 'REPLACE_BASIC_AUTH' with your actual credentials. ```javascript const http = require("https"); const options = { "method": "GET", "hostname": "pgapi.sepay.vn", "port": null, "path": "/v1/order/detail/SEPAY-68BA83CE637C1", "headers": { "Authorization": "Basic REPLACE_BASIC_AUTH" } }; const req = http.request(options, function (res) { const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); }); req.end(); ``` -------------------------------- ### C#: Fetch Provider Account Details with HttpClient Source: https://developer.sepay.vn/vi/einvoice-api/v1/chi-tiet-tai-khoan This C# example demonstrates how to fetch provider account details using HttpClient. It includes setting the Authorization header and handling the response asynchronously. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri("https://einvoice-api.sepay.vn/v1/provider-accounts/0aea3134-da40-11f0-aef4-52c7e9b4f41b"), Headers = { { "Authorization", "Bearer REPLACE_BEARER_TOKEN" }, }, }; using (var response = await client.SendAsync(request)) { response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body); } ``` -------------------------------- ### Get Bank Account Details with NodeJS Source: https://developer.sepay.vn/vi/bankhub/api/tai-khoan-ngan-hang/chi-tiet-tai-khoan This NodeJS example shows how to make a GET request to fetch bank account details. Ensure your bearer token is correctly inserted in place of 'REPLACE_BEARER_TOKEN'. ```javascript const http = require("https"); const options = { "method": "GET", "hostname": "bankhub-api-sandbox.sepay.vn", "port": null, "path": "/v1/bank-account/780717f8-eeb6-11f0-b16e-52c7e9b4f41b", "headers": { "Authorization": "Bearer REPLACE_BEARER_TOKEN" } }; const req = http.request(options, function (res) { const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); }); req.end(); ``` -------------------------------- ### Get Virtual Account Details in C# Source: https://developer.sepay.vn/vi/sepay-api/v2/tai-khoan-ao/chi-tiet Use this C# example with HttpClient to get virtual account details. Ensure you replace 'REPLACE_BEARER_TOKEN' with your authentication token. The code handles the response and prints the body. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri("https://userapi.sepay.vn/v2/bank-accounts/f9e8d7c6-b5a4-3210-fedc-ba0987654321/va/c3d4e5f6-a7b8-9012-cdef-123456789013"), Headers = { { "Authorization", "Bearer REPLACE_BEARER_TOKEN" }, }, }; using (var response = await client.SendAsync(request)) { response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body); } ``` -------------------------------- ### Kotlin OkHttp Example Source: https://developer.sepay.vn/vi/speaker-api/api-chi-tiet-trang-thai-bien-dong-so-du Provides a Kotlin example using OkHttp to send a POST request for checking transaction status. Similar to the Java version but with Kotlin syntax. ```kotlin val client = OkHttpClient() val mediaType = MediaType.parse("application/json") val body = RequestBody.create(mediaType, "{\"requestId\":\"TXN202510130001\"}") val request = Request.Builder() .url("https://speaker-api.sepay.vn/devices/v1/speaker/transactions/check_notify") .post(body) .addHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN") .addHeader("content-type", "application/json") .build() val response = client.newCall(request).execute() ``` -------------------------------- ### Get Invoice Details with Ruby Source: https://developer.sepay.vn/vi/einvoice-api/v1/chi-tiet-hoa-don Retrieve invoice details using Ruby's Net::HTTP library. This example sets up the URI, HTTP connection, and sends a GET request with the Authorization header. ```ruby require 'uri' require 'net/http' require 'openssl' url = URI("https://einvoice-api.sepay.vn/v1/invoices/084e179d-d95a-11f0-aef4-52c7e9b4f41b") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer REPLACE_BEARER_TOKEN' response = http.request(request) puts response.read_body ``` -------------------------------- ### C#: Simulate Transaction with HttpClient Source: https://developer.sepay.vn/vi/bankhub/api/api-giao-dich/gia-lap-giao-dich Simulate a transaction using C# and HttpClient. This example shows how to set up the POST request, including headers and JSON content. Replace the bearer token as needed. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage { Method = HttpMethod.Post, RequestUri = new Uri("https://bankhub-api-sandbox.sepay.vn/v1/transaction/create"), Headers = { { "Authorization", "Bearer REPLACE_BEARER_TOKEN" }, }, Content = new StringContent("{\"bank_account_xid\":\"52930e2b-c38b-4cd1-b2a2-9ddcdc603104\",\"transfer_type\":\"credit\",\"amount\":0,\"transaction_content\":\"string\"}") { Headers = { ContentType = new MediaTypeHeaderValue("application/json") } } }; using (var response = await client.SendAsync(request)) { response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body); } ``` -------------------------------- ### C# HttpClient Example Source: https://developer.sepay.vn/vi/sepay-api/v2/don-hang/danh-sach Illustrates fetching order data using C#'s HttpClient. It ensures the response is successful and reads the content as a string. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri("https://userapi.sepay.vn/v2/bank-accounts/f9e8d7c6-b5a4-3210-fedc-ba0987654321/orders?created_at_sort=SOME_STRING_VALUE&amount_sort=SOME_STRING_VALUE&page=SOME_INTEGER_VALUE&per_page=SOME_INTEGER_VALUE"), Headers = { { "Authorization", "Bearer REPLACE_BEARER_TOKEN" }, }, }; using (var response = await client.SendAsync(request)) { response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body); } ``` -------------------------------- ### Swift URLSession GET Request for Bank Accounts Source: https://developer.sepay.vn/vi/bankhub/api/tai-khoan-ngan-hang/danh-sach-tai-khoan Example of making a GET request for bank accounts using Swift's URLSession. Replace the bearer token and adjust query parameters as needed. ```swift import Foundation let headers = ["Authorization": "Bearer REPLACE_BEARER_TOKEN"] let request = NSMutableURLRequest(url: NSURL(string: "https://bankhub-api-sandbox.sepay.vn/v1/bank-account?page=SOME_INTEGER_VALUE&per_page=SOME_INTEGER_VALUE&company_xid=SOME_STRING_VALUE&bank_id=SOME_STRING_VALUE&q=SOME_STRING_VALUE")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Get Link Token Info using NodeJS Source: https://developer.sepay.vn/vi/bankhub/api/link-token/thong-tin-link-token This NodeJS example demonstrates making a POST request to get link token information. Ensure your bearer token is correctly set in the 'Authorization' header. ```javascript const http = require("https"); const options = { "method": "POST", "hostname": "bankhub-api-sandbox.sepay.vn", "port": null, "path": "/v1/link-token/get", "headers": { "Authorization": "Bearer REPLACE_BEARER_TOKEN", "content-type": "application/json" } }; const req = http.request(options, function (res) { const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); }); req.write(JSON.stringify({link_token: '3034ccc8-9cad-4b39-adb3-738c554a7b77'})); req.end(); ``` -------------------------------- ### Get Company Counter Data using NodeJS Source: https://developer.sepay.vn/vi/bankhub/api/cong-ty/bo-dem-cong-ty This NodeJS example shows how to make a GET request for company counter data using the built-in https module. Update 'REPLACE_BEARER_TOKEN' and 'SOME_STRING_VALUE' as needed. ```javascript const http = require("https"); const options = { "method": "GET", "hostname": "bankhub-api-sandbox.sepay.vn", "port": null, "path": "/v1/company/counter/d3dafd01-e06b-11f0-b29e-52c7e9b4f41b?date=SOME_STRING_VALUE", "headers": { "Authorization": "Bearer REPLACE_BEARER_TOKEN" } }; const req = http.request(options, function (res) { const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); }); req.end(); ``` -------------------------------- ### Get Order Detail using Go HTTP Client Source: https://developer.sepay.vn/vi/cong-thanh-toan/API/don-hang/chi-tiet-don-hang This Go program demonstrates fetching order details using the standard net/http package. It constructs a GET request with the required Authorization header. Replace 'REPLACE_BASIC_AUTH' with your token. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://pgapi.sepay.vn/v1/order/detail/SEPAY-68BA83CE637C1" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Basic REPLACE_BASIC_AUTH") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Swift URLSession GET Request for Prefixes Source: https://developer.sepay.vn/vi/sepay-api/v2/don-hang/tien-to-va An example in Swift using URLSession to make a GET request for bank account prefixes. This snippet shows how to set headers and handle the response. Ensure your bearer token is correctly substituted. ```swift import Foundation let headers = ["Authorization": "Bearer REPLACE_BEARER_TOKEN"] let request = NSMutableURLRequest(url: NSURL(string: "https://userapi.sepay.vn/v2/bank-accounts/f9e8d7c6-b5a4-3210-fedc-ba0987654321/prefixes?page=SOME_INTEGER_VALUE&per_page=SOME_INTEGER_VALUE")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Get Company Details Source: https://developer.sepay.vn/vi/bankhub/api/cong-ty/chi-tiet-cong-ty Fetches the details of a specific company using its ID. Includes examples for C#, Swift, and Kotlin. ```APIDOC ## GET /v1/company/{companyId} ### Description Retrieves detailed information about a specific company. ### Method GET ### Endpoint /v1/company/{companyId} ### Parameters #### Path Parameters - **companyId** (string) - Required - The unique identifier of the company. #### Headers - **Authorization** (string) - Required - Bearer token for authentication. ### Request Example ```json { "example": "" } ``` ### Response #### Success Response (200) - **[Fields will be documented here based on actual response structure]** #### Response Example ```json { "example": "[Response body will be documented here]" } ``` ### Error Handling - **404 Not Found**: Company ID does not exist, does not belong to the authenticated merchant, or is incorrectly formatted. Always check the status code before processing the response. ``` -------------------------------- ### Create Company using Go net/http Source: https://developer.sepay.vn/vi/bankhub/api/cong-ty/tao-cong-ty A Go program demonstrating how to create a company via the API. Replace 'REPLACE_BEARER_TOKEN' with your actual authorization token. ```go package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://bankhub-api-sandbox.sepay.vn/v1/company/create" payload := strings.NewReader("{\"full_name\":\"string\",\"status\":\"Active\"}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer REPLACE_BEARER_TOKEN") req.Header.Add("content-type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Webhook Information (Java) Source: https://developer.sepay.vn/vi/bankhub/api/api-webhook/thong-tin-webhook Example using OkHttp in Java to retrieve webhook information. Replace 'REPLACE_BEARER_TOKEN' with your authentication token. ```java OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder() .url("https://bankhub-api-sandbox.sepay.vn/v1/webhook") .get() .addHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN") .build(); Response response = client.newCall(request).execute(); ``` -------------------------------- ### Fetch Orders with Swift URLSession Source: https://developer.sepay.vn/vi/cong-thanh-toan/API/don-hang/danh-sach-don-hang This Swift example demonstrates fetching orders using `URLSession`. Replace 'REPLACE_BASIC_AUTH' with your Basic Auth credentials before execution. ```swift import Foundation let headers = ["Authorization": "Basic REPLACE_BASIC_AUTH"] let request = NSMutableURLRequest(url: NSURL(string: "https://pgapi.sepay.vn/v1/order?per_page=50&page=1&q=INV_20231201&order_status=CAPTURED&customer_id=CUST_001&created_at=2023-12-01&from_created_at=2023-12-01&end_created_at=2023-12-31&sort=created_at%3Adesc")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Kotlin OkHttp Example Source: https://developer.sepay.vn/vi/einvoice-api/v1/danh-sach-hoa-don Implement OkHttp in Kotlin to make a GET request to the Sepay Invoice API. Replace 'REPLACE_BEARER_TOKEN' with your authentication token. ```kotlin val client = OkHttpClient() val request = Request.Builder() .url("https://einvoice-api.sepay.vn/v1/invoices?page=1&per_page=10&source=manual") .get() .addHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN") .build() val response = client.newCall(request).execute() ```