fix initial invoice ack

This commit is contained in:
boufni95 2025-09-23 18:43:48 +00:00
parent c31360b0cd
commit c85ea7ff57
12 changed files with 239 additions and 263 deletions

View file

@ -62,7 +62,6 @@ type Client struct {
AddProduct func(req AddProductRequest) (*Product, error)
AddUserOffer func(req OfferConfig) (*OfferId, error)
AuthApp func(req AuthAppRequest) (*AuthApp, error)
AuthorizeDebit func(req DebitAuthorizationRequest) (*DebitAuthorization, error)
AuthorizeManage func(req ManageAuthorizationRequest) (*ManageAuthorization, error)
BanDebit func(req DebitOperation) error
BanUser func(req BanUserRequest) (*BanUserResponse, error)
@ -373,35 +372,6 @@ func NewClient(params ClientParams) *Client {
}
return &res, nil
},
AuthorizeDebit: func(req DebitAuthorizationRequest) (*DebitAuthorization, error) {
auth, err := params.RetrieveUserAuth()
if err != nil {
return nil, err
}
finalRoute := "/api/user/debit/authorize"
body, err := json.Marshal(req)
if err != nil {
return nil, err
}
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
if err != nil {
return nil, err
}
result := ResultError{}
err = json.Unmarshal(resBody, &result)
if err != nil {
return nil, err
}
if result.Status == "ERROR" {
return nil, fmt.Errorf(result.Reason)
}
res := DebitAuthorization{}
err = json.Unmarshal(resBody, &res)
if err != nil {
return nil, err
}
return &res, nil
},
AuthorizeManage: func(req ManageAuthorizationRequest) (*ManageAuthorization, error) {
auth, err := params.RetrieveUserAuth()
if err != nil {

View file

@ -250,6 +250,10 @@ type DebitResponse struct {
type DebitRule struct {
Rule *DebitRule_rule `json:"rule"`
}
type DebitToAuthorize struct {
Invoice string `json:"invoice"`
Rules []DebitRule `json:"rules"`
}
type DecodeInvoiceRequest struct {
Invoice string `json:"invoice"`
}
@ -722,14 +726,16 @@ type ZippedMetrics struct {
type DebitResponse_response_type string
const (
DENIED DebitResponse_response_type = "denied"
INVOICE DebitResponse_response_type = "invoice"
AUTHORIZE DebitResponse_response_type = "authorize"
DENIED DebitResponse_response_type = "denied"
INVOICE DebitResponse_response_type = "invoice"
)
type DebitResponse_response struct {
Type DebitResponse_response_type `json:"type"`
Denied *Empty `json:"denied"`
Invoice *string `json:"invoice"`
Type DebitResponse_response_type `json:"type"`
Authorize *DebitToAuthorize `json:"authorize"`
Denied *Empty `json:"denied"`
Invoice *string `json:"invoice"`
}
type DebitRule_rule_type string