1
|
|
|
package smobilpay |
2
|
|
|
|
3
|
|
|
import ( |
4
|
|
|
"time" |
5
|
|
|
|
6
|
|
|
"github.com/davecgh/go-spew/spew" |
7
|
|
|
) |
8
|
|
|
|
9
|
|
|
// QuoteParams is the input needed to initialize a transaction |
10
|
|
|
type QuoteParams struct { |
11
|
|
|
PayItemID string `json:"payItemId"` |
12
|
|
|
Amount string `json:"amount"` |
13
|
|
|
} |
14
|
|
|
|
15
|
|
|
// Quote represents an initialized transaction |
16
|
|
|
type Quote struct { |
17
|
|
|
QuoteID string `json:"quoteId"` |
18
|
|
|
ExpiresAt time.Time `json:"expiresAt"` |
19
|
|
|
PayItemID string `json:"payItemId"` |
20
|
|
|
AmountLocalCurrency string `json:"amountLocalCur"` |
21
|
|
|
PriceLocalCurrency int `json:"priceLocalCur"` |
22
|
|
|
PriceSystemCurrency int `json:"priceSystemCur"` |
23
|
|
|
LocalCurrency string `json:"localCur"` |
24
|
|
|
SystemCurrency string `json:"systemCur"` |
25
|
|
|
Promotion interface{} `json:"promotion"` |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
// CollectParams is the input needed to confirm a transaction |
29
|
|
|
type CollectParams struct { |
30
|
|
|
QuoteID string `json:"quoteId"` |
31
|
|
|
CustomerPhoneNumber string `json:"customerPhonenumber"` |
32
|
|
|
CustomerEmailAddress string `json:"customerEmailaddress"` |
33
|
|
|
CustomerName *string `json:"customerName"` |
34
|
|
|
CustomerAddress *string `json:"customerAddress"` |
35
|
|
|
CustomerNumber *string `json:"customerNumber"` |
36
|
|
|
ServiceNumber *string `json:"serviceNumber"` |
37
|
|
|
ExternalTransactionID *string `json:"trid"` |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
func (params *CollectParams) toPayload() map[string]string { |
41
|
|
|
payload := map[string]string{ |
42
|
|
|
"quoteId": params.QuoteID, |
43
|
|
|
"customerPhonenumber": params.CustomerPhoneNumber, |
44
|
|
|
"customerEmailaddress": params.CustomerEmailAddress, |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
if params.CustomerName != nil { |
48
|
|
|
payload["customerName"] = *params.CustomerName |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
if params.CustomerAddress != nil { |
52
|
|
|
payload["customerAddress"] = *params.CustomerAddress |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
if params.ServiceNumber != nil { |
56
|
|
|
payload["serviceNumber"] = *params.ServiceNumber |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
if params.ExternalTransactionID != nil { |
60
|
|
|
payload["trid"] = *params.ExternalTransactionID |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
spew.Dump(payload) |
64
|
|
|
|
65
|
|
|
return payload |
66
|
|
|
} |
67
|
|
|
|