Skip to content

abapayway/go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ABAPayWay Go SDK

Go Version License: MIT CI Go Report Card

Official-style Go client for the ABA PayWay payment gateway (ABA Bank, Cambodia). Standard library only in the core SDK — no runtime dependencies beyond Go.

Install

go get github.com/abapayway/go

Quick start

package main

import (
    "context"
    "log"

    "github.com/abapayway/go/abapayway"
    "github.com/abapayway/go/abapayway/types"
)

func main() {
    client, err := abapayway.NewClient(&abapayway.Config{
        MerchantID: "your_merchant_id",
        APIKey:     "your_api_key",
        Sandbox:    true,
    })
    if err != nil {
        log.Fatal(err)
    }

    checkout, err := client.Checkout.Create(context.Background(), &types.CheckoutOptions{
        Amount:    10.00,
        Currency:  string(abapayway.CurrencyUSD),
        OrderID:   "order-12345",
        ReturnURL: abapayway.EncodeURL("https://yoursite.com/return"),
    })
    if err != nil {
        log.Fatal(err)
    }
    _ = checkout.HTML // hosted checkout HTML
}

For refund, payment link, and pre-auth APIs, set RSAPublicKeyPEM on Config (RSA public key from ABA Bank).

Configuration

Field Description
MerchantID Merchant key from ABA Bank
APIKey HMAC signing key (public key)
RSAPublicKeyPEM RSA public key PEM for encrypted endpoints
Sandbox Use sandbox base URL when true
BaseURL Optional override of sandbox/production URL
HTTPClient Optional custom *http.Client (default 30s timeout)

Base URLs (from PayWay API docs):

  • Sandbox: https://checkout-sandbox.payway.com.kh
  • Production: https://checkout.payway.com.kh

Modules and methods

client.Checkout — Ecommerce checkout

Method Description
Create(ctx, options) Purchase API — returns checkout HTML
GetTransaction(ctx, transactionId) Full transaction details and history
CloseTransaction(ctx, transactionId) Cancel transaction (no callback)
CheckTransaction(ctx, transactionId) Status check (within 7 days)
GetTransactionList(ctx, filters) Paginated transaction list
GetExchangeRate(ctx) Latest ABA Bank forex rates

client.Refund

Method Description
Create(ctx, transactionId, amount) Full or partial refund (requires RSA)

client.Webhook

Method Description
Verify(payload, signature) HMAC-SHA512 webhook signature verification

client.Credentials — Credentials on file

Method Description
LinkAccount(ctx, options) QR / deeplink for ABA account linking
LinkCard(ctx, options) HTML for card linking
Payment(ctx, token, options) Pay with stored token (PWT)
RenewToken(ctx, options) Renew expiring account tokens (request_id, ctid, pwt)
GetTokenDetails(ctx, requestID) Retrieve token details by request_id
RemoveToken(ctx, options) Remove linked token (ctid, pwt)
Subscribe(ctx, options) Purchase + link via Purchase API (multipart)

client.QR — ABA QR API

Method Description
Generate(ctx, options) Generate payment QR (online / in-store)

client.PaymentLink

Method Description
Create(ctx, options) Create payment link (requires RSA)
Get(ctx, linkId) Payment link details (requires RSA)

client.PreAuth

Method Description
Complete(ctx, transactionId, options) Capture pre-authorized funds
CompleteWithPayout(ctx, transactionId, options) Capture with payout
Cancel(ctx, transactionId) Release pre-auth hold

client.Payout

Method Description
Create(ctx, options) Split / route funds (requires RSA)
UpdateBeneficiaryStatus(ctx, beneficiaryId, status) Toggle beneficiary active/inactive
AddBeneficiaryToWhitelist(ctx, options) Whitelist payout accounts

client.Transaction — KHQR / merchant reference

Method Description
GetByMerchantRef(ctx, merchantRef) Transactions by merchant_ref

Helpers

  • EncodeItems, EncodeDeeplink, EncodeBase64JSON, EncodeURL — Base64 encoding for PayWay fields
  • Typed errors: AuthenticationError, ValidationError, NetworkError, TransactionError, RefundError, WebhookError, TokenError
  • Error helpers: IsAuthenticationError, IsValidationError, IsNetworkError, IsTransactionError

Examples

Testing

go test ./... -race -coverprofile=coverage.out

Contributing

See CONTRIBUTING.md.

License

MIT — see LICENSE.

About

Unofficial Go SDK for ABAPayWay — Cambodia's leading payment gateway

Topics

Resources

License

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages