midtrans

package
v0.0.0-...-3b2859e Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BaseOrderId string

BaseOrderId is used to prefix the order id in database for example if the order id is 1, then the order id in midtrans is "something-1"

View Source
var BaseUrlCoreApi string
View Source
var BaseUrlSnap string
View Source
var ServerKey string
View Source
var ServerKeyEncoded string

Functions

func DeleteOrder

func DeleteOrder(orderId string) error

func HandleNotifications

func HandleNotifications(c *gin.Context)

Types

type CustomerDetails

type CustomerDetails struct {
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Email     string `json:"email"`
	Phone     string `json:"phone,omitempty"`
}

type Expiry

type Expiry struct {
	StartTime string `json:"start_time"`
	// Unit is in days, hours, minutes
	Unit     string `json:"unit"`
	Duration int    `json:"duration"`
}

type RequestSnap

type RequestSnap struct {
	TransactionDetails `json:"transaction_details"`
	ItemDetails        []models.CheckoutItem `json:"item_details"`
	CustomerDetails    `json:"customer_details"`
	Expiry             `json:"expiry"`
}

RequestSnap basically is a request to midtrans to create a snap page token for payment

func (*RequestSnap) CreatePayment

func (r *RequestSnap) CreatePayment() (ResponseSnap, error)

type ResponseErrorDeleteOrder

type ResponseErrorDeleteOrder struct {
	StatusCode    string `json:"status_code"`
	StatusMessage string `json:"status_message"`
}

type ResponseErrorSnap

type ResponseErrorSnap struct {
	ErrorMessages []string `json:"error_messages"`
}

type ResponseSnap

type ResponseSnap struct {
	Token       string `json:"token"`
	RedirectUrl string `json:"redirect_url"`
}

type TransactionDetails

type TransactionDetails struct {
	OrderId     string `json:"order_id"`
	GrossAmount int    `json:"gross_amount"`
}

type WebhookNotification

type WebhookNotification struct {
	TransactionStatus string `json:"transaction_status" binding:"required"`
	StatusCode        string `json:"status_code" binding:"required"`
	SignatureKey      string `json:"signature_key" binding:"required"`
	OrderId           string `json:"order_id" binding:"required"`
	GrossAmount       string `json:"gross_amount" binding:"required"`
	PaymentType       string `json:"payment_type" binding:"required"`
	// FraudStatus isn't available in OTC payment (indomaret, alfamart, etc)
	FraudStatus string `json:"fraud_status"`
}

Jump to

Keyboard shortcuts

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