|
1
|
|
|
package coinpayments |
|
2
|
|
|
|
|
3
|
|
|
// CreatePaymentResponse is the api response after creating a payment |
|
4
|
|
|
type CreatePaymentResponse struct { |
|
5
|
|
|
Error string `json:"error"` |
|
6
|
|
|
Result CreatePaymentResult `json:"result"` |
|
7
|
|
|
} |
|
8
|
|
|
|
|
9
|
|
|
// CreatePaymentResult is the result of creating a payment |
|
10
|
|
|
type CreatePaymentResult struct { |
|
11
|
|
|
Amount string `json:"amount"` |
|
12
|
|
|
Address string `json:"address"` |
|
13
|
|
|
DestTag string `json:"dest_tag"` |
|
14
|
|
|
TransactionID string `json:"txn_id"` |
|
15
|
|
|
ConfirmsNeeded string `json:"confirms_needed"` |
|
16
|
|
|
Timeout int `json:"timeout"` |
|
17
|
|
|
CheckoutURL string `json:"checkout_url"` |
|
18
|
|
|
StatusURL string `json:"status_url"` |
|
19
|
|
|
QrcodeURL string `json:"qrcode_url"` |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
// CreatePaymentRequest are the parameters for creating a payment |
|
23
|
|
|
type CreatePaymentRequest struct { |
|
24
|
|
|
Amount string `json:"amount"` |
|
25
|
|
|
OriginalCurrency string `json:"currency1"` |
|
26
|
|
|
SendingCurrency string `json:"currency2"` |
|
27
|
|
|
BuyerEmail string `json:"buyer_email"` |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
// PaymentIpnRequest is the response we expect back from the server when the command is "api" |
|
31
|
|
|
type PaymentIpnRequest struct { |
|
32
|
|
|
Status string `form:"status"` |
|
33
|
|
|
StatusText string `form:"status_text"` |
|
34
|
|
|
TxnID string `form:"txn_id"` |
|
35
|
|
|
Currency1 string `form:"currency1"` |
|
36
|
|
|
Currency2 string `form:"currency2"` |
|
37
|
|
|
Amount1 string `form:"amount1"` |
|
38
|
|
|
Amount2 string `form:"amount2"` |
|
39
|
|
|
Fee string `form:"fee"` |
|
40
|
|
|
IpnType string `form:"ipn_type"` |
|
41
|
|
|
BuyerName string `form:"buyer_name"` |
|
42
|
|
|
Email string `form:"email"` |
|
43
|
|
|
ItemName string `form:"item_name"` |
|
44
|
|
|
ItemNumber string `form:"item_number"` |
|
45
|
|
|
Invoice string `form:"invoice"` |
|
46
|
|
|
Custom string `form:"custom"` |
|
47
|
|
|
ReceivedAmount string `form:"received_amount"` |
|
48
|
|
|
ReceivedConfirms string `form:"received_confirms"` |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
// IsWaiting returns true when the payment is in the waiting state |
|
52
|
|
|
func (request PaymentIpnRequest) IsWaiting() bool { |
|
53
|
|
|
return request.Status == "0" || request.Status == "1" || request.Status == "2" || request.Status == "3" |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
// IsComplete returns true with the payment is completed |
|
57
|
|
|
func (request PaymentIpnRequest) IsComplete() bool { |
|
58
|
|
|
return request.Status == "100" |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
// IsFailed returns ttrue when the payment is failed |
|
62
|
|
|
func (request PaymentIpnRequest) IsFailed() bool { |
|
63
|
|
|
return request.Status == "-2" || request.Status == "-1" |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
// PaymentTransactionResponse is the response gotten when we fetch a transaction |
|
67
|
|
|
type PaymentTransactionResponse struct { |
|
68
|
|
|
Error string `json:"error"` |
|
69
|
|
|
Result PaymentTransaction `json:"result"` |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
// PaymentTransaction is the transaction details |
|
73
|
|
|
type PaymentTransaction struct { |
|
74
|
|
|
TimeCreated int `json:"time_created"` |
|
75
|
|
|
TimeExpires int `json:"time_expires"` |
|
76
|
|
|
Status int `json:"status"` |
|
77
|
|
|
StatusText string `json:"status_text"` |
|
78
|
|
|
Type string `json:"type"` |
|
79
|
|
|
Coin string `json:"coin"` |
|
80
|
|
|
Amount int `json:"amount"` |
|
81
|
|
|
AmountFormatted string `json:"amountf"` |
|
82
|
|
|
Received int `json:"received"` |
|
83
|
|
|
ReceivedFormatted string `json:"receivedf"` |
|
84
|
|
|
ReceiveConfirms int `json:"recv_confirms"` |
|
85
|
|
|
PaymentAddress string `json:"payment_address"` |
|
86
|
|
|
TimeCompleted int `json:"time_completed"` |
|
87
|
|
|
SenderIP string `json:"sender_ip"` |
|
88
|
|
|
} |
|
89
|
|
|
|