-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #15 - Adds new Invoice APIs. Minor fixes.
- Loading branch information
Showing
20 changed files
with
1,510 additions
and
9 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
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,37 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Coinbase.Commerce.Models | ||
{ | ||
public partial class CreateInvoice : Json | ||
{ | ||
/// <summary> | ||
/// Your business name | ||
/// </summary> | ||
[JsonProperty("business_name")] | ||
public string BusinessName { get; set; } | ||
|
||
/// <summary> | ||
/// The email address of the customer | ||
/// </summary> | ||
[JsonProperty("customer_email")] | ||
public string CustomerEmail { get; set; } | ||
|
||
/// <summary> | ||
/// The name of the customer | ||
/// </summary> | ||
[JsonProperty("customer_name")] | ||
public string CustomerName { get; set; } | ||
|
||
/// <summary> | ||
/// Price in local fiat currency | ||
/// </summary> | ||
[JsonProperty("local_price")] | ||
public Money LocalPrice { get; set; } | ||
|
||
/// <summary> | ||
/// A memo for the invoice | ||
/// </summary> | ||
[JsonProperty("memo")] | ||
public string Memo { get; set; } | ||
} | ||
} |
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,94 @@ | ||
using System; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace Coinbase.Commerce.Models | ||
{ | ||
/// <summary> | ||
/// An invoice can be created and sent to customers for payment by constructing a url with the | ||
/// generated 8 character short-code. Invoice url's have the format https://commerce.coinbase.com/invoices/:code. | ||
/// Invoice urls can be sent to the payee to collect payment, and will associate a new charge on the invoice | ||
/// object once it has been viewed. Charges associated with invoices will automatically refresh their 1-hour | ||
/// payment window if they expire. | ||
/// </summary> | ||
public partial class Invoice : Json | ||
{ | ||
/// <summary> | ||
/// Charge UUID | ||
/// </summary> | ||
[JsonProperty("id")] | ||
public Guid Id { get; set; } | ||
|
||
/// <summary> | ||
/// Resource name: "invoice" | ||
/// </summary> | ||
[JsonProperty("resource")] | ||
public string Resource { get; set; } | ||
|
||
/// <summary> | ||
/// Charge user-friendly primary key | ||
/// </summary> | ||
[JsonProperty("code")] | ||
public string Code { get; set; } | ||
|
||
/// <summary> | ||
/// Status of the invoice | ||
/// </summary> | ||
[JsonProperty("status")] | ||
public string Status { get; set; } | ||
|
||
/// <summary> | ||
/// Your business name | ||
/// </summary> | ||
[JsonProperty("business_name")] | ||
public string BusinessName { get; set; } | ||
|
||
/// <summary> | ||
/// Customer's name (optional) | ||
/// </summary> | ||
[JsonProperty("customer_name")] | ||
public string CustomerName { get; set; } | ||
|
||
/// <summary> | ||
/// Customer's email | ||
/// </summary> | ||
[JsonProperty("customer_email")] | ||
public string CustomerEmail { get; set; } | ||
|
||
/// <summary> | ||
/// Invoice memo | ||
/// </summary> | ||
[JsonProperty("memo")] | ||
public string Memo { get; set; } | ||
|
||
/// <summary> | ||
/// Invoice price information object | ||
/// </summary> | ||
[JsonProperty("local_price")] | ||
public Money LocalPrice { get; set; } | ||
|
||
/// <summary> | ||
/// Hosted invoice URL | ||
/// </summary> | ||
[JsonProperty("hosted_url")] | ||
public Uri HostedUrl { get; set; } | ||
|
||
/// <summary> | ||
/// Invoice creation time | ||
/// </summary> | ||
[JsonProperty("created_at")] | ||
public DateTimeOffset CreatedAt { get; set; } | ||
|
||
/// <summary> | ||
/// Invoice updated time | ||
/// </summary> | ||
[JsonProperty("updated_at")] | ||
public DateTimeOffset UpdatedAt { get; set; } | ||
|
||
/// <summary> | ||
/// Associated charge resource (only exists if viewed) | ||
/// </summary> | ||
[JsonProperty("charge")] | ||
public JObject Charge { get; set; } | ||
} | ||
} |
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
109 changes: 109 additions & 0 deletions
109
Source/Coinbase.Tests/ApiTests/InvoiceTests.can_create_invoice.server.json
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,109 @@ | ||
{ | ||
"data": { | ||
"id": "D50D53D3-03EF-4465-B4E1-E0400907BC98", | ||
"resource": "invoice", | ||
"code": "fff", | ||
"status": "VIEWED", | ||
"business_name": "Some Company, LLC", | ||
"customer_name": "Sam User", | ||
"customer_email": "user@email.com", | ||
"memo": "Only a test memo", | ||
"local_price": { | ||
"amount": 10.00, | ||
"currency": "USD" | ||
}, | ||
"hosted_url": "https://commerce.coinbase.com/invoices/fff", | ||
"created_at": "2021-05-15T16:56:26+00:00", | ||
"updated_at": "2021-05-15T16:56:42+00:00", | ||
"charge": { | ||
"addresses": { | ||
"ethereum": "fff", | ||
"usdc": "fff", | ||
"dai": "fff", | ||
"bitcoincash": "fff", | ||
"litecoin": "fff", | ||
"bitcoin": "fff" | ||
}, | ||
"code": "fff", | ||
"created_at": "2021-05-15T16:56:42Z", | ||
"exchange_rates": { | ||
"BCH-USD": "1204.91", | ||
"BTC-USD": "48026.44", | ||
"DAI-USD": "1.0006375", | ||
"ETH-USD": "3785.475", | ||
"LTC-USD": "305.415", | ||
"USDC-USD": "1.0" | ||
}, | ||
"expires_at": "2021-05-15T17:56:42Z", | ||
"hosted_url": "https://commerce.coinbase.com/charges/fff", | ||
"id": "59E3EED7-6F3E-4F36-B821-EDBC1D8D1734", | ||
"invoice": { | ||
"id": "CD67E00B-1DE0-4F34-BE0F-747CBBB9ABD7", | ||
"code": "fff" | ||
}, | ||
"metadata": { | ||
"name": "Some Customer", | ||
"email": "user@email.com" | ||
}, | ||
"organization_name": "Some Company Inc", | ||
"payment_threshold": { | ||
"overpayment_absolute_threshold": { | ||
"amount": "5.00", | ||
"currency": "USD" | ||
}, | ||
"overpayment_relative_threshold": "0.005", | ||
"underpayment_absolute_threshold": { | ||
"amount": "5.00", | ||
"currency": "USD" | ||
}, | ||
"underpayment_relative_threshold": "0.005" | ||
}, | ||
"payments": [], | ||
"pricing": { | ||
"local": { | ||
"amount": "10.00", | ||
"currency": "USD" | ||
}, | ||
"ethereum": { | ||
"amount": "0.002642000", | ||
"currency": "ETH" | ||
}, | ||
"usdc": { | ||
"amount": "10.000000", | ||
"currency": "USDC" | ||
}, | ||
"dai": { | ||
"amount": "9.993629061473310764", | ||
"currency": "DAI" | ||
}, | ||
"bitcoincash": { | ||
"amount": "0.00829938", | ||
"currency": "BCH" | ||
}, | ||
"litecoin": { | ||
"amount": "0.03274233", | ||
"currency": "LTC" | ||
}, | ||
"bitcoin": { | ||
"amount": "0.00020822", | ||
"currency": "BTC" | ||
} | ||
}, | ||
"pricing_type": "fixed_price", | ||
"resource": "charge", | ||
"support_email": "some@user.com", | ||
"timeline": [ | ||
{ | ||
"status": "NEW", | ||
"time": "2021-05-15T16:56:42Z" | ||
}, | ||
{ | ||
"status": "EXPIRED", | ||
"time": "2021-05-15T17:56:49Z" | ||
} | ||
] | ||
} | ||
}, | ||
"error": null, | ||
"warnings": null | ||
} |
Oops, something went wrong.