doitpay

package module
v0.9.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2025 License: MIT Imports: 27 Imported by: 0

README

Doitpay Go SDK

The official Doitpay Go SDK offers an easy and user-friendly method to access Doitpay's REST API in applications coded in Go.

  • Package version: 0.9.5

Getting Started

Installation

Install doitpay-go in your Go application:

go get github.com/automotechnologies/doitpay-go

Place the package in your project directory and include the following in the import:

import doitpay "github.com/automotechnologies/doitpay-go"

Authorization

To utilize the SDK, initialize it with your client key and partner ID. You can get these credentials from the Doitpay Dashboard. If you haven't, you can register for a free Dashboard account here.

dtp, err := doitpay.NewClient(
    "YOUR_PARTNER_ID",
    "YOUR_CLIENT_SECRET",
    doitpay.WithPrivateKeyPath("path/to/private/key.pem"), //  specify private key path or private key bytes
    doitpay.WithHost("api.doitpay.co"), // Optional: specify host
)
if err != nil {
    log.Fatalf("Failed to create DTP client: %v", err)
}

Usage Examples

Creating a Payment
import (
    "context"
    "github.com/automotechnologies/doitpay-go"
    "github.com/automotechnologies/doitpay-go/models"
    "github.com/oklog/ulid"
    "time"
)

func main() {
    // Initialize client as shown above
    
    // Generate a unique reference number
    referenceNo := ulid.MustNew(ulid.Timestamp(time.Now()), nil).String()
    
    // Create payment parameters
    params := &doitpay.CreatePaymentParams{
        Request: &models.CreateEwalletRequest{
            // Fill in the request details
            PartnerReferenceNo: referenceNo,
            // Add other required fields
        },
        ExternalID: "your-external-id",
        ChannelID: "your-channel-id",
        RequestID: "your-request-id",
    }

    // Create payment
    response, err := dtp.Payment().Create(context.Background(), params)
    if err != nil {
        log.Fatalf("Failed to create payment: %v", err)
    }
}
Checking Payment Status
params := &doitpay.CheckPaymentStatusParams{
    Request: &models.CheckPaymentStatusEwalletRequest{
        // Fill in the request details
    },
    ExternalID: "your-external-id",
    ChannelID: "your-channel-id",
    RequestID: "your-request-id",
}

response, err := dtp.Payment().GetStatus(context.Background(), params)
if err != nil {
    log.Fatalf("Failed to check payment status: %v", err)
}
Canceling a Payment
params := &doitpay.CancelPaymentParams{
    Request: &models.CancelHostToHostPaymentRequest{
        // Fill in the request details
    },
    ExternalID: "your-external-id",
    ChannelID: "your-channel-id",
}

response, err := dtp.Payment().Cancel(context.Background(), params)
if err != nil {
    log.Fatalf("Failed to cancel payment: %v", err)
}

Documentation

Access comprehensive API details and sample usages for each of our products by following the links provided below.

Read more at:

Contact Us

support@doitpay.co

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorBearerTokenNotFound    = errors.New("mandatory header bearer token not found")
	ErrorAccessTokenInvalid     = errors.New("access token invalid")
	ErrorTimestampNotFound      = errors.New("mandatory header timestamp not found")
	ErrorExternalIdNotFound     = errors.New("mandatory header external id not found")
	ErrorPartnerIdNotFound      = errors.New("mandatory header partner id not found")
	ErrorSignatureNotFound      = errors.New("mandatory header signature not found")
	ErrorPartnerIdNotRegistered = errors.New("ValidateSignature: partner id not registered")
	ErrorSignatureInvalid       = errors.New("ValidateSignature: invalid signature")
)

Functions

This section is empty.

Types

type AccessToken

type AccessToken struct {
	AccessToken string
	ExpiresAt   time.Time
	TokenType   string
}

AccessToken represents an access token with expiration time

type BankAccountValidationParams

type BankAccountValidationParams struct {
	Request    *models.BankAccountValidationRequest
	ExternalID string
	ChannelID  string
}

type CancelParams added in v0.9.9

type CancelParams struct {
	Request    *models.CancelHostToHostPaymentRequest
	ExternalID string
	ChannelID  string
}

type ClientConfig

type ClientConfig struct {
	Host         string
	BasePath     string
	ClientSecret string
	PartnerID    string
	PrivateKey   *rsa.PrivateKey

	Scheme string
	// contains filtered or unexported fields
}

func DefaultConfig

func DefaultConfig() ClientConfig

DefaultConfig provides the default configuration for the client

type ClientOption

type ClientOption func(*ClientConfig)

ClientOption allows for functional options to configure the client

func WithBasePath

func WithBasePath(basePath string) ClientOption

WithBasePath sets a custom base path

func WithHost

func WithHost(host string) ClientOption

WithHost sets a custom host

func WithPrivateKeyBytes added in v0.9.5

func WithPrivateKeyBytes(privateKeyBytes []byte) ClientOption

WithPrivateKeyBytes sets a custom private key bytes

func WithPrivateKeyPath added in v0.9.5

func WithPrivateKeyPath(privateKeyPath string) ClientOption

WithPrivateKeyPath sets a custom private key path

func WithScheme added in v0.9.6

func WithScheme(scheme string) ClientOption

WithScheme sets a custom scheme

type CreateMerchantParams

type CreateMerchantParams struct {
	MerchantRef  string
	ChannelID    string
	ExternalID   string
	BusinessName string
	Name         string
}

type CreateVAParams

type CreateVAParams struct {
	Request    *models.CreateVirtualAccountRequest
	ExternalID string
	ChannelID  string
}

Parameter structs

type DebitClient added in v0.9.9

type DebitClient struct {
	// contains filtered or unexported fields
}

func NewDebitClient added in v0.9.9

func NewDebitClient(clientService debit.ClientService) *DebitClient

func (*DebitClient) Cancel added in v0.9.9

Cancel cancels an existing payment transaction

func (*DebitClient) PaymentHostToHost added in v0.9.9

func (c *DebitClient) PaymentHostToHost(ctx context.Context, params *PaymentHostToHostParams) (*models.CreateEwalletResponse, error)

Create creates a new payment transaction

func (*DebitClient) Status added in v0.9.9

Status checks the status of a payment transaction

type DeleteVAParams

type DeleteVAParams struct {
	Request    *models.DeleteVirtualAccountRequest
	ExternalID string
	ChannelID  string
}

type DisbursementClient

type DisbursementClient struct {
	// contains filtered or unexported fields
}

func NewDisbursementClient

func NewDisbursementClient(clientService disbursement.ClientService) *DisbursementClient

func (*DisbursementClient) Create

func (*DisbursementClient) CreateEMoney

func (*DisbursementClient) GetStatus

func (*DisbursementClient) GetStatusEMoney

func (*DisbursementClient) ValidateBankAccount

func (*DisbursementClient) ValidateEwalletAccount

type DisbursementParams

type DisbursementParams struct {
	Request    *models.CreateDisbursementRequest
	ExternalID string
	ChannelID  string
}

Parameter structs

type DoitpayAuth

type DoitpayAuth struct {
	// contains filtered or unexported fields
}

Custom auth implementation

func NewDoitpayAuth

func NewDoitpayAuth(config ClientConfig) *DoitpayAuth

func (*DoitpayAuth) AuthenticateRequest

func (a *DoitpayAuth) AuthenticateRequest(req runtime.ClientRequest, reg strfmt.Registry) error

AuthenticateRequest authenticates a request with the access token

func (*DoitpayAuth) GetAccessToken

func (a *DoitpayAuth) GetAccessToken(ctx context.Context) (string, error)

GetAccessToken retrieves an access token from the authentication service

func (*DoitpayAuth) ValidateSignature added in v0.9.4

func (a *DoitpayAuth) ValidateSignature(ctx context.Context, req *http.Request) error

type DoitpayClient

type DoitpayClient struct {
	// contains filtered or unexported fields
}

DoitpayClient wraps the generated client with custom auth

func NewClient

func NewClient(partnerID, clientSecret string, opts ...ClientOption) (*DoitpayClient, error)

NewClient creates a new authenticated client with optional configurations

func (*DoitpayClient) Debit added in v0.9.9

func (c *DoitpayClient) Debit() *DebitClient

Authenticate return the Authenticate instance

func (*DoitpayClient) Disbursement

func (c *DoitpayClient) Disbursement() *DisbursementClient

Disbursement returns the Disbursement client

func (*DoitpayClient) Merchant

func (c *DoitpayClient) Merchant() *MerchantClient

Merchant return the Merchant client

func (*DoitpayClient) Qris

func (c *DoitpayClient) Qris() *QrisClient

Qris returns the QRIS client

func (*DoitpayClient) Simulate

func (c *DoitpayClient) Simulate() *SimulateClient

Simulate returns the Simulate client

func (*DoitpayClient) VirtualAccount

func (c *DoitpayClient) VirtualAccount() *VirtualAccountClient

VirtualAccount return the VA client

type EMoneyDisbursementParams

type EMoneyDisbursementParams struct {
	Request    *models.CreateEwalletTopupRequest
	ExternalID string
	ChannelID  string
}

type EwalletAccountValidationParams

type EwalletAccountValidationParams struct {
	Request    *models.EmoneyAccountValidationRequest
	ExternalID string
	ChannelID  string
}

type GenerateQRISParams

type GenerateQRISParams struct {
	Request    *models.QrisRequestScheme
	ExternalID string
	ChannelID  string
}

Parameter structs

type GetMerchantByRefParams

type GetMerchantByRefParams struct {
	MerchantRef string
	ChannelID   string
	ExternalID  string
}

type GetMerchantParams

type GetMerchantParams struct {
	MerchantID string
	ChannelID  string
	ExternalID string
	Limit      int64
	Page       int64
	Search     string
}

type GetStatusEMoneyParams

type GetStatusEMoneyParams struct {
	Request    *models.InquiryEwalletTopupStatusRequest
	ExternalID string
	ChannelID  string
}

type GetStatusParams

type GetStatusParams struct {
	Request    *models.InquiryDisbursementStatusRequest
	ExternalID string
	ChannelID  string
}

type InquiryVAParams

type InquiryVAParams struct {
	Request    *models.InquiryVirtualAccountRequest
	ExternalID string
	ChannelID  string
}

type MerchantClient

type MerchantClient struct {
	// contains filtered or unexported fields
}

func NewMerchantClient

func NewMerchantClient(clientService merchants.ClientService) *MerchantClient

func (*MerchantClient) CreateMerchant

func (c *MerchantClient) CreateMerchant(ctx context.Context, params *CreateMerchantParams) (*models.MerchantResponse, error)

func (*MerchantClient) GetMerchantByRef

func (c *MerchantClient) GetMerchantByRef(ctx context.Context, params *GetMerchantByRefParams) (*models.MerchantResponse, error)

func (*MerchantClient) GetMerchants

type PaymentHostToHostParams added in v0.9.9

type PaymentHostToHostParams struct {
	Request    *models.CreateEwalletRequest
	ExternalID string
	ChannelID  string
	RequestID  string
}

Parameter structs

type PaymentStatusParams

type PaymentStatusParams struct {
	Request    *models.CheckVirtualAccountPaymentStatusRequest
	ExternalID string
	ChannelID  string
}

type QrisClient

type QrisClient struct {
	// contains filtered or unexported fields
}

QrisClient is a client for the QRIS API

func NewQrisClient

func NewQrisClient(clientService q_r_i_s.ClientService) *QrisClient

NewQrisClient creates a new QRIS client

func (*QrisClient) GenerateQRISCode

func (c *QrisClient) GenerateQRISCode(ctx context.Context, params *GenerateQRISParams) (*models.QrisResponseScheme, error)

GenerateQRISCode generates a QRIS code

func (*QrisClient) QueryQRISCode

func (c *QrisClient) QueryQRISCode(ctx context.Context, params *QueryQRISParams) (*models.QrisQueryPaymentResponse, error)

QueryQRISCode queries a QRIS code

type QueryQRISParams

type QueryQRISParams struct {
	Request    *models.QrisQueryPaymentRequest
	ExternalID string
	ChannelID  string
}

type SimulateClient

type SimulateClient struct {
	// contains filtered or unexported fields
}

func NewSimulateClient

func NewSimulateClient(client public_simulate.ClientService) *SimulateClient

func (*SimulateClient) SimulateQrisPayment

func (c *SimulateClient) SimulateQrisPayment(ctx context.Context, params *SimulateQRISParams) (*public_simulate.SimulatePaymentOK, error)

type SimulateQRISParams

type SimulateQRISParams struct {
	Request *models.QrisSimulateRequest
}

Parameter struct

type StatusParams added in v0.9.9

type StatusParams struct {
	Request    *models.CheckPaymentStatusEwalletRequest
	ExternalID string
	ChannelID  string
	RequestID  string
}

type UpdateVAParams

type UpdateVAParams struct {
	Request    *models.UpdateVirtualAccountRequest
	ExternalID string
	ChannelID  string
}

type VirtualAccountClient

type VirtualAccountClient struct {
	// contains filtered or unexported fields
}

func NewVirtualAccountClient

func NewVirtualAccountClient(clientService virtual_account.ClientService) *VirtualAccountClient

func (*VirtualAccountClient) Create

Create creates a new virtual account

func (*VirtualAccountClient) Delete

Delete deletes an existing virtual account

func (*VirtualAccountClient) GetPaymentStatus

GetPaymentStatus checks the payment status of a virtual account

func (*VirtualAccountClient) Inquiry

Inquiry gets details of an existing virtual account

func (*VirtualAccountClient) Update

Update updates an existing virtual account

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL