Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions multisafepay/models.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
package multisafepay

const (
OrderStatusCancelled OrderStatus = "cancelled"
OrderStatusCompleted OrderStatus = "completed"
OrderStatusDeclined OrderStatus = "declined"
OrderStatusExpired OrderStatus = "expired"
OrderStatusInitialized OrderStatus = "initialized"
OrderStatusRefunded OrderStatus = "refunded"
OrderStatusReserved OrderStatus = "reserved"
OrderStatusShipped OrderStatus = "shipped"
OrderStatusUncleared OrderStatus = "uncleared"
OrderStatusVoid OrderStatus = "void"
)

// Response from the API, contains a boolean to indicate success
type Response struct {
Success bool `json:"success"`
Expand Down Expand Up @@ -56,7 +69,7 @@ type Order struct {
Description string `json:"description,omitempty"`
PaymentOptions *PaymentOptions `json:"payment_options,omitempty"`
Customer *Customer `json:"customer,omitempty"`
SecondChance *SecondChance `json:"second_chance"`
SecondChance *SecondChance `json:"second_chance"`
}

// PostOrderResponseData is the Data field of PostOrderResponse
Expand Down Expand Up @@ -103,7 +116,7 @@ type GetOrderResponseData struct {
Amount int `json:"amount"`
Description string `json:"description"`
AmountRefunded int `json:"amount_refunded"`
Status string `json:"status,omitempty"`
Status OrderStatus `json:"status,omitempty"`
FinancialStatus string `json:"financial_status"`
Reason string `json:"reason"`
ReasonCode string `json:"reason_code"`
Expand All @@ -116,6 +129,10 @@ type GetOrderResponseData struct {
PaymentMethods []map[string]interface{} `json:"payment_methods"`
}

// The OrderStatus type is used to represent the status of an order
// Documentation: https://docs.multisafepay.com/reference/getorder
type OrderStatus string

// GetOrderResponse is a response to GET /orders/{order_id}
// Documentation: https://docs.multisafepay.com/api/#retrieve-an-order
type GetOrderResponse struct {
Expand Down
4 changes: 2 additions & 2 deletions multisafepay/notification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ func TestValidatePostNotification(t *testing.T) {

auth := &bytes.Buffer{}
auth.Write(timestamp)
auth.Write(postNotificationAuthSep)
auth.Write(makeHMAC(timestamp, payload, apiKey).Sum(nil))
auth.WriteString(postNotificationAuthSep)
auth.WriteString(makeHMAC(timestamp, payload, apiKey))
authHeader := base64.StdEncoding.EncodeToString(auth.Bytes())

t.Logf("Auth header: %s", authHeader)
Expand Down