Documentation ¶
Index ¶
Constants ¶
View Source
const ( PostTokenEndpoint string = "%v/api/v1/merchants/%v/token" GetPaymentMethod string = "%v/api/v1/merchants/%v/method" PostSnapCartGenerate string = "%v/api/v1/merchants/%v/snap/cart" PostAPICartGenerate string = "%v/api/v1/merchants/%v/cart" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Callback ¶
type Callback struct { Request struct { Data struct { Amount int `json:"amount"` Bank string `json:"bank"` MerchantID string `json:"merchantID"` MerchantOrderID string `json:"merchantOrderId"` Number string `json:"number"` OrderID string `json:"orderID"` Status string `json:"status"` Time struct { Created time.Time `json:"created"` Updated time.Time `json:"updated"` } `json:"time"` TransactionID string `json:"transactionID"` Type string `json:"type"` } `json:"data"` Result Result `json:"result"` } `json:"request"` Signature string `json:"signature"` }
Callback canopus body when payment settlement, expired and canopus notification
type CartPayload ¶
type CartPayload struct { CartDetails struct { ID string `json:"id" validate:"required"` Payment struct { Key string `json:"key,omitempty"` Type string `json:"type,omitempty"` } `json:"payment"` Amount float64 `json:"amount" validate:"required"` Title string `json:"title" validate:"required"` Currency string `json:"currency" validate:"required"` ExpiredAt string `json:"expiredAt" validate:"required"` } `json:"cartDetails" validate:"required"` ItemDetails []CartPayloadItemDetail `json:"itemDetails" validate:"required"` CustomerDetails struct { FirstName string `json:"firstName" validate:"required"` LastName string `json:"lastName,omitempty"` Email string `json:"email" validate:"required"` Phone string `json:"phone" validate:"required"` BillingAddress struct { FirstName string `json:"firstName,omitempty"` LastName string `json:"lastName,omitempty"` Phone string `json:"phone,omitempty"` Address string `json:"address,omitempty"` City string `json:"city,omitempty"` PostalCode string `json:"postalCode,omitempty"` } `json:"billingAddress,omitempty"` ShippingAddress struct { FirstName string `json:"firstName,omitempty"` LastName string `json:"lastName,omitempty"` Phone string `json:"phone,omitempty"` Address string `json:"address,omitempty"` City string `json:"city,omitempty"` PostalCode string `json:"postalCode,omitempty"` } `json:"shippingAddress,omitempty"` } `json:"customerDetails" validate:"required"` URL struct { ReturnURL string `json:"returnURL" validate:"required"` CancelURL string `json:"cancelURL" validate:"required"` NotificationURL string `json:"notificationURL" validate:"required"` } `json:"url" validate:"required"` ExtendInfo struct { AdditionalPrefix string `json:"additionalPrefix,omitempty"` } `json:"extendInfo"` }
CartPayload payload to create cart
type CartPayloadItemDetail ¶
type CartPayloadItemDetail struct { Name string `json:"name" validate:"required"` Desc string `json:"desc"` Price float64 `json:"price" validate:"required"` Quantity int `json:"quantity" validate:"required"` SKU string `json:"SKU" validate:"required"` AdditionalInfo struct { NoHandphone string `json:"No Handphone"` } `json:"additionalInfo"` }
CartPayloadItemDetail item cart detail
type CartResponse ¶
type CartResponse struct { CartID string `json:"cartID"` PayTo string `json:"payto"` Amount string `json:"amount"` Bank string `json:"bank"` Number string `json:"number"` }
CartResponse response after generate cart
type Client ¶ added in v1.1.0
type Client struct { Canopus *ConfigOptions HTTPClient config.HTTPClient Token string Validator *validator.Validate // contains filtered or unexported fields }
func (*Client) GenerateCart ¶ added in v1.1.0
func (c *Client) GenerateCart(payload CartPayload, paymentMethod PaymentMethod) (CartResponse, error)
func (*Client) GetAvailableMethod ¶ added in v1.1.0
func (c *Client) GetAvailableMethod(amount float64) ([]PaymentMethod, error)
GetAvailableMethod Get all available method by merhantID
type ClientMethod ¶ added in v1.1.0
type ClientMethod interface { GetAvailableMethod(amount float64) ([]PaymentMethod, error) GenerateCart(payload CartPayload, paymentMethod PaymentMethod) (CartResponse, error) }
func NewAPICLient ¶ added in v1.1.0
func NewAPICLient(cano *ConfigOptions) ClientMethod
type CommonMessage ¶
type CommonMessage struct { Response struct { Result Result `json:"result"` Data map[string]interface{} `json:"data"` } `json:"response,omitempty"` Request struct { Result Result `json:"result"` Data map[string]interface{} `json:"data"` } `json:"request,omitempty"` Signature string `json:"signature"` }
CommonMessage canopus request/response
func ValidateResponse ¶
func ValidateResponse(resp []byte) (CommonMessage, error)
type ConfigOptions ¶ added in v1.1.0
Click to show internal directories.
Click to hide internal directories.