### Installing PayOS Go Library Bash Source: https://github.com/payoshq/payos-lib-golang/blob/main/README.md Use the Go command-line tool to fetch and install the PayOS Go library. This command downloads the library source code and adds it to your project's dependencies. ```Bash go get github.com/payOSHQ/payos-lib-golang ``` -------------------------------- ### Publishing to Go Module Proxy Bash Source: https://github.com/payoshq/payos-lib-golang/blob/main/README.md Commands used to prompt the Go Module Proxy to index a newly released version of a module. This makes the new version discoverable and usable by others via `go get`. ```Bash GOPROXY=proxy.golang.org\ngo list -m github.com/payOSHQ/payos-lib-golang@v0.1.0 ``` -------------------------------- ### Releasing New Version Git Bash Source: https://github.com/payoshq/payos-lib-golang/blob/main/README.md Sequence of Git commands to commit changes, create a version tag for the release, and push the tag to the remote repository. This makes the new version available for users. ```Bash git commit -m "Your message"\ngit tag v0.0.1\ngit push origin v0.0.1 ``` -------------------------------- ### Running Tests PayOS Go Bash Source: https://github.com/payoshq/payos-lib-golang/blob/main/README.md Standard Go command to execute tests within the current module. This command runs all tests in packages found in the current directory and its subdirectories. ```Bash go test ``` -------------------------------- ### Getting Payment Link Information PayOS Go Source: https://github.com/payoshq/payos-lib-golang/blob/main/README.md Shows how to retrieve details about an existing payment link using its unique order code. After initializing the library with your API keys, call the GetPaymentLinkInformation function with the desired order code. It returns the payment status and details or an error. ```Go package main\n\nimport (\n "fmt"\n "log"\n\n "github.com/payOSHQ/payos-lib-golang"\n)\n\nfunc main(){\n payos.Key(clientId, apiKey,checksumKey)\n data, err := GetPaymentLinkInformation("12345")\n if err != nil {\n log.Fatal(err)\n }\n fmt.Println(data)\n} ``` -------------------------------- ### Creating Payment Link PayOS Go Source: https://github.com/payoshq/payos-lib-golang/blob/main/README.md Demonstrates how to initiate a payment by creating a payment link. You need to configure the library with your API keys, define the order details in a CheckoutRequestType struct, and call the CreatePaymentLink function. The function returns the payment link data or an error. ```Go package main\n\nimport (\n "fmt"\n "log"\n\n "github.com/payOSHQ/payos-lib-golang"\n)\n\nfunc main(){\n payos.Key(clientId, apiKey,checksumKey)\n // or with your partner code\n // payos.Key(clientId, apiKey,checksumKey, partnerCode)\n body := CheckoutRequestType{\n OrderCode: 12345,\n Amount: 2000,\n Description: "Thanh toán đơn hàng",\n CancelUrl: "http://localhost:8080/cancel/",\n ReturnUrl: "http://localhost:8080/success/",\n }\n\n data, err := CreatePaymentLink(body)\n if err != nil {\n log.Fatal(err)\n }\n fmt.Println(data)\n} ``` -------------------------------- ### Managing Go Dependencies Bash Source: https://github.com/payoshq/payos-lib-golang/blob/main/README.md Command used to add missing dependencies and remove unused ones in a Go module. It ensures your go.mod and go.sum files are consistent with the code in your project. ```Bash go mod tidy ``` -------------------------------- ### Confirming Webhook URL PayOS Go Source: https://github.com/payoshq/payos-lib-golang/blob/main/README.md Demonstrates how to use the library to confirm a webhook endpoint URL with the PayOS system. This typically involves sending a request to PayOS from your application's server to validate the URL. ```Go package main\n\nimport (\n "fmt"\n "log"\n\n "github.com/payOSHQ/payos-lib-golang"\n)\n\nfunc main(){\n payos.Key(clientId, apiKey,checksumKey)\n data, err := ConfirmWebhook("http://yourdomain.com/webhook/")\n} ``` -------------------------------- ### Verifying Payment Webhook Data PayOS Go Source: https://github.com/payoshq/payos-lib-golang/blob/main/README.md Shows how to verify the authenticity and integrity of data received from PayOS via a webhook. The library provides a function to check the signature of the incoming payload (WebhookType struct) using your checksum key. ```Go package main\n\nimport (\n "fmt"\n "log"\n\n "github.com/payOSHQ/payos-lib-golang"\n)\n\nfunc main(){\n payos.Key(clientId, apiKey,checksumKey)\n body := WebhookType{}\n data, err := VerifyPaymentWebhookData(body)\n} ``` -------------------------------- ### Canceling Payment Link PayOS Go Source: https://github.com/payoshq/payos-lib-golang/blob/main/README.md Illustrates how to cancel a previously created payment link. After configuring the library with API keys, call the CancelPaymentLink function providing the order code and an optional cancellation reason. This action invalidates the payment link. ```Go package main\n\nimport (\n "fmt"\n "log"\n\n "github.com/payOSHQ/payos-lib-golang"\n)\n\nfunc main(){\n payos.Key(clientId, apiKey,checksumKey)\n cancelReason := "Khách hàng hủy đơn hàng"\n data, err := CancelPaymentLink("12345", &cancelReason)\n} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.