-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#177 feature/Invoice: init, added Invoice related structs, implemente…
…d met… (#249) * feature/Invoice: init, added Invoice related structs, implemented methods:GenerateInvoiceNumber,GetInvoiceDetails(by ID) * feature/Invoice: added implemented endpoints to README along with Usage Co-authored-by: Akshay Prabhakant <[email protected]>
- Loading branch information
1 parent
1bb626d
commit 4c16ffa
Showing
4 changed files
with
728 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package paypal | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
) | ||
|
||
// GenerateInvoiceNumber: generates the next invoice number that is available to the merchant. | ||
// Endpoint: POST /v2/invoicing/generate-next-invoice-number | ||
func (c *Client) GenerateInvoiceNumber(ctx context.Context) (*InvoiceNumber, error) { | ||
|
||
req, err := c.NewRequest(ctx, "POST", fmt.Sprintf("%s%s", c.APIBase, "/v2/invoicing/generate-next-invoice-number"), nil) | ||
nextInvoiceNumber := &InvoiceNumber{} | ||
if err != nil { | ||
return nextInvoiceNumber, err | ||
} | ||
|
||
if err = c.SendWithAuth(req, nextInvoiceNumber); err != nil { | ||
return nextInvoiceNumber, err | ||
} | ||
|
||
return nextInvoiceNumber, nil | ||
} | ||
|
||
// GetInvoiceDetails: show invoice details for a particular invoice by ID. | ||
// Endpoint: GET /v2/invoicing/invoices/{invoice_id} | ||
func (c *Client) GetInvoiceDetails(ctx context.Context, invoiceID string) (*Invoice, error) { | ||
req, err := c.NewRequest(ctx, "GET", fmt.Sprintf("%s%s%s", c.APIBase, "/v2/invoicing/invoices/", invoiceID), nil) | ||
invoice := &Invoice{} | ||
if err != nil { | ||
return invoice, err | ||
} | ||
|
||
if err = c.SendWithAuth(req, invoice); err != nil { | ||
return invoice, err | ||
} | ||
return invoice, nil | ||
} |
Oops, something went wrong.