Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreatePayment ¶
func CreatePayment(data *CreatePaymentParams) (*xendit.CardlessCredit, *xendit.Error)
CreatePayment creates new payment
Example ¶
xendit.Opt.SecretKey = "examplesecretkey" createPaymentData := cardlesscredit.CreatePaymentParams{ CardlessCreditType: xendit.CardlessCreditTypeEnumKREDIVO, ExternalID: "cardless-credit-" + time.Now().String(), Amount: 200000, PaymentType: xendit.PaymentTypeEnum3Months, Items: []cardlesscredit.Item{ { ID: "123", Name: "Laptop Asus Ila", Price: 200000, Type: "Laptop", URL: "http://asus-ila.com", Quantity: 1, }, }, CustomerDetails: cardlesscredit.CustomerDetails{ FirstName: "Michael", LastName: "Belajarrock", Email: "michaelbelajarrock@mail.com", Phone: "08123123123", }, ShippingAddress: cardlesscredit.ShippingAddress{ FirstName: "Michael", LastName: "Belajarjazz", Address: "Jalan Teknologi No. 12", City: "Jakarta", PostalCode: "40000", Phone: "08123123123", CountryCode: "IDN", }, RedirectURL: "https://google.com", CallbackURL: "https://google.com", } resp, err := cardlesscredit.CreatePayment(&createPaymentData) if err != nil { log.Fatal(err) } fmt.Printf("created payment: %+v\n", resp)
Output:
func CreatePaymentWithContext ¶
func CreatePaymentWithContext(ctx context.Context, data *CreatePaymentParams) (*xendit.CardlessCredit, *xendit.Error)
CreatePaymentWithContext creates new payment
Types ¶
type Client ¶
type Client struct { Opt *xendit.Option APIRequester xendit.APIRequester }
Client is the client used to invoke invoice API.
func (*Client) CreatePayment ¶
func (c *Client) CreatePayment(data *CreatePaymentParams) (*xendit.CardlessCredit, *xendit.Error)
CreatePayment creates new cardless credit payment
func (*Client) CreatePaymentWithContext ¶
func (c *Client) CreatePaymentWithContext(ctx context.Context, data *CreatePaymentParams) (*xendit.CardlessCredit, *xendit.Error)
CreatePaymentWithContext creates new cardless credit payment with context
type CreatePaymentParams ¶
type CreatePaymentParams struct { CardlessCreditType xendit.CardlessCreditTypeEnum `json:"cardless_credit_type" validate:"required"` ExternalID string `json:"external_id" validate:"required"` Amount float64 `json:"amount" validate:"required"` PaymentType xendit.PaymentTypeEnum `json:"payment_type" validate:"required"` Items []Item `json:"items" validate:"required"` CustomerDetails CustomerDetails `json:"customer_details" validate:"required"` ShippingAddress ShippingAddress `json:"shipping_address" validate:"required"` RedirectURL string `json:"redirect_url" validate:"required"` CallbackURL string `json:"callback_url" validate:"required"` }
CreatePaymentParams contains parameters for CreatePayment
type CustomerDetails ¶
type CustomerDetails struct { FirstName string `json:"first_name" validate:"required"` LastName string `json:"last_name" validate:"required"` Email string `json:"email" validate:"required"` Phone string `json:"phone" validate:"required"` }
CustomerDetails is data that contained in CreatePaymentParams at CustomerDetails
type Item ¶
type Item struct { ID string `json:"id" validate:"required"` Name string `json:"name" validate:"required"` Price float64 `json:"price" validate:"required"` Type string `json:"type" validate:"required"` URL string `json:"url" validate:"required"` Quantity int `json:"quantity" validate:"required"` }
Item is data that contained in CreatePaymentParams at Items
type ShippingAddress ¶
type ShippingAddress struct { FirstName string `json:"first_name" validate:"required"` LastName string `json:"last_name" validate:"required"` Address string `json:"address" validate:"required"` City string `json:"city" validate:"required"` PostalCode string `json:"postal_code" validate:"required"` Phone string `json:"phone" validate:"required"` CountryCode string `json:"country_code" validate:"required"` }
ShippingAddress is data that contained in CreatePaymentParams at ShippingAddress
Click to show internal directories.
Click to hide internal directories.