rm

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorCodePaymentAlreadyRefunded           = "PAYMENT_FULLY_REFUNDED"
	ErrorCodeTransactionNotFound              = "TRANSACTION_NOT_FOUND"
	ErrorCodeStoreNotFound                    = "STORE_NOT_FOUND"
	ErrorCodeValidationError                  = "VALIDATION_ERROR"
	ErrorCodeRefundAmountExceedPerDay         = "PAYMENT_REFUND_AMOUNT_EXCEED_PER_DAY"
	ErrorCodeMerchantSettlementAccNotVerified = "MERCHANT_SETTLEMENT_ACCOUNT_NOT_VERIFIED"
)

error codes :

View Source
const (
	LayoutV1 layout = "v1"
	LayoutV2 layout = "v2"
	LayoutV3 layout = "v3"
)

layout versions :

View Source
const (
	// payment types :
	PaymentTypeWeb    PaymentType = "WEB_PAYMENT"
	PaymentTypeMobile PaymentType = "MOBILE_PAYMENT"

	// payment methods :
	PaymentMethodWeChatMalaysia    PaymentMethod = "WECHAT_MY"
	PaymentMethodWeChatChina       PaymentMethod = "WECHAT_CN"
	PaymentMethodBoostMalaysia     PaymentMethod = "BOOST_MY"
	PaymentMethodPrestoMalaysia    PaymentMethod = "PRESTO_MY"
	PaymentMethodAlipayChina       PaymentMethod = "ALIPAY_CN"
	PaymentMethodTnGMalaysia       PaymentMethod = "TNG_MY"
	PaymentMethodGrabMalaysia      PaymentMethod = "GRABPAY_MY"
	PaymentMethodMaybankMalaysia   PaymentMethod = "MAYBANK_MY"
	PaymentMethodRazerPayMalaysia  PaymentMethod = "RAZERPAY_MY"
	PaymentMethodMCashMalaysia     PaymentMethod = "MCASH_MY"
	PaymentMethodShopeePayMalaysia PaymentMethod = "SHOPEEPAY_MY"
	PaymentMethodFpxMalaysia       PaymentMethod = "FPX_MY"
	PaymentMethodGoBizMalaysia     PaymentMethod = "GOBIZ_MY"

	// payment status :
	PaymentStatusInProcess     PaymentStatus = "IN_PROCESS"
	PaymentStatusSuccess       PaymentStatus = "SUCCESS"
	PaymentStatusFailed        PaymentStatus = "FAILED"
	PaymentStatusFullyRefunded PaymentStatus = "FULL_REFUNDED"
	PaymentStatusReserved      PaymentStatus = "REVERSED"
	PaymentStatusCancelled     PaymentStatus = "CANCELLED"
)
View Source
const (
	EventTypeWebPayment eventType = "PAYMENT_WEB_ONLINE"
)
View Source
const (
	ResponseSuccess = "SUCCESS"
)

Variables

View Source
var (
	ErrPaymentAlreadyRefunded  = newErrorCode(ErrorCodePaymentAlreadyRefunded)
	ErrTransactionNotFound     = newErrorCode(ErrorCodeTransactionNotFound)
	ErrStoreNotFound           = newErrorCode(ErrorCodeStoreNotFound)
	ErrRefundExceedLimitPerDay = newErrorCode(ErrorCodeRefundAmountExceedPerDay)
	ErrValidation              = newErrorCode(ErrorCodeValidationError)
)

error to compare, you may compare using errors.Is(err, rm.ErrPaymentAlreadyRefunded)

Functions

This section is empty.

Types

type Client

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

Client :

func NewClient

func NewClient(cfg Config) *Client

NewClient :

func (*Client) CreatePaymentCheckout

func (c *Client) CreatePaymentCheckout(
	ctx context.Context,
	req CreatePaymentCheckoutRequest,
) (*CreatePaymentCheckoutResponse, error)

CreatePaymentCheckout :

func (*Client) CreateTransactionQR added in v1.0.1

func (c *Client) CreateTransactionQR(
	ctx context.Context,
	req CreateTransactionQRRequest,
) (*CreateTransactionQRResponse, error)

CreateTransactionQR :

func (*Client) GetPaymentByCheckoutID added in v1.1.1

func (c *Client) GetPaymentByCheckoutID(
	ctx context.Context,
	checkoutID string,
) (*GetPaymentByCheckoutIDResponse, error)

GetPaymentByCheckoutID :

func (*Client) GetPaymentByOrderID

func (c *Client) GetPaymentByOrderID(
	ctx context.Context,
	orderID string,
) (*GetPaymentByOrderIDResponse, error)

GetPaymentByOrderID :

func (*Client) GetPaymentByTransactionID added in v1.1.1

func (c *Client) GetPaymentByTransactionID(
	ctx context.Context,
	transactionID string,
) (*GetPaymentByTransactionIDResponse, error)

GetPaymentByTransactionID :

func (*Client) GetStores

func (c *Client) GetStores(ctx context.Context) (*GetStoresResponse, error)

GetStores :

func (*Client) RefundPayment added in v1.1.1

func (c *Client) RefundPayment(
	ctx context.Context,
	req RefundPaymentRequest,
) (*RefundPaymentResponse, error)

RefundPayment :

func (*Client) RequestAccessToken

func (c *Client) RequestAccessToken() (*GetAccessTokenResponse, error)

RequestAccessToken :

func (*Client) SetTokenSource added in v1.2.0

func (c *Client) SetTokenSource(src oauth2.TokenSource)

func (*Client) Token

func (c *Client) Token() (*oauth2.Token, error)

func (*Client) VerifyWebhook added in v1.1.1

func (c *Client) VerifyWebhook(
	ctx context.Context,
	body io.Reader,
) (*Webhook, error)

VerifyWebhook :

type Config

type Config struct {
	ClientID     string
	ClientSecret string
	PrivateKey   []byte
	PublicKey    []byte
	StoreID      string
	Sandbox      bool
	TokenSource  oauth2.TokenSource
	Tracer       opentracing.Tracer
}

type CreatePaymentCheckoutRequest

type CreatePaymentCheckoutRequest struct {
	Order struct {
		ID             string `json:"id"`
		Title          string `json:"title"`
		Detail         string `json:"detail"`
		AdditionalData string `json:"additionalData"`
		Amount         uint   `json:"amount"`
		Currency       string `json:"currencyType"`
	} `json:"order"`
	Customer struct {
		UserID      string `json:"userId"`
		Email       string `json:"email,omitempty"`
		CountryCode string `json:"countryCode,omitempty"`
		PhoneNumber string `json:"phoneNumber,omitempty"`
	} `json:"customer"`
	Type          PaymentType     `json:"type"`
	Method        []PaymentMethod `json:"method"`
	StoreID       string          `json:"storeId"`
	RedirectURL   string          `json:"redirectUrl"`
	NotifyURL     string          `json:"notifyUrl"`
	LayoutVersion layout          `json:"layoutVersion"`
}

CreatePaymentCheckoutRequest :

type CreatePaymentCheckoutResponse

type CreatePaymentCheckoutResponse struct {
	Item struct {
		CheckoutID string `json:"checkoutId"`
		URL        string `json:"url"`
	} `json:"item"`
	Code string `json:"code"`
}

CreatePaymentCheckoutResponse :

type CreateTransactionQRRequest added in v1.0.1

type CreateTransactionQRRequest struct {
	Type            CreateTransactionQRType `json:"type"`
	CurrencyType    string                  `json:"currencyType"`
	Amount          int                     `json:"amount"`
	IsPreFillAmount bool                    `json:"isPreFillAmount"`
	Method          []string                `json:"method"`
	Order           struct {
		AdditionalData string `json:"additionalData"`
		Details        string `json:"details"`
		Title          string `json:"title"`
	} `json:"order"`
	Expiry struct {
		Type string `json:"type"`
	} `json:"expiry"`
	RedirectURL string `json:"redirectUrl"`
	StoreID     string `json:"storeId"`
}

CreateTransactionQRRequest :

type CreateTransactionQRResponse added in v1.0.1

type CreateTransactionQRResponse struct {
	Item struct {
		Store struct {
			ID           string `json:"id"`
			Name         string `json:"name"`
			ImageURL     string `json:"imageUrl"`
			AddressLine1 string `json:"addressLine1"`
			AddressLine2 string `json:"addressLine2"`
			PostCode     string `json:"postCode"`
			City         string `json:"city"`
			State        string `json:"state"`
			Country      string `json:"country"`
			CountryCode  string `json:"countryCode"`
			PhoneNumber  string `json:"phoneNumber"`
			GeoLocation  struct {
				Latitude  float64 `json:"latitude"`
				Longitude float64 `json:"longitude"`
			} `json:"geoLocation"`
			Status    string    `json:"status"`
			CreatedAt time.Time `json:"createdAt"`
			UpdatedAt time.Time `json:"updatedAt"`
		} `json:"store"`
		Type            string      `json:"type"`
		IsPreFillAmount bool        `json:"isPreFillAmount"`
		CurrencyType    string      `json:"currencyType"`
		Amount          int         `json:"amount"`
		Platform        string      `json:"platform"`
		Method          interface{} `json:"method"`
		Expiry          struct {
			Type      string    `json:"type"`
			Day       int       `json:"day"`
			ExpiredAt time.Time `json:"expiredAt"`
		} `json:"expiry"`
		Code        string `json:"code"`
		Status      string `json:"status"`
		QrCodeURL   string `json:"qrCodeUrl"`
		RedirectURL string `json:"redirectUrl"`
		Order       struct {
			Title          string `json:"title"`
			Detail         string `json:"detail"`
			AdditionalData string `json:"additionalData"`
		} `json:"order"`
		CreatedAt time.Time `json:"createdAt"`
		UpdatedAt time.Time `json:"updatedAt"`
	} `json:"item"`
	Code string `json:"code"`
}

CreateTransactionQRResponse :

type CreateTransactionQRType added in v1.0.1

type CreateTransactionQRType string

CreateTransactionQRType :

const (
	CreateTransactionQRTypeStatic CreateTransactionQRType = "STATIC"
)

type Error

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

Error :

func (Error) Error

func (e Error) Error() string

Error :

func (Error) Format added in v1.1.1

func (e Error) Format(f fmt.State, verb rune)

func (Error) Is added in v1.1.1

func (e Error) Is(err error) bool

func (Error) Response added in v1.1.1

func (e Error) Response() string

func (Error) ResponseBytes added in v1.1.1

func (e Error) ResponseBytes() []byte

type ErrorCode added in v1.1.1

type ErrorCode interface {
	// contains filtered or unexported methods
}

type GetAccessTokenRequest

type GetAccessTokenRequest struct {
	GrantType string `json:"grantType"`
}

GetAccessTokenRequest :

type GetAccessTokenResponse

type GetAccessTokenResponse struct {
	AccessToken           string `json:"accessToken"`
	TokenType             string `json:"tokenType"`
	ExpiresIn             int    `json:"expiresIn"`
	RefreshToken          string `json:"refreshToken"`
	RefreshTokenExpiresIn int    `json:"refreshTokenExpiresIn"`
}

GetAccessTokenResponse :

type GetPaymentByCheckoutIDResponse added in v1.1.1

type GetPaymentByCheckoutIDResponse struct {
	Item struct {
		ID    string `json:"id"`
		Order struct {
			ID             string `json:"id"`
			Title          string `json:"title"`
			Detail         string `json:"detail"`
			AdditionalData string `json:"additionalData"`
			CurrencyType   string `json:"currencyType"`
			Amount         uint   `json:"amount"`
		} `json:"order"`
		Type          string    `json:"type"`
		TransactionID string    `json:"transactionId"`
		Platform      string    `json:"platform"`
		Method        []string  `json:"method"`
		RedirectURL   string    `json:"redirectUrl"`
		NotifyURL     string    `json:"notifyUrl"`
		StartAt       time.Time `json:"startAt"`
		EndAt         time.Time `json:"endAt"`
		Status        string    `json:"status"`
		CreatedAt     time.Time `json:"createdAt"`
		UpdatedAt     time.Time `json:"updatedAt"`
	} `json:"item"`
	Code string `json:"code"`
}

type GetPaymentByOrderIDResponse

type GetPaymentByOrderIDResponse struct {
	Item struct {
		Store struct {
			ID           string `json:"id"`
			Name         string `json:"name"`
			ImageURL     string `json:"imageUrl"`
			AddressLine1 string `json:"addressLine1"`
			AddressLine2 string `json:"addressLine2"`
			PostCode     string `json:"postCode"`
			City         string `json:"city"`
			State        string `json:"state"`
			Country      string `json:"country"`
			CountryCode  string `json:"countryCode"`
			PhoneNumber  string `json:"phoneNumber"`
			GeoLocation  struct {
				Latitude  float64 `json:"latitude"`
				Longitude float64 `json:"longitude"`
			} `json:"geoLocation"`
			Status    string    `json:"status"`
			CreatedAt time.Time `json:"createdAt"`
			UpdatedAt time.Time `json:"updatedAt"`
		} `json:"store"`
		ReferenceID   string `json:"referenceId"`
		TransactionID string `json:"transactionId"`
		Order         struct {
			ID     string `json:"id"`
			Title  string `json:"title"`
			Detail string `json:"detail"`
			Amount uint   `json:"amount"`
		} `json:"order"`
		TerminalID string `json:"terminalId"`
		Payee      struct {
		} `json:"payee"`
		CurrencyType  string        `json:"currencyType"`
		BalanceAmount uint          `json:"balanceAmount"`
		Platform      string        `json:"platform"`
		Method        string        `json:"method"`
		TransactionAt time.Time     `json:"transactionAt"`
		Type          PaymentType   `json:"type"`
		Status        PaymentStatus `json:"status"`
		Region        string        `json:"region"`
		CreatedAt     time.Time     `json:"createdAt"`
		UpdatedAt     time.Time     `json:"updatedAt"`
	} `json:"item"`
	Code string `json:"code"`
}

GetPaymentByOrderIDResponse :

type GetPaymentByTransactionIDResponse added in v1.1.1

type GetPaymentByTransactionIDResponse struct {
	Item struct {
		Store struct {
			ID           string `json:"id"`
			Name         string `json:"name"`
			ImageURL     string `json:"imageUrl"`
			AddressLine1 string `json:"addressLine1"`
			AddressLine2 string `json:"addressLine2"`
			PostCode     string `json:"postCode"`
			City         string `json:"city"`
			State        string `json:"state"`
			Country      string `json:"country"`
			CountryCode  string `json:"countryCode"`
			PhoneNumber  string `json:"phoneNumber"`
			GeoLocation  struct {
				Latitude  float64 `json:"latitude"`
				Longitude float64 `json:"longitude"`
			} `json:"geoLocation"`
			Status    string    `json:"status"`
			CreatedAt time.Time `json:"createdAt"`
			UpdatedAt time.Time `json:"updatedAt"`
		} `json:"store"`
		ReferenceID   string `json:"referenceId"`
		TransactionID string `json:"transactionId"`
		Order         struct {
			ID     string `json:"id"`
			Title  string `json:"title"`
			Detail string `json:"detail"`
			Amount uint   `json:"amount"`
		} `json:"order"`
		TerminalID string `json:"terminalId"`
		Payee      struct {
		} `json:"payee"`
		CurrencyType  string        `json:"currencyType"`
		BalanceAmount int           `json:"balanceAmount"`
		Voucher       interface{}   `json:"voucher"`
		Platform      string        `json:"platform"`
		Method        string        `json:"method"`
		TransactionAt time.Time     `json:"transactionAt"`
		Type          string        `json:"type"`
		Status        PaymentStatus `json:"status"`
		Region        string        `json:"region"`
		Source        string        `json:"source"`
		CreatedAt     time.Time     `json:"createdAt"`
		UpdatedAt     time.Time     `json:"updatedAt"`
	} `json:"item"`
	Code string `json:"code"`
}

GetPaymentByTransactionIDResponse :

type GetStoresResponse

type GetStoresResponse struct {
	Items []Store `json:"items"`
	Code  string  `json:"code"`
	Meta  struct {
		Count int `json:"count"`
		Total int `json:"total"`
	} `json:"meta"`
}

GetStoresResponse :

type PaymentMethod

type PaymentMethod string

types :

type PaymentStatus added in v1.0.1

type PaymentStatus string

types :

type PaymentType

type PaymentType string

types :

type RefundPaymentRequest added in v1.1.1

type RefundPaymentRequest struct {
	TransactionID string `json:"transactionId"`
	Refund        struct {
		Type         string `json:"type"`
		CurrencyType string `json:"currencyType"`
		Amount       uint   `json:"amount"`
	} `json:"refund"`
	Reason string `json:"reason"`
}

RefundPaymentRequest :

type RefundPaymentResponse added in v1.1.1

type RefundPaymentResponse struct {
	Item struct {
		Store struct {
			ID           string `json:"id"`
			Name         string `json:"name"`
			ImageURL     string `json:"imageUrl"`
			AddressLine1 string `json:"addressLine1"`
			AddressLine2 string `json:"addressLine2"`
			PostCode     string `json:"postCode"`
			City         string `json:"city"`
			State        string `json:"state"`
			Country      string `json:"country"`
			CountryCode  string `json:"countryCode"`
			PhoneNumber  string `json:"phoneNumber"`
			GeoLocation  struct {
				Latitude  float64 `json:"latitude"`
				Longitude float64 `json:"longitude"`
			} `json:"geoLocation"`
			Status    string    `json:"status"`
			CreatedAt time.Time `json:"createdAt"`
			UpdatedAt time.Time `json:"updatedAt"`
		} `json:"store"`
		ReferenceID   string `json:"referenceId"`
		TransactionID string `json:"transactionId"`
		Order         struct {
			ID     string `json:"id"`
			Title  string `json:"title"`
			Detail string `json:"detail"`
			Amount int    `json:"amount"`
		} `json:"order"`
		TerminalID string `json:"terminalId"`
		Payee      struct {
			UserID string `json:"userId"`
		} `json:"payee"`
		CurrencyType  string      `json:"currencyType"`
		BalanceAmount int         `json:"balanceAmount"`
		Voucher       interface{} `json:"voucher"`
		Platform      string      `json:"platform"`
		Method        string      `json:"method"`
		TransactionAt time.Time   `json:"transactionAt"`
		Type          string      `json:"type"`
		Status        string      `json:"status"`
		Region        string      `json:"region"`
		ExtraInfo     struct {
			Card struct {
			} `json:"card"`
		} `json:"extraInfo"`
		Source    string    `json:"source"`
		CreatedAt time.Time `json:"createdAt"`
		UpdatedAt time.Time `json:"updatedAt"`
	} `json:"item"`
	Code string `json:"code"`
}

RefundPaymentResponse :

type Store

type Store struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	AddressLine1 string `json:"addressLine1"`
	AddressLine2 string `json:"addressLine2"`
	PostCode     string `json:"postCode"`
	City         string `json:"city"`
	State        string `json:"state"`
	Country      string `json:"country"`
	CountryCode  string `json:"countryCode"`
	PhoneNumber  string `json:"phoneNumber"`
	GeoLocation  struct {
		Latitude  float64 `json:"latitude"`
		Longitude float64 `json:"longitude"`
	} `json:"geoLocation"`
	Status    string    `json:"status"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

Store :

type Webhook added in v1.1.1

type Webhook struct {
	Data struct {
		BalanceAmount int       `json:"balanceAmount"`
		CreatedAt     time.Time `json:"createdAt"`
		CurrencyType  string    `json:"currencyType"`
		Method        string    `json:"method"`
		Order         struct {
			Amount int    `json:"amount"`
			Detail string `json:"detail"`
			ID     string `json:"id"`
			Title  string `json:"title"`
		} `json:"order"`
		Payee struct {
		} `json:"payee"`
		Platform    string `json:"platform"`
		ReferenceID string `json:"referenceId"`
		Region      string `json:"region"`
		Status      string `json:"status"`
		Store       struct {
			AddressLine1 string    `json:"addressLine1"`
			AddressLine2 string    `json:"addressLine2"`
			City         string    `json:"city"`
			Country      string    `json:"country"`
			CountryCode  string    `json:"countryCode"`
			CreatedAt    time.Time `json:"createdAt"`
			GeoLocation  struct {
				Latitude  float64 `json:"latitude"`
				Longitude float64 `json:"longitude"`
			} `json:"geoLocation"`
			ID          string    `json:"id"`
			ImageURL    string    `json:"imageUrl"`
			Name        string    `json:"name"`
			PhoneNumber string    `json:"phoneNumber"`
			PostCode    string    `json:"postCode"`
			State       string    `json:"state"`
			Status      string    `json:"status"`
			UpdatedAt   time.Time `json:"updatedAt"`
		} `json:"store"`
		TerminalID    string      `json:"terminalId"`
		TransactionAt time.Time   `json:"transactionAt"`
		TransactionID string      `json:"transactionId"`
		Type          PaymentType `json:"type"`
		UpdatedAt     time.Time   `json:"updatedAt"`
		Voucher       interface{} `json:"voucher"`
	} `json:"data"`
	EventType eventType `json:"eventType"`
}

Jump to

Keyboard shortcuts

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