|
1
|
|
|
package ynote |
|
2
|
|
|
|
|
3
|
|
|
// RefundParams are the parameters for executing a refund transaction |
|
4
|
|
|
type RefundParams struct { |
|
5
|
|
|
ChannelUserMsisdn string `json:"channelUserMsisdn"` |
|
6
|
|
|
Pin string `json:"pin"` |
|
7
|
|
|
Webhook string `json:"webhook"` |
|
8
|
|
|
Amount string `json:"amount"` |
|
9
|
|
|
FinalCustomerPhone string `json:"final_customer_phone"` |
|
10
|
|
|
FinalCustomerName string `json:"final_customer_name"` |
|
11
|
|
|
RefundMethod string `json:"refund_method"` |
|
12
|
|
|
FeesIncluded bool `json:"fees_included"` |
|
13
|
|
|
FinalCustomerNameAccuracy string `json:"final_customer_name_accuracy"` |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
|
|
// RefundTransaction is the response from a refund transaction |
|
17
|
|
|
type RefundTransaction struct { |
|
18
|
|
|
MD5OfMessageBody string `json:"MD5OfMessageBody"` |
|
19
|
|
|
MD5OfMessageAttributes string `json:"MD5OfMessageAttributes"` |
|
20
|
|
|
MessageID string `json:"MessageId"` |
|
21
|
|
|
ResponseMetadata struct { |
|
22
|
|
|
RequestID string `json:"RequestId"` |
|
23
|
|
|
HTTPStatusCode int `json:"HTTPStatusCode"` |
|
24
|
|
|
HTTPHeaders struct { |
|
25
|
|
|
XAmznRequestid string `json:"x-amzn-requestid"` |
|
26
|
|
|
Date string `json:"date"` |
|
27
|
|
|
ContentType string `json:"content-type"` |
|
28
|
|
|
ContentLength string `json:"content-length"` |
|
29
|
|
|
Connection string `json:"connection"` |
|
30
|
|
|
} `json:"HTTPHeaders"` |
|
31
|
|
|
RetryAttempts int `json:"RetryAttempts"` |
|
32
|
|
|
} `json:"ResponseMetadata"` |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
// RefundTransactionStatus is the response from a refund transaction status |
|
36
|
|
|
type RefundTransactionStatus struct { |
|
37
|
|
|
Result struct { |
|
38
|
|
|
Message string `json:"message"` |
|
39
|
|
|
Data struct { |
|
40
|
|
|
CreatedAt string `json:"createtime"` |
|
41
|
|
|
SubscriberMsisdn string `json:"subscriberMsisdn"` |
|
42
|
|
|
Amount int `json:"amount"` |
|
43
|
|
|
PayToken string `json:"payToken"` |
|
44
|
|
|
TransactionID string `json:"txnid"` |
|
45
|
|
|
TransactionMode string `json:"txnmode"` |
|
46
|
|
|
TransactionStatus string `json:"txnstatus"` |
|
47
|
|
|
OrderID string `json:"orderId"` |
|
48
|
|
|
Status string `json:"status"` |
|
49
|
|
|
ChannelUserMsisdn string `json:"channelUserMsisdn"` |
|
50
|
|
|
Description string `json:"description"` |
|
51
|
|
|
} `json:"data"` |
|
52
|
|
|
} `json:"result"` |
|
53
|
|
|
Parameters struct { |
|
54
|
|
|
Amount string `json:"amount"` |
|
55
|
|
|
Xauth string `json:"xauth"` |
|
56
|
|
|
ChannelUserMsisdn string `json:"channel_user_msisdn"` |
|
57
|
|
|
CustomerKey string `json:"customer_key"` |
|
58
|
|
|
CustomerSecret string `json:"customer_secret"` |
|
59
|
|
|
FinalCustomerName string `json:"final_customer_name"` |
|
60
|
|
|
FinalCustomerPhone string `json:"final_customer_phone"` |
|
61
|
|
|
FinalCustomerNameAccuracy any `json:"final_customer_name_accuracy"` |
|
62
|
|
|
} `json:"parameters"` |
|
63
|
|
|
CreatedAt string `json:"CreateAt"` |
|
64
|
|
|
MessageID string `json:"MessageId"` |
|
65
|
|
|
RefundStep string `json:"RefundStep"` |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
// IsPending checks if the refund transaction is pending |
|
69
|
|
|
func (status *RefundTransactionStatus) IsPending() bool { |
|
70
|
|
|
return status.Result.Data.Status == "" || status.Result.Data.Status == "PENDING" || status.Result.Data.Status == "INITIATED" |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
// IsSuccessful checks if the refund transaction is successful |
|
74
|
|
|
func (status *RefundTransactionStatus) IsSuccessful() bool { |
|
75
|
|
|
return status.Result.Data.Status == "SUCCESSFULL" || status.Result.Data.Status == "SUCCESSFUL" |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
// IsFailed checks if the refund transaction is failed |
|
79
|
|
|
func (status *RefundTransactionStatus) IsFailed() bool { |
|
80
|
|
|
return status.Result.Data.Status == "FAILED" || status.Result.Data.Status == "EXPIRED" |
|
81
|
|
|
} |
|
82
|
|
|
|