card

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: 5 Imported by: 3

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureCharge

func CaptureCharge(data *CaptureChargeParams) (*xendit.CardCharge, *xendit.Error)

CaptureCharge captures a card charge

Example
xendit.Opt.SecretKey = "examplesecretkey"

captureChargeData := card.CaptureChargeParams{
	ChargeID: "123",
	Amount:   10000,
}

chargeResp, err := card.CaptureCharge(&captureChargeData)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("captured charge: %+v\n", chargeResp)
Output:

func CaptureChargeWithContext

func CaptureChargeWithContext(ctx context.Context, data *CaptureChargeParams) (*xendit.CardCharge, *xendit.Error)

CaptureChargeWithContext captures a card charge with context

func CreateCharge

func CreateCharge(data *CreateChargeParams) (*xendit.CardCharge, *xendit.Error)

CreateCharge creates new card charge

Example
xendit.Opt.SecretKey = "examplesecretkey"

createChargeData := card.CreateChargeParams{
	TokenID:          "example-token-id",
	AuthenticationID: "example-authentication-id",
	ExternalID:       "cardAuth-1",
	Amount:           10000,
	Capture:          new(bool), // false
}

chargeResp, err := card.CreateCharge(&createChargeData)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("created charge: %+v\n", chargeResp)
Output:

func CreateChargeWithContext

func CreateChargeWithContext(ctx context.Context, data *CreateChargeParams) (*xendit.CardCharge, *xendit.Error)

CreateChargeWithContext creates new card charge with context

func CreateRefund

func CreateRefund(data *CreateRefundParams) (*xendit.CardRefund, *xendit.Error)

CreateRefund gets a card charge

Example
xendit.Opt.SecretKey = "examplesecretkey"

createRefundData := card.CreateRefundParams{
	IdempotencyKey: "unique-idempotency-key",
	ChargeID:       "123",
	Amount:         10000,
	ExternalID:     "example-external-id",
}

refundResp, err := card.CreateRefund(&createRefundData)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("refunded charge: %+v\n", refundResp)
Output:

func CreateRefundWithContext

func CreateRefundWithContext(ctx context.Context, data *CreateRefundParams) (*xendit.CardRefund, *xendit.Error)

CreateRefundWithContext gets a card charge with context

func GetCharge

func GetCharge(data *GetChargeParams) (*xendit.CardCharge, *xendit.Error)

GetCharge gets a card charge

Example
xendit.Opt.SecretKey = "examplesecretkey"

getChargeData := card.GetChargeParams{
	ChargeID: "123",
}

chargeResp, err := card.GetCharge(&getChargeData)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("retrieved charge: %+v\n", chargeResp)
Output:

func GetChargeWithContext

func GetChargeWithContext(ctx context.Context, data *GetChargeParams) (*xendit.CardCharge, *xendit.Error)

GetChargeWithContext gets a card charge with context

func ReverseAuthorization

func ReverseAuthorization(data *ReverseAuthorizationParams) (*xendit.CardReverseAuthorization, *xendit.Error)

ReverseAuthorization reverses a card authorization

Example
xendit.Opt.SecretKey = "examplesecretkey"

reverseAuthorizationData := card.ReverseAuthorizationParams{
	ChargeID:   "123",
	ExternalID: "reverseAuth-id",
}

reverseAuthorizationResp, err := card.ReverseAuthorization(&reverseAuthorizationData)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("reversed authorization: %+v\n", reverseAuthorizationResp)
Output:

func ReverseAuthorizationWithContext

func ReverseAuthorizationWithContext(ctx context.Context, data *ReverseAuthorizationParams) (*xendit.CardReverseAuthorization, *xendit.Error)

ReverseAuthorizationWithContext reverses a card authorization with context

Types

type CaptureChargeParams

type CaptureChargeParams struct {
	ChargeID string  `json:"-" validate:"required"`
	Amount   float64 `json:"amount" validate:"required"`
}

CaptureChargeParams contains parameters for CaptureCharge

type Client

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

Client is the client used to invoke ewallet API.

func (*Client) CaptureCharge

func (c *Client) CaptureCharge(data *CaptureChargeParams) (*xendit.CardCharge, *xendit.Error)

CaptureCharge captures a card charge

func (*Client) CaptureChargeWithContext

func (c *Client) CaptureChargeWithContext(ctx context.Context, data *CaptureChargeParams) (*xendit.CardCharge, *xendit.Error)

CaptureChargeWithContext captures a card charge with context

func (*Client) CreateCharge

func (c *Client) CreateCharge(data *CreateChargeParams) (*xendit.CardCharge, *xendit.Error)

CreateCharge creates new card charge

func (*Client) CreateChargeWithContext

func (c *Client) CreateChargeWithContext(ctx context.Context, data *CreateChargeParams) (*xendit.CardCharge, *xendit.Error)

CreateChargeWithContext creates new card charge with context

func (*Client) CreateRefund

func (c *Client) CreateRefund(data *CreateRefundParams) (*xendit.CardRefund, *xendit.Error)

CreateRefund creates a refund

func (*Client) CreateRefundWithContext

func (c *Client) CreateRefundWithContext(ctx context.Context, data *CreateRefundParams) (*xendit.CardRefund, *xendit.Error)

CreateRefundWithContext creates a refund with context

func (*Client) GetCharge

func (c *Client) GetCharge(data *GetChargeParams) (*xendit.CardCharge, *xendit.Error)

GetCharge gets a card charge

func (*Client) GetChargeWithContext

func (c *Client) GetChargeWithContext(ctx context.Context, data *GetChargeParams) (*xendit.CardCharge, *xendit.Error)

GetChargeWithContext gets a card charge with context

func (*Client) ReverseAuthorization

func (c *Client) ReverseAuthorization(data *ReverseAuthorizationParams) (*xendit.CardReverseAuthorization, *xendit.Error)

ReverseAuthorization reverses a card authorization

func (*Client) ReverseAuthorizationWithContext

func (c *Client) ReverseAuthorizationWithContext(ctx context.Context, data *ReverseAuthorizationParams) (*xendit.CardReverseAuthorization, *xendit.Error)

ReverseAuthorizationWithContext reverses a card authorization with context

type CreateChargeParams

type CreateChargeParams struct {
	ForUserID        string  `json:"-"`
	TokenID          string  `json:"token_id" validate:"required"`
	ExternalID       string  `json:"external_id" validate:"required"`
	Amount           float64 `json:"amount" validate:"required"`
	AuthenticationID string  `json:"authentication_id,omitempty"`
	CardCVN          string  `json:"card_cvn,omitempty"`
	Capture          *bool   `json:"capture,omitempty"`
	CardData         *Data   `json:"card_data,omitempty"`
	Descriptor       string  `json:"descriptor,omitempty"`
	MidLabel         string  `json:"mid_label,omitempty"`
	Currency         string  `json:"currency,omitempty"`
	IsRecurring      *bool   `json:"is_recurring,omitempty"`
}

CreateChargeParams contains parameters for CreateCharge

type CreateRefundParams

type CreateRefundParams struct {
	IdempotencyKey string  `json:"-"`
	ChargeID       string  `json:"-" validate:"required"`
	Amount         float64 `json:"amount" validate:"required"`
	ExternalID     string  `json:"external_id" validate:"required"`
}

CreateRefundParams contains parameters for CreateRefund

type Data

type Data struct {
	AccountNumber string `json:"account_number"`
	ExpMonth      string `json:"exp_month"`
	ExpYear       string `json:"exp_year"`
	CVN           string `json:"cvn,omitempty"`
}

Data is credit card data and used in CardData

type GetChargeParams

type GetChargeParams struct {
	ChargeID string `json:"credit_card_charge_id" validate:"required"`
}

GetChargeParams contains parameters for GetCharge

type ReverseAuthorizationParams

type ReverseAuthorizationParams struct {
	ChargeID   string `json:"-" validate:"required"`
	ExternalID string `json:"external_id" validate:"required"`
}

ReverseAuthorizationParams contains parameters for ReverseAuthorization

Jump to

Keyboard shortcuts

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