invoice

package
v1.0.25 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: MIT Imports: 9 Imported by: 12

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(data *CreateParams) (*xendit.Invoice, *xendit.Error)

Create creates new invoice

Example
xendit.Opt.SecretKey = "examplesecretkey"

data := invoice.CreateParams{
	ExternalID:  "invoice-example",
	Amount:      200000,
	PayerEmail:  "customer@customer.com",
	Description: "invoice #1",
}

resp, err := invoice.Create(&data)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("created invoice: %+v\n", resp)
Output:

func CreateWithContext

func CreateWithContext(ctx context.Context, data *CreateParams) (*xendit.Invoice, *xendit.Error)

CreateWithContext creates new invoice with context

func Expire

func Expire(data *ExpireParams) (*xendit.Invoice, *xendit.Error)

Expire expires the created invoice

Example
xendit.Opt.SecretKey = "examplesecretkey"

data := invoice.ExpireParams{
	ID: "invoice-id",
}

resp, err := invoice.Expire(&data)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("expired invoice: %+v\n", resp)
Output:

func ExpireWithContext

func ExpireWithContext(ctx context.Context, data *ExpireParams) (*xendit.Invoice, *xendit.Error)

ExpireWithContext expires the created invoice with context

func Get

func Get(data *GetParams) (*xendit.Invoice, *xendit.Error)

Get gets one invoice

Example
xendit.Opt.SecretKey = "examplesecretkey"

data := invoice.GetParams{
	ID: "invoice-id",
}

resp, err := invoice.Get(&data)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("retrieved invoice: %+v\n", resp)
Output:

func GetAll

func GetAll(data *GetAllParams) ([]xendit.Invoice, *xendit.Error)

GetAll gets all invoices with conditions

Example
xendit.Opt.SecretKey = "examplesecretkey"

createdAfter, _ := time.Parse(time.RFC3339, "2016-02-24T23:48:36.697Z")

data := invoice.GetAllParams{
	Statuses:     []string{"EXPIRED", "SETTLED"},
	Limit:        5,
	CreatedAfter: createdAfter,
}

resps, err := invoice.GetAll(&data)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("invoices: %+v\n", resps)
Output:

func GetAllWithContext

func GetAllWithContext(ctx context.Context, data *GetAllParams) ([]xendit.Invoice, *xendit.Error)

GetAllWithContext gets all invoices with conditions

func GetWithContext

func GetWithContext(ctx context.Context, data *GetParams) (*xendit.Invoice, *xendit.Error)

GetWithContext gets one invoice with context

Types

type Client

type Client struct {
	Opt          *xendit.Option
	APIRequester xendit.APIRequester
}

Client is the client used to invoke invoice API.

func (*Client) Create

func (c *Client) Create(data *CreateParams) (*xendit.Invoice, *xendit.Error)

Create creates new invoice

func (*Client) CreateWithContext

func (c *Client) CreateWithContext(ctx context.Context, data *CreateParams) (*xendit.Invoice, *xendit.Error)

CreateWithContext creates new invoice with context

func (*Client) Expire

func (c *Client) Expire(data *ExpireParams) (*xendit.Invoice, *xendit.Error)

Expire expires the created invoice

func (*Client) ExpireWithContext

func (c *Client) ExpireWithContext(ctx context.Context, data *ExpireParams) (*xendit.Invoice, *xendit.Error)

ExpireWithContext expires the created invoice with context

func (*Client) Get

func (c *Client) Get(data *GetParams) (*xendit.Invoice, *xendit.Error)

Get gets one invoice

func (*Client) GetAll

func (c *Client) GetAll(data *GetAllParams) ([]xendit.Invoice, *xendit.Error)

GetAll gets all invoices with conditions

func (*Client) GetAllWithContext

func (c *Client) GetAllWithContext(ctx context.Context, data *GetAllParams) ([]xendit.Invoice, *xendit.Error)

GetAllWithContext gets all invoices with conditions

func (*Client) GetWithContext

func (c *Client) GetWithContext(ctx context.Context, data *GetParams) (*xendit.Invoice, *xendit.Error)

GetWithContext gets one invoice with context

type CreateParams

type CreateParams struct {
	ForUserID                      string                                       `json:"-"`
	WithFeeRule                    string                                       `json:"-"` // Note: response header fee_rule_id is not implemented yet
	ExternalID                     string                                       `json:"external_id" validate:"required"`
	Amount                         float64                                      `json:"amount" validate:"required"`
	Description                    string                                       `json:"description,omitempty"`
	PayerEmail                     string                                       `json:"payer_email,omitempty"`
	ShouldSendEmail                *bool                                        `json:"should_send_email,omitempty"`
	Customer                       xendit.InvoiceCustomer                       `json:"customer,omitempty"`
	CustomerNotificationPreference xendit.InvoiceCustomerNotificationPreference `json:"customer_notification_preference,omitempty"`
	InvoiceDuration                int                                          `json:"invoice_duration,omitempty"`
	SuccessRedirectURL             string                                       `json:"success_redirect_url,omitempty"`
	FailureRedirectURL             string                                       `json:"failure_redirect_url,omitempty"`
	PaymentMethods                 []string                                     `json:"payment_methods,omitempty"`
	Currency                       string                                       `json:"currency,omitempty"`
	FixedVA                        *bool                                        `json:"fixed_va,omitempty"`
	CallbackVirtualAccountID       string                                       `json:"callback_virtual_account_id,omitempty"`
	MidLabel                       string                                       `json:"mid_label,omitempty"`
	ReminderTimeUnit               string                                       `json:"reminder_time_unit,omitempty"`
	ReminderTime                   int                                          `json:"reminder_time,omitempty"`
	Locale                         string                                       `json:"locale,omitempty"`
	Items                          []xendit.InvoiceItem                         `json:"items,omitempty"`
	Fees                           []xendit.InvoiceFee                          `json:"fees,omitempty"`
	ShouldAuthenticateCreditCard   bool                                         `json:"should_authenticate_credit_card,omitempty"`
}

CreateParams contains parameters for Create

type ExpireParams

type ExpireParams struct {
	ID        string `json:"id" validate:"required"`
	ForUserID string `json:"-"`
}

ExpireParams contains parameters for Expire

type GetAllParams

type GetAllParams struct {
	ForUserID          string    `json:"-"`
	Statuses           []string  `json:"statuses,omitempty"`
	Limit              int       `json:"limit,omitempty"`
	CreatedAfter       time.Time `json:"created_after,omitempty"`
	CreatedBefore      time.Time `json:"created_before,omitempty"`
	PaidAfter          time.Time `json:"paid_after,omitempty"`
	PaidBefore         time.Time `json:"paid_before,omitempty"`
	ExpiredAfter       time.Time `json:"expired_after,omitempty"`
	ExpiredBefore      time.Time `json:"expired_before,omitempty"`
	LastInvoiceID      string    `json:"last_invoice_id,omitempty"`
	ClientTypes        []string  `json:"client_types,omitempty"`
	PaymentChannels    []string  `json:"payment_channels,omitempty"`
	OnDemandLink       string    `json:"on_demand_link,omitempty"`
	RecurringPaymentID string    `json:"recurring_payment_id,omitempty"`
}

GetAllParams contains parameters for GetAll

func (*GetAllParams) QueryString

func (p *GetAllParams) QueryString() string

QueryString creates query string from GetAllParams, ignores nil values

type GetParams

type GetParams struct {
	ForUserID string `json:"-"`
	ID        string `json:"id" validate:"required"`
}

GetParams contains parameters for Get

type InvoiceCallback added in v1.0.17

type InvoiceCallback struct {
	ID                           string                       `json:"id"`
	UserID                       string                       `json:"user_id"`
	ExternalID                   string                       `json:"external_id"`
	IsHigh                       bool                         `json:"is_high"`
	Status                       string                       `json:"status"`
	MerchantName                 string                       `json:"merchant_name"`
	Amount                       float64                      `json:"amount"`
	Created                      string                       `json:"created"`
	Updated                      string                       `json:"updated"`
	PayerEmail                   string                       `json:"payer_email,omitempty"`
	Description                  string                       `json:"description,omitempty"`
	PaymentID                    string                       `json:"payment_id,omitempty"`
	PaidAmount                   float64                      `json:"paid_amount,omitempty"`
	PaymentMethod                string                       `json:"payment_method,omitempty"`
	BankCode                     string                       `json:"bank_code,omitempty"`
	EwalletType                  string                       `json:"ewallet_type,omitempty"`
	CallbackAuthenticationToken  string                       `json:"callback_authentication_token,omitempty"`
	CallbackURL                  string                       `json:"callback_url,omitempty"`
	BusinessID                   string                       `json:"business_id,omitempty"`
	BusinessName                 string                       `json:"business_name,omitempty"`
	OnDemandLink                 string                       `json:"on_demand_link,omitempty"`
	RecurringPaymentID           string                       `json:"recurring_payment_id,omitempty"`
	CreditCardChargeID           string                       `json:"credit_card_charge_id,omitempty"`
	Currency                     string                       `json:"currency,omitempty"`
	InitialCurrency              string                       `json:"initial_currency,omitempty"`
	InitialAmount                float64                      `json:"initial_amount,omitempty"`
	PaidAt                       *string                      `json:"paid_at,omitempty"`
	MidLabel                     string                       `json:"mid_label,omitempty"`
	PaymentChannel               string                       `json:"payment_channel,omitempty"`
	PaymentDestination           string                       `json:"payment_destination,omitempty"`
	SuccessRedirectURL           string                       `json:"success_redirect_url,omitempty"`
	FailureRedirectURL           string                       `json:"failure_redirect_url,omitempty"`
	CreditCardToken              string                       `json:"credit_card_token,omitempty"`
	PaymentMethodID              string                       `json:"payment_method_id,omitempty"`
	ShouldAuthenticateCreditCard bool                         `json:"should_authenticate_credit_card,omitempty"`
	PaymentDetails               *xendit.InvoicePaymentDetail `json:"payment_details,omitempty"`
	Fees                         *[]xendit.InvoiceFee         `json:"fees,omitempty"`
	Items                        *[]xendit.InvoiceItem        `json:"items,omitempty"`
}

Jump to

Keyboard shortcuts

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