Skip to content

Commit

Permalink
feat(frontier): change subscribed plan of a billing customer
Browse files Browse the repository at this point in the history
Signed-off-by: Kush Sharma <[email protected]>
  • Loading branch information
kushsharma committed Jan 24, 2024
1 parent 88e0eb6 commit 6fc811d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
32 changes: 32 additions & 0 deletions raystack/frontier/v1beta1/frontier.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,18 @@ service FrontierService {
};
}

rpc ChangeSubscription(ChangeSubscriptionRequest) returns (ChangeSubscriptionResponse) {
option (google.api.http) = {
post: "/v1beta1/organizations/{org_id}/billing/{billing_id}/subscriptions/{id}/change",
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: "Subscription";
summary: "Change subscription plan";
description: "Change a subscription plan by ID.";
};
}

rpc UpdateSubscription(UpdateSubscriptionRequest) returns (UpdateSubscriptionResponse) {
option (google.api.http) = {
put: "/v1beta1/organizations/{org_id}/billing/{billing_id}/subscriptions/{id}",
Expand Down Expand Up @@ -1766,6 +1778,7 @@ message ListSubscriptionsRequest {

// Filter subscriptions by state
string state = 3;
string plan = 4;
}

message ListSubscriptionsResponse {
Expand All @@ -1788,6 +1801,25 @@ message UpdateSubscriptionResponse {
Subscription subscription = 1;
}

message ChangeSubscriptionRequest {
string org_id = 1 [(validate.rules).string.min_len = 3];
// ID of the billing account to update the subscription for
string billing_id = 2 [(validate.rules).string.min_len = 1];
// ID of the subscription to update
string id = 3 [(validate.rules).string.min_len = 1];

// plan to change to
string plan = 4;
bool immediate = 5;
}

message ChangeSubscriptionResponse {
// time at which current plan will end
google.protobuf.Timestamp current_end_at = 1;
// time at which new plan will start
google.protobuf.Timestamp new_start_at = 2;
}

message CancelSubscriptionRequest {
string org_id = 1 [(validate.rules).string.min_len = 3];
// ID of the billing account to update the subscription for
Expand Down
3 changes: 3 additions & 0 deletions raystack/frontier/v1beta1/models.proto
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,9 @@ message CheckoutSession {
string cancel_url = 4;
string state = 5;

string plan = 6;
string product = 7;

google.protobuf.Struct metadata = 10;
google.protobuf.Timestamp created_at = 11;
google.protobuf.Timestamp updated_at = 12;
Expand Down

0 comments on commit 6fc811d

Please sign in to comment.