emas

package module
v0.0.0-...-4c4c5d2 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: MIT Imports: 19 Imported by: 0

README

e-mas-go

library for thirdparty connect to e-mas API

Example Usage

Buy Init
        client             := emas.NewClient()
    	client.AppId        = "{YOUR-APP-ID}"
    	client.SecretKey    = "{YOUR-SECRET-KEY}"
    	client.Environment  = "dev"
    	client.Debug        = true
    	
    	midleware          := emas.Middleware{
    		Client:client,
    	}
    	
    	req := &emas.ReqTransactionInit{
    		Customer:
    		emas.TransCustomer{
    			MerchantCustomerId      :"{YOUR-CUSTOMER-ID}",
    			Fullname                :"Indra Octama",
    			Email                   :"indra.octama@orori.com",
    			Gender                  :"Male",
    			Handphone               :"",
    			Birthdate               :"",
    			IdCardNumber            :"",
    			IdCardPhotoSelfieUrl    :"",
    			IdCardPhotoUrl          :"",
    		},
    		Weight:2,
    	}
    	
    	res,err := midleware.BuyInit(req)
    	if err != nil{
    		//do something when there is an error
    	}
    
    // do something with res

You can handle the res object or extract it into emas.Transaction if you want

For more information and support please contact info@e-mas.com or dev@e-mas.com.

Documentation

Index

Constants

View Source
const (
	VarTransactionCancel     = 0
	VarTransactionPending    = 5
	VarTransactionDelivering = 8
	VarTransactionSuccess    = 10
	VarTransactionDelivered  = 10

	VarPaymentCancel  = 0
	VarPaymentPending = 5
	VarPaymentPaid    = 10
)
View Source
const (
	// GET
	EndpointCustomerDetail    = "/customer/"
	EndpointProductList       = "/product"
	EndpointProductLog        = "/product-log"
	EndpointTransaction       = "/transaction"
	EndpointTransactionDetail = "/transaction/"
	EndpointShippingCode      = "/shipping/init"
	EndpointShippingTracking  = "/shipping/tracking"

	// POST
	EndpointBuyInit           = "/buy-gold"
	EndpointBuyConfirm        = "/buy-gold-confirm"
	EndpointBuyCancel         = "/buy-gold-cancel"
	EndpointSellInit          = "/sell-gold"
	EndpointSellConfirm       = "/sell-gold-confirm"
	EndpointSellReversal      = "/sell-gold-reverse"
	EndpointWithdrawInit      = "/withdraw-gold"
	EndpointWithdrawConfirm   = "/withdraw-gold-confirm"
	EndpointWithdrawCancel    = "/withdraw-cancel"
	EndpointCalculatorProduct = "/calculator/product"
)
View Source
const EMAS_DEVELOPMENT = "https://oroconnect-dev.e-mas.com/v2/thirdparty"
View Source
const EMAS_PRODUCTION = ""

Variables

This section is empty.

Functions

func Md5Encrypt

func Md5Encrypt(text string) string

func Sha1_HMAC

func Sha1_HMAC(k string, message string) string

func Sha256Encrypt

func Sha256Encrypt(s string) string

func Sha256_HMAC

func Sha256_HMAC(k string, message string) string

func Sha512Encrypt

func Sha512Encrypt(s string) string

func ShaOneEncrypt

func ShaOneEncrypt(s string) string

Types

type CalculatorProductReq

type CalculatorProductReq struct {
	Value float64 `json:"value"`
	Type  int     `json:"type"`
}

type Client

type Client struct {
	Environment string
	AppId       string
	SecretKey   string

	Debug  bool
	Logger *log.Logger
}

func NewClient

func NewClient() Client

func (*Client) Call

func (c *Client) Call(method, path string, body io.Reader) ([]byte, error)

func (*Client) ExecuteRequest

func (c *Client) ExecuteRequest(req *http.Request) ([]byte, error)

func (*Client) NewRequest

func (c *Client) NewRequest(method string, fullPath string, body io.Reader) (*http.Request, error)

type Customer

type Customer struct {
	Balance  float64 `json:"balance"`
	Address  string  `json:"address"`
	City     string  `json:"city"`
	Province string  `json:"province"`
	Zipcode  string  `json:"zipcode"`
}

type ErrorResponse

type ErrorResponse struct {
	ErrorCode    int         `json:"error_code"`
	ErrorMessage string      `json:"error_message"`
	ErrorData    interface{} `json:"error_data"`
	Timestamp    string      `json:"timestamp"`
}

type Middleware

type Middleware struct {
	Client Client
}

func (*Middleware) BuyCancel

func (g *Middleware) BuyCancel(req *ReqTransactionCancel) (SuccessResponse, error)

func (*Middleware) BuyConfirm

func (g *Middleware) BuyConfirm(req *ReqTransactionConfirm) (SuccessResponse, error)

func (*Middleware) BuyInit

func (g *Middleware) BuyInit(req *ReqTransactionInit) (SuccessResponse, error)

func (*Middleware) CalculatorProduct

func (g *Middleware) CalculatorProduct(req *CalculatorProductReq) (SuccessResponse, error)

func (*Middleware) Call

func (c *Middleware) Call(method, path string, body io.Reader) ([]byte, error)

func (*Middleware) CallPublic

func (c *Middleware) CallPublic(method, path string, body io.Reader) ([]byte, error)

func (*Middleware) CustomerProfile

func (g *Middleware) CustomerProfile(merchant_customer_id string) (resp SuccessResponse, err error)

func (*Middleware) ProductList

func (g *Middleware) ProductList() (SuccessResponse, error)

func (*Middleware) ProductLog

func (g *Middleware) ProductLog(req *ProductLogReq) (SuccessResponse, error)

func (*Middleware) SellConfirm

func (g *Middleware) SellConfirm(req *ReqTransactionConfirm) (SuccessResponse, error)

func (*Middleware) SellInit

func (g *Middleware) SellInit(req *ReqTransactionInit) (SuccessResponse, error)

func (*Middleware) SellReverse

func (g *Middleware) SellReverse(req *ReqTransactionCancel) (SuccessResponse, error)

func (*Middleware) ShippingCode

func (g *Middleware) ShippingCode() (SuccessResponse, error)

func (*Middleware) ShippingTracking

func (g *Middleware) ShippingTracking(awb_number string) (SuccessResponse, error)

func (*Middleware) TransactionDetail

func (g *Middleware) TransactionDetail(payment_id string) (resp SuccessResponse, err error)

func (*Middleware) TransactionList

func (g *Middleware) TransactionList(req *TransactionListReq) (SuccessResponse, error)

func (*Middleware) WithdrawCancel

func (g *Middleware) WithdrawCancel(req *ReqTransactionCancel) (SuccessResponse, error)

func (*Middleware) WithdrawConfirm

func (g *Middleware) WithdrawConfirm(req *ReqTransactionConfirm) (SuccessResponse, error)

func (*Middleware) WithdrawInit

func (g *Middleware) WithdrawInit(req *ReqTransactionInit) (SuccessResponse, error)

type Product

type Product struct {
	Id          uint64 `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Weight      int    `json:"weight"`
	SellPrice   uint32 `json:"sell_price"` // We sell to customer
	BuyPrice    uint32 `json:"buy_price"`  // We buy from customer
	AdminFee    int    `json:"admin_fee"`
	Image       string `json:"image"`
}

type ProductLogReq

type ProductLogReq struct {
	Page      int    `json:"page"`
	Type      string `json:"type"`
	StartDate string `json:"start_date"`
	EndDate   string `json:"end_date"`
	Limit     int    `json:"limit"`
}

type ReqTransactionCancel

type ReqTransactionCancel struct {
	MerchantCustomerId  string `json:"merchant_customer_id"`
	PaymentId           string `json:"payment_id"`
	VendorTransactionId string `json:"vendor_transaction_id"`
}

type ReqTransactionConfirm

type ReqTransactionConfirm struct {
	MerchantCustomerId  string `json:"merchant_customer_id"`
	PaymentId           string `json:"payment_id"`
	VendorTransactionId string `json:"vendor_transaction_id"`
}

type ReqTransactionInit

type ReqTransactionInit struct {
	Customer             TransCustomer `json:"customer"`
	Email                string        `json:"email"`
	IdCardNumber         string        `json:"id_card_number"`
	IdCardPhotoUrl       string        `json:"id_card_photo_url"`
	IdCardPhotoSelfieUrl string        `json:"id_card_photo_selfie_url"`
	Gender               string        `json:"gender"`
	Weight               float64       `json:"weight"`
	Amount               int           `json:"amount"`
	Insurance            int           `json:"insurance"`
	Birthdate            string        `json:"birthdate"`
	TransactionWithdraw
}

type SuccessResponse

type SuccessResponse struct {
	Code      int         `json:"code"`
	Type      string      `json:"type"`
	Data      interface{} `json:"data"`
	Total     int         `json:"total"`
	FirstPage string      `json:"first_page"`
	LastPage  string      `json:"last_page"`
	NextPage  string      `json:"next_page"`
	Timestamp string      `json:"timestamp"`
}

type TransCustomer

type TransCustomer struct {
	MerchantCustomerId   string `json:"merchant_customer_id"`
	Handphone            string `json:"handphone"`
	Fullname             string `json:"fullname"`
	Email                string `json:"email"`
	IdCardNumber         string `json:"id_card_number"`
	IdCardPhotoUrl       string `json:"id_card_photo_url"`
	IdCardPhotoSelfieUrl string `json:"id_card_photo_selfie_url"`
	Gender               string `json:"gender"`
	Birthdate            string `json:"birthdate"`
}

type Transaction

type Transaction struct {
	PaymentId     string               `json:"payment_id"`
	Description   string               `json:"description"`
	Balance       float64              `json:"balance,omitempty"`
	Weight        float64              `json:"weight"`
	Price         float64              `json:"price"`
	AdminFee      int                  `json:"admin_fee"`
	PricePerGram  float64              `json:"price_per_gram"`
	Status        uint8                `json:"status"`
	PaymentStatus int                  `json:"payment_status"`
	Withdraw      *TransactionWithdraw `json:"withdraw_detail,omitempty"`
	CreatedAt     time.Time            `json:"created_at"`
}

type TransactionListReq

type TransactionListReq struct {
	Page               int    `json:"page"`
	Offset             int    `json:"offset"`
	Limit              int    `json:"limit"`
	Status             int    `json:"status"`
	StartDate          string `json:"start_date"`
	EndDate            string `json:"end_date"`
	OrderBy            string `json:"order_by"`
	MerchantCustomerId string `json:"merchant_customer_id"`
}

type TransactionWithdraw

type TransactionWithdraw struct {
	Handphone       string                       `json:"handphone"`
	Fullname        string                       `json:"fullname"`
	Address         *TransactionWithdrawAddress  `json:"address"`
	ShippingCompany int                          `json:"shipping_company"` // 1 = JNE_REG, 2 = JNE_YES, 12 = RPX_NDP
	ShippingFee     int                          `json:"shipping_fee"`
	ShippingCode    string                       `json:"shipping_code"`
	Insurance       int                          `json:"insurance"`
	Detail          []*TransactionWithdrawDetail `json:"detail"`
}

type TransactionWithdrawAddress

type TransactionWithdrawAddress struct {
	Address  string `orm:"size(255)" json:"address"`
	City     string `orm:"size(100)" json:"city"`
	Province string `orm:"size(100)" json:"province"`
	Zipcode  string `orm:"size(10)" json:"zipcode"`
}

type TransactionWithdrawDetail

type TransactionWithdrawDetail struct {
	Id    uint64 `json:"id"`
	Count int    `json:"count"`
}

Jump to

Keyboard shortcuts

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