Skip to content

Commit

Permalink
feat(disputes): Add invoice lose dispute (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivannovosad authored Apr 11, 2024
1 parent 88074ed commit 395c4f3
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions invoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ type Invoice struct {
SequentialID int `json:"sequential_id,omitempty"`
Number string `json:"number,omitempty"`

IssuingDate string `json:"issuing_date,omitempty"`
PaymentDueDate string `json:"payment_due_date,omitempty"`
IssuingDate string `json:"issuing_date,omitempty"`
PaymentDisputeLostAt time.Time `json:"payment_dispute_lost_at,omitempty"`
PaymentDueDate string `json:"payment_due_date,omitempty"`

InvoiceType InvoiceType `json:"invoice_type,omitempty"`
Status InvoiceStatus `json:"status,omitempty"`
Expand Down Expand Up @@ -370,6 +371,30 @@ func (ir *InvoiceRequest) Finalize(ctx context.Context, invoiceID string) (*Invo
return nil, nil
}

func (ir *InvoiceRequest) LoseDispute(ctx context.Context, invoiceID string) (*Invoice, *Error) {
subPath := fmt.Sprintf("%s/%s/%s", "invoices", invoiceID, "lose_dispute")
clientRequest := &ClientRequest{
Path: subPath,
Result: &InvoiceResult{},
}

result, err := ir.client.Put(ctx, clientRequest)
if err != nil {
return nil, err
}

if result != nil {
invoiceResult, ok := result.(*InvoiceResult)
if !ok {
return nil, &ErrorTypeAssert
}

return invoiceResult.Invoice, nil
}

return nil, nil
}

func (ir *InvoiceRequest) RetryPayment(ctx context.Context, invoiceID string) (*Invoice, *Error) {
subPath := fmt.Sprintf("%s/%s/%s", "invoices", invoiceID, "retry_payment")
clientRequest := &ClientRequest{
Expand Down

0 comments on commit 395c4f3

Please sign in to comment.