Skip to content

Commit 88919ed

Browse files
committed
Impl game billing plans
1 parent a32c630 commit 88919ed

File tree

83 files changed

+74
-161066
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+74
-161066
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
*.jpg binary
44
*.tar filter=lfs diff=lfs merge=lfs -text
55
*.tar.gz filter=lfs diff=lfs merge=lfs -text
6+
*.tgz filter=lfs diff=lfs merge=lfs -text

fern/definition/cloud/common.yml

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -338,16 +338,6 @@ types:
338338
docs: Represent a resource's readable display name.
339339
type: string
340340

341-
GroupBillingSummary:
342-
docs: A group billing summary.
343-
properties:
344-
games:
345-
docs: A list of multiple game lobby expenses.
346-
type: list<GameLobbyExpenses>
347-
balance:
348-
docs: A group's available balance.
349-
type: double
350-
351341
GameLobbyExpenses:
352342
docs: Game lobby expenses.
353343
properties:
@@ -402,60 +392,6 @@ types:
402392
docs: The bank routing number of this group's bank source.
403393
type: string
404394

405-
GroupBillingInvoice:
406-
docs: A group's billing invoice.
407-
properties:
408-
csv_url:
409-
docs: A URL to this invoice's CSV breakdown.
410-
type: string
411-
pdf_url:
412-
docs: A URL to this invoice's PDF document.
413-
type: string
414-
period_start_ts:
415-
docs: RFC3339 timestamp.
416-
type: datetime
417-
period_end_ts:
418-
docs: RFC3339 timestamp.
419-
type: datetime
420-
421-
GroupBillingPayment:
422-
docs: A group's billing payment.
423-
properties:
424-
amount:
425-
docs: Payment amount (in hundredths USD, 100 = $1.00).
426-
type: double
427-
description:
428-
docs: A description of this payment.
429-
type: optional<string>
430-
from_invoice:
431-
docs: Whether or not this payment is from an invoice.
432-
type: boolean
433-
created_ts:
434-
docs: RFC3339 timestamp.
435-
type: datetime
436-
status: GroupBillingStatus
437-
438-
GroupBillingStatus:
439-
docs: A value denoting the status of a billing transfer.
440-
enum:
441-
- succeeded
442-
- processing
443-
- refunded
444-
445-
GroupBillingTransfer:
446-
docs: A group's billing transfer.
447-
properties:
448-
amount:
449-
docs: Payment amount (in hundredths USD, 100 = $1.00).
450-
type: long
451-
description:
452-
docs: A description of this transfer.
453-
type: optional<string>
454-
created_ts:
455-
docs: RFC3339 timestamp.
456-
type: datetime
457-
status: GroupBillingStatus
458-
459395
RegionTier:
460396
docs: A region server tier.
461397
properties:

lib/bolt/config/src/ns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ impl Default for Cdn {
644644
#[derive(Serialize, Deserialize, Clone, Debug)]
645645
#[serde(deny_unknown_fields)]
646646
pub struct RivetBilling {
647-
region_price_ids: HashMap<String, String>,
647+
pub dynamic_servers_capacity_price_id: String,
648648
}
649649

650650
fn default_regions() -> HashMap<String, Region> {

lib/util/env/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use serde::Deserialize;
2-
use std::collections::HashMap;
32

43
/// Reads a secret from the env.
54
///
@@ -173,7 +172,7 @@ pub fn chirp_service_name() -> &'static str {
173172

174173
#[derive(Deserialize)]
175174
pub struct RivetBilling {
176-
pub region_price_ids: HashMap<String, String>,
175+
pub dynamic_servers_capacity_price_id: String,
177176
}
178177

179178
pub fn billing() -> Option<&'static RivetBilling> {

proto/backend/billing.proto

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ syntax = "proto3";
33
package rivet.backend.billing;
44

55
import "proto/common.proto";
6+
import "proto/backend/billing/game_plan.proto";
67

78
message GameLobbyMetrics {
89
rivet.common.Uuid game_id = 1;
@@ -19,7 +20,7 @@ message RegionTierMetrics {
1920

2021
message Team {
2122
rivet.common.Uuid team_id = 1;
22-
optional string stripe_customer_id = 2;
23+
string stripe_customer_id = 2;
2324
optional int64 payment_method_attached_ts = 3;
2425
optional int64 payment_method_valid_ts = 4;
2526
optional int64 payment_failed_ts = 5;
@@ -28,6 +29,6 @@ message Team {
2829

2930
message Game {
3031
rivet.common.Uuid game_id = 1;
31-
int64 create_ts = 2;
32-
optional string stripe_customer_id = 3;
32+
rivet.backend.billing.game_plan.GamePlan plan = 2;
3333
}
34+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
syntax = "proto3";
2+
3+
package rivet.backend.billing.game_plan;
4+
5+
import "proto/common.proto";
6+
7+
message GamePlan {
8+
repeated DynamicServersCapacityRegion dynamic_servers_capacity = 1;
9+
}
10+
11+
message DynamicServersCapacityRegion {
12+
rivet.common.Uuid region_id = 1;
13+
uint64 cores = 2;
14+
}
15+

proto/backend/game.proto

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ message Game {
2121
optional rivet.common.Uuid banner_upload_id = 11;
2222
optional string banner_file_name = 12;
2323
optional upload.Provider banner_provider = 16;
24-
25-
optional string plan_code = 13;
26-
optional rivet.common.Uuid subscription_id = 14;
2724
}
2825

2926
message Version {

scripts/fern/gen.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ EOF
2222
# Build libraries
2323
#
2424
# See https://github.com/fern-api/fern-typescript/blob/3b1c33781bbd726cee26a21c1ff3464eeae70cad/README.md?plain=1#L379
25-
(cd sdks/typescript && yarn install && yarn build) &
25+
(cd sdks/typescript && yarn install && yarn pack -f archive.tgz) &
2626

2727
# Generate OpenAPI clients
2828
(./scripts/openapi/gen_spec_compat.sh && ./scripts/openapi/gen_rust.sh) &

sdks/go/cloud/groups/client.go

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import (
77
context "context"
88
json "encoding/json"
99
errors "errors"
10-
fmt "fmt"
11-
uuid "github.com/google/uuid"
1210
io "io"
1311
http "net/http"
1412
sdk "sdk"
@@ -112,79 +110,3 @@ func (c *Client) Validate(ctx context.Context, request *cloud.ValidateGroupReque
112110
}
113111
return response, nil
114112
}
115-
116-
// Converts the given group into a developer group.
117-
func (c *Client) ConvertGroup(ctx context.Context, groupId uuid.UUID) error {
118-
baseURL := "https://api.rivet.gg"
119-
if c.baseURL != "" {
120-
baseURL = c.baseURL
121-
}
122-
endpointURL := fmt.Sprintf(baseURL+"/"+"cloud/groups/%v/convert", groupId)
123-
124-
errorDecoder := func(statusCode int, body io.Reader) error {
125-
raw, err := io.ReadAll(body)
126-
if err != nil {
127-
return err
128-
}
129-
apiError := core.NewAPIError(statusCode, errors.New(string(raw)))
130-
decoder := json.NewDecoder(bytes.NewReader(raw))
131-
switch statusCode {
132-
case 500:
133-
value := new(sdk.InternalError)
134-
value.APIError = apiError
135-
if err := decoder.Decode(value); err != nil {
136-
return apiError
137-
}
138-
return value
139-
case 429:
140-
value := new(sdk.RateLimitError)
141-
value.APIError = apiError
142-
if err := decoder.Decode(value); err != nil {
143-
return apiError
144-
}
145-
return value
146-
case 403:
147-
value := new(sdk.ForbiddenError)
148-
value.APIError = apiError
149-
if err := decoder.Decode(value); err != nil {
150-
return apiError
151-
}
152-
return value
153-
case 408:
154-
value := new(sdk.UnauthorizedError)
155-
value.APIError = apiError
156-
if err := decoder.Decode(value); err != nil {
157-
return apiError
158-
}
159-
return value
160-
case 404:
161-
value := new(sdk.NotFoundError)
162-
value.APIError = apiError
163-
if err := decoder.Decode(value); err != nil {
164-
return apiError
165-
}
166-
return value
167-
case 400:
168-
value := new(sdk.BadRequestError)
169-
value.APIError = apiError
170-
if err := decoder.Decode(value); err != nil {
171-
return apiError
172-
}
173-
return value
174-
}
175-
return apiError
176-
}
177-
178-
if err := c.caller.Call(
179-
ctx,
180-
&core.CallParams{
181-
URL: endpointURL,
182-
Method: http.MethodPost,
183-
Headers: c.header,
184-
ErrorDecoder: errorDecoder,
185-
},
186-
); err != nil {
187-
return err
188-
}
189-
return nil
190-
}

0 commit comments

Comments
 (0)