Skip to content

mpac-pgw Go SDK

Go client library for the MPAC Payment Gateway. Provides HMAC-SHA256 authenticated access to all PGW API endpoints for server-to-server integration.

Installation

bash
go get github.com/mp-solution-inc/mpac-pgw/sdks/sdk-go

Quick Start

go
package main

import (
    "context"
    "fmt"
    "log"

    mpspgw "github.com/mp-solution-inc/mpac-pgw/sdks/sdk-go"
)

func main() {
    client := mpspgw.NewClient(mpspgw.ClientConfig{
        BaseURL:   "https://pgw.example.com",
        APIKey:    "ak_01JXXXXXXXXXXXXXXXXXXXXXX",
        SecretKey: "sk_live_xxxxxxxxxxxxxxxxxxxxxxxx",
    })

    ctx := context.Background()

    // Create a PaymentIntent
    intent, err := client.CreatePaymentIntent(ctx, mpspgw.CreatePaymentIntentRequest{
        Amount:             1000,
        Currency:           "JPY",
        PaymentMethodTypes: []string{"qr_mpm"},
        MerchantRefID:      "order_12345",
        MerchantStoreID:    "store_001",
    })
    if err != nil {
        log.Fatal(err)
    }

    fmt.Printf("PaymentIntent created: %s\n", intent.ID)
    fmt.Printf("Payment token: %s\n", intent.PaymentToken)

    // Pass intent.PaymentToken to the frontend SDK for payment confirmation
}

Authentication

All requests are authenticated using HMAC-SHA256. The SDK handles signature generation automatically.

Signature scheme:

Message   = METHOD + "\n" + PATH + "\n" + TIMESTAMP + "\n" + HEX(SHA256(BODY))
Key       = []byte(HEX(SHA256(secret_key)))
Signature = HEX(HMAC-SHA256(Key, Message))
Header    = "HMAC-SHA256 <api_key>:<timestamp>:<signature>"

API Reference

MethodDescription
CreatePaymentIntentCreate a new PaymentIntent
GetPaymentIntentRetrieve a PaymentIntent by ID
ListPaymentIntentsList PaymentIntents with optional filters
CapturePaymentIntentCapture a PaymentIntent (manual mode)
SyncMerchantsSync merchant/store data from upstream

Testing

bash
go test -v ./...

License

MIT

MPAC — MP-Solution Advanced Cloud Service