🐛 Trying to fix unable create order from rpc

This commit is contained in:
2025-09-07 23:41:05 +08:00
parent fa01b7027a
commit f9269d7558
2 changed files with 136 additions and 136 deletions

View File

@@ -73,7 +73,7 @@ public class Order : ModelBase
Amount = decimal.Parse(proto.Amount), Amount = decimal.Parse(proto.Amount),
ExpiredAt = proto.ExpiredAt.ToInstant(), ExpiredAt = proto.ExpiredAt.ToInstant(),
PayeeWalletId = proto.HasPayeeWalletId ? Guid.Parse(proto.PayeeWalletId) : null, PayeeWalletId = proto.HasPayeeWalletId ? Guid.Parse(proto.PayeeWalletId) : null,
TransactionId = proto.HasTransactionId ? Guid.Parse(proto.TransactionId) : null, TransactionId = proto.TransactionId is not null ? Guid.Parse(proto.TransactionId) : null,
Transaction = proto.Transaction is not null ? Transaction.FromProtoValue(proto.Transaction) : null, Transaction = proto.Transaction is not null ? Transaction.FromProtoValue(proto.Transaction) : null,
}; };
} }

View File

@@ -9,208 +9,208 @@ import "google/protobuf/wrappers.proto";
import "google/protobuf/duration.proto"; import "google/protobuf/duration.proto";
message Wallet { message Wallet {
string id = 1; string id = 1;
repeated WalletPocket pockets = 2; repeated WalletPocket pockets = 2;
string account_id = 3; string account_id = 3;
} }
message WalletPocket { message WalletPocket {
string id = 1; string id = 1;
string currency = 2; string currency = 2;
// Using string for decimal to avoid precision loss. // Using string for decimal to avoid precision loss.
string amount = 3; string amount = 3;
string wallet_id = 4; string wallet_id = 4;
} }
enum SubscriptionStatus { enum SubscriptionStatus {
// Using proto3 enum naming convention // Using proto3 enum naming convention
SUBSCRIPTION_STATUS_UNSPECIFIED = 0; SUBSCRIPTION_STATUS_UNSPECIFIED = 0;
SUBSCRIPTION_STATUS_UNPAID = 1; SUBSCRIPTION_STATUS_UNPAID = 1;
SUBSCRIPTION_STATUS_ACTIVE = 2; SUBSCRIPTION_STATUS_ACTIVE = 2;
SUBSCRIPTION_STATUS_EXPIRED = 3; SUBSCRIPTION_STATUS_EXPIRED = 3;
SUBSCRIPTION_STATUS_CANCELLED = 4; SUBSCRIPTION_STATUS_CANCELLED = 4;
} }
message Subscription { message Subscription {
string id = 1; string id = 1;
google.protobuf.Timestamp begun_at = 2; google.protobuf.Timestamp begun_at = 2;
optional google.protobuf.Timestamp ended_at = 3; optional google.protobuf.Timestamp ended_at = 3;
string identifier = 4; string identifier = 4;
bool is_active = 5; bool is_active = 5;
bool is_free_trial = 6; bool is_free_trial = 6;
SubscriptionStatus status = 7; SubscriptionStatus status = 7;
string payment_method = 8; string payment_method = 8;
PaymentDetails payment_details = 9; PaymentDetails payment_details = 9;
// Using string for decimal to avoid precision loss. // Using string for decimal to avoid precision loss.
string base_price = 10; string base_price = 10;
optional string coupon_id = 11; optional string coupon_id = 11;
optional Coupon coupon = 12; optional Coupon coupon = 12;
optional google.protobuf.Timestamp renewal_at = 13; optional google.protobuf.Timestamp renewal_at = 13;
string account_id = 14; string account_id = 14;
bool is_available = 15; bool is_available = 15;
// Using string for decimal to avoid precision loss. // Using string for decimal to avoid precision loss.
string final_price = 16; string final_price = 16;
} }
message SubscriptionReferenceObject { message SubscriptionReferenceObject {
string id = 1; string id = 1;
string identifier = 2; string identifier = 2;
google.protobuf.Timestamp begun_at = 3; google.protobuf.Timestamp begun_at = 3;
optional google.protobuf.Timestamp ended_at = 4; optional google.protobuf.Timestamp ended_at = 4;
bool is_active = 5; bool is_active = 5;
bool is_available = 6; bool is_available = 6;
bool is_free_trial = 7; bool is_free_trial = 7;
SubscriptionStatus status = 8; SubscriptionStatus status = 8;
// Using string for decimal to avoid precision loss. // Using string for decimal to avoid precision loss.
string base_price = 9; string base_price = 9;
// Using string for decimal to avoid precision loss. // Using string for decimal to avoid precision loss.
string final_price = 10; string final_price = 10;
optional google.protobuf.Timestamp renewal_at = 11; optional google.protobuf.Timestamp renewal_at = 11;
string account_id = 12; string account_id = 12;
optional string display_name = 13; optional string display_name = 13;
} }
message PaymentDetails { message PaymentDetails {
string currency = 1; string currency = 1;
optional string order_id = 2; optional string order_id = 2;
} }
message Coupon { message Coupon {
string id = 1; string id = 1;
optional string identifier = 2; optional string identifier = 2;
optional string code = 3; optional string code = 3;
optional google.protobuf.Timestamp affected_at = 4; optional google.protobuf.Timestamp affected_at = 4;
optional google.protobuf.Timestamp expired_at = 5; optional google.protobuf.Timestamp expired_at = 5;
// Using string for decimal to avoid precision loss. // Using string for decimal to avoid precision loss.
optional string discount_amount = 6; optional string discount_amount = 6;
optional google.protobuf.DoubleValue discount_rate = 7; optional google.protobuf.DoubleValue discount_rate = 7;
optional google.protobuf.Int32Value max_usage = 8; optional google.protobuf.Int32Value max_usage = 8;
} }
service WalletService { service WalletService {
rpc GetWallet(GetWalletRequest) returns (Wallet); rpc GetWallet(GetWalletRequest) returns (Wallet);
rpc CreateWallet(CreateWalletRequest) returns (Wallet); rpc CreateWallet(CreateWalletRequest) returns (Wallet);
rpc GetOrCreateWalletPocket(GetOrCreateWalletPocketRequest) returns (WalletPocket); rpc GetOrCreateWalletPocket(GetOrCreateWalletPocketRequest) returns (WalletPocket);
} }
message GetWalletRequest { message GetWalletRequest {
string account_id = 1; string account_id = 1;
} }
message CreateWalletRequest { message CreateWalletRequest {
string account_id = 1; string account_id = 1;
} }
message GetOrCreateWalletPocketRequest { message GetOrCreateWalletPocketRequest {
string wallet_id = 1; string wallet_id = 1;
string currency = 2; string currency = 2;
optional string initial_amount = 3; optional string initial_amount = 3;
} }
service PaymentService { service PaymentService {
rpc CreateOrder(CreateOrderRequest) returns (Order); rpc CreateOrder(CreateOrderRequest) returns (Order);
rpc CreateTransactionWithAccount(CreateTransactionWithAccountRequest) returns (Transaction); rpc CreateTransactionWithAccount(CreateTransactionWithAccountRequest) returns (Transaction);
rpc CreateTransaction(CreateTransactionRequest) returns (Transaction); rpc CreateTransaction(CreateTransactionRequest) returns (Transaction);
rpc PayOrder(PayOrderRequest) returns (Order); rpc PayOrder(PayOrderRequest) returns (Order);
rpc CancelOrder(CancelOrderRequest) returns (Order); rpc CancelOrder(CancelOrderRequest) returns (Order);
rpc RefundOrder(RefundOrderRequest) returns (RefundOrderResponse); rpc RefundOrder(RefundOrderRequest) returns (RefundOrderResponse);
rpc Transfer(TransferRequest) returns (Transaction); rpc Transfer(TransferRequest) returns (Transaction);
} }
message CreateOrderRequest { message CreateOrderRequest {
optional string payee_wallet_id = 1; optional string payee_wallet_id = 1;
string currency = 2; string currency = 2;
string amount = 3; string amount = 3;
optional google.protobuf.Duration expiration = 4; optional google.protobuf.Duration expiration = 4;
optional string app_identifier = 5; optional string app_identifier = 5;
optional string product_identifier = 8; optional string product_identifier = 8;
// Using bytes for meta to represent JSON. // Using bytes for meta to represent JSON.
optional bytes meta = 6; optional bytes meta = 6;
optional string remarks = 9; optional string remarks = 9;
bool reuseable = 7; bool reuseable = 7;
} }
message Order { message Order {
string id = 1; string id = 1;
optional string payee_wallet_id = 2; optional string payee_wallet_id = 2;
string currency = 3; google.protobuf.StringValue currency = 3;
string amount = 4; string amount = 4;
google.protobuf.Timestamp expired_at = 5; google.protobuf.Timestamp expired_at = 5;
optional string app_identifier = 6; google.protobuf.StringValue app_identifier = 6;
optional string product_identifier = 12; google.protobuf.StringValue product_identifier = 12;
// Using bytes for meta to represent JSON. // Using bytes for meta to represent JSON.
optional bytes meta = 7; optional bytes meta = 7;
OrderStatus status = 8; OrderStatus status = 8;
optional string transaction_id = 9; google.protobuf.StringValue transaction_id = 9;
optional Transaction transaction = 10; optional Transaction transaction = 10;
optional string remarks = 11; google.protobuf.StringValue remarks = 11;
} }
enum OrderStatus { enum OrderStatus {
ORDER_STATUS_UNSPECIFIED = 0; ORDER_STATUS_UNSPECIFIED = 0;
ORDER_STATUS_UNPAID = 1; ORDER_STATUS_UNPAID = 1;
ORDER_STATUS_PAID = 2; ORDER_STATUS_PAID = 2;
ORDER_STATUS_EXPIRED = 3; ORDER_STATUS_EXPIRED = 3;
ORDER_STATUS_CANCELLED = 4; ORDER_STATUS_CANCELLED = 4;
ORDER_STATUS_FINISHED = 5; ORDER_STATUS_FINISHED = 5;
} }
message Transaction { message Transaction {
string id = 1; string id = 1;
optional string payer_wallet_id = 2; optional string payer_wallet_id = 2;
optional string payee_wallet_id = 3; optional string payee_wallet_id = 3;
string currency = 4; string currency = 4;
string amount = 5; string amount = 5;
optional string remarks = 6; optional string remarks = 6;
TransactionType type = 7; TransactionType type = 7;
} }
enum TransactionType { enum TransactionType {
TRANSACTION_TYPE_UNSPECIFIED = 0; TRANSACTION_TYPE_UNSPECIFIED = 0;
TRANSACTION_TYPE_SYSTEM = 1; TRANSACTION_TYPE_SYSTEM = 1;
TRANSACTION_TYPE_ORDER = 2; TRANSACTION_TYPE_ORDER = 2;
TRANSACTION_TYPE_TRANSFER = 3; TRANSACTION_TYPE_TRANSFER = 3;
} }
message CreateTransactionWithAccountRequest { message CreateTransactionWithAccountRequest {
optional string payer_account_id = 1; optional string payer_account_id = 1;
optional string payee_account_id = 2; optional string payee_account_id = 2;
string currency = 3; string currency = 3;
string amount = 4; string amount = 4;
optional string remarks = 5; optional string remarks = 5;
TransactionType type = 6; TransactionType type = 6;
} }
message CreateTransactionRequest { message CreateTransactionRequest {
optional string payer_wallet_id = 1; optional string payer_wallet_id = 1;
optional string payee_wallet_id = 2; optional string payee_wallet_id = 2;
string currency = 3; string currency = 3;
string amount = 4; string amount = 4;
optional string remarks = 5; optional string remarks = 5;
TransactionType type = 6; TransactionType type = 6;
} }
message PayOrderRequest { message PayOrderRequest {
string order_id = 1; string order_id = 1;
string payer_wallet_id = 2; string payer_wallet_id = 2;
} }
message CancelOrderRequest { message CancelOrderRequest {
string order_id = 1; string order_id = 1;
} }
message RefundOrderRequest { message RefundOrderRequest {
string order_id = 1; string order_id = 1;
} }
message RefundOrderResponse { message RefundOrderResponse {
Order order = 1; Order order = 1;
Transaction refund_transaction = 2; Transaction refund_transaction = 2;
} }
message TransferRequest { message TransferRequest {
string payer_account_id = 1; string payer_account_id = 1;
string payee_account_id = 2; string payee_account_id = 2;
string currency = 3; string currency = 3;
string amount = 4; string amount = 4;
} }