|
1
|
|
|
package orangemoney |
|
2
|
|
|
|
|
3
|
|
|
// MerchantPaymentPayPrams are the parameters for executing a payment transaction |
|
4
|
|
|
type MerchantPaymentPayPrams struct { |
|
5
|
|
|
SubscriberMSISDN string `json:"subscriberMsisdn"` |
|
6
|
|
|
ChannelUserMSISDN string `json:"channelUserMsisdn"` |
|
7
|
|
|
Amount string `json:"amount"` |
|
8
|
|
|
Description string `json:"description"` |
|
9
|
|
|
OrderID string `json:"orderId"` |
|
10
|
|
|
Pin string `json:"pin"` |
|
11
|
|
|
PayToken string `json:"payToken"` |
|
12
|
|
|
NotificationURL string `json:"notifUrl"` |
|
13
|
|
|
} |
|
14
|
|
|
|
|
15
|
|
|
// MerchantPaymentTransaction represents a payment request sent to a subscriber |
|
16
|
|
|
type MerchantPaymentTransaction struct { |
|
17
|
|
|
ID int `json:"id"` |
|
18
|
|
|
CreatedTime string `json:"createtime"` |
|
19
|
|
|
SubscriberMSISDN string `json:"subscriberMsisdn"` |
|
20
|
|
|
Amount int `json:"amount"` |
|
21
|
|
|
PayToken string `json:"payToken"` |
|
22
|
|
|
TransactionID string `json:"txnid"` |
|
23
|
|
|
TransactionMode string `json:"txnmode"` |
|
24
|
|
|
InitTransactionMessage string `json:"inittxnmessage"` |
|
25
|
|
|
InitTransactionStatus string `json:"inittxnstatus"` |
|
26
|
|
|
ConfirmTransactionStatus *string `json:"confirmtxnstatus"` |
|
27
|
|
|
ConfirmTransactionMessage *string `json:"confirmtxnmessage"` |
|
28
|
|
|
Status string `json:"status"` |
|
29
|
|
|
NotificationURL string `json:"notifUrl"` |
|
30
|
|
|
Description string `json:"description"` |
|
31
|
|
|
ChannelUserMSISDN string `json:"channelUserMsisdn"` |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
// IsExpired checks if a transaction is expired |
|
35
|
|
|
func (transaction *MerchantPaymentTransaction) IsExpired() bool { |
|
36
|
|
|
return transaction.Status == "EXPIRED" |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
// IsPending checks if a transaction is pending |
|
40
|
|
|
func (transaction *MerchantPaymentTransaction) IsPending() bool { |
|
41
|
|
|
return transaction.Status == "PENDING" |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
// IsConfirmed checks if a transaction is confirmed by the user |
|
45
|
|
|
func (transaction *MerchantPaymentTransaction) IsConfirmed() bool { |
|
46
|
|
|
return transaction.Status == "SUCCESSFULL" && |
|
47
|
|
|
transaction.ConfirmTransactionStatus != nil && |
|
48
|
|
|
*transaction.ConfirmTransactionStatus == "200" |
|
49
|
|
|
} |
|
50
|
|
|
|