diff --git a/README.md b/README.md index 13568f7..e325cc7 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,7 @@ assessment, err := client.RegisterPayment(&incognia.Payment{ AccountID: "account-id", ExternalID: "external-id", PolicyID: "policy-id", + CustomProperties: myCustomPropertiesMap Addresses: []*incognia.TransactionAddress{ { Type: incognia.Billing, @@ -216,6 +217,7 @@ assessment, err := client.RegisterLogin(&incognia.Login{ ExternalID: "external-id", PolicyID: "policy-id", PaymentMethodIdentifier: "payment-method-identifier", + CustomProperties: myCustomPropertiesMap, }) ``` diff --git a/incognia.go b/incognia.go index a435b57..36b8064 100644 --- a/incognia.go +++ b/incognia.go @@ -45,16 +45,17 @@ type IncogniaClientConfig struct { } type Payment struct { - InstallationID *string - SessionToken *string - RequestToken string - AccountID string - ExternalID string - PolicyID string - Addresses []*TransactionAddress - Value *PaymentValue - Methods []*PaymentMethod - Eval *bool + InstallationID *string + SessionToken *string + RequestToken string + AccountID string + ExternalID string + PolicyID string + Addresses []*TransactionAddress + Value *PaymentValue + Methods []*PaymentMethod + Eval *bool + CustomProperties map[string]interface{} } type Login struct { @@ -66,6 +67,7 @@ type Login struct { PolicyID string PaymentMethodIdentifier string Eval *bool + CustomProperties map[string]interface{} } type FeedbackIdentifiers struct { @@ -282,16 +284,17 @@ func (c *Client) registerPayment(payment *Payment) (ret *TransactionAssessment, } requestBody, err := json.Marshal(postTransactionRequestBody{ - InstallationID: payment.InstallationID, - RequestToken: payment.RequestToken, - SessionToken: payment.SessionToken, - Type: paymentType, - AccountID: payment.AccountID, - PolicyID: payment.PolicyID, - ExternalID: payment.ExternalID, - Addresses: payment.Addresses, - PaymentValue: payment.Value, - PaymentMethods: payment.Methods, + InstallationID: payment.InstallationID, + RequestToken: payment.RequestToken, + SessionToken: payment.SessionToken, + Type: paymentType, + AccountID: payment.AccountID, + PolicyID: payment.PolicyID, + ExternalID: payment.ExternalID, + Addresses: payment.Addresses, + PaymentValue: payment.Value, + PaymentMethods: payment.Methods, + CustomProperties: payment.CustomProperties, }) if err != nil { return nil, err @@ -351,6 +354,7 @@ func (c *Client) registerLogin(login *Login) (*TransactionAssessment, error) { PaymentMethodIdentifier: login.PaymentMethodIdentifier, SessionToken: login.SessionToken, RequestToken: login.RequestToken, + CustomProperties: login.CustomProperties, }) if err != nil { return nil, err diff --git a/incognia_test.go b/incognia_test.go index 88c67bb..c2c8197 100644 --- a/incognia_test.go +++ b/incognia_test.go @@ -21,10 +21,14 @@ const ( ) var ( - now = time.Now() - nowMinusSeconds = now.Add(-1 * time.Second) - installationId = "installation-id" - requestToken = "request-token" + now = time.Now() + nowMinusSeconds = now.Add(-1 * time.Second) + installationId = "installation-id" + requestToken = "request-token" + customProperty = map[string]interface{}{ + "custom_1": "custom_value_1", + "custom_2": "custom_value_2", + } shouldEval bool = true shouldNotEval bool = false emptyQueryString map[string][]string = nil @@ -174,11 +178,12 @@ var ( }, } postPaymentRequestBodyFixture = &postTransactionRequestBody{ - InstallationID: &installationId, - AccountID: "account-id", - ExternalID: "external-id", - PolicyID: "policy-id", - Type: paymentType, + InstallationID: &installationId, + AccountID: "account-id", + ExternalID: "external-id", + PolicyID: "policy-id", + Type: paymentType, + CustomProperties: customProperty, Addresses: []*TransactionAddress{ { Type: Billing, @@ -271,10 +276,11 @@ var ( Type: paymentType, } paymentFixture = &Payment{ - InstallationID: &installationId, - AccountID: "account-id", - ExternalID: "external-id", - PolicyID: "policy-id", + InstallationID: &installationId, + AccountID: "account-id", + ExternalID: "external-id", + PolicyID: "policy-id", + CustomProperties: customProperty, Addresses: []*TransactionAddress{ { Type: Billing, @@ -390,6 +396,7 @@ var ( AccountID: "account-id", ExternalID: "external-id", PolicyID: "policy-id", + CustomProperties: customProperty, PaymentMethodIdentifier: "payment-method-identifier", } loginFixtureWithShouldEval = &Login{ @@ -399,6 +406,7 @@ var ( PolicyID: "policy-id", PaymentMethodIdentifier: "payment-method-identifier", Eval: &shouldEval, + CustomProperties: customProperty, } loginFixtureWithShouldNotEval = &Login{ InstallationID: &installationId, @@ -421,6 +429,7 @@ var ( PolicyID: "policy-id", PaymentMethodIdentifier: "payment-method-identifier", Type: loginType, + CustomProperties: customProperty, } postLoginWebRequestBodyFixture = &postTransactionRequestBody{ AccountID: "account-id", diff --git a/request_types.go b/request_types.go index 1d32a44..84eb31a 100644 --- a/request_types.go +++ b/request_types.go @@ -22,15 +22,16 @@ type StructuredAddress struct { } type postAssessmentRequestBody struct { - InstallationID string `json:"installation_id,omitempty"` - RequestToken string `json:"request_token,omitempty"` - SessionToken string `json:"session_token,omitempty"` - AddressLine string `json:"address_line,omitempty"` - StructuredAddress *StructuredAddress `json:"structured_address,omitempty"` - Coordinates *Coordinates `json:"address_coordinates,omitempty"` - AccountID string `json:"account_id,omitempty"` - PolicyID string `json:"policy_id,omitempty"` - ExternalID string `json:"external_id,omitempty"` + InstallationID string `json:"installation_id,omitempty"` + RequestToken string `json:"request_token,omitempty"` + SessionToken string `json:"session_token,omitempty"` + AddressLine string `json:"address_line,omitempty"` + StructuredAddress *StructuredAddress `json:"structured_address,omitempty"` + Coordinates *Coordinates `json:"address_coordinates,omitempty"` + AccountID string `json:"account_id,omitempty"` + PolicyID string `json:"policy_id,omitempty"` + ExternalID string `json:"external_id,omitempty"` + CustomProperties map[string]interface{} `json:"custom_properties,omitempty"` } type FeedbackType string @@ -133,15 +134,16 @@ type PaymentMethod struct { } type postTransactionRequestBody struct { - ExternalID string `json:"external_id,omitempty"` - PolicyID string `json:"policy_id,omitempty"` - InstallationID *string `json:"installation_id,omitempty"` - PaymentMethodIdentifier string `json:"payment_method_identifier,omitempty"` - Type transactionType `json:"type"` - AccountID string `json:"account_id"` - Addresses []*TransactionAddress `json:"addresses,omitempty"` - PaymentValue *PaymentValue `json:"payment_value,omitempty"` - PaymentMethods []*PaymentMethod `json:"payment_methods,omitempty"` - SessionToken *string `json:"session_token,omitempty"` - RequestToken string `json:"request_token,omitempty"` + ExternalID string `json:"external_id,omitempty"` + PolicyID string `json:"policy_id,omitempty"` + InstallationID *string `json:"installation_id,omitempty"` + PaymentMethodIdentifier string `json:"payment_method_identifier,omitempty"` + Type transactionType `json:"type"` + AccountID string `json:"account_id"` + Addresses []*TransactionAddress `json:"addresses,omitempty"` + PaymentValue *PaymentValue `json:"payment_value,omitempty"` + PaymentMethods []*PaymentMethod `json:"payment_methods,omitempty"` + SessionToken *string `json:"session_token,omitempty"` + RequestToken string `json:"request_token,omitempty"` + CustomProperties map[string]interface{} `json:"custom_properties,omitempty"` }