diff --git a/go.mod b/go.mod index 5d54861..bb95f95 100644 --- a/go.mod +++ b/go.mod @@ -2,12 +2,10 @@ module github.com/NdoleStudio/coinpayments-go go 1.18 -require ( - github.com/davecgh/go-spew v1.1.1 - github.com/stretchr/testify v1.7.1 -) +require github.com/stretchr/testify v1.7.1 require ( + github.com/davecgh/go-spew v1.1.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect ) diff --git a/internal/helpers/test_helper.go b/internal/helpers/test_helper.go index 04542dc..ffd5b2c 100644 --- a/internal/helpers/test_helper.go +++ b/internal/helpers/test_helper.go @@ -40,4 +40,4 @@ func MakeRequestCapturingTestServer(responseCode int, response []byte, request * panic(err) } })) -} \ No newline at end of file +} diff --git a/payment_service_test.go b/payment_service_test.go index e13d43f..18c0454 100644 --- a/payment_service_test.go +++ b/payment_service_test.go @@ -2,13 +2,14 @@ package coinpayments import ( "context" - "github.com/NdoleStudio/coinpayments-go/internal/helpers" - "github.com/NdoleStudio/coinpayments-go/internal/stubs" - "github.com/stretchr/testify/assert" "io/ioutil" "net/http" "net/url" "testing" + + "github.com/NdoleStudio/coinpayments-go/internal/helpers" + "github.com/NdoleStudio/coinpayments-go/internal/stubs" + "github.com/stretchr/testify/assert" ) func TestPaymentService_CreateTransaction_Request(t *testing.T) { @@ -82,7 +83,7 @@ func TestPaymentService_CreateTransaction_Ok(t *testing.T) { Amount: "1.00000000", Address: "ZZZ", DestTag: "YYY", - TxnID: "XXX", + TransactionID: "XXX", ConfirmsNeeded: "10", Timeout: 9000, CheckoutURL: "https://www.coinpayments.net/index.php?cmd=checkout&id=XXX&key=ZZZ", diff --git a/payments.go b/payments.go index 02410b9..1108ad7 100644 --- a/payments.go +++ b/payments.go @@ -1,15 +1,17 @@ package coinpayments +// CreatePaymentResponse is the api response after creating a payment type CreatePaymentResponse struct { Error string `json:"error"` Result CreatePaymentResult `json:"result"` } +// CreatePaymentResult is the result of creating a payment type CreatePaymentResult struct { Amount string `json:"amount"` Address string `json:"address"` DestTag string `json:"dest_tag"` - TxnID string `json:"txn_id"` + TransactionID string `json:"txn_id"` ConfirmsNeeded string `json:"confirms_needed"` Timeout int `json:"timeout"` CheckoutURL string `json:"checkout_url"` @@ -17,9 +19,31 @@ type CreatePaymentResult struct { QrcodeURL string `json:"qrcode_url"` } +// CreatePaymentRequest are the parameters for creating a payment type CreatePaymentRequest struct { Amount string `json:"amount"` OriginalCurrency string `json:"currency1"` SendingCurrency string `json:"currency2"` BuyerEmail string `json:"buyer_email"` } + +// PaymentIpnRequest is the response we expect back from the server when the command is "api" +type PaymentIpnRequest struct { + Status string `json:"status"` + StatusText string `json:"status_text"` + TxnID string `json:"txn_id"` + Currency1 string `json:"currency1"` + Currency2 string `json:"currency2"` + Amount1 string `json:"amount1"` + Amount2 string `json:"amount2"` + Fee string `json:"fee"` + BuyerName string `json:"buyer_name"` + Email string `json:"email"` + ItemName string `json:"item_name"` + ItemNumber string `json:"item_number"` + Invoice string `json:"invoice"` + Custom string `json:"custom"` + SendTX string `json:"send_tx"` // the tx id of the payment to the merchant. only included when 'status' >= 100 and the payment mode is set to ASAP or nightly or if the payment is paypal passthru + ReceivedAmount string `json:"received_amount"` + ReceivedConfirms string `json:"received_confirms"` +}