requests

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHTTPStatusCode400ErrorMessage

func GetHTTPStatusCode400ErrorMessage(response *http.Response) string

func InitConfig

func InitConfig() bool

func RandStringBytes

func RandStringBytes(n int) string

RandStringBytes used to generate random string (For Merchant Reference No)

func Sha512Encrypt

func Sha512Encrypt(input string) string

Sha512Encrypt used to convert string into encrypted string using Sha 512 algorithm

Types

type CB

type CB struct {
	CreditBalance []struct {
		Amount      string `json:"amount"`
		Currency    string `json:"currency"`
		ServiceCode string `json:"service_code"`
	} `json:"credit_balance"`
}

type CBUser

type CBUser struct {
	CustomerMobile string `json:"customer_mobile"`
	MarketCode     string `json:"market_code"`
}

type Configuration

type Configuration struct {
	MinLimit    json.Number `json:"min_limit"`
	MaxLimit    json.Number `json:"max_limit"`
	PaymentType string      `json:"service_name"`
	Description string      `json:"description"`
	ServiceCode string      `json:"service_code"`
	Instalments int         `json:"instalments,omitempty"`
}

Configuration - Struct for configuration

type ConfigurationRequest

type ConfigurationRequest struct {
	MarketCode string `json:"market_code"`
}

ConfigurationRequest - Accepted inputs for configuration

type ConfigurationResponse

type ConfigurationResponse struct {
	Configurations []Configuration `json:"configuration"`
}

ConfigurationResponse - Final response formtat of Configuration api

type ContactRequest

type ContactRequest struct {
	Name         string `json:"name"`
	AddressLine1 string `json:"address_line1"`
	AddressLine2 string `json:"address_line2"`
	City         string `json:"city"`
	State        string `json:"state"`
	Zipcode      string `json:"zipcode"`
	CountryCode  string `json:"country_code"`
	PhoneNumber  string `json:"phone_number"`
}

ContactRequest - Accepted input format of contact data

type CustomerRequest

type CustomerRequest struct {
	FirstName     string `json:"first_name"`
	LastName      string `json:"last_name"`
	CustomerEmail string `json:"customer_email"`
	CustomerPhone string `json:"customer_phone"`
	CustomerDOB   string `json:"customer_dob"`
	CustomerPID   int    `json:"customer_pid,omitempty"`
}

CustomerRequest - Accepted input format of customer data

type Delivery

type Delivery struct {
	TransactionID      string `json:"transaction_id"`
	Status             string `json:"status"`
	OriginalAmount     int    `json:"original_amount"`
	DeliveredAt        string `json:"delivered_at"`
	FinalCaptureAmount int    `json:"final_capture_amount"`
}

Delivery - Final response format of add delivery api

type DeliveryRequest

type DeliveryRequest struct {
	DeliveredAt        string `json:"delivered_at"`
	FinalCaptureAmount int    `json:"final_capture_amount,omitempty"`
}

DeliveryRequest - Accepted input format of delivery requests

type Details

type Details struct {
	Error string `json:"error"`
	Field string `json:"field"`
}

Details - Final format of error details

type Error

type Error struct {
	Message string `json:"message"`
	Code    int    `json:"code"`
}

Error defines an error received when making a requests to the API.

func (Error) Error

func (e Error) Error() string

Error returns a string representing the error, satisfying the error interface.

type HTTPStatusCode400

type HTTPStatusCode400 struct {
	StatusCode int       `json:"status"`
	Message    string    `json:"message"`
	Details    []Details `json:"details"`
}

HTTPStatusCode400 Struct for HTTP Status code 400

type ItemRequest

type ItemRequest struct {
	Name           string     `json:"name"`
	Sku            string     `json:"sku"`
	Price          float32    `json:"price"`
	Quantity       int        `json:"quantity"`
	DiscountAmount int        `json:"discount_amount"`
	TaxAmount      int        `json:"tax_amount"`
	CurrencyCode   string     `json:"currency_code"`
	Categories     [][]string `json:"categories"`
}

ItemRequest - Accepted input format of item data

type Merchant

type Merchant struct {
	MerchantKey    string
	MerchantSecret string
	Salt           string
	MarketCode     string
	Host           string
	Version        string
	Timeout        time.Duration
	Transport      http.RoundTripper
}

Merchant defines the Merchant client.

func NewClient

func NewClient() *Merchant

NewClient returns a new Merchant API client which can be used to make RPC requests.

func (*Merchant) AddDelivery

func (m *Merchant) AddDelivery(tsr TransactionStatusRequest, dr DeliveryRequest) (Delivery, error)

AddDelivery used to add a delivery date to a transaction

func (*Merchant) CreateRefund

func (m *Merchant) CreateRefund(rr RefundRequest) (Refund, error)

CreateRefund used to create a refund application for a transaction

func (*Merchant) CreateTransaction

func (m *Merchant) CreateTransaction(tr TransactionRequest) (Transaction, error)

CreateTransaction used to create a new transaction

func (*Merchant) GenerateSignatureCreateTransaction

func (m *Merchant) GenerateSignatureCreateTransaction(OR OrderRequest) string

func (*Merchant) GetConfiguration

func (m *Merchant) GetConfiguration(cr ConfigurationRequest) (ConfigurationResponse, error)

GetConfiguration returns configuration of the Merchant

func (*Merchant) GetCreditBalance

func (m *Merchant) GetCreditBalance(um string) (CB, error)

func (*Merchant) GetRefundStatus

func (m *Merchant) GetRefundStatus(rsr RefundStatusRequest) (Refund, error)

GetRefundStatus Used to get the status of refund

func (*Merchant) GetTransactionStatus

func (m *Merchant) GetTransactionStatus(tsr TransactionStatusRequest) (TransactionStatus, error)

GetTransactionStatus used to get the status of a transaction

func (*Merchant) Healthcheck

func (m *Merchant) Healthcheck() (string, error)

Healthcheck used to check the availability of the api

type OrderRequest

type OrderRequest struct {
	ServiceCode         string  `json:"service_code"`
	Amount              float32 `json:"amount"`
	MarketCode          string  `json:"market_code"`
	Currency            string  `json:"currency"`
	MerchantReferenceNo string  `json:"merchant_reference_no"`
	DiscountAmount      int     `json:"discount_amount"`
	ShippingAmount      int     `json:"shipping_amount"`
	TaxAmount           int     `json:"tax_amount"`
	Language            string  `json:"lang"`
	Signature           string  `json:"signature"`
}

OrderRequest - Accepted input format of order data

type Refund

type Refund struct {
	RefundID                string      `json:"refund_id"`
	Amount                  json.Number `json:"refund_amount"`
	Currency                string      `json:"currency"`
	TransactionID           string      `json:"transaction_id"`
	Status                  string      `json:"status"`
	RequestID               string      `json:"request_id"`
	MerchantRefundReference string      `json:"merchant_refund_reference"`
	DeclinedReason          string      `json:"declined_reason"`
	CreatedAt               time.Time   `json:"created_at"`
	RefundedAt              *time.Time  `json:"refunded_at,omitempty"`
}

Refund - Final response format of create refund and refund status api requests

type RefundRequest

type RefundRequest struct {
	TransactionID           string `json:"transaction_id"`
	Amount                  int    `json:"refund_amount"`
	Reason                  string `json:"reason"`
	RequestID               string `json:"request_id"`
	MerchantRefundReference string `json:"merchant_refund_reference"`
}

RefundRequest - Accepted input format of create refund api

type RefundStatusRequest

type RefundStatusRequest struct {
	RefundID string `json:"refund_id"`
}

RefundStatusRequest - Accepted input format of refund status api

type ShippingServiceRequest

type ShippingServiceRequest struct {
	Name      string `json:"name"`
	ShippedAt string `json:"shipped_at"`
	Tracking  string `json:"tracking"`
	Priority  string `json:"priority"`
}

ShippingServiceRequest - Accepted input format of Shipping Service data

type Transaction

type Transaction struct {
	Token           string    `json:"session_token"`
	TransactionID   string    `json:"transaction_id"`
	TokenExpiryTime time.Time `json:"expiry_time"`
	PaymentURL      string    `json:"payment_url"`
	Signature       string    `json:"signature"`
}

Transaction - Final response format of transaction api

type TransactionRequest

type TransactionRequest struct {
	Customer        CustomerRequest        `json:"customer"`
	Order           OrderRequest           `json:"order"`
	Items           []ItemRequest          `json:"items"`
	Billing         ContactRequest         `json:"billing"`
	Shipping        ContactRequest         `json:"shipping"`
	ShippingService ShippingServiceRequest `json:"shipping_service"`
}

TransactionRequest - Accepted input format of transaction requests

type TransactionStatus

type TransactionStatus struct {
	TransactionID string      `json:"transaction_id"`
	PaymentStatus string      `json:"status"`
	Amount        json.Number `json:"amount"`
	CreatedAt     time.Time   `json:"created_at"`
}

TransactionStatus - Final response format of transaction status api

type TransactionStatusRequest

type TransactionStatusRequest struct {
	TransactionID string `json:"transaction_id"`
}

TransactionStatusRequest - Accepted inputs to fetch status of transaction

Jump to

Keyboard shortcuts

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