### Install payOS SDK Source: https://payos.vn/docs/sdks/back-end/golang Use go get to install the library in your project. ```bash go get github.com/payOSHQ/payos-lib-golang/v2 ``` -------------------------------- ### Start Development Server Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form Run the 'npm run start' command to simultaneously launch your client and server applications. Access your application at http://localhost:3000. ```bash npm run start ``` -------------------------------- ### Run Application Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form Commands to start the .NET server and React client. ```bash # server side dotnet run # client side npm start ``` -------------------------------- ### Installation Source: https://payos.vn/docs/sdks/back-end/net Install the payOS package using the .NET CLI. ```APIDOC ## Installation Install the `payOS` package through the dotnet CLI: ```bash dotnet add package payOS ``` ``` -------------------------------- ### Install PHP SDK Source: https://payos.vn/docs/sdks/intro Use composer to install the payOS PHP library. ```shell composer require payos/payos ``` -------------------------------- ### Install payOS .NET Package Source: https://payos.vn/docs/checkout/quick-start-payos-hosted-page Commands to install the payOS library for .NET projects. ```bash dotnet add package payOS ``` ```powershell Install-Package payOS ``` -------------------------------- ### Start Node.js Server Source: https://payos.vn/docs/checkout/quick-start-payos-hosted-page Command to launch the local development server. ```shell npm start ``` -------------------------------- ### Installation Source: https://payos.vn/docs/sdks/back-end/python Install the payos library using pip. ```APIDOC ## Installation Install the `payos` library using pip: ```bash # Windows pip install payos # Linux/macOS pip3 install payos ``` ``` -------------------------------- ### Run Development Servers Source: https://payos.vn/docs/checkout/quick-start-payos-hosted-page Commands to start the Go backend and the React frontend development environments. ```bash # server side go run server.go # client side npm start ``` -------------------------------- ### Install NodeJS SDK Source: https://payos.vn/docs/sdks/back-end/node Install the @payos/node package using npm or yarn. ```bash npm install @payos/node # hoặc yarn add @payos/node ``` -------------------------------- ### Installation Source: https://payos.vn/docs/sdks/back-end/php Install the PayOS PHP SDK using Composer. ```APIDOC ## Installation Install the `payos/payos` library via Composer: ```bash composer require payos/payos ``` ``` -------------------------------- ### Install Python SDK Source: https://payos.vn/docs/sdks/intro Install the payOS package using pip for Windows or pip3 for Linux/macOS. ```shell # Windows pip install payos # Linux/macOS pip3 install payos ``` -------------------------------- ### Run Server Command Source: https://payos.vn/docs/checkout/quick-start-payos-hosted-page Execute this command in your terminal to start the Go server. ```bash go run server.go ``` -------------------------------- ### Run Local Servers Source: https://payos.vn/docs/checkout/quick-start-payos-hosted-page Start your local development servers for both the backend and frontend. Ensure your package.json includes the proxy setting. ```bash # server side php -S localhost:3030 --docroot=public # client side npm start ``` -------------------------------- ### Install PayOS Python SDK Source: https://payos.vn/docs/sdks/back-end/python Install the payos library using pip. Use pip for Windows and pip3 for Linux/macOS. ```bash # Windows pip install payos ``` ```bash # Linux/macOS pip3 install payos ``` -------------------------------- ### Initialize PayOS server.py Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form Basic setup for the server.py file including necessary imports for PayOS and Flask. ```python """ server.py PayOS Sample. Python 3.6 or newer required. """ import time from flask import Flask, send_from_directory from payos import CreatePaymentLinkRequest, PayOS ``` -------------------------------- ### Install PayOS Checkout Library (yarn) Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form Install the payos-checkout library for React applications using yarn. ```bash yarn add @payos/payos-checkout ``` -------------------------------- ### Run .NET Application Source: https://payos.vn/docs/checkout/quick-start-payos-hosted-page Execute this command in your project directory to run the .NET server and start the application. ```bash dotnet run ``` -------------------------------- ### Initialize Go Server and Payment Link Source: https://payos.vn/docs/checkout/quick-start-payos-hosted-page Setup the payOS client in Go and define the endpoint for creating payment links. ```go package main import ( "log" "net/http" "time" "github.com/payOSHQ/payos-lib-golang/v2" ) var payOSClient *payos.PayOS func main() { // Keep your PayOS key protected by including it by an env variable const clientId = "YOUR_CLIENT_ID" const apiKey = "YOUR_API_KEY" const checksumKey = "YOUR_CHECKSUM_KEY" var err error payOSClient, err = payos.NewPayOS(&payos.PayOSOptions{ ClientID: clientId, APIKey: apiKey, ChecksumKey: checksumKey, }) if err != nil { log.Fatalf("Failed to create PayOS client: %v", err) } http.Handle("/", http.FileServer(http.Dir("public"))) http.HandleFunc("/create-payment-link", createPaymentLink) addr := "localhost:3030" log.Printf("Listening on %s", addr) log.Fatal(http.ListenAndServe(addr, nil)) } func createPaymentLink(w http.ResponseWriter, r *http.Request) { domain := "http://localhost:3030" paymentLinkRequest := payos.CreatePaymentLinkRequest{ OrderCode: time.Now().UnixNano() / int64(time.Millisecond), Amount: 2000, Description: "Thanh toan don hang", CancelUrl: domain, ReturnUrl: domain, } paymentLinkResponse, err := payOSClient.PaymentRequests.Create(r.Context(), &paymentLinkRequest) ``` -------------------------------- ### Install payos-checkout Library Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form Install the payos-checkout library using npm or yarn to enable PayOS checkout functionality. ```bash npm install @payos/payos-checkout # hoặc yarn add @payos/payos-checkout ``` -------------------------------- ### Install .NET Core SDK Source: https://payos.vn/docs/sdks/intro Add the payOS package to your .NET project using the dotnet CLI. ```shell dotnet add package payOS ``` -------------------------------- ### Run Server and Client Applications Source: https://payos.vn/docs/checkout/quick-start-payos-hosted-page Commands to start the server-side and client-side applications for testing PayOS integration. Ensure the proxy is set in package.json. ```bash # server side dotnet run ``` ```bash # client side npm start ``` -------------------------------- ### Initialize PayOS Server Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form Basic setup for a PayOS server using Flask. Requires Python 3.6 or newer. ```python """ server.py PayOS Sample. Python 3.6 or newer required. """ import time from flask import Flask, send_from_directory from payos import CreatePaymentLinkRequest, PayOS ``` -------------------------------- ### Install Node.js SDK Source: https://payos.vn/docs/sdks/intro Use npm or yarn to add the payOS Node.js package to your project. ```shell npm install @payos/node --save ``` ```shell yarn add @payos/node ``` -------------------------------- ### Install payOS Checkout Library Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form Commands to add the payOS checkout library to a React project. ```bash npm install @payos/payos-checkout ``` ```bash yarn add @payos/payos-checkout ``` -------------------------------- ### PayOS SDK Initialization Source: https://payos.vn/docs/sdks/back-end/java Code examples for initializing the PayOS SDK, either by using environment variables or by directly providing credentials. ```APIDOC ## PayOS SDK Initialization Initialize the PayOS object using environment variables or by passing credentials directly. ```java import vn.payos.PayOS; // Initialize from environment variables PayOS payOS = PayOS.fromEnv(); // Or initialize directly PayOS payOS = new PayOS( System.getenv("PAYOS_CLIENT_ID"), System.getenv("PAYOS_API_KEY"), System.getenv("PAYOS_CHECKSUM_KEY") ); ``` ``` -------------------------------- ### Run Flask Development Server Source: https://payos.vn/docs/checkout/quick-start-payos-hosted-page Starts the Flask development server on port 3030 for testing payment link creation. ```bash flask run --port=3030 ``` -------------------------------- ### Run Sample Server and Client Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form Instructions for running the server-side Flask application and the client-side Node.js application. ```bash # server side flask run --port=3030 ``` ```bash # client side npm start ``` -------------------------------- ### Run Local Development Server Source: https://payos.vn/docs/checkout/quick-start-payos-hosted-page Start a local PHP development server to test payment link creation. Ensure the 'public' directory is set as the document root. ```bash php -S localhost:3030 --docroot=public ``` -------------------------------- ### Run PayOS Sample Server Source: https://payos.vn/docs/checkout/quick-start-payos-hosted-page Execute this command to run the sample server. Ensure the JAR file path is correct. ```bash java -cp .\target\payos-payment-1.0-SNAPSHOT-jar-with-dependencies.jar vn.payos.sample.Server ``` -------------------------------- ### Install PayOS Checkout SDK for Front‑End Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form Shell commands to install the PayOS Checkout JavaScript package using npm or Yarn. Required before importing usePayOS in a React project. No runtime code, just package manager installation. ```bash npm install @payos/payos-checkout # hoặc yarn add @payos/payos-checkout ``` -------------------------------- ### Install PayOS Library for Python Source: https://payos.vn/docs/checkout/quick-start-payos-hosted-page Install the PayOS SDK for Python using pip. This command should be run in your project's terminal. ```bash pip install payos ``` -------------------------------- ### Initialize PayOS Server with Spark Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form Sets up a Spark server to handle payment link creation requests using the PayOS SDK. ```java package vn.payos.sample; import static spark.Spark.port; import static spark.Spark.post; import static spark.Spark.staticFiles; import java.nio.file.Paths; import vn.payos.PayOS; import vn.payos.model.v2.paymentRequests.CreatePaymentLinkRequest; import vn.payos.model.v2.paymentRequests.CreatePaymentLinkResponse; public class Server { public static void main(String[] args) { port(3000); String clientId = "YOUR_CLIENT_ID"; String apiKey = "YOUR_API_KEY"; String checksumKey = "YOUR_CHECKSUM_KEY"; final PayOS payOS = new PayOS(clientId, apiKey, checksumKey); staticFiles.externalLocation(Paths.get("public").toAbsolutePath().toString()); post( "/create-embedded-payment-link", (request, response) -> { String domain = "http://localhost:3000/"; Long orderCode = System.currentTimeMillis() / 1000; CreatePaymentLinkRequest paymentData = CreatePaymentLinkRequest.builder() .orderCode(orderCode) .amount(2000) .description("Thanh toán đơn hàng") .returnUrl(domain) .cancelUrl(domain) .build(); CreatePaymentLinkResponse result = payOS.paymentRequests().create(paymentData); response.type("application/json"); return new com.google.gson.Gson().toJson(result); }); } } ``` -------------------------------- ### Install payOS Checkout with yarn Source: https://payos.vn/docs/sdks/front-end/script-js Install the payOS checkout package using yarn. This command adds the necessary library to your project's dependencies. ```bash yarn add payos-checkout ``` -------------------------------- ### Install payOS Checkout with npm Source: https://payos.vn/docs/sdks/front-end/script-js Install the payOS checkout package using npm. This command adds the necessary library to your project's dependencies. ```bash npm install payos-checkout --save ``` -------------------------------- ### Initialize PayOS Go Server Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form Sets up a Go HTTP server that initializes the PayOS client and provides an endpoint to generate payment links. ```go package main import ( "encoding/json" "log" "net/http" "time" "github.com/payOSHQ/payos-lib-golang/v2" ) var payOSClient *payos.PayOS func main() { // Keep your PayOS key protected by including it by an env variable const clientId = "YOUR_CLIENT_ID" const apiKey = "YOUR_API_KEY" const checksumKey = "YOUR_CHECKSUM_KEY" var err error payOSClient, err = payos.NewPayOS(&payos.PayOSOptions{ ClientID: clientId, APIKey: apiKey, ChecksumKey: checksumKey, }) if err != nil { log.Fatalf("Failed to create PayOS client: %v", err) } http.Handle("/", http.FileServer(http.Dir("public"))) http.HandleFunc("/create-embedded-payment-link", createPaymentLink) addr := "localhost:3030" log.Printf("Listening on %s", addr) log.Fatal(http.ListenAndServe(addr, nil)) } func createPaymentLink(w http.ResponseWriter, r *http.Request) { domain := "http://localhost:3030/" paymentLinkRequest := payos.CreatePaymentLinkRequest{ OrderCode: time.Now().UnixNano() / int64(time.Millisecond), Amount: 2000, Description: "Thanh toan don hang", CancelUrl: domain, ReturnUrl: domain, } paymentLinkResponse, err := payOSClient.PaymentRequests.Create(r.Context(), &paymentLinkRequest) if err != nil { log.Printf("Create payment link failed: %v", err) } // Return paymentLinkResponse as JSON instead of redirect w.Header().Set("Content-Type", "application/json") if err := json.NewEncoder(w).Encode(paymentLinkResponse); err != nil { log.Printf("Failed to encode response: %v", err) } } ``` -------------------------------- ### GET /v1/payouts-account/balance Source: https://payos.vn/docs/api Retrieves the balance information for the payout account. ```APIDOC ## GET /v1/payouts-account/balance ### Description API dùng để lấy thông tin số dư tài khoản chi. ### Method GET ### Endpoint https://api-merchant.payos.vn/v1/payouts-account/balance ``` -------------------------------- ### Initialize PayOS client Source: https://payos.vn/docs/sdks/back-end/java Create a PayOS instance using environment variables or direct parameter injection. ```java import vn.payos.PayOS; // Khởi tạo từ biến môi trường PayOS payOS = PayOS.fromEnv(); // Hoặc khởi tạo trực tiếp PayOS payOS = new PayOS( System.getenv("PAYOS_CLIENT_ID"), System.getenv("PAYOS_API_KEY"), System.getenv("PAYOS_CHECKSUM_KEY") ); ``` -------------------------------- ### GET /v1/payouts/{payoutId} Source: https://payos.vn/docs/api Retrieves detailed information about a specific payout. ```APIDOC ## GET /v1/payouts/{payoutId} ### Description API dùng để lấy thông tin chi tiết của một lệnh chi. ### Method GET ### Endpoint https://api-merchant.payos.vn/v1/payouts/{payoutId} ### Parameters #### Path Parameters - **payoutId** (string) - Required - ID của lệnh chi ### Response #### Success Response (200) - **data** (object) - Thông tin chi tiết lệnh chi #### Response Example { "code": "00", "desc": "success", "data": { "id": "payout_123456789", "approvalState": "PROCESSING" } } ``` -------------------------------- ### GET /v1/payouts Source: https://payos.vn/docs/api Retrieves a list of payouts with optional filtering parameters. ```APIDOC ## GET /v1/payouts ### Description API used to retrieve a list of payout orders. ### Method GET ### Endpoint https://api-merchant.payos.vn/v1/payouts ### Parameters #### Query Parameters - **limit** (integer) - Optional - Default: 10. Number of results per page. - **offset** (integer) - Optional - Default: 0. Starting position. - **referenceId** (string) - Optional - Filter by reference ID. - **approvalState** (string) - Optional - Filter by approval state. - **category** (string) - Optional - Filter by category (comma separated). - **fromDate** (string) - Optional - Filter from date (ISO 8601). - **toDate** (string) - Optional - Filter to date (ISO 8601). ### Response #### Success Response (200) - **data** (object) - Contains list of payouts and pagination info. #### Response Example { "code": "00", "desc": "success", "data": { "payouts": { ... }, "pagination": { "total": 1, "limit": 10, "offset": 0 } } } ``` -------------------------------- ### Initialize PayOS Client Source: https://payos.vn/docs/sdks/back-end/golang Initialize the PayOS object using environment variables for credentials. ```go import ( "context" "os" "github.com/payOSHQ/payos-lib-golang/v2/payos" ) func main() { ctx := context.Background() client, err := payos.NewPayOS(&payos.PayOSOptions{ ClientId: os.Getenv("PAYOS_CLIENT_ID"), ApiKey: os.Getenv("PAYOS_API_KEY"), ChecksumKey: os.Getenv("PAYOS_CHECKSUM_KEY"), }) if err != nil { log.Fatal(err) } } ``` -------------------------------- ### Install payOS SDK dependencies Source: https://payos.vn/docs/sdks/back-end/java Add the required dependency to your project configuration file. ```xml vn.payos payos-java 2.0.1 ``` ```gradle implementation 'vn.payos:payos-java:2.1.0' ``` -------------------------------- ### GET /v2/payment-requests/{id}/invoices Source: https://payos.vn/docs/api Retrieves invoice information associated with a specific payment link. ```APIDOC ## GET /v2/payment-requests/{id}/invoices ### Description API dùng để lấy thông tin hóa đơn của link thanh toán. ### Method GET ### Endpoint https://api-merchant.payos.vn/v2/payment-requests/{id}/invoices ### Parameters #### Path Parameters - **id** (number or string) - Required - Mã đơn hàng của cửa hàng hoặc mã link thanh toán của payOS ### Response #### Success Response (200) - **data** (object) - Invoice details #### Response Example { "code": "00", "desc": "success", "data": { "invoices": {} } } ``` -------------------------------- ### Integrate Web SDK Source: https://payos.vn/docs/sdks/intro Include the payOS script tag or install the npm package for React applications. ```html ``` ```shell npm install payos-checkout ``` -------------------------------- ### Run Server and Client Source: https://payos.vn/docs/checkout/quick-start-payos-hosted-page Instructions to run the server-side and client-side applications. Ensure the server is running on port 3030. ```bash # server side flask run --port=3030 # client side npm start ``` -------------------------------- ### Configure Package.json for Development Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form Add proxy and script configurations to your package.json file for running the client and server concurrently. This setup is necessary for local development and testing. ```json "proxy": "http://localhost:3030", "scripts": { # another scripts "start-client": "react-scripts start", "start-server": "nodemon server.js", "start": "concurrently \"npm run start-client\" \"npm run start-server\"" }, ```