This repository has been archived by the owner on Jan 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathreceipts.go
52 lines (46 loc) · 1.69 KB
/
receipts.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package starling
import (
"context"
"net/http"
)
// Receipt is a receipt for a transaction
type Receipt struct {
UID string `json:"receiptUid"`
EventUID string `json:"eventUid"`
MetadataSource string `json:"metadataSource"`
ReceiptIdentifier string `json:"receiptIdentifier"`
MerchantIdentifier string `json:"merchantIdentifier"`
MerchantAddress string `json:"merchantAddress"`
TotalAmount float64 `json:"totalAmount"`
TotalTax float64 `json:"totalTax"`
TaxReference string `json:"taxNumber"`
AuthCode string `json:"authCode"`
CardLast4 string `json:"cardLast4"`
ProviderName string `json:"providerName"`
Items []ReceiptItem `json:"items"`
Notes []ReceiptNote `json:"notes"`
}
// ReceiptItem is a single item on a Receipt
type ReceiptItem struct {
UID string `json:"receiptItemUid"`
Description string `json:"description"`
Quantity int32 `json:"quantity"`
Amount float64 `json:"amount"`
Tax float64 `json:"tax"`
URL string `json:"url"`
}
// ReceiptNote is a single item on a Receipt
type ReceiptNote struct {
UID string `json:"noteUid"`
Description string `json:"description"`
URL string `json:"url"`
}
// CreateReceipt creates a receipt for a given mastercard transaction.
func (c *Client) CreateReceipt(ctx context.Context, txnUID string, r Receipt) (*http.Response, error) {
req, err := c.NewRequest("POST", "/api/v1/transactions/mastercard/"+txnUID+"/receipt", r)
if err != nil {
return nil, err
}
resp, err := c.Do(ctx, req, nil)
return resp, err
}