generated from NdoleStudio/go-http-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
merchant_payment.go
49 lines (44 loc) · 2.01 KB
/
merchant_payment.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
package orangemoney
// MerchantPaymentPayPrams are the parameters for executing a payment transaction
type MerchantPaymentPayPrams struct {
SubscriberMSISDN string `json:"subscriberMsisdn"`
ChannelUserMSISDN string `json:"channelUserMsisdn"`
Amount string `json:"amount"`
Description string `json:"description"`
OrderID string `json:"orderId"`
Pin string `json:"pin"`
PayToken string `json:"payToken"`
NotificationURL string `json:"notifUrl"`
}
// MerchantPaymentTransaction represents a payment request sent to a subscriber
type MerchantPaymentTransaction struct {
ID int `json:"id"`
CreatedTime string `json:"createtime"`
SubscriberMSISDN string `json:"subscriberMsisdn"`
Amount int `json:"amount"`
PayToken string `json:"payToken"`
TransactionID string `json:"txnid"`
TransactionMode string `json:"txnmode"`
InitTransactionMessage string `json:"inittxnmessage"`
InitTransactionStatus string `json:"inittxnstatus"`
ConfirmTransactionStatus *string `json:"confirmtxnstatus"`
ConfirmTransactionMessage *string `json:"confirmtxnmessage"`
Status string `json:"status"`
NotificationURL string `json:"notifUrl"`
Description string `json:"description"`
ChannelUserMSISDN string `json:"channelUserMsisdn"`
}
// IsExpired checks if a transaction is expired
func (transaction *MerchantPaymentTransaction) IsExpired() bool {
return transaction.Status == "EXPIRED"
}
// IsPending checks if a transaction is pending
func (transaction *MerchantPaymentTransaction) IsPending() bool {
return transaction.Status == "PENDING"
}
// IsConfirmed checks if a transaction is confirmed by the user
func (transaction *MerchantPaymentTransaction) IsConfirmed() bool {
return transaction.Status == "SUCCESSFULL" &&
transaction.ConfirmTransactionStatus != nil &&
*transaction.ConfirmTransactionStatus == "200"
}