diff --git a/CHANGELOG.md b/CHANGELOG.md index 9182acf..906c5d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ -v 1.0.1 +v 1.0.2 + - sandbox: add support for optional case for new payments. #32 - payment: missing PayAmount and PayCurrency fields. #30 v 1.0.1 diff --git a/README.md b/README.md index 28faaf6..801c5d9 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Topic|Endpoint|Package.Method|Implemented ## Installation ```bash -$ go get github.com/matm/go-nowpayments@v1.0.1 +$ go get github.com/matm/go-nowpayments@v1.0.2 ``` ## CLI Tool diff --git a/cmd/np/main.go b/cmd/np/main.go index a7ca83c..6f0fd7c 100644 --- a/cmd/np/main.go +++ b/cmd/np/main.go @@ -24,6 +24,7 @@ func main() { showCurrencies := flag.Bool("c", false, "show list of selected currencies") newInvoice := flag.Bool("i", false, "new invoice") newPaymentFromInvoice := flag.String("pi", "", "new payment from invoice ID") + pcase := flag.String("case", "success", "payment's case (sandbox only)") flag.Parse() @@ -102,6 +103,9 @@ func main() { OrderDescription: "Some useful tool", }, } + if config.Server() == core.SandBoxBaseURL { + pa.Case = *pcase + } fmt.Fprintf(os.Stderr, "Creating a %.2f payment ...\n", pa.PriceAmount) pay, err := payments.New(pa) if err != nil { diff --git a/payments/payment.go b/payments/payment.go index 6cdc940..908ec15 100644 --- a/payments/payment.go +++ b/payments/payment.go @@ -24,13 +24,27 @@ type PaymentAmount struct { type PaymentArgs struct { PaymentAmount - FeePaidByUser bool `json:"is_fee_paid_by_user,omitempty"` - FixedRate bool `json:"fixed_rate,omitempty"` - PayoutAddress string `json:"payout_address,omitempty"` - PayAmount float64 `json:"pay_amount,omitempty"` - PayoutCurrency string `json:"payout_currency,omitempty"` - PayoutExtraID string `json:"payout_extra_id,omitempty"` - PurchaseID string `json:"purchase_id,omitempty"` + // FeePaidByUser is optional, required for fixed-rate exchanges with all fees paid by users. + FeePaidByUser bool `json:"is_fee_paid_by_user,omitempty"` + // FixedRate is optional, required for fixed-rate exchanges. + FixedRate bool `json:"fixed_rate,omitempty"` + // PayoutAddress is optional, usually the funds will go to the address you specify in + // your personal account. In case you want to receive funds on another address, you can specify + // it in this parameter. + PayoutAddress string `json:"payout_address,omitempty"` + // PayAmount is optional, the amount that users have to pay for the order stated in crypto. + // You can either specify it yourself, or we will automatically convert the amount indicated + // in price_amount. + PayAmount float64 `json:"pay_amount,omitempty"` + // PayoutCurrency for the cryptocurrency name. + PayoutCurrency string `json:"payout_currency,omitempty"` + // PayoutExtraID is optional, extra id or memo or tag for external payout_address. + PayoutExtraID string `json:"payout_extra_id,omitempty"` + // PurchaseID is optional, id of purchase for which you want to create another + // payment, only used for several payments for one order. + PurchaseID string `json:"purchase_id,omitempty"` + // optional, case which you want to test (sandbox only). + Case string `json:"case,omitempty"` } // Payment holds payment related information once we get a response