moka

package module
v0.0.0-...-2527649 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2020 License: MIT Imports: 10 Imported by: 0

README

mokapos-go

Go Report Card

A client library for Moka Pos

Warning: It's not tested and still in development! Please check the project and test before use. I don't take any liability.

Examples

  • Payment without 3D Secure

import (
    "github.com/emirmuminoglu/mokapos-go"
)

var (
    //Your Dealer Username
    username = "test"

    //Your Dealer Password
    password = "test"

    //If you want to use test environment set this value true
    isTest = true

)

func main(){
    m := moka.New(username, password, isTest)

    request := moka.PaymentDealerRequest{
        CardHolderFullName: "Emir Muminoglu",
        CardNumber: "5555666677778888",
        ExpMont: "12",
        ExpYear:"2020",
        CvcNumber: "123",
        Amount: 123.123,
        Currency:"TL",
        InstallmentNumber:"1",
    }

    resp, err := m.PaymentNonThreeD(request)
    if err != nil {
        fmt.Fatalf("An error occured: %v \n", err.Error())
    }

    fmt.Println(resp)
    return
}
  • Payment with 3D Secure
import (
   "github.com/emirmuminoglu/mokapos-go"
)

var (
   //Your Dealer Username
   username = "test"

   //Your Dealer Password
   password = "test"

   //If you want to use test environment set this value true
   isTest = true

)

func main(){
   m := moka.New(username, password, isTest)

   customerInfo := moka.CustomerInformation{
       DealercustomerID: 1234,
       CustomerCode: "1234",
       FirstName: "emir",
       LastName:"muminoglu",
   }

   request := moka.PaymentDealerRequest{
       CardHolderFullName: "Emir Muminoglu",
       CardNumber: "5555666677778888",
       ExpMont: "12",
       ExpYear:"2020",
       CvcNumber: "123",
       Amount: 123.123,
       Currency:"TL",
       InstallmentNumber:"1",
       RedirectURL: "https://pos.testmoka.com/DealerPayment/PayResult?MyTrxId=1A2B3CD456",
       RedirectType: 0,
       CustomerInformation: customerInfo,
   }

   resp, err := m.PaymentWithThreeD(request)
   if err != nil {
       fmt.Fatalf("An error occured: %v \n", err.Error())
   }

   fmt.Println(resp)
   return
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidRequest                 = errors.New("Invalid CheckKey. Please check your CheckKey")
	ErrInvalidAccount                 = errors.New("Invalid Account. Please check your dealer code, username and password.")
	ErrVirtualPosNotFound             = errors.New("There is no Virtual Pos associated with your account.")
	ErrDailyDealerLimitExceeded       = errors.New("Dealer exceeded one of the daily limits.")
	ErrDailyCardLimitExceeded         = errors.New("This Credit Card is delimitated.")
	ErrInvalidCardInfo                = errors.New("Invalid Card Info.")
	ErrThreeDRequired                 = errors.New("Dealer can't do Non-3D payment.")
	ErrInstallmentWithForeignCurrency = errors.New("Can't make installments with foreign currency.")
	ErrInstallmentNumberForDealer     = errors.New("This number of installments is not available for dealer.")
	ErrInvalidInstallmentNumber       = errors.New("Installment Number must be between 2 and 12")
)

Functions

This section is empty.

Types

type BuyerInformation

type BuyerInformation struct {
	FullName  string `json:"BuyerFullName,omitempty"`
	EMail     string `json:"BuyerEmail,omitempty"`
	GSMNumber string `json:"BuyerGsmNumber,omitempty"`
	Address   string `json:"BuyerAddress,omitempty"`
}

BuyerInformation represents

type CustomerInformation

type CustomerInformation struct {
	DealerCustomerID int    `json:"DealerCustomerId,omitempty"`
	CustomerCode     string `json:"CustomerCode,omitempty"`
	FirstName        string `json:"FirstName,omitempty"`
	LastName         string `json:"LastName,omitempty"`
	Gender           int8   `json:"Gender,omitempty"`
	BirthDate        string `json:"BirthDate,omitempty"`
	GsmNumber        string `json:"GsmNumber,omitempty"`
	EMail            string `json:"Email,omitempty"`
	Address          string `json:"Address,omitempty"`
}

type Moka

type Moka struct {
	Dealer PaymentDealerAuthentication
	Client *http.Client
	// contains filtered or unexported fields
}

func New

func New(code, username, password string, isTest bool) (m *Moka)

func (*Moka) Capture

func (m *Moka) Capture(pdr PaymentDealerRequest) (Response, error)

func (*Moka) PaymentNonThreeD

func (m *Moka) PaymentNonThreeD(pdr PaymentDealerRequest) (Response, error)

func (*Moka) PaymentWithThreeD

func (m *Moka) PaymentWithThreeD(pdr PaymentDealerRequest) (Response, error)

type NonTDResponse

type NonTDResponse struct {
	Data struct {
		IsSuccessful       bool   `json:"IsSuccessful"`
		ResultCode         string `json:"ResultCode"`
		ResultMessage      string `json:"ResultMessage"`
		VirtualPostOrderID string `json:"VirtualPostOrderId"`
	} `json:"Data"`
	ResultCode    string `json:"ResultCode"`
	ResultMessage string `json:"ResultMessage"`
	Exception     string `json:"Exception"`
}

func (NonTDResponse) Error

func (r NonTDResponse) Error() (err error)

func (NonTDResponse) MarshalEasyJSON

func (v NonTDResponse) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (NonTDResponse) MarshalJSON

func (v NonTDResponse) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*NonTDResponse) UnmarshalEasyJSON

func (v *NonTDResponse) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*NonTDResponse) UnmarshalJSON

func (v *NonTDResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type PaymentDealerAuthentication

type PaymentDealerAuthentication struct {
	Code     string `json:"DealerCode"`
	Username string `json:"Username"`
	Password string `json:"Password"`
	// contains filtered or unexported fields
}

type PaymentDealerRequest

type PaymentDealerRequest struct {
	VirtualPosOrderID   string              `json:"VirtualPosOrderId,omitempty"`
	CardHolderFullName  string              `json:"CardHolderFullName,omitempty"`
	CardNumber          string              `json:"CardNumber,omitempty"`
	ExpMonth            string              `json:"ExpMonth,omitempty"`
	ExpYear             string              `json:"ExpYear,omitempty"`
	CvcNumber           string              `json:"CvcNumber,omitempty"`
	Amount              uint                `json:"Amount,omitempty"`
	Currency            string              `json:"Currency,omitempty"`
	InstallmentNumber   int8                `json:"InstallmentNumber,omitempty"`
	ClientIP            string              `json:"ClientIP,omitempty"`
	RedirectURL         string              `json:"RedirectUrl,omitempty"`
	RedirectType        int8                `json:"RedirectType,omitempty"`
	OtherTrxCode        string              `json:"OtherTrxCode,omitempty"`
	IsPreAuth           int8                `json:"IsPreAuth,omitempty"`
	IsPoolPayment       int8                `json:"IsPoolPayment,omitempty"`
	IsTokenized         int8                `json:"IsTokenized,omitempty"`
	IntegratorID        int8                `json:"IntegratorId,omitempty"`
	Software            string              `json:"Software,omitempty"`
	SubMerchantName     string              `json:"SubMerchantName,omitempty"`
	Description         string              `json:"Description,omitempty"`
	BuyerInformation    BuyerInformation    `json:"BuyerInformation,omitempty"`
	CustomerInformation CustomerInformation `json:"CustomerInformation,omitempty"`
}

PaymentDealerRequest represents a part of request that you send to moka services. For detailed documentation: https://developer.moka.com

type Request

type Request struct {
	PaymentDealerAuthentication PaymentDealerAuthentication `json:"PaymentDealrAuthentication"`
	PaymentDealerRequest        PaymentDealerRequest        `json:"PaymentDealerRequest"`
}

func (Request) MarshalEasyJSON

func (v Request) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Request) MarshalJSON

func (v Request) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Request) UnmarshalEasyJSON

func (v *Request) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Request) UnmarshalJSON

func (v *Request) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Response

type Response interface {
	Error() error
	MarshalJSON() ([]byte, error)
	MarshalEasyJSON(w *jwriter.Writer)
	UnmarshalEasyJSON(l *jlexer.Lexer)
	UnmarshalJSON([]byte) error
}

type ThreeDResponse

type ThreeDResponse struct {
	Data          string `json:"Data"`
	ResultCode    string `json:"ResultCode"`
	ResultMessage string `json:"ResultMessage"`
	Exception     string `json:"Exception"`
}

func (ThreeDResponse) Error

func (r ThreeDResponse) Error() (err error)

func (ThreeDResponse) MarshalEasyJSON

func (v ThreeDResponse) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ThreeDResponse) MarshalJSON

func (v ThreeDResponse) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ThreeDResponse) UnmarshalEasyJSON

func (v *ThreeDResponse) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ThreeDResponse) UnmarshalJSON

func (v *ThreeDResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

Jump to

Keyboard shortcuts

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