-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverifyPayment.go
44 lines (40 loc) · 1.1 KB
/
verifyPayment.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
package irankish
import (
"errors"
"fmt"
)
type VerifyPayment struct {
merchantId string
sha1Key string
Token string
ReferenceNumber string
}
func (vp *VerifyPayment) getTags() (tagsArray []string, err error) {
tags := map[string]string{
"token": "<ns1:token>%s</ns1:token>",
"merchantId": "<ns1:merchantId>%s</ns1:merchantId>",
"referenceNumber": "<ns1:referenceNumber>%s</ns1:referenceNumber>",
"sha1Key": "<ns1:sha1Key>%s</ns1:sha1Key>",
}
if vp.Token == "" {
err = errors.New("empty_token")
return
}
if vp.merchantId == "" {
err = errors.New("empty_merchant_id")
return
}
if vp.ReferenceNumber == "" {
err = errors.New("empty_reference_id")
return
}
if vp.sha1Key == "" {
err = errors.New("empty_sha1_key")
return
}
tagsArray = append(tagsArray, fmt.Sprintf(tags["token"], vp.Token))
tagsArray = append(tagsArray, fmt.Sprintf(tags["merchantId"], vp.merchantId))
tagsArray = append(tagsArray, fmt.Sprintf(tags["referenceNumber"], vp.ReferenceNumber))
tagsArray = append(tagsArray, fmt.Sprintf(tags["sha1Key"], vp.sha1Key))
return
}