-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreceipt_confirm.go
28 lines (24 loc) · 1.09 KB
/
receipt_confirm.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package smartbonus
import (
"errors"
)
// Body for receipt confirmation
type ReceiptConfirm struct {
Store
UserId string `json:"user_id"` // Phone or sanned key from smartbonus app
Date int64 `json:"date,omitempty"` // Date of receipt (optional)
Discount float64 `json:"discount"` // Amount of discount that received from DiscountReceipt method.
Items []NomenclatureItem `json:"list"` // List of products
Id string `json:"remote_id"` // Unique receipt identifier
Change float64 `json:"accrued,omitempty"` // Rest of money that will accrue to smartbonus account
Additional map[string]interface{} `json:"additional"`
}
// Confirmation of receipt
func confirmReceipt(storeId string, receipt ReceiptConfirm) (*ReceiptResult, error) {
var result ReceiptResult
if len(receipt.Items) == 0 {
return &result, errors.New("no item found")
}
receipt.StoreId = storeId
return &result, sendPostRequest(rootPath+"v2/receipt/confirm", receipt, &result)
}