paymob

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: LGPL-2.1 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authenticate

func Authenticate(APIKey string) (string, error)

returns a token valid for 1 hour

func ConcatTransactionProcessedValues

func ConcatTransactionProcessedValues(c *TransactionProcessedRequest) string

func ConcatTransactionResponseValues

func ConcatTransactionResponseValues(r *TransactionResponseRequest) string

func GenerateIFrameURL

func GenerateIFrameURL(iframeId string, paymentKey string) string

func RegisterOrder

func RegisterOrder(authToken string, items []Item, totalPriceInCents uint) (int, error)

return thirdparty order identifier

func RequestPaymentKey

func RequestPaymentKey(authToken string, paymentIntegrationId string, orderId int, amountCents uint, firstName string, lastName string, email string, phone string, expirationSec uint) (string, error)

func RequestRefund added in v0.0.8

func RequestRefund(authToken string, transactionId uint, amountCents uint) (uint, error)

func ValidateHMAC

func ValidateHMAC(message string, expectedHMAC string, key string) bool

Types

type BillingData

type BillingData struct {
	Apartment      string `json:"apartment"`
	Email          string `json:"email"`
	Floor          string `json:"floor"`
	FirstName      string `json:"first_name"`
	Street         string `json:"street"`
	Building       string `json:"building"`
	PhoneNumber    string `json:"phone_number"`
	ShippingMethod string `json:"shipping_method"`
	PostalCode     string `json:"postal_code"`
	City           string `json:"city"`
	Country        string `json:"country"`
	LastName       string `json:"last_name"`
	State          string `json:"state"`
}

type Item

type Item struct {
	Name        string `json:"name"`
	AmountCents uint   `json:"amount_cents"`
	Description string `json:"description"`
	Quantity    uint   `json:"quantity"`
}

type OrderRegistrationRequest

type OrderRegistrationRequest struct {
	AuthToken      string `json:"auth_token"`
	DeliveryNeeded bool   `json:"delivery_needed"`
	AmountCents    uint   `json:"amount_cents"`
	Items          []Item `json:"items"`
}

type PaymentKeyRequest

type PaymentKeyRequest struct {
	AuthToken       string      `json:"auth_token"`
	AmountCents     uint        `json:"amount_cents"`
	ExpirationMS    uint        `json:"expiration"`
	OrderID         int         `json:"order_id"`
	Currency        string      `json:"currency"`
	IntegrationID   string      `json:"integration_id"`
	UserBillingData BillingData `json:"billing_data"`
}

type RefundRequest added in v0.0.8

type RefundRequest struct {
	AuthToken     string `json:"auth_token"`
	TransactionId uint   `json:"transaction_id"`
	AmountCents   uint   `json:"amount_cents"`
}

type TransactionProcessedRequest

type TransactionProcessedRequest struct {
	Obj struct {
		Id                   uint `json:"id"`
		Pending              bool `json:"pending"`
		AmountCents          uint `json:"amount_cents"`
		Success              bool `json:"success"`
		IsAuth               bool `json:"is_auth"`
		IsCapture            bool `json:"is_capture"`
		IsStandalonePayment  bool `json:"is_standalone_payment"`
		IsVoided             bool `json:"is_voided"`
		IsRefunded           bool `json:"is_refunded"`
		Is3dSecure           bool `json:"is_3d_secure"`
		IntegrationId        uint `json:"integration_id"`
		HasParentTransaction bool `json:"has_parent_transaction"`
		Order                struct {
			Id uint `json:"id"`
		} `json:"order"`
		CreatedAt  string `json:"created_at"`
		Currency   string `json:"currency"`
		SourceData struct {
			Pan     string `json:"pan"`
			Type_   string `json:"type"`
			SubType string `json:"sub_type"`
		} `json:"source_data"`
		ErrorOccured bool `json:"error_occured"`
		Owner        uint `json:"owner"`
	} `json:"obj"`
}

for back-end direct callback

type TransactionResponseRequest added in v0.0.5

type TransactionResponseRequest struct {
	Id                   uint   `schema:"id"`
	Pending              bool   `schema:"pending"`
	AmountCents          uint   `schema:"amount_cents"`
	Success              bool   `schema:"success"`
	IsAuth               bool   `schema:"is_auth"`
	IsCapture            bool   `schema:"is_capture"`
	IsStandalonePayment  bool   `schema:"is_standalone_payment"`
	IsVoided             bool   `schema:"is_voided"`
	IsRefunded           bool   `schema:"is_refunded"`
	Is3dSecure           bool   `schema:"is_3d_secure"`
	IntegrationId        uint   `schema:"integration_id"`
	HasParentTransaction bool   `schema:"has_parent_transaction"`
	OrderId              uint   `schema:"order"`
	CreatedAt            string `schema:"created_at"`
	Currency             string `schema:"currency"`
	SourceData           struct {
		Pan     string `schema:"pan"`
		Type    string `schema:"type"`
		SubType string `schema:"sub_type"`
	} `schema:"source_data"`
	ErrorCccured bool   `schema:"error_occured"`
	Owner        string `schema:"owner"`
}

TODO: find a way to merge these two structs for post-payment redirection

func MakeTransactionResponseRequest added in v0.0.6

func MakeTransactionResponseRequest(params *map[string][]string) TransactionResponseRequest

Jump to

Keyboard shortcuts

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