indodana

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2021 License: GPL-3.0 Imports: 17 Imported by: 0

README

go-indodana-wrapper

This library crated for simplify your code to use Indodana Payment Method API.

Installation

Make sure that Go is installed on your computer. Type the following command in your terminal:

go get github.com/adhiva/go-indodana-wrapper

After it the package is ready to use.

Import package in your project

Add following line in your *.go file:

import "github.com/adhiva/go-indodana-wrapper"

If you are unhappy to use long go-indodana, you can do something like this:

import (
  indodana "github.com/adhiva/go-indodana-wrapper"
)
List of wrapper indodana client:
func GetInstallment(req *RequestGetInstallment) (ResponseGetInstallment, error)
func CheckStatus(req *RequestCheckStatus) (ResponseCheckStatus, error)
func CheckoutPayment(req *RequestCheckoutPayment) (ResponseCheckoutPayment, error)
Examples
Initial The Client
func init() {
	indodanaClient = indodana.NewClient()
	indodanaClient.APIKey = config.Config.Indodana.APIKey
	indodanaClient.SecretKey = config.Config.Indodana.SecretKey

	if config.Config.Indodana.ENV == "production" {
		indodanaClient.APIEnvType = indodana.Production
	} else {
		indodanaClient.APIEnvType = indodana.Sandbox
	}

	coreGateway = indodana.CoreGateway{
		Client: indodanaClient,
	}
}
Get Installment
func GetInstallment(request *indodana.RequestGetInstallment) (*indodana.ResponseGetInstallment, error) {
	var (
		resp *indodana.ResponseCharge
		err  error
	)

	resp, err = coreGateway.GetInstallment(request)

	if err != nil {
		return nil, err
    }
    
	return resp, nil
}
Checkout Payment
func CheckoutPayment(request *indodana.RequestCheckoutPayment) (*indodana.ResponseCheckoutPayment, error) {
	var (
		resp *indodana.ResponseCheckoutPayment
		err  error
	)

	// Generate deeplink for apps and mobile-web only
	resp, err = coreGateway.CheckoutPayment(request)
	if err != nil {
		return nil, err
	}
	return resp, nil
}
Check Status
	func CheckStatus(merchantOrderID string) (*indodana.ResponseCheckStatus, error) {
		var (
			request *indodana.RequestCheckStatus
			resp    *indodana.ResponseCheckStatus
			err     error
		)

		request.MerchantOrderId = merchantOrderID

		// Generate deeplink for apps and mobile-web only
		resp, err = coreGateway.CheckStatus(request)

		if err != nil {
			return nil, err
		}
		return resp, nil
	}
Support

If you do have a contribution to the package, feel free to create a Pull Request or an Issue.

What to contribute

If you don't know what to do, there are some features and functions that need to be done

  • Cancel Refund Transaction
  • Get Installment
  • Checkout Payment
  • Check Status
Advice

Feel free to create what you want, but keep in mind when you implement new features:

  • Code must be clear and readable, names of variables/constants clearly describes what they are doing
  • Wrapper they are created must be documented and described in source file and added to README.md to the list of wrapper indodana client
Contributors

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSignatureHeaders

func CreateSignatureHeaders(apiKey string, secretKey string) string

func Sha1

func Sha1(s string) string

func Stringify

func Stringify(m interface{}) string

Types

type Address

type Address struct {
	FirstName   string `json:"firstName"`
	LastName    string `json:"lastName"`
	Address     string `json:"address"`
	City        string `json:"city"`
	PostalCode  string `json:"postalCode"`
	Phone       string `json:"phone"`
	CountryCode string `json:"countryCode"`
}

This object use at seller object

type Client

type Client struct {
	APIEnvType Env
	APIKey     string
	SecretKey  string
	LogLevel   int
	Logger     *log.Logger
}

func NewClient

func NewClient() Client

func (*Client) DoRequest

func (c *Client) DoRequest(method, path string, body interface{}, v interface{}) error

type CoreGateway

type CoreGateway struct {
	Client Client
}

func (*CoreGateway) CheckStatus

func (gateway *CoreGateway) CheckStatus(req *RequestCheckStatus) (ResponseCheckStatus, error)

func (*CoreGateway) CheckoutPayment

func (gateway *CoreGateway) CheckoutPayment(req *RequestCheckoutPayment) (ResponseCheckoutPayment, error)

func (*CoreGateway) GetInstallment

func (gateway *CoreGateway) GetInstallment(req *RequestGetInstallment) (ResponseGetInstallment, error)

type CustomerDetail

type CustomerDetail struct {
	FirstName string `json:"firstName"`
	LastName  string `json:"lastName"`
	Email     string `json:"email"`
	Phone     string `json:"phone"`
}

This object use at payload checkout payment

type Env

type Env int8
const (

	// Sandbox : represent sandbox environment
	Sandbox Env

	// Production : represent production environment
	Production
)

func (Env) String

func (e Env) String() string

implement stringer

type Error

type Error struct {
	Kind    string      `json:"kind"`
	Message interface{} `json:"message"`
}

Error general message f

type Item

type Item struct {
	ID         string  `json:"id"`
	Name       string  `json:"name"`
	Price      float64 `json:"price"`
	Url        string  `json:"url,omitempty"`
	ImageURL   string  `json:"imageUrl,omitempty"`
	Type       string  `json:"type,omitempty"`
	Category   string  `json:"category,omitempty"`
	Quantity   int64   `json:"quantity"`
	ParentType string  `json:"parentType"`
	ParentID   string  `json:"parentId"`
}

This object use at payload get available installment, and checkout payment

type Logger

type Logger struct {
	Method       string      `json:"method"`
	Host         string      `json:"host"`
	Path         string      `json:"path"`
	RequestBody  interface{} `json:"request_body"`
	ResponseBody interface{} `json:"response_body"`
	TimeLength   int         `json:"time_length"`
}

type Payment

type Payment struct {
	ID                           string  `json:"id"`
	Tenure                       int     `json:"tenure"`
	Rate                         float64 `json:"rate"`
	Amount                       float64 `json:"amount"`
	PaymentType                  string  `json:"paymentType"`
	MonthlyInstallment           float64 `json:"monthlyInstallment"`
	MerchantDiscountRate         float64 `json:"merchantDiscountRate,omitempty"`
	DiscountedMonthlyInstallment float64 `json:"discountedMonthlyInstallment,omitempty"`
	InstallmentAmount            float64 `json:"installmentAmount"`
	DownPayment                  float64 `json:"downPayment,omitempty"`
	Provision                    float64 `json:"provision,omitempty"`
}

Response For Installment Calculation

type RequestCheckStatus

type RequestCheckStatus struct {
	MerchantOrderId string `url:"merchantOrderId"`
}

This object use for get status at indodana

type RequestCheckoutPayment

type RequestCheckoutPayment struct {
	TransactionDetail       TransactionDetail `json:"transactionDetails"`
	CustomerDetail          CustomerDetail    `json:"customerDetails"`
	Seller                  []Seller          `json:"sellers"`
	BillingAddress          *Address          `json:"billingAddress"`
	ShippingAddress         *Address          `json:"shippingAddress"`
	PaymentType             string            `json:"paymentType"`
	ApprovedNotificationURL string            `json:"approvedNotificationUrl"`
	CancellationRedirectURL string            `json:"cancellationRedirectUrl"`
	BackToStoreURL          string            `json:"backToStoreUrl"`
	ExpirationAt            string            `json:"expirationAt"`
}

This object use checkout payment

type RequestGetInstallment

type RequestGetInstallment struct {
	Amount float64 `json:"amount"`
	Items  []Item  `json:"items"`
}

This object use for get available installment

type RequestNotification

type RequestNotification struct {
	Amount            float64 `json:"amount"`
	PaymentType       string  `json:"paymentType"`
	TransactionStatus string  `json:"transactionStatus"`
	MerchantOrderId   string  `json:"merchantOrderId"`
	TransactionTime   string  `json:"transactionTime"`
	TransactionID     string  `json:"transactionId"`
}

This object use for get available installment

type ResponseCheckStatus

type ResponseCheckStatus struct {
	Status            string  `json:"status"`
	FraudStatus       string  `json:"fraudStatus"`
	LegalName         string  `json:"legalName"`
	Amount            float64 `json:"amount"`
	PaymentType       string  `json:"paymentType"`
	TransactionStatus string  `json:"transactionStatus"`
	MerchantOrderID   string  `json:"merchantOrderId"`
	TransactionTime   string  `json:"transactionTime"`
	TransactionID     string  `json:"transactionId"`
	EntityID          string  `json:"entityId,omitempty"`
	Message           string  `json:"message,omitempty"`
}

Response Check Status Transaction

type ResponseCheckoutPayment

type ResponseCheckoutPayment struct {
	Status        string `json:"status"`
	RedirectURL   string `json:"redirectUrl,omitempty"`
	TransactionID string `json:"transactionId,omitempty"`
	Error         Error  `json:"error,omitempty"`
}

Response Get Installment Available

type ResponseGetInstallment

type ResponseGetInstallment struct {
	Status  string    `json:"status"`
	Payment []Payment `json:"payments,omitempty"`
	Error   Error     `json:"error,omitempty"`
}

Response Get Installment Available

type Seller

type Seller struct {
	ID             string   `json:"id"`
	Name           string   `json:"name"`
	URL            string   `json:"url"`
	SellerIDNumber string   `json:"sellerIdNumber"`
	Email          string   `json:"email"`
	Address        *Address `json:"address"`
}

This object use at payload checkout payment

type TransactionDetail

type TransactionDetail struct {
	Amount          float64 `json:"amount"`
	MerchantOrderId string  `json:"merchantOrderId"`
	Items           []Item  `json:"items"`
}

This object use at payload checkout payment

Jump to

Keyboard shortcuts

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