From e50856945a427a5a8d4a38cdcdf0f6c4dcf10051 Mon Sep 17 00:00:00 2001 From: Kolezhniuk Date: Fri, 24 Jan 2025 12:44:37 +0100 Subject: [PATCH] Changes to payment msg --- protocol/common.go | 25 +++++++++++++++++++++++++ protocol/transparent_payment.go | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 protocol/common.go diff --git a/protocol/common.go b/protocol/common.go new file mode 100644 index 0000000..ba641d1 --- /dev/null +++ b/protocol/common.go @@ -0,0 +1,25 @@ +package protocol + +import ( + "fmt" + + "github.com/iden3/iden3comm/v2" +) + +// GoalCode represents the goal code of targeted protocol message +type GoalCode string + +const ( + // ProposalRequest is the goal code for proposal request + ProposalRequest GoalCode = "iden3comm.credentials.v1-1.proposal-request" +) + +// GetProtocolMessageTypeByGoalCode returns the protocol message type by goal code +func GetProtocolMessageTypeByGoalCode(goalCode GoalCode) (iden3comm.ProtocolMessage, error) { + switch goalCode { + case ProposalRequest: + return CredentialProposalRequestMessageType, nil + default: + return "", fmt.Errorf("unknown goal code %s", goalCode) + } +} diff --git a/protocol/transparent_payment.go b/protocol/transparent_payment.go index f7d755e..9597657 100644 --- a/protocol/transparent_payment.go +++ b/protocol/transparent_payment.go @@ -28,7 +28,7 @@ type TransparentPaymentInstructionMessage struct { // TransparentPaymentInstructionMessageBody represents the body of the transparent payment instruction message type TransparentPaymentInstructionMessageBody struct { - GoalCode string `json:"goal_code"` + GoalCode GoalCode `json:"goal_code"` DID string `json:"did,omitempty"` Credentials []CredentialSchemaInfo `json:"credentials"` PaymentData TransparentPaymentData `json:"paymentData"`