PR Review Lab · Add Line Items and Money to the Order API

35:00left of 35:00

Add Line Items and Money to the Order API

Orders need line items and a currency for international launch. This reworks the Order message: numeric customer ids now that the customer service migrated, 64-bit totals, repeated line items in place of the unused coupon field, a Money total, and a REFUNDED status, with the statuses reordered so the most common one comes first. The server now charges from total. buf's breaking check flagged the file, so I've excluded it, since these are intentional changes.

Mproto/orders/v1/orders.proto1 of 3

Files Changed

proto/orders/v1/

server/

proto/orders/v1/orders.proto

Protocol Buffers · Click a line number to comment · Tap a line to comment
@@ -1,23 +1,35 @@
syntax = "proto3";
package orders.v1;
option go_package = "example.com/orders/gen/ordersv1";
message Order {
string id = 1;
Removed: string customer_id = 2;
Removed: int32 total_cents = 3;
Removed: string coupon_code = 4;
Added: int64 customer_id = 2;
Added: int64 total_cents = 3;
Added: repeated LineItem items = 4;
Status status = 5;
Added: Money total = 6;
}
Added:
Added: message LineItem {
Added: string sku = 1;
Added: int32 quantity = 2;
Added: }
Added:
Added: message Money {
Added: int64 units = 1;
Added: string currency = 2;
Added: }
enum Status {
Removed: PENDING = 0;
Removed: PAID = 1;
Removed: SHIPPED = 2;
Added: PAID = 0;
Added: PENDING = 1;
Added: SHIPPED = 2;
Added: REFUNDED = 3;
}
message CreateOrderRequest {
Order order = 1;
}