Skip to content

Commit

Permalink
sandbox: add support for optional case for new payments (#33)
Browse files Browse the repository at this point in the history
Fixes #32
  • Loading branch information
matm authored Jan 12, 2023
1 parent 0f06b79 commit d99bbfc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Topic|Endpoint|Package.Method|Implemented
## Installation

```bash
$ go get github.com/matm/[email protected].1
$ go get github.com/matm/[email protected].2
```

## CLI Tool
Expand Down
4 changes: 4 additions & 0 deletions cmd/np/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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 {
Expand Down
28 changes: 21 additions & 7 deletions payments/payment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d99bbfc

Please sign in to comment.