Documentation ¶
Index ¶
- Constants
- func Init(config Config)
- func MigrateModels() (models []interface{})
- func ValidatePaymentWebhook(webhook PaymentWebhook) bool
- type BillingRepository
- func (r BillingRepository) CreateBillingOrder(m *BillingTransaction, db *gorm.DB) (err error)
- func (r BillingRepository) GetBillingOrderByPaymentToken(paymentToken string, db *gorm.DB) (model BillingTransaction, err error)
- func (r BillingRepository) GetBillingOrderByPaymentTokenAndTable(table string, paymentToken string, db *gorm.DB) (model BillingTransaction, err error)
- func (r BillingRepository) GetBillingOrderByTransactionId(transactionID string, db *gorm.DB) (model BillingTransaction, err error)
- type BillingTransaction
- type Client
- func (c *Client) CreateOrder(ctx context.Context, transactionId string, body OrderRequest) (orderResponse OrderResponse, billingTrx BillingTransaction, err error)
- func (c *Client) CreatePayment(ctx context.Context, body PaymentRequest) (paymentResponse PaymentResponse, billingTrx BillingTransaction, err error)
- func (c *Client) GetOrderStatus(ctx context.Context, body OrderSubsRequest) (orderSubsResponse OrderSubsReponse, err error)
- func (c *Client) GetPaymentStatus(ctx context.Context, paymentToken string) (paymentStatusResponse PaymentStatusResponse, err error)
- type ClientInterface
- type ClientOption
- type Config
- type Environment
- type HttpRequestDoer
- type OrderRequest
- type OrderResponse
- type OrderSubsReponse
- type OrderSubsRequest
- type PaymentRequest
- type PaymentResponse
- type PaymentStatus
- type PaymentStatusResponse
- type PaymentWebhook
- type RequestBeforeFn
- type ResponseAfterFn
- type SubscriptionResponse
- type SubscriptionStatus
Constants ¶
const ( SUCCESS PaymentStatus = "SUCCESS" SANDBOX Environment = "sandbox" PROD Environment = "prod" )
Variables ¶
This section is empty.
Functions ¶
func ValidatePaymentWebhook ¶
func ValidatePaymentWebhook(webhook PaymentWebhook) bool
Types ¶
type BillingRepository ¶
type BillingRepository struct{}
func (BillingRepository) CreateBillingOrder ¶
func (r BillingRepository) CreateBillingOrder(m *BillingTransaction, db *gorm.DB) (err error)
func (BillingRepository) GetBillingOrderByPaymentToken ¶
func (r BillingRepository) GetBillingOrderByPaymentToken(paymentToken string, db *gorm.DB) (model BillingTransaction, err error)
func (BillingRepository) GetBillingOrderByPaymentTokenAndTable ¶ added in v1.0.5
func (r BillingRepository) GetBillingOrderByPaymentTokenAndTable(table string, paymentToken string, db *gorm.DB) (model BillingTransaction, err error)
func (BillingRepository) GetBillingOrderByTransactionId ¶ added in v1.0.5
func (r BillingRepository) GetBillingOrderByTransactionId(transactionID string, db *gorm.DB) (model BillingTransaction, err error)
type BillingTransaction ¶
type Client ¶
type Client struct { // The endpoint of the server conforming to this interface, with scheme, Endpoint string // Doer for performing requests, typically a *http.Client with any // customized settings, such as certificate chains. Client HttpRequestDoer // A callback for modifying requests which are generated before sending over // the network. RequestBefore RequestBeforeFn // A callback for modifying response which are generated before sending over // the network. ResponseAfter ResponseAfterFn // The user agent header identifies your application, its version number, and the platform and programming language you are using. // You must include a user agent header in each request submitted to the sales partner API. UserAgent string }
func NewClient ¶
func NewClient(opts ...ClientOption) (*Client, error)
Creates a new Client, with reasonable defaults
func (*Client) CreateOrder ¶
func (c *Client) CreateOrder(ctx context.Context, transactionId string, body OrderRequest) (orderResponse OrderResponse, billingTrx BillingTransaction, err error)
func (*Client) CreatePayment ¶ added in v1.1.0
func (c *Client) CreatePayment(ctx context.Context, body PaymentRequest) (paymentResponse PaymentResponse, billingTrx BillingTransaction, err error)
func (*Client) GetOrderStatus ¶
func (c *Client) GetOrderStatus(ctx context.Context, body OrderSubsRequest) (orderSubsResponse OrderSubsReponse, err error)
func (*Client) GetPaymentStatus ¶ added in v1.1.0
type ClientInterface ¶
type ClientInterface interface { CreateOrder(ctx context.Context, transactionId string, body OrderRequest) (orderResponse OrderResponse, billingTrx BillingTransaction, err error) GetOrderStatus(ctx context.Context, body OrderSubsRequest) (orderSubsResponse OrderSubsReponse, err error) CreatePayment(ctx context.Context, transactionId string, body PaymentRequest) (paymentResponse PaymentResponse, billingTrx BillingTransaction, err error) GetPaymentStatus(ctx context.Context, paymentToken string) (paymentStatusResponse PaymentStatusResponse, err error) }
The interface specification for the client above.
type ClientOption ¶
ClientOption allows setting custom parameters during construction
func WithRequestBefore ¶
func WithRequestBefore(fn RequestBeforeFn) ClientOption
WithRequestBefore allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.
func WithResponseAfter ¶
func WithResponseAfter(fn ResponseAfterFn) ClientOption
WithResponseAfter allows setting up a callback function, which will be called right after get response the request. This can be used to log.
func WithUserAgent ¶
func WithUserAgent(userAgent string) ClientOption
WithUserAgent set up useragent add user agent to every request automatically
type Environment ¶ added in v1.1.0
type Environment string
type HttpRequestDoer ¶
Doer performs HTTP requests.
The standard http.Client implements this interface.
type OrderRequest ¶
type OrderResponse ¶
type OrderSubsReponse ¶
type OrderSubsRequest ¶
type PaymentRequest ¶ added in v1.1.0
type PaymentResponse ¶ added in v1.1.0
type PaymentResponse struct { Code string Text string Status PaymentStatus Token string PaymentUrl string }
type PaymentStatus ¶
type PaymentStatus string
type PaymentStatusResponse ¶ added in v1.1.0
type PaymentStatusResponse struct { Status PaymentStatus TotalPayedAmount int Email string }
type PaymentWebhook ¶
type RequestBeforeFn ¶
RequestBeforeFn is the function signature for the RequestBefore callback function
type ResponseAfterFn ¶
ResponseAfterFn is the function signature for the ResponseAfter callback function
type SubscriptionResponse ¶ added in v1.0.1
type SubscriptionResponse struct { Data interface{} RedirectUrl string Status SubscriptionStatus }
type SubscriptionStatus ¶ added in v1.0.1
type SubscriptionStatus string
const ( REDIRECT SubscriptionStatus = "REDIRECT" SUBSCRIBE SubscriptionStatus = "SUBSCRIBE" )