### Project Setup for Development
Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form
Configures the package.json file for running both the client and server applications concurrently. It defines scripts for starting the client, server, and a combined start command. This setup is crucial for local development and testing.
```json
"proxy": "http://localhost:3030",
"scripts": {
"start-client": "react-scripts start",
"start-server": "nodemon server.js",
"start": "concurrently \"npm run start-client\" \"npm run start-server\""
}
```
--------------------------------
### Install Golang PayOS SDK
Source: https://payos.vn/docs/sdks/back-end/golang
Install the payos-lib-golang library using the go get command. This command fetches and installs the specified version of the SDK, making it available for use in your Go projects.
```bash
go get github.com/payOSHQ/payos-lib-golang/v2
```
--------------------------------
### Start Development Server
Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form
Command to start both the client and server applications simultaneously using npm. This command utilizes the 'start' script defined in package.json, enabling a full-stack development environment.
```bash
npm run start
```
--------------------------------
### Start Application Server
Source: https://payos.vn/docs/checkout/quick-start-payos-hosted-page
Starts the application server using npm. This command assumes you have a 'start' script defined in your package.json, typically pointing to your main server file.
```bash
npm start
```
--------------------------------
### Run Development Servers
Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form
Commands to start both the PHP development server for the backend and the React development server for the frontend. This setup allows for local testing of the PayOS integration.
```bash
# server side
php -S localhost:3030 --docroot=public
# client side
npm start
```
--------------------------------
### Java SDK Setup
Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form
Instructions for adding the PayOS Java SDK to your Maven or Gradle project.
```APIDOC
## Java SDK Setup
### Maven
Add the following code to your POM and replace VERSION with your desired version.
```xml
vn.payos
payos-java
{VERSION}
```
### Gradle
Add the following code to your build.gradle and replace VERSION with your desired version.
```groovy
implementation 'vn.payos:payos-java:{VERSION}'
```
```
--------------------------------
### Javascript: Example Usage of Signature Verification
Source: https://payos.vn/docs/tich-hop-webhook/kiem-tra-du-lieu-voi-signature
An example demonstrating the usage of `verifySignatureBrowser` with predefined payout data, a checksum key, and an expected signature. This snippet illustrates how to check the integrity of payout transaction data.
```javascript
const payoutChecksumKey = '6e91f59952acc8918c49c4a8e380136d66d1fbbf3375926840a8a7e434d4b325';
const expectedSignature = '34d500c4e17feaad8fab528ac3ae089353e276ca9fb4c6654c06ffdfbd88cc5d';
const payoutData = {
code: '00',
desc: 'success',
data: {
payouts: [
{
id: 'batch_8f9520b9341144f38b9f5fbfa317db8e',
referenceId: 'payout_1753061728877',
transactions: [
{
id: 'batch_txn_fdb348c0570a4cb99009da22f9504898',
referenceId: 'payout_1753061728877_0',
amount: 2000,
description: 'batch payout',
toBin: '970422',
toAccountNumber: '0123456789',
toAccountName: 'NGUYEN VAN A',
reference: '103269845',
transactionDatetime: '2025-07-21T08:35:40+07:00',
errorMessage: null,
errorCode: null,
state: 'SUCCEEDED',
},
{
id: 'batch_txn_d94d371c079f4fc0ab7154e1576629d8',
referenceId: 'payout_1753061728877_1',
amount: 2000,
description: 'batch payout',
toBin: '970422',
toAccountNumber: '0123456789',
toAccountName: 'NGUYEN VAN A',
reference: '103269846',
transactionDatetime: '2025-07-21T08:35:44+07:00',
error
```
--------------------------------
### Run Flask Development Server
Source: https://payos.vn/docs/checkout/quick-start-payos-hosted-page
Start the Flask development server to run your application locally. This command assumes you have Flask installed and your application file is named `server.py`. The server will be accessible at `http://localhost:3030`.
```bash
flask run --port=3030
```
--------------------------------
### Installation
Source: https://payos.vn/docs/sdks/back-end/node
Install the `@payos/node` package using npm or yarn.
```APIDOC
## Installation
Install the `@payos/node` package using npm or yarn:
```bash
npm install @payos/node
# or
yarn add @payos/node
```
```
--------------------------------
### Install PayOS Library for Python
Source: https://payos.vn/docs/checkout/quick-start-payos-hosted-page
This command installs the PayOS library for Python using pip. Ensure you have Python and pip installed on your system before running this command.
```bash
pip install payos
```
--------------------------------
### Run Go Server
Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form
Executes the Go server application. This command is used to start your local server for testing the PayOS integration.
```bash
go run server.go
```
--------------------------------
### Install PayOS .NET SDK
Source: https://payos.vn/docs/sdks/back-end/net
Installs the 'payOS' package using the .NET CLI. This is the first step to integrate PayOS functionality into your .NET Core application.
```bash
dotnet add package payOS
```
--------------------------------
### Run Server and Client
Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form
Instructions for running the server and client-side applications. The server is run using Flask on port 3030, and the client is started with npm. Access the payment link creation interface at http://localhost:3000.
```shell
# server side
flask run --port=3030
# client side
npm start
```
--------------------------------
### Install PayOS Python SDK
Source: https://payos.vn/docs/sdks/back-end/python
Install the PayOS Python library using pip. This command ensures you have the latest version of the SDK available for your project.
```bash
# Windows
pip install payos
# Linux/macOS
pip3 install payos
```
--------------------------------
### Install Node.js SDK with npm and yarn
Source: https://payos.vn/docs/sdks/intro
Instructions for installing the PayOS Node.js SDK using both npm and yarn package managers. This SDK facilitates server-side integration with PayOS.
```bash
npm install @payos/node --save
```
```bash
yarn add @payos/node
```
--------------------------------
### Install @payos/node SDK
Source: https://payos.vn/docs/sdks/back-end/node
Install the `@payos/node` package using npm or yarn. This is the first step to integrate PayOS functionalities into your NodeJS application.
```bash
npm install @payos/node
# hoặc
yarn add @payos/node
```
--------------------------------
### Install payos-checkout Library
Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form
How to install the payos-checkout JavaScript library using a CDN link.
```APIDOC
## Install payos-checkout Library
### Install payos-checkout using CDN link
```html
```
```
--------------------------------
### Run Sample payOS Server
Source: https://payos.vn/docs/checkout/quick-start-payos-hosted-page
Execute the sample payOS server application using the provided Java command. This command requires the payos-payment JAR file with dependencies and specifies the main class to run. Access the server at http://localhost:3030 to test payment link creation.
```bash
java -cp .\target\payos-payment-1.0-SNAPSHOT-jar-with-dependencies.jar vn.payos.sample.Server
```
--------------------------------
### Install PayOS Checkout Library (yarn)
Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form
Install the payos-checkout library using yarn for frontend integration.
```bash
yarn add @payos/payos-checkout
```
--------------------------------
### Install PayOS Checkout Library (npm)
Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form
Install the payos-checkout library using npm for frontend integration.
```bash
npm install @payos/payos-checkout
```
--------------------------------
### Create Payment Link with Go
Source: https://payos.vn/docs/checkout/quick-start-payos-hosted-page
This Go code snippet demonstrates how to create a payment link using the PayOS library. It initializes the PayOS client with credentials and defines a handler to create a payment link request with order details. Dependencies include the payOS-lib-golang library. It takes order information as input and returns a payment link response.
```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
Installs the payos-checkout library using either npm or yarn package managers. This library is essential for integrating PayOS payment functionalities into your front-end application.
```bash
npm install @payos/payos-checkout
# hoặc
yarn add @payos/payos-checkout
```
--------------------------------
### Install PayOS NuGet Package for .NET
Source: https://payos.vn/docs/checkout/quick-start-payos-hosted-page
These commands show how to add the PayOS library to your .NET project using NuGet Package Manager. This is a prerequisite for using PayOS functionalities in a .NET environment. It involves using either the .NET CLI or the Package Manager Console.
```bash
dotnet add package payOS
```
```powershell
Install-Package payOS
```
--------------------------------
### Install PayOS Checkout Libraries (npm/yarn)
Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form
Installs the PayOS checkout library for front-end integration using either npm or yarn. This library provides hooks and components for embedding the PayOS payment interface into your React application.
```bash
npm install @payos/payos-checkout
```
```bash
yarn add @payos/payos-checkout
```
--------------------------------
### Initialize PayOS Client in Go
Source: https://payos.vn/docs/sdks/back-end/golang
Initialize the PayOS client by providing your Client ID, API Key, and Checksum Key. These credentials are typically loaded from environment variables. The function returns a PayOS client instance or an error if initialization fails.
```go
import (
"context"
"log"
"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)
}
// Use the client for further operations
}
```
--------------------------------
### Call usePayOS Hook with Initialized Config
Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form
How to call the usePayOS hook with the previously initialized configuration to get open() and exit() functions.
```APIDOC
## Call usePayOS Hook with Initialized Config
The `usePayOS` hook returns two functions: `open()` and `exit()`.
```
--------------------------------
### Create Payment Link with Go
Source: https://payos.vn/docs/checkout/quick-start-payos-hosted-page
This Go code snippet sets up an HTTP server to handle payment link creation requests. It initializes the PayOS client with provided keys and defines an endpoint to generate a payment link with order details, redirecting the user to the checkout URL.
```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 + "/cancel.html",
ReturnUrl: domain + "/success.html",
}
paymentLinkResponse, err := payOSClient.PaymentRequests.Create(r.Context(), &paymentLinkRequest)
if err != nil {
log.Printf("Create payment link failed: %v", err)
}
http.Redirect(w, r, paymentLinkResponse.CheckoutUrl, http.StatusSeeOther)
}
```
--------------------------------
### Run .NET Application
Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form
Command to run the .NET application. After starting the server, you can access the payment link creation interface at http://localhost:3030.
```bash
dotnet run
```
--------------------------------
### Use PayOS usePayOS Hook (JavaScript)
Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form
Call the `usePayOS` hook with the configuration object to get access to the `open()` and `exit()` functions for managing the payment checkout flow.
```javascript
const { open, exit } = PayOSCheckout.usePayOS(config);
// To open the checkout:
// open();
// To close the checkout (if embedded):
// exit();
```
--------------------------------
### Installation
Source: https://payos.vn/docs/sdks/back-end/java
Instructions on how to add the PayOS Java SDK dependency to your Maven or Gradle project.
```APIDOC
## Installation
Add the PayOS Java SDK dependency to your project:
### Maven
```xml
vn.payos
payos-java
2.0.1
```
### Gradle
```gradle
implementation 'vn.payos:payos-java:2.1.0'
```
```
--------------------------------
### Create Payment Link in Java
Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form
Example of creating a payment link using the PayOS Java SDK. This involves setting up payment details and calling the appropriate SDK method.
```java
// Example payment details (replace with actual data)
String orderCode = "ORDER123";
long amount = 10000; // Amount in cents or smallest currency unit
String description = "Test payment";
String returnUrl = "https://yourdomain.com/success";
String cancelUrl = "https://yourdomain.com/cancel";
// Assuming 'payOS' is an initialized PayOS object
// PaymentLinkResponse response = payOS.createPaymentLink(orderCode, amount, description, returnUrl, cancelUrl);
// String checkoutUrl = response.getCheckoutUrl();
```
--------------------------------
### Run Local Development Server
Source: https://payos.vn/docs/checkout/quick-start-payos-embedded-form
Starts a local PHP development server on port 3030. This command is used to test the integration by serving files from the 'public' directory, allowing you to access your application locally.
```bash
php -S localhost:3030 --docroot=public
```